diff options
author | Jorge Ruesga <jorge@ruesga.com> | 2013-08-20 04:15:20 +0200 |
---|---|---|
committer | Jorge Ruesga <jorge@ruesga.com> | 2013-08-20 04:15:20 +0200 |
commit | 07ed5da642865ee9abb4de11c37df6ed06e65458 (patch) | |
tree | 653e2cf947e5b7b10fcb977be08bc72a922f3c23 | |
parent | 83e76b109b4d2b1863f0cfe2e2b407aff7b94f2a (diff) | |
download | android_packages_wallpapers_PhotoPhase-07ed5da642865ee9abb4de11c37df6ed06e65458.tar.gz android_packages_wallpapers_PhotoPhase-07ed5da642865ee9abb4de11c37df6ed06e65458.tar.bz2 android_packages_wallpapers_PhotoPhase-07ed5da642865ee9abb4de11c37df6ed06e65458.zip |
Recycle ununsed bitmap
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
-rw-r--r-- | src/org/cyanogenmod/wallpapers/photophase/utils/BitmapUtils.java | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/org/cyanogenmod/wallpapers/photophase/utils/BitmapUtils.java b/src/org/cyanogenmod/wallpapers/photophase/utils/BitmapUtils.java index 3848402..81b0bcf 100644 --- a/src/org/cyanogenmod/wallpapers/photophase/utils/BitmapUtils.java +++ b/src/org/cyanogenmod/wallpapers/photophase/utils/BitmapUtils.java @@ -84,16 +84,16 @@ public class BitmapUtils { * Method that decodes an Exif bitmap * * @param file The file to decode - * @param bitmap The bitmap reference + * @param src The bitmap reference * @return Bitmap The decoded bitmap */ - private static Bitmap decodeExifBitmap(File file, Bitmap bitmap) { + private static Bitmap decodeExifBitmap(File file, Bitmap src) { try { // Try to load the bitmap as a bitmap file ExifInterface exif = new ExifInterface(file.getAbsolutePath()); int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1); if (orientation == 0) { - return bitmap; + return src; } Matrix matrix = new Matrix(); if (orientation == 6) { @@ -104,12 +104,15 @@ public class BitmapUtils { matrix.postRotate(270); } // Rotate the bitmap - return Bitmap.createBitmap( - bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); + Bitmap out = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true); + if (!out.equals(src)) { + src.recycle(); + } + return out; } catch (IOException e) { // Ignore } - return bitmap; + return src; } /** |