I save .jpg
image in my cache
folder. Image is 4,032x3,024 (24-bit color) that weights 3.35MB.
Now, I wanted to convert this very same jpg
to bitmap
.
I used code:
val bitmapFromJpg = BitmapFactory.decodeFile(jpgFile.absolutePath)
But what surprised me was that it automatically changed the orignal size of the image - 1,024x768 (32-bit).
Even with
val opts = BitmapFactory.Options()
opts.inSampleSize = 1
val bitmapFromJpg = BitmapFactory.decodeFile(jpgFile.absolutePath, opts)
result is the same...
Why is this happening and how to avoid it (I want to keep original size)?
Yes you can change inScaled
By default it's value is true
, try this code
val opts = BitmapFactory.Options()
opts.inSampleSize = 1
opts.inScaled = false
val bitmapFromJpg = BitmapFactory.decodeFile(jpgFile.absolutePath, opts)
I tested this my jpg
image size(HeightXWidth) was 600X600 and after converting to bitmap
it remain same 600X600.