0

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
Matthew
  • 15
  • 2
  • 6
  • Does "decodedString" contain the image? – Christine Jun 12 '12 at 23:49
  • it is supposed to, it should contain the base64 decoded bytes that represent the image and it's not empty – Matthew Jun 12 '12 at 23:54
  • "supposed to" is not the same as "is". You can check it when you debug your app, or you can have the string written to the log output. – Christine Jun 13 '12 at 00:13
  • Since the array is too big to post all its contents, I edited the original post to show the size of the array and the first 200 positions. Thanks for helping me Christine :) – Matthew Jun 13 '12 at 03:21

1 Answers1

1

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.

Matthew
  • 15
  • 2
  • 6
  • How did you overcome this issue, I have the same situation? – Byron Feb 02 '13 at 16:18
  • Hello Byron, someone suggested this [link](http://stackoverflow.com/questions/11035377/android-is-it-possible-to-convert-a-tiff-image-to-jpg-png/11035742#11035742) even though at the end I used a different aproach by changing the format of the image on the server side. – Matthew Feb 02 '13 at 19:49
  • Hi Matthew, I also followed that same link and added the libtif to my application. The problem im facing now is I get OutOfMemory when trying to convert it to a bitmap. LIBTIF is actually throwing the exception. Thanx for your reply – Byron Feb 02 '13 at 20:48