diff options
| author | Wei Huang <weih@google.com> | 2012-06-06 14:47:58 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-06-06 14:47:58 -0700 |
| commit | e6d36bb213c749a750bffd5e37ce85c232a64ff3 (patch) | |
| tree | d1eb883aad6935700e47644692cf8ff5e9c03b97 | |
| parent | 699ef52cb398a2d5a7ec962e7df2837a6dbccef4 (diff) | |
| parent | 4b9c37d08dc78118de53c1f3349024164abf2512 (diff) | |
| download | android_packages_apps_Gallery2-e6d36bb213c749a750bffd5e37ce85c232a64ff3.tar.gz android_packages_apps_Gallery2-e6d36bb213c749a750bffd5e37ce85c232a64ff3.tar.bz2 android_packages_apps_Gallery2-e6d36bb213c749a750bffd5e37ce85c232a64ff3.zip | |
Merge "Check the offset of output rect when cropping image." into jb-dev
| -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); |
