I got this Base64 gif image:
R0lGODlhDAAMALMBAP8AAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAACH5BAUKAAEALAAAAAAMAAwAQAQZMMhJK7iY4p3nlZ8XgmNlnibXdVqolmhcRQA7
Now I want to display this Base64 String within my IPhone App.
I could get this working by using the WebView:
aUIWebView.scalesPageToFit = NO;
aUIWebView.opaque = NO;
aUIWebView.backgroundColor = [UIColor clearColor];
[aUIWebView loadHTMLString:
@"<html><body style=""background-color: transparent""><img src=""data:image/png;base64,R0lGODlhDAAMALMBAP8AAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAUKAAEALAAAAAAMAAwAQAQZMMhJK7iY4p3nlZ8XgmNlnibXdVqolmhcRQA7"" /></body></html>"
baseURL:nil];
Is it possible to do the same thing by using the UIImageView?
Code snippet for downloading a text file with base64 image string inside, then saving/reading the file and finally creating an image to display right in the view
In Case You Need To Decode Image To Base64 Click Here
Just in case anyone is looking for the Swift code to accomplish this (based on the Objective-C answer provided by Jonathan M), here it is:
Objective-C
Encoding
Decoding
Option
Swift
Encoding
Decoding
Very old question, but as of iOS7 there is a new, much easier way to do so, hence I'm writing it here so future readers can use this.
Very easy to use, and will not hit the 2048 byte size limit of a URL.
This Code will display an base64 encoded string as a picture:
restauInfo.picture is an NSString which contains the base64 encoded JPG
In my case the Value from "restauInfo.picture" comes from a database
You can do something like the following:
Then call it like this: