For Android when loading an image into memory to make sure we don't go over the RAM limit we usually do
BitmapFactory.Options bounds = new BitmapFactory.Options();
bounds.inJustDecodeBounds = true;
And then decode the bitmap to find its width and we can decide whether to sample based on that.
My question is, if we are loading the bitmap from local storage (SD card), can't we get the file location of the bitmap:
File file = new File(mPathToFile);
and then check
if(file.length()>MAX){
sampleSize = 2;//2 is just an example
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = sampleSize;
bitmap = BitmapFactory.decodeFile(mPathToFile, options);
}
Is this wrong? Stupid?