0

I've downsampled an image and received a byte array from it. I'm now trying to create a Bitmap using this byte array using the following two methods. Here's my code:

InputStream is = new ByteArrayInputStream(output);
Bitmap DSimg =  BitmapFactory.decodeStream(is);
Bitmap DSimage = BitmapFactory.decodeByteArray(output, 0, output.length);

In this case output is a byte array where byte[] output = [117, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] (that's 16 total values).

I've tried using InputStream and decodeByteArray to return an image but I'm getting null for both Bitmaps, and logcat hasn't displayed any errors. Is my array that I'm passing in wrong? Or, to be more blunt, what's wrong with my code?

David
  • 53
  • 1
  • 6

1 Answers1

0

What makes you think that your output array contains a valid image? All I see is an array full of nulls, except for the first byte. Put a valid image in your byte array and then it will work.

Dennis Estenson
  • 1,022
  • 10
  • 11