diff options
author | Owen Lin <owenlin@google.com> | 2012-05-30 16:39:21 +0800 |
---|---|---|
committer | Owen Lin <owenlin@google.com> | 2012-06-06 14:49:25 +0800 |
commit | eae57c0ccbb9d22a61f681fed3d2696a5135d3c4 (patch) | |
tree | aae5db175ea3b8bcb7fc847e0755a63345848ec6 /src | |
parent | eb05110658d06001d077b5fe2250e97465e248ed (diff) | |
download | android_packages_apps_Snap-eae57c0ccbb9d22a61f681fed3d2696a5135d3c4.tar.gz android_packages_apps_Snap-eae57c0ccbb9d22a61f681fed3d2696a5135d3c4.tar.bz2 android_packages_apps_Snap-eae57c0ccbb9d22a61f681fed3d2696a5135d3c4.zip |
Check the offset of output rect when cropping image.
bug: 6568720
Change-Id: I36c98cab5830eaac15369ada1a1a988e10b0fbf4
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/gallery3d/app/CropImage.java | 6 | ||||
-rw-r--r-- | src/com/android/gallery3d/app/Wallpaper.java | 10 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/com/android/gallery3d/app/CropImage.java b/src/com/android/gallery3d/app/CropImage.java index 835970b4f..4f450d85e 100644 --- a/src/com/android/gallery3d/app/CropImage.java +++ b/src/com/android/gallery3d/app/CropImage.java @@ -612,8 +612,14 @@ public class CropImage extends AbstractGalleryActivity { int sample = BitmapUtils.computeSampleSizeLarger( Math.max(scaleX, scaleY)); options.inSampleSize = sample; + + // The decoding result is what we want if + // 1. The size of the decoded bitmap match the destination's size + // 2. The destination covers the whole output bitmap + // 3. No rotation if ((rect.width() / sample) == dest.width() && (rect.height() / sample) == dest.height() + && (outputX == dest.width()) && (outputY == dest.height()) && rotation == 0) { // To prevent concurrent access in GLThread synchronized (mRegionDecoder) { diff --git a/src/com/android/gallery3d/app/Wallpaper.java b/src/com/android/gallery3d/app/Wallpaper.java index 07a3d5313..c08c1d705 100644 --- a/src/com/android/gallery3d/app/Wallpaper.java +++ b/src/com/android/gallery3d/app/Wallpaper.java @@ -18,9 +18,9 @@ package com.android.gallery3d.app; import android.app.Activity; import android.content.Intent; +import android.graphics.Point; import android.net.Uri; import android.os.Bundle; -import android.view.Display; /** * Wallpaper picker for the gallery application. This just redirects to the @@ -78,9 +78,10 @@ public class Wallpaper extends Activity { case STATE_PHOTO_PICKED: { int width = getWallpaperDesiredMinimumWidth(); int height = getWallpaperDesiredMinimumHeight(); - Display display = getWindowManager().getDefaultDisplay(); - float spotlightX = (float) display.getWidth() / width; - float spotlightY = (float) display.getHeight() / height; + Point size = new Point(); + getWindowManager().getDefaultDisplay().getSize(size); + float spotlightX = (float) size.x / width; + float spotlightY = (float) size.y / height; Intent request = new Intent(CropImage.ACTION_CROP) .setDataAndType(mPickedItem, IMAGE_TYPE) .addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT) @@ -91,6 +92,7 @@ public class Wallpaper extends Activity { .putExtra(CropImage.KEY_SPOTLIGHT_X, spotlightX) .putExtra(CropImage.KEY_SPOTLIGHT_Y, spotlightY) .putExtra(CropImage.KEY_SCALE, true) + .putExtra(CropImage.KEY_SCALE_UP_IF_NEEDED, true) .putExtra(CropImage.KEY_NO_FACE_DETECTION, true) .putExtra(CropImage.KEY_SET_AS_WALLPAPER, true); startActivity(request); |