Skip to content

Instantly share code, notes, and snippets.

@primalmotion
Created April 20, 2010 10:06
Show Gist options
  • Save primalmotion/372259 to your computer and use it in GitHub Desktop.
Save primalmotion/372259 to your computer and use it in GitHub Desktop.
@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