diff options
author | Mark Wei <markwei@google.com> | 2012-08-29 15:05:38 -0700 |
---|---|---|
committer | Mark Wei <markwei@google.com> | 2012-08-29 15:05:38 -0700 |
commit | 4f38cc1673163848c7b843cb9d23b21945b0bf82 (patch) | |
tree | 311d8674f7b330acaac30ff6fce8acc8f90ede01 /photoviewer | |
parent | 114cef99189d693ed9cd8cf778a60823d06d5298 (diff) | |
download | android_frameworks_ex-4f38cc1673163848c7b843cb9d23b21945b0bf82.tar.gz android_frameworks_ex-4f38cc1673163848c7b843cb9d23b21945b0bf82.tar.bz2 android_frameworks_ex-4f38cc1673163848c7b843cb9d23b21945b0bf82.zip |
Attachment image viewer should not scale images larger than original size.
Bug: 7049410
Change-Id: I1ed2555203e1541f1481cae4f17f532eaa57c1cd
Diffstat (limited to 'photoviewer')
-rw-r--r-- | photoviewer/src/com/android/ex/photo/loaders/PhotoBitmapLoader.java | 5 | ||||
-rw-r--r-- | photoviewer/src/com/android/ex/photo/views/PhotoView.java | 8 |
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); } |