Created
April 20, 2010 10:06
-
-
Save primalmotion/372259 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation TNBase64Image : CPImage | |
{ | |
CPString _baseEncoded64Data @accessors(setter=setBaseEncoded64Data:); | |
CPString _contentType @accessors(setter=setContentType:); | |
} | |
+ (TNBase64Image)base64ImageWithContentType:(CPString)aContentType andData:(CPString)someBase64Data | |
{ | |
var img = [[TNBase64Image alloc] init]; | |
[img setBaseEncoded64Data:someBase64Data]; | |
[img setContentType:aContentType]; | |
[img load]; | |
return img; | |
} | |
- (void)load | |
{ | |
if (_loadStatus == CPImageLoadStatusLoading || _loadStatus == CPImageLoadStatusCompleted) | |
return; | |
var data = @"data:" + _contentType + @";base64," + _baseEncoded64Data; | |
_loadStatus = CPImageLoadStatusLoading; | |
_image = new Image(); | |
_filename = data; | |
_image.src = data; | |
[self _imageDidLoad]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment