Reputation: 3879
I have retrieved a jpeg image from a web service using an HTTP GET call, and I need to display it in an ImageView, but it is encoded in Base64. Therefore, I used the following code to convert it:
byte[] bytes = Base64.decode(imageStringInBase64, Base64.DEFAULT);
Bitmap bmp = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
However, I get the error: --- SkImageDecoder::Factory returned null
When logged to the console, imageStringInBase64 looks like this:
data:image/jpeg;base64,/9j/4AAQ ... a bunch of stuff ... /B6TTbssco
Upvotes: 3
Views: 1497
Reputation: 30168
If data:image...
is the value in imageStringInBase64
then that won't work. You need just the base64 encoded data (everything after the last comma).
Upvotes: 5