Extract thumbnail from DNG RAW image file and show it in android ImageView

I am trying to get a thumbnail image from a DNG RAW image file and show it in android. I successfully read all the necessary tags and got the values ​​to form the image. But I did not work with the image before I ran into the problem of creating a bitmap image. Reading the original image tags, I got the following values:

image width = 320

image height = 216

Compression = 1 (1 = Uncompressed)

sample Per Pixel = 3

bit per sample = 8

image start offset = 7044

Interpretation color = 2 (2 = ARGB_8888)

to get image data, which is my code:

int uBitsPerPixel = samplePerPixel * bitPerSample;
int lengthOfBitmap = imageLength * imageWidth * uBitsPerPixel/8;//size of image data
InputStream fis = new FileInputStream(file);
byte[] img = new byte[lengthOfBitmap];
fis.skip(startOffset);//image data starting position
fis.read(img, 0, lengthOfBitmap);
fis.close();

. , null.

BitmapFactory.Options bmpFactoryOptions = new BitmapFactory.Options();
bmpFactoryOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
bitmap = BitmapFactory.decodeStream(inputStream, null, bmpFactoryOptions);

, ? .

+4

Source: https://habr.com/ru/post/1660036/


All Articles