My application gets crashed on opening a .png file which is having size of 2.5MB. This file is of high resolution.Im getting OOM error.
The piece of code which causes the error is:
long sizeInMB = imageFile.length()/(1024*1024);
if(sizeInMB > 2){
int inSampleSize = (int) (sizeInMB/5);
if(sizeInMB%5 > 0){
inSampleSize++;
}
Options opts = new Options();
opts.inSampleSize=inSampleSize;
bitmap = BitmapFactory.decodeFile(filePath, opts);
}else{
bitmap = BitmapFactory.decodeFile(filePath);
}
The line bitmap = BitmapFactory.decodeFile(filePath)
causes the error.
Any help will be appreciated,
Thanks in advance