From 1259bc49d956887477ad6d789668fb61f572b046 Mon Sep 17 00:00:00 2001 From: Sascha Haeberling Date: Wed, 21 Aug 2013 18:57:10 -0700 Subject: Speed up filmstrip by not decoding with default 3000px. Bug: 10330214 Bug: 10430152 We need to tell the wrapped data adapters about the size we need. Also, use a more efficient way to determine the sample size. Change-Id: Ie2c6fb438f06d97d6e5420afdceccccf41040020 --- .../camera/data/AbstractLocalDataAdapterWrapper.java | 1 + src/com/android/camera/data/LocalMediaData.java | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'src') 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; -- cgit v1.2.3