summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei Huang <weih@google.com>2012-06-06 14:49:49 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-06-06 14:49:49 -0700
commitf19f0cb5c1a18be8689bfdf054ac06c27a8484ca (patch)
treeaae5db175ea3b8bcb7fc847e0755a63345848ec6
parent9c5710a08d83c6728ef5bd58c77475706b6ee61f (diff)
parenteae57c0ccbb9d22a61f681fed3d2696a5135d3c4 (diff)
downloadandroid_packages_apps_Snap-f19f0cb5c1a18be8689bfdf054ac06c27a8484ca.tar.gz
android_packages_apps_Snap-f19f0cb5c1a18be8689bfdf054ac06c27a8484ca.tar.bz2
android_packages_apps_Snap-f19f0cb5c1a18be8689bfdf054ac06c27a8484ca.zip
am e6d36bb2: Merge "Check the offset of output rect when cropping image." into jb-dev
* commit 'e6d36bb213c749a750bffd5e37ce85c232a64ff3': Check the offset of output rect when cropping image.
-rw-r--r--src/com/android/gallery3d/app/CropImage.java6
-rw-r--r--src/com/android/gallery3d/app/Wallpaper.java10
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);