Any APIs or code to Convert Raw Image (like DNG) to JPG format in Java/Android

Any APIs or code to Convert Raw Image (like DNG) to JPG format in Java/Android

You can use bitmap from raw image.

And for that you can extend every byte to 32-bit ARGB int. A is alpha 0xff and R G B are pixel values.
Try following code.
Source is byte array of Raw image.

byte [] Source; //Comes from somewhere...
byte [] Bits = new byte[Source.length*4]; //Thats where the ARGB array goes.
int i;
for(i=0;i<Source.length;i++)
{
    Bits[i*4] =
        Bits[i*4+1] =
        Bits[i*4+2] = ~Source[i]; //Invert the source bits
    Bits[i*4+3] = -1;//0xff, thats the alpha.
}

//Now put these nice ARGB pixels into a Bitmap object

Bitmap bm = Bitmap.createBitmap(Width, Height, Bitmap.Config.ARGB_8888);
bm.copyPixelsFromBuffer(ByteBuffer.wrap(Bits));

Or library is available here. But you need to use ndk for same.

Any APIs or code to Convert Raw Image (like DNG) to JPG format in Java/Android

Leave a Reply

Your email address will not be published. Required fields are marked *