Fix for ImageResizer crashing the application when a broken image is retrieved... (#72)

This commit is contained in:
Nathanael Anderson
2017-03-23 02:42:02 -06:00
committed by Hristo Hristov
parent 37491faa4c
commit 053e3071b7

View File

@@ -147,7 +147,18 @@ public abstract class Resizer extends Worker {
addInBitmapOptions(options, cache);
}
return BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options);
Bitmap results = null;
try {
// This can throw an error on a corrupted image when using an inBitmap
results = BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options);
}
catch (Exception e) {
// clear the inBitmap and try again
options.inBitmap = null;
results = BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options);
// If image is broken, rather than an issue with the inBitmap, we will get a NULL out in this case...
}
return results;
}
public static Bitmap decodeSampledBitmapFromByteArray(