diff options
author | Owen Lin <owenlin@google.com> | 2011-08-30 10:38:59 +0800 |
---|---|---|
committer | Owen Lin <owenlin@google.com> | 2011-09-05 11:28:18 +0800 |
commit | ace280a70fd1ead67039b9667d3905c85703c094 (patch) | |
tree | add5ae4895e61f13a9b55c91b9890bb6ecc9a58e /src/com/android/gallery3d/data/LocalImage.java | |
parent | 9c12d7512df688131384328fb6ffb89b36cc4393 (diff) | |
download | android_packages_apps_Snap-ace280a70fd1ead67039b9667d3905c85703c094.tar.gz android_packages_apps_Snap-ace280a70fd1ead67039b9667d3905c85703c094.tar.bz2 android_packages_apps_Snap-ace280a70fd1ead67039b9667d3905c85703c094.zip |
Improve the performance of Reviewing a photo.
fix: 5144370
There is two componenet in the photo page. One is the large photo and the
other is the thumbnail strip. They idenpendently load their own data and images.
This change fixes several issues here:
1. Prevent sending to many jobs to ThreadPool and block others.
In a worse case, if the thumbnail strip send image requests first,
it may block the ThreadPool very long.
2. Improve the performance of extracting thumbnails from local files.
Now we try to extract the thumbnails from EXIF data first.
Change-Id: I45100d4daa025efb479f47c4f105de2b4731b498
Diffstat (limited to 'src/com/android/gallery3d/data/LocalImage.java')
-rw-r--r-- | src/com/android/gallery3d/data/LocalImage.java | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/com/android/gallery3d/data/LocalImage.java b/src/com/android/gallery3d/data/LocalImage.java index f3dedf037..7ab04c568 100644 --- a/src/com/android/gallery3d/data/LocalImage.java +++ b/src/com/android/gallery3d/data/LocalImage.java @@ -18,10 +18,10 @@ package com.android.gallery3d.data; import com.android.gallery3d.app.GalleryApp; import com.android.gallery3d.common.BitmapUtils; -import com.android.gallery3d.util.UpdateHelper; import com.android.gallery3d.util.GalleryUtils; import com.android.gallery3d.util.ThreadPool.Job; import com.android.gallery3d.util.ThreadPool.JobContext; +import com.android.gallery3d.util.UpdateHelper; import android.content.ContentResolver; import android.content.ContentValues; @@ -33,6 +33,7 @@ import android.media.ExifInterface; import android.net.Uri; import android.provider.MediaStore.Images; import android.provider.MediaStore.Images.ImageColumns; +import android.util.Log; import java.io.File; import java.io.IOException; @@ -158,6 +159,25 @@ public class LocalImage extends LocalMediaItem { public Bitmap onDecodeOriginal(JobContext jc, int type) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; + + // try to decode from JPEG EXIF + if (type == MediaItem.TYPE_MICROTHUMBNAIL) { + ExifInterface exif = null; + byte [] thumbData = null; + try { + exif = new ExifInterface(mLocalFilePath); + if (exif != null) { + thumbData = exif.getThumbnail(); + } + } catch (Throwable t) { + Log.w(TAG, "fail to get exif thumb", t); + } + if (thumbData != null) { + Bitmap bitmap = DecodeUtils.requestDecodeIfBigEnough( + jc, thumbData, options, getTargetSize(type)); + if (bitmap != null) return bitmap; + } + } return DecodeUtils.requestDecode( jc, mLocalFilePath, options, getTargetSize(type)); } |