diff options
author | Owen Lin <owenlin@google.com> | 2011-09-13 23:44:43 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-09-13 23:44:43 -0700 |
commit | 6eb768fc3012ee427f267d1b5312669afea9624b (patch) | |
tree | 9dfb9b158a3ac396caa7758bbd22ec13669a8474 /src/com | |
parent | 36064d1d4450494983652a5264a5d27cab454eed (diff) | |
parent | b251df22a421b5affb15d7a18700889647dbc856 (diff) | |
download | android_packages_apps_Snap-6eb768fc3012ee427f267d1b5312669afea9624b.tar.gz android_packages_apps_Snap-6eb768fc3012ee427f267d1b5312669afea9624b.tar.bz2 android_packages_apps_Snap-6eb768fc3012ee427f267d1b5312669afea9624b.zip |
Merge "Fix picasa images rotate incorrectly."
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/gallery3d/app/PhotoDataAdapter.java | 26 | ||||
-rw-r--r-- | src/com/android/gallery3d/data/MediaItem.java | 6 |
2 files changed, 30 insertions, 2 deletions
diff --git a/src/com/android/gallery3d/app/PhotoDataAdapter.java b/src/com/android/gallery3d/app/PhotoDataAdapter.java index b976dec84..9b1c8c4c0 100644 --- a/src/com/android/gallery3d/app/PhotoDataAdapter.java +++ b/src/com/android/gallery3d/app/PhotoDataAdapter.java @@ -16,6 +16,7 @@ package com.android.gallery3d.app; +import com.android.gallery3d.common.BitmapUtils; import com.android.gallery3d.common.Utils; import com.android.gallery3d.data.ContentListener; import com.android.gallery3d.data.DataManager; @@ -30,6 +31,8 @@ import com.android.gallery3d.ui.TileImageViewAdapter; import com.android.gallery3d.util.Future; import com.android.gallery3d.util.FutureListener; import com.android.gallery3d.util.ThreadPool; +import com.android.gallery3d.util.ThreadPool.Job; +import com.android.gallery3d.util.ThreadPool.JobContext; import android.graphics.Bitmap; import android.graphics.BitmapRegionDecoder; @@ -487,6 +490,25 @@ public class PhotoDataAdapter implements PhotoPage.Model { } } + private static class ScreenNailJob implements Job<Bitmap> { + private MediaItem mItem; + + public ScreenNailJob(MediaItem item) { + mItem = item; + } + + @Override + public Bitmap run(JobContext jc) { + Bitmap bitmap = mItem.requestImage(MediaItem.TYPE_THUMBNAIL).run(jc); + if (jc.isCancelled()) return null; + if (bitmap != null) { + bitmap = BitmapUtils.rotateBitmap(bitmap, + mItem.getRotation() - mItem.getFullImageRotation(), true); + } + return bitmap; + } + } + // Returns the task if we started the task or the task is already started. private Future<?> startTaskIfNeeded(int index, int which) { if (index < mActiveStart || index >= mActiveEnd) return null; @@ -507,7 +529,7 @@ public class PhotoDataAdapter implements PhotoPage.Model { && (entry.requestedBits & BIT_SCREEN_NAIL) == 0) { entry.requestedBits |= BIT_SCREEN_NAIL; entry.screenNailTask = mThreadPool.submit( - item.requestImage(MediaItem.TYPE_THUMBNAIL), + new ScreenNailJob(item), new ScreenNailListener(item.getDataVersion())); // request screen nail return entry.screenNailTask; @@ -547,7 +569,7 @@ public class PhotoDataAdapter implements PhotoPage.Model { } } else { entry = new ImageEntry(); - entry.rotation = item.getRotation(); + entry.rotation = item.getFullImageRotation(); mImageCache.put(version, entry); } } diff --git a/src/com/android/gallery3d/data/MediaItem.java b/src/com/android/gallery3d/data/MediaItem.java index 430d8327d..090625192 100644 --- a/src/com/android/gallery3d/data/MediaItem.java +++ b/src/com/android/gallery3d/data/MediaItem.java @@ -63,6 +63,12 @@ public abstract class MediaItem extends MediaObject { return null; } + // The rotation of the full-resolution image. By default, it returns the value of + // getRotation(). + public int getFullImageRotation() { + return getRotation(); + } + public int getRotation() { return 0; } |