diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2014-04-13 14:05:19 +0200 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2014-04-13 14:05:19 +0200 |
| commit | bb81e7802261664be5de6aa4037ef55473c0cb8a (patch) | |
| tree | 9528ef127777c17192054766feef4bb6db31f514 /main/src/cgeo/geocaching/utils | |
| parent | 52671d45a0571abd484165ad4702b57facf624b8 (diff) | |
| download | cgeo-bb81e7802261664be5de6aa4037ef55473c0cb8a.zip cgeo-bb81e7802261664be5de6aa4037ef55473c0cb8a.tar.gz cgeo-bb81e7802261664be5de6aa4037ef55473c0cb8a.tar.bz2 | |
fix #3757: NPE while downsampling image
Diffstat (limited to 'main/src/cgeo/geocaching/utils')
| -rw-r--r-- | main/src/cgeo/geocaching/utils/ImageUtils.java | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/main/src/cgeo/geocaching/utils/ImageUtils.java b/main/src/cgeo/geocaching/utils/ImageUtils.java index 68ea7bb..e226703 100644 --- a/main/src/cgeo/geocaching/utils/ImageUtils.java +++ b/main/src/cgeo/geocaching/utils/ImageUtils.java @@ -189,11 +189,13 @@ public final class ImageUtils { sampleOptions.inSampleSize = sampleSize; } final Bitmap decodedImage = BitmapFactory.decodeFile(filePath, sampleOptions); - for (int i = 0; i < ORIENTATIONS.length; i++) { - if (orientation == ORIENTATIONS[i]) { - final Matrix matrix = new Matrix(); - matrix.postRotate(ROTATION[i]); - return Bitmap.createBitmap(decodedImage, 0, 0, decodedImage.getWidth(), decodedImage.getHeight(), matrix, true); + if (decodedImage != null) { + for (int i = 0; i < ORIENTATIONS.length; i++) { + if (orientation == ORIENTATIONS[i]) { + final Matrix matrix = new Matrix(); + matrix.postRotate(ROTATION[i]); + return Bitmap.createBitmap(decodedImage, 0, 0, decodedImage.getWidth(), decodedImage.getHeight(), matrix, true); + } } } return decodedImage; |
