I have a Bitmap and I want to get the size of the bitmap in KB, MB or etc
TRID NUMBER 1 - so I tried this but it is returning the wrong output because I have an image whose size is 42.57 KB but in the result, it is returning 128 B
// originalBitmap is global var
ByteArrayOutputStream stream = new ByteArrayOutputStream();
originalBitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] imageInByte = stream.toByteArray();
long bitmap_size = imageInByte.length / 1024;
Log.d(TAG, "size of bitmap - "+Formatter.formatShortFileSize(this,bitmap_size));
TRID NUMBER 2 - so In this tried is simply done this thing but it is also showing wrong output it showing 1.2 MB of that same image whose size is 42.57 KB
Log.d(TAG, "Image size : "+Formatter.formatShortFileSize(this, originalBitmap.getByteCount()));
NOTE: I have no real device so tested this in the emulator. may this cause or what do you think
any help will be appreciated! thank you.