diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-09-30 16:22:02 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-09-30 16:22:02 +0200 |
commit | fd6f5b0e84763e98be6299d63d48786c602211a3 (patch) | |
tree | 11f83edae968df55cbbb5de907aff20b78de83be | |
parent | 0733a941276fbb976c3b0d0b40f724b2cfd34e31 (diff) |
calculate sample size for thumbnails as well
Diffstat (limited to '')
-rw-r--r-- | src/eu/siacs/conversations/persistance/FileBackend.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/eu/siacs/conversations/persistance/FileBackend.java b/src/eu/siacs/conversations/persistance/FileBackend.java index 2b2aa86e..d86c0ee1 100644 --- a/src/eu/siacs/conversations/persistance/FileBackend.java +++ b/src/eu/siacs/conversations/persistance/FileBackend.java @@ -250,7 +250,10 @@ public class FileBackend { if (!file.exists()) { file = getJingleFileLegacy(message); } - Bitmap fullsize = BitmapFactory.decodeFile(file.getAbsolutePath()); + BitmapFactory.Options options = new BitmapFactory.Options(); + options.inSampleSize = calcSampleSize(file, size); + Bitmap fullsize = BitmapFactory.decodeFile(file.getAbsolutePath(), + options); if (fullsize == null) { throw new FileNotFoundException(); } @@ -414,6 +417,17 @@ public class FileBackend { options.inJustDecodeBounds = true; BitmapFactory.decodeStream(context.getContentResolver() .openInputStream(image), null, options); + return calcSampleSize(options, size); + } + + private int calcSampleSize(File image, int size) { + BitmapFactory.Options options = new BitmapFactory.Options(); + options.inJustDecodeBounds = true; + BitmapFactory.decodeFile(image.getAbsolutePath(), options); + return calcSampleSize(options, size); + } + + private int calcSampleSize(BitmapFactory.Options options, int size) { int height = options.outHeight; int width = options.outWidth; int inSampleSize = 1; @@ -428,7 +442,6 @@ public class FileBackend { } } return inSampleSize; - } public Uri getJingleFileUri(Message message) { |