Matthew
Matthew

Reputation: 15

Android: BitmapFactory.decodeByteArray returning null decoding a base64 image

I'm getting an image encoded in base64Binary from a .net web service, when I try to create a bitmap with the decoded string, I get null. Any idea why? thx for your help! :D

  1. I'm sure the response string isn't null, I tested it and its length is 28000. I also checked its content with an online decoder and it returns the image I need.

  2. I'm using Android native Base64 Library to decode it before using bitmapfactory

  3. I use Ksoap2 to get the Image base64 String

  4. It's Android 2.2 google API

Here's the code:

String serverResponse = "" + result.get(0);

byte[] decodedString = Base64.decode(serverResponse, Base64.DEFAULT);

imgMap = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);

ImgMap is the bitmap and it always gets null, what am i doing wrong?

I get a log entry that says :

TAG: SKIA     
TEXT: ---SkImageDecoder:: Factory returned null

This is how decodedString looks like:

06-13 03:09:54.957: D/CODED(491): SIZE: 22486
06-13 03:09:55.008: D/CODED(491): Content: first 200 positions of the array: 737342012400068796785786984327110111410997110121068656783328411111110810710511632737305048495058485358505132494858515158525200000000000000000000000000000000000000000000000000000000000000000250-20401000000001301000-22900113010003930021301000100031301000400061301000000071

Upvotes: 0

Views: 3520

Answers (1)

Matthew
Matthew

Reputation: 15

I think i figured it out.

Looks like the response base 64 string is a TIFF image and android doesn't support that format, therefore the Factory doesn't recognize it as an image and stops the decode process.

Upvotes: 1

Related Questions