Android - Read PNG image without alpha and decode as ARGB_8888 Android

Posted by loki666 on Stack Overflow See other posts from Stack Overflow or by loki666
Published on 2010-05-21T12:19:46Z Indexed on 2010/05/21 12:20 UTC
Read the original article Hit count: 967

Filed under:
|
|
|
|

I try to read an image from sdcard (in emulator) and then create a Bitmap image with the "BitmapFactory.decodeByteArray" method. I set the options:

options.inPrefferedConfig = Bitmap.Config.ARGB_8888
options.inDither = false

Then I extract the pixels into a ByteBuffer.

ByteBuffer buffer = ByteBuffer.allocateDirect(width*height*4)
bitmap.copyPixelsToBuffer(buffer)

I use this ByteBuffer then in the JNI to convert it into RGB format and want to calculate on it.

But always I get false data - I test without modifying the ByteBuffer. Only thing I do is to put it into the native method into JNI. Then cast it into a unsigned char* and convert it back into a ByteBuffer before returning it back to Java.

Before displaying the image I get data back with

bitmap.copyPixelsFromBuffer( buffer )

But then it has wrong data in it.

My Question is if this is because the image is internally converted into RGB 565 or what is wrong here?

May anybody has an idea, it would be great!

© Stack Overflow or respective owner

Related posts about android

Related posts about bitmap