aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/utils/ImageUtil.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/utils/ImageUtil.java')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/utils/ImageUtil.java22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/ImageUtil.java b/src/main/java/de/thedevstack/conversationsplus/utils/ImageUtil.java
index b28e6f1c..0edf6ad0 100644
--- a/src/main/java/de/thedevstack/conversationsplus/utils/ImageUtil.java
+++ b/src/main/java/de/thedevstack/conversationsplus/utils/ImageUtil.java
@@ -338,20 +338,28 @@ public final class ImageUtil {
public static int calcSampleSize(Uri image, int size) throws FileNotFoundException {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
- BitmapFactory.decodeStream(StreamUtil.openInputStreamFromContentResolver(image), null, options);
- return calcSampleSize(options, size);
+ Bitmap bmp = BitmapFactory.decodeStream(StreamUtil.openInputStreamFromContentResolver(image), null, options);
+ int height = options.outHeight;
+ int width = options.outWidth;
+ if (null != bmp) {
+ bmp.recycle();
+ }
+ return calcSampleSize(width, height, size);
}
public static int calcSampleSize(File image, int size) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
- BitmapFactory.decodeFile(image.getAbsolutePath(), options);
- return calcSampleSize(options, size);
- }
-
- public static int calcSampleSize(BitmapFactory.Options options, int size) {
+ Bitmap bmp = BitmapFactory.decodeFile(image.getAbsolutePath(), options);
int height = options.outHeight;
int width = options.outWidth;
+ if (null != bmp) {
+ bmp.recycle();
+ }
+ return calcSampleSize(width, height, size);
+ }
+
+ private static int calcSampleSize(int width, int height, int size) {
int inSampleSize = 1;
if (height > size || width > size) {