calculate sample size for thumbnails as well

This commit is contained in:
iNPUTmice 2014-09-30 16:22:02 +02:00
parent 0733a94127
commit fd6f5b0e84

View file

@ -250,7 +250,10 @@ public class FileBackend {
if (!file.exists()) { if (!file.exists()) {
file = getJingleFileLegacy(message); 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) { if (fullsize == null) {
throw new FileNotFoundException(); throw new FileNotFoundException();
} }
@ -414,6 +417,17 @@ public class FileBackend {
options.inJustDecodeBounds = true; options.inJustDecodeBounds = true;
BitmapFactory.decodeStream(context.getContentResolver() BitmapFactory.decodeStream(context.getContentResolver()
.openInputStream(image), null, options); .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 height = options.outHeight;
int width = options.outWidth; int width = options.outWidth;
int inSampleSize = 1; int inSampleSize = 1;
@ -428,7 +442,6 @@ public class FileBackend {
} }
} }
return inSampleSize; return inSampleSize;
} }
public Uri getJingleFileUri(Message message) { public Uri getJingleFileUri(Message message) {