summaryrefslogtreecommitdiffstats
path: root/photoviewer
diff options
context:
space:
mode:
authorMark Wei <markwei@google.com>2012-08-29 18:04:17 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-08-29 18:04:17 -0700
commit28bfd5ecc0d1828d1004f8a3163b738afc74967b (patch)
treebb025d8ebecb5bedbf25a2ae81b13a39f0936a5b /photoviewer
parent9cb4051d02351dfb400f31e5193f55d5c8d22b10 (diff)
parent97992e595ffb8eef8a6a12609cc4da368d4e0f6f (diff)
downloadandroid_frameworks_ex-28bfd5ecc0d1828d1004f8a3163b738afc74967b.tar.gz
android_frameworks_ex-28bfd5ecc0d1828d1004f8a3163b738afc74967b.tar.bz2
android_frameworks_ex-28bfd5ecc0d1828d1004f8a3163b738afc74967b.zip
am 97992e59: am c645df0a: am 4f38cc16: Attachment image viewer should not scale images larger than original size.
* commit '97992e595ffb8eef8a6a12609cc4da368d4e0f6f': Attachment image viewer should not scale images larger than original size.
Diffstat (limited to 'photoviewer')
-rw-r--r--photoviewer/src/com/android/ex/photo/loaders/PhotoBitmapLoader.java5
-rw-r--r--photoviewer/src/com/android/ex/photo/views/PhotoView.java8
2 files changed, 10 insertions, 3 deletions
diff --git a/photoviewer/src/com/android/ex/photo/loaders/PhotoBitmapLoader.java b/photoviewer/src/com/android/ex/photo/loaders/PhotoBitmapLoader.java
index f5c5cd0..7049370 100644
--- a/photoviewer/src/com/android/ex/photo/loaders/PhotoBitmapLoader.java
+++ b/photoviewer/src/com/android/ex/photo/loaders/PhotoBitmapLoader.java
@@ -22,6 +22,7 @@ import android.content.ContentResolver;
import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
+import android.util.DisplayMetrics;
import com.android.ex.photo.fragments.PhotoViewFragment;
import com.android.ex.photo.util.ImageUtils;
@@ -49,8 +50,10 @@ public class PhotoBitmapLoader extends AsyncTaskLoader<Bitmap> {
if (context != null && mPhotoUri != null) {
final ContentResolver resolver = context.getContentResolver();
- return ImageUtils.createLocalBitmap(resolver, Uri.parse(mPhotoUri),
+ Bitmap bitmap = ImageUtils.createLocalBitmap(resolver, Uri.parse(mPhotoUri),
PhotoViewFragment.sPhotoSize);
+ bitmap.setDensity(DisplayMetrics.DENSITY_MEDIUM);
+ return bitmap;
}
return null;
diff --git a/photoviewer/src/com/android/ex/photo/views/PhotoView.java b/photoviewer/src/com/android/ex/photo/views/PhotoView.java
index 647d168..e767cba 100644
--- a/photoviewer/src/com/android/ex/photo/views/PhotoView.java
+++ b/photoviewer/src/com/android/ex/photo/views/PhotoView.java
@@ -699,7 +699,6 @@ public class PhotoView extends View implements GestureDetector.OnGestureListener
final boolean fits = (dwidth < 0 || vwidth == dwidth) &&
(dheight < 0 || vheight == dheight);
- // Set the matrix to fill the screen
if (fits && !mAllowCrop) {
mMatrix.reset();
} else {
@@ -710,7 +709,12 @@ public class PhotoView extends View implements GestureDetector.OnGestureListener
} else {
mTempDst.set(0, 0, vwidth, vheight);
}
- mMatrix.setRectToRect(mTempSrc, mTempDst, Matrix.ScaleToFit.CENTER);
+
+ if (dwidth < vwidth && dheight < vheight && !mAllowCrop) {
+ mMatrix.setTranslate(vwidth / 2 - dwidth / 2, vheight / 2 - dheight / 2);
+ } else {
+ mMatrix.setRectToRect(mTempSrc, mTempDst, Matrix.ScaleToFit.CENTER);
+ }
}
mOriginalMatrix.set(mMatrix);
}