Convert 16-Bit RAW RGB_565 Image to Bitmap on Android

All your problems with Audio, Video and Images.

Convert 16-Bit RAW RGB_565 Image to Bitmap on Android

Postby itsuandme » Thu Sep 26, 2013 9:29 pm

I am trying to get a 16-bit color image that is 80 x 60 resolution from an embedded camera (Datasheet: I am successfully able to get 9600 (80 * 60 * 16 / 8) bytes from the camera, but I have a problem displaying the image. I am using the following code to convert the byte array into a Bitmap:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.     bm = Bitmap.createBitmap(80, 60, Bitmap.Config.RGB_565);
  2.     bm.copyPixelsFromBuffer(ByteBuffer.wrap(jpegBytes));
Parsed in 0.010 seconds, using GeSHi

jpegBytes is the array of the image's bytes and it is 9600 bytes long.

Right now, I am getting images that look like this:


99% of the time. However, I am able to get non-corrupted images that look like this:


very rarely.

It seems like all the pixels are in the correct spot, but have their RGB values mixed up. For example, the white portion between both photos is the same because the order of RGB does not matter to get white. However, it is clear that the colors are mixed up because the red chair is showing up as blue in the corrupted image and the blue backpack is showing up as green in the corrupted image.

Does anyone have any suggestions as to why this is happening?
Once Poster
Once Poster
Posts: 1
Joined: Thu Sep 26, 2013 9:26 pm


Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 14 guests