java - Android 16-Bit Color Image to Bitmap -


i trying 16-bit color image 80 x 60 resolution embedded camera (datasheet here). able 9600 (80 * 60 * 16 / 8) bytes camera, have problem displaying image. using following code convert byte array bitmap:

bm = bitmap.createbitmap(80, 60, bitmap.config.rgb_565); bm.copypixelsfrombuffer(bytebuffer.wrap(jpegbytes)); 

jpegbytes array of image's bytes , 9600 bytes long.

right now, getting images this:

corrupted image

99% of time. however, able non-corrupted images this:

uncorrupted image

very rarely. have suggestions why happening? much!

update:

it seems pixels in correct spot, have rgb values mixed up. example, white portion between both photos same because order of rgb not matter white. however, clear colors mixed because red chair showing blue in corrupted image , blue backpack showing green in corrupted image

use config.argb_8888 bitmap config

from docs public static final bitmap.config rgb_565 :

each pixel stored on 2 bytes , rgb channels encoded: red stored 5 bits of precision (32 possible values), green stored 6 bits of precision (64 possible values) , blue stored 5 bits of precision. this configuration can produce slight visual artifacts depending on configuration of source. instance, without dithering, result might show greenish tint. better results dithering should applied. configuration may useful when using opaque bitmaps not require high color fidelity.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -