diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/camera/data/AbstractLocalDataAdapterWrapper.java | 1 | ||||
-rw-r--r-- | src/com/android/camera/data/LocalMediaData.java | 18 |
2 files changed, 10 insertions, 9 deletions
diff --git a/src/com/android/camera/data/AbstractLocalDataAdapterWrapper.java b/src/com/android/camera/data/AbstractLocalDataAdapterWrapper.java index 5df87f5a8..ef1e4258c 100644 --- a/src/com/android/camera/data/AbstractLocalDataAdapterWrapper.java +++ b/src/com/android/camera/data/AbstractLocalDataAdapterWrapper.java @@ -51,6 +51,7 @@ public abstract class AbstractLocalDataAdapterWrapper implements LocalDataAdapte public void suggestViewSizeBound(int w, int h) { mSuggestedWidth = w; mSuggestedHeight = h; + mAdapter.suggestViewSizeBound(w, h); } @Override diff --git a/src/com/android/camera/data/LocalMediaData.java b/src/com/android/camera/data/LocalMediaData.java index f80b4a02f..48db0df4c 100644 --- a/src/com/android/camera/data/LocalMediaData.java +++ b/src/com/android/camera/data/LocalMediaData.java @@ -426,20 +426,20 @@ public abstract class LocalMediaData implements LocalData { @Override protected Bitmap doInBackground(Void... v) { - BitmapFactory.Options opts = null; - Bitmap b; - int sample = 1; - while (mDecodeWidth * sample < width - || mDecodeHeight * sample < height) { - sample *= 2; + int sampleSize = 1; + if (width > mDecodeWidth || height > mDecodeHeight) { + int heightRatio = Math.round((float) height / (float) mDecodeHeight); + int widthRatio = Math.round((float) width / (float) mDecodeWidth); + sampleSize = heightRatio < widthRatio ? heightRatio : widthRatio; } - opts = new BitmapFactory.Options(); - opts.inSampleSize = sample; + + BitmapFactory.Options opts = new BitmapFactory.Options(); + opts.inSampleSize = sampleSize; opts.inTempStorage = DECODE_TEMP_STORAGE; if (isCancelled() || !isUsing()) { return null; } - b = BitmapFactory.decodeFile(path, opts); + Bitmap b = BitmapFactory.decodeFile(path, opts); if (orientation != 0) { if (isCancelled() || !isUsing()) { return null; |