diff --git a/app/src/main/java/eu/faircode/email/ImageHelper.java b/app/src/main/java/eu/faircode/email/ImageHelper.java index d09b4e3f6e..8f9e3359fd 100644 --- a/app/src/main/java/eu/faircode/email/ImageHelper.java +++ b/app/src/main/java/eu/faircode/email/ImageHelper.java @@ -335,27 +335,10 @@ class ImageHelper { Uri uri = Uri.parse(a.source); Log.i("Loading image source=" + uri); - BitmapFactory.Options options; - try (InputStream is = context.getContentResolver().openInputStream(uri)) { - options = new BitmapFactory.Options(); - options.inJustDecodeBounds = true; - BitmapFactory.decodeStream(is, null, options); - } - - int scaleToPixels = res.getDisplayMetrics().widthPixels; - int factor = 1; - while (options.outWidth / factor > scaleToPixels) - factor *= 2; - Bitmap bm; + int scaleToPixels = res.getDisplayMetrics().widthPixels; try (InputStream is = context.getContentResolver().openInputStream(uri)) { - if (factor > 1) { - options.inJustDecodeBounds = false; - options.inSampleSize = factor; - bm = BitmapFactory.decodeStream(is, null, options); - } else - bm = BitmapFactory.decodeStream(is); - + bm = getScaledBitmap(is, a.source, scaleToPixels); if (bm == null) throw new FileNotFoundException(a.source); }