September 26th, 2013, 04:16 PM
Convert 16-Bit RAW RGB_565 Image to Bitmap on Android
I am trying to get a 16-bit color image that is 80 x 60 resolution from an embedded camera (Datasheet: http://www.mouser.com/ds/2/451/uCAM-DS-rev7-3555.pdf). 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:
jpegBytes is the array of the image's bytes and it is 9600 bytes long.
bm = Bitmap.createBitmap(80, 60, Bitmap.Config.RGB_565);
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:
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?
Tags for this Thread
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!