I have searched for this, and i found that for api less than 12, usually what is used is bitmap.getrowbytes * bitmap.getheight;
However, for an image i am obtaining the following:
mBitmap.getRowBytes() = 320
mBitmap.getHeight() = 100
mBitmap.getWidth() = 80.
Thus according to the above formula I get 32,000.
However when i check the file that i m reading the bitmap image from from adb using
ls -l
I get that the size is 90Kb.
I am reading the image as follows:
Uri chosenImageUri = data.getData();
if (chosenImageUri != null) {
try {
InputStream photoStream = getContentResolver().openInputStream(chosenImageUri);
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inSampleSize = 4;
Bitmap mBitmap = BitmapFactory.decodeStream(photoStream,null, opts);
photoStream.close();
}
}
Why are the results different? Thank you.
Ok I just understood what’s going on. I will post this in case it helps anyone.
The reason of this is that I am using bitmapfactoryoptons along with insamplesize =4.
What happens is
For example, inSampleSize == 4 returns an image that is 1/4 the width/height of the original, and 1/16 the number of pixels. Any value <= 1 is treated the same as 1.
as mentioned here