开发者

Convert BLOB image from NSData to NSString so it can be displayed in HTML UIWebView

So I successfully retrieved my BLOB image from the database and set it to NSData *content..

content = [[NSData alloc]
       initWithBytes:sqlite3_column_blob(query, 16)
       length:sqlite3_column_bytes(query, 16)];

What I am trying to do is to get this content into a NSString, because I would like to 开发者_Python百科then pass this string to javascript and display the image. I am not exactly sure if this is even possible, but i have read on the link below that you can display images in css/html in base64. http://mark.koli.ch/2009/07/howto-include-binary-image-data-in-cascading-style-sheets-css.html

The issue I am having is converting my NSData to an NSString so I can then put it into my UIWebView's loadHTMLString....I cannot use a UIImage, must be a UIWebView.

Thanks! Greg


content = [[NSData alloc] initWithBytes:sqlite3_column_blob(query, 16) length:sqlite3_column_bytes(query, 16)]; NSString *path = [webDirectory stringByAppendingPathComponent:@"image.png"]; [content writeToFile:path atomically:NO]; [content release]; 

I was able to figure out my solution by writing the file out to a png. Where webDirectory is your directory of choice

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜