I have a 2448x3264 image on my SD card that consumes 1,667,072 bytes but when I load it as a Bitmap and calculate its size using getRowBytes()*getHeight()
I end up with 15,980,544 bytes.
Why does this happen and how can I calculate the actual size of the file?
BMP stands for bitmap, a raster-based file type designed in the early days of computer graphics to display images independently from devices. Because BMP files are information-rich, they tend to have large file sizes.
The bitmap is stored in its original compressed form to save memory (PNG, JPEG, etc) The bitmap is stored in 24-bpp format so its slower to access than a 32-bpp image. The bitmap is not stored in a packed memory array and is fragmented so can't be read/written fast.
The two main factors which affect the quality of a bitmap picture are and colour depth. The resolution is the number of pixels per , measured in dots per inch () or pixels per inch (ppi). The higher the resolution the better the of the picture. A picture with a low resolution will when the picture is enlarged.
If you're displaying large amounts of bitmap data in your app, you're likely to run into OutOfMemoryError errors. The recycle() method allows an app to reclaim memory as soon as possible. Caution: You should use recycle() only when you are sure that the bitmap is no longer being used.
That is because the image is compressed when it is on disk (stored in a JPG, PNG, or similar format). Once you load the image into memory, it is no longer compressed and takes up as much memory as is necessary for all the pixels (typically width * height * 4 for RGBA_8888, or width * height * 2 for RGB_565).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With