From 0dca1b590f4cae2fe42afc9245f1a8ea81f9e6d3 Mon Sep 17 00:00:00 2001 From: Ruben Brunk Date: Fri, 12 Jul 2013 17:23:39 -0700 Subject: Combine ImageLoader and CropLoader utility classes. Bug: 9356969 Bug: 9170644 - Refactor to eliminate code duplication in image loading classes. - Fix bugs caused by the inability to determine MIME types for images that aren't in Gallery's content provider (causes b/9356969). Change-Id: I30c2ba5c0cd37aac624681a2cec9abddaa78f9c2 --- .../gallery3d/filtershow/imageshow/ImageShow.java | 3 ++- .../filtershow/imageshow/MasterImage.java | 28 ++++++++++++---------- 2 files changed, 17 insertions(+), 14 deletions(-) (limited to 'src/com/android/gallery3d/filtershow/imageshow') diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java index 8b9d57cb9..2da358c2c 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java +++ b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java @@ -40,6 +40,7 @@ import com.android.gallery3d.filtershow.FilterShowActivity; import com.android.gallery3d.filtershow.cache.ImageLoader; import com.android.gallery3d.filtershow.filters.ImageFilter; import com.android.gallery3d.filtershow.pipeline.ImagePreset; +import com.android.gallery3d.filtershow.tools.SaveCopyTask; import java.io.File; @@ -394,7 +395,7 @@ public class ImageShow extends View implements OnGestureListener, } public void saveImage(FilterShowActivity filterShowActivity, File file) { - ImageLoader.saveImage(getImagePreset(), filterShowActivity, file); + SaveCopyTask.saveImage(getImagePreset(), filterShowActivity, file); } diff --git a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java index 7b11cf35e..08d8c45eb 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java +++ b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java @@ -26,29 +26,29 @@ import android.os.Handler; import android.os.Message; import com.android.gallery3d.filtershow.FilterShowActivity; -import com.android.gallery3d.filtershow.history.HistoryManager; -import com.android.gallery3d.filtershow.history.HistoryItem; -import com.android.gallery3d.filtershow.pipeline.FilteringPipeline; import com.android.gallery3d.filtershow.cache.ImageLoader; -import com.android.gallery3d.filtershow.pipeline.RenderingRequest; -import com.android.gallery3d.filtershow.pipeline.RenderingRequestCaller; import com.android.gallery3d.filtershow.filters.FilterRepresentation; import com.android.gallery3d.filtershow.filters.ImageFilter; +import com.android.gallery3d.filtershow.history.HistoryItem; +import com.android.gallery3d.filtershow.history.HistoryManager; import com.android.gallery3d.filtershow.pipeline.Buffer; +import com.android.gallery3d.filtershow.pipeline.FilteringPipeline; +import com.android.gallery3d.filtershow.pipeline.ImagePreset; +import com.android.gallery3d.filtershow.pipeline.RenderingRequest; +import com.android.gallery3d.filtershow.pipeline.RenderingRequestCaller; import com.android.gallery3d.filtershow.pipeline.SharedBuffer; import com.android.gallery3d.filtershow.pipeline.SharedPreset; -import com.android.gallery3d.filtershow.pipeline.ImagePreset; import com.android.gallery3d.filtershow.state.StateAdapter; import java.util.Vector; public class MasterImage implements RenderingRequestCaller { - - private static final String LOGTAG = "MasterImage"; private boolean DEBUG = false; private static final boolean DISABLEZOOM = false; + public static final int SMALL_BITMAP_DIM = 160; + public static final int MAX_BITMAP_DIM = 900; private static MasterImage sMasterImage = null; private boolean mSupportsHighRes = false; @@ -188,13 +188,16 @@ public class MasterImage implements RenderingRequestCaller { public boolean loadBitmap(Uri uri, int size) { setUri(uri); - mOrientation = ImageLoader.getOrientation(mActivity, uri); - mOriginalBitmapLarge = ImageLoader.loadOrientedScaledBitmap(this, mActivity, uri, size, - true, mOrientation); + mOrientation = ImageLoader.getMetadataOrientation(mActivity, uri); + Rect originalBounds = new Rect(); + mOriginalBitmapLarge = ImageLoader.loadOrientedConstrainedBitmap(uri, mActivity, + Math.min(MAX_BITMAP_DIM, size), + mOrientation, originalBounds); + setOriginalBounds(originalBounds); if (mOriginalBitmapLarge == null) { return false; } - int sw = ImageLoader.SMALL_BITMAP_DIM; + int sw = SMALL_BITMAP_DIM; int sh = (int) (sw * (float) mOriginalBitmapLarge.getHeight() / (float) mOriginalBitmapLarge .getWidth()); mOriginalBitmapSmall = Bitmap.createScaledBitmap(mOriginalBitmapLarge, sw, sh, true); @@ -547,7 +550,6 @@ public class MasterImage implements RenderingRequestCaller { } } - public float getScaleFactor() { return mScaleFactor; } -- cgit v1.2.3