Ashfaq
Ashfaq

Reputation: 435

Android Java Bitmap.getByteCount() showing larger size than actual size

I downloaded an image file of size 5.8 KB into an ImageView for my Android App.I saved the image to my application directory using bitmap.compress() method. And as I wanted to know the size of the image I downloaded I used Bitmap.getByteCount() to get the size of the image. Following is the code:
But here I am getting the size as 201.984 KB for an image whose actual size is just 5.8 KB. Can anyone say me what is wrong? Thaadvance!

Upvotes: 0

Views: 1641

Answers (2)

nurisezgin
nurisezgin

Reputation: 1570

Bitmap and other format difference.

For Example Bitmap ARGB_8888 Every pixel contains alpha, red, green, blue channel. And than every changel size 8 bit.(0

Example :

Width = 50px Height = 50px Format = ARGB_8888 Size = 50 x 50 x 32bit(4byte) = 2500 x 4 = 10000 bytes

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006829

But here I am getting the size as 201.984 KB

Bitmap is a decoded image. getByteCount() returns the size, in memory, of the decoded image.

for an image whose actual size is just 5.8 KB

What you think the "actual size" appears to be the compressed size on disk. That is not the same as the size of the decoded image in memory, nor should it be.

Upvotes: 1

Related Questions