1

I was looking to convert the Raw Image data (like .DNG extension) to JPG format using Android. There is a similar app in Playstore

Raw Decoder Free

Can anyone provide me some clue or any open source code to do same.

[EDIT] I have already tried THIS using Visual C++ and able to develop the Application for Windows OS.

The stuff I am looking for Android.

Biraj Zalavadia
  • 28,348
  • 10
  • 61
  • 77
AjayR
  • 4,169
  • 4
  • 44
  • 78
  • Considering an app already does it, I can guarantee that there is such an API or library somewhere. What have you tried so far? – Raghav Sood May 27 '14 at 04:25
  • 1
    Looks tough... http://stackoverflow.com/questions/1222324/reading-raw-images-from-java – Hirak May 27 '14 at 04:32
  • I have tried http://www.libraw.org/ using VC++ and working perfectly. – AjayR May 27 '14 at 04:45
  • Seems most camera raw files 1) Is some kind of TIFF/Exif derivate, and b) contains a JPEG. So if you can parse TIFF, it should be quite easy to just extract that JPEG. If you want to get the real RAW data for further processing, it's more work but still doable. Here's a great source: http://lclevy.free.fr/ – Harald K May 27 '14 at 07:27

1 Answers1

1

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]; //That's 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, that's 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.

Rohit
  • 2,646
  • 6
  • 27
  • 52