summaryrefslogtreecommitdiffstats
path: root/photoviewer
diff options
context:
space:
mode:
authorMark Wei <markwei@google.com>2012-08-29 18:02:47 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-08-29 18:02:47 -0700
commit97992e595ffb8eef8a6a12609cc4da368d4e0f6f (patch)
tree4727416a73e57326b0519d253e729d64696f4351 /photoviewer
parent4689c6f834a99fe8b57f2391bc14d13a3c6645cb (diff)
parentc645df0a6d37dcf794e7ed8c8a334c08df8b9da6 (diff)
downloadandroid_frameworks_ex-97992e595ffb8eef8a6a12609cc4da368d4e0f6f.tar.gz
android_frameworks_ex-97992e595ffb8eef8a6a12609cc4da368d4e0f6f.tar.bz2
android_frameworks_ex-97992e595ffb8eef8a6a12609cc4da368d4e0f6f.zip
am c645df0a: am 4f38cc16: Attachment image viewer should not scale images larger than original size.
* commit 'c645df0a6d37dcf794e7ed8c8a334c08df8b9da6': 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);
}