diff options
author | pezhan <pezhan@codeaurora.org> | 2017-03-01 14:28:34 +0800 |
---|---|---|
committer | Arne Coucheron <arco68@gmail.com> | 2017-06-13 07:18:36 +0200 |
commit | c188ffee66e30718a792bfccb581a9e630a1c4f1 (patch) | |
tree | 6ae1d5b6146fc214243ede5e6af11b6000464bfd | |
parent | d24a8ede150863e67f67bbd04279b138c7fde242 (diff) | |
download | android_packages_apps_Snap-c188ffee66e30718a792bfccb581a9e630a1c4f1.tar.gz android_packages_apps_Snap-c188ffee66e30718a792bfccb581a9e630a1c4f1.tar.bz2 android_packages_apps_Snap-c188ffee66e30718a792bfccb581a9e630a1c4f1.zip |
SnapdragonCamera: Fix Camera1 force close when refocusing the picture.
When the screen is PORTRAIT mode, we get the screen always height < width.
But we get the image always height < width.Under this circumstance,
the inSampleSize maybe incorrect , which will cause OOM when create bitmap.
Need to check the screen's orientation,and choose the correct width and
height to calculate the inSampleSize.
Change-Id: I11743c862ebdb9d35c4fc5de7bf40003c69b7219
CRs-Fixed: 2013250
-rw-r--r-- | src/com/android/camera/RefocusActivity.java | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/com/android/camera/RefocusActivity.java b/src/com/android/camera/RefocusActivity.java index 599d46656..bc80a4f1b 100644 --- a/src/com/android/camera/RefocusActivity.java +++ b/src/com/android/camera/RefocusActivity.java @@ -39,6 +39,7 @@ import android.animation.PropertyValuesHolder; import android.animation.ValueAnimator; import android.app.Activity; import android.content.Context; +import android.content.res.Configuration; import android.content.res.Resources; import android.content.Intent; import android.graphics.Bitmap; @@ -215,6 +216,8 @@ public class RefocusActivity extends Activity { private class LoadImageTask extends AsyncTask<String, Void, Bitmap> { protected Bitmap doInBackground(String... path) { final BitmapFactory.Options o = new BitmapFactory.Options(); + int height; + int width; o.inJustDecodeBounds = true; BitmapFactory.decodeFile(path[0], o); ExifInterface exif = new ExifInterface(); @@ -226,13 +229,24 @@ public class RefocusActivity extends Activity { } int h = o.outHeight; int w = o.outWidth; + int screenOrientation = RefocusActivity.this.getResources().getConfiguration() + .orientation; + if (screenOrientation == Configuration.ORIENTATION_PORTRAIT) { + height = mWidth; + width = mHeight; + } else { + height = mHeight; + width = mWidth; + } int sample = 1; - if (h > mHeight || w > mWidth) { - while (h / sample / 2 > mHeight && w / sample / 2 > mWidth) { + if (h > height || w > width) { + while (h / sample / 2 > height && w / sample / 2 > width) { sample *= 2; } } - + Log.d(TAG, "sample = " + sample); + Log.d(TAG, "h = " + h + " height = " + height); + Log.d(TAG, "w = " + w + " width = " + width); o.inJustDecodeBounds = false; o.inSampleSize = sample; Bitmap bitmap = BitmapFactory.decodeFile(path[0], o); |