diff options
author | Gilles-Arnaud Bleu-Laine <gilles@ti.com> | 2011-09-22 18:05:07 -0500 |
---|---|---|
committer | Wu-cheng Li <wuchengli@google.com> | 2011-09-27 14:28:52 +0800 |
commit | 1743de666ba52fd8a32babb36de01c7e3b56c2a7 (patch) | |
tree | 9493b4c1279de720ccd8b8495af037b190787242 /src/com | |
parent | 9c58ffd7b175c05fb99b4adfea96dd11dfe41b74 (diff) | |
download | LegacyCamera-1743de666ba52fd8a32babb36de01c7e3b56c2a7.zip LegacyCamera-1743de666ba52fd8a32babb36de01c7e3b56c2a7.tar.gz LegacyCamera-1743de666ba52fd8a32babb36de01c7e3b56c2a7.tar.bz2 |
Prevent re-compression of thumbnail upon closing camera
Thumbnail is compressed to JPEG at 90% quality every time the application is
closed. This behavior causes the degrading issue that the quality of thumbnail
is getting worse.
Adding a new flag to ensure thumbnail is compressed and
stored only when it is newly generated.
bug:5371985
Change-Id: I90cedeebf2d4c5dfc25e6524529f7f1e5a6f63fc
Signed-off-by: Gilles-Arnaud Bleu-Laine <gilles@ti.com>
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/camera/Camera.java | 6 | ||||
-rw-r--r-- | src/com/android/camera/Thumbnail.java | 14 | ||||
-rw-r--r-- | src/com/android/camera/VideoCamera.java | 3 |
3 files changed, 16 insertions, 7 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index 4c576a5..1a598f2 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -1251,10 +1251,8 @@ public class Camera extends ActivityBase implements FocusManager.Listener, if (mFirstTimeInitialized) { mOrientationListener.disable(); - if (!mIsImageCaptureIntent) { - if (mThumbnail != null) { - mThumbnail.saveTo(new File(getFilesDir(), Thumbnail.LAST_THUMB_FILENAME)); - } + if (!mIsImageCaptureIntent && mThumbnail != null && !mThumbnail.fromFile()) { + mThumbnail.saveTo(new File(getFilesDir(), Thumbnail.LAST_THUMB_FILENAME)); } } diff --git a/src/com/android/camera/Thumbnail.java b/src/com/android/camera/Thumbnail.java index d35b966..a0f892b 100644 --- a/src/com/android/camera/Thumbnail.java +++ b/src/com/android/camera/Thumbnail.java @@ -48,6 +48,8 @@ public class Thumbnail { private Uri mUri; private Bitmap mBitmap; + // whether this thumbnail is read from file + private boolean mFromFile = false; public Thumbnail(Uri uri, Bitmap bitmap, int orientation) { mUri = uri; @@ -63,6 +65,14 @@ public class Thumbnail { return mBitmap; } + public void setFromFile(boolean fromFile) { + mFromFile = fromFile; + } + + public boolean fromFile() { + return mFromFile; + } + private static Bitmap rotateImage(Bitmap bitmap, int orientation) { if (orientation != 0) { // We only rotate the thumbnail once even if we get OOM. @@ -128,7 +138,9 @@ public class Thumbnail { Util.closeSilently(b); Util.closeSilently(d); } - return createThumbnail(uri, bitmap, 0); + Thumbnail thumbnail = createThumbnail(uri, bitmap, 0); + if (thumbnail != null) thumbnail.setFromFile(true); + return thumbnail; } public static Thumbnail getLastThumbnail(ContentResolver resolver) { diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java index a95ef27..10cfc85 100644 --- a/src/com/android/camera/VideoCamera.java +++ b/src/com/android/camera/VideoCamera.java @@ -71,7 +71,6 @@ import java.io.IOException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; -import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -928,7 +927,7 @@ public class VideoCamera extends ActivityBase } resetScreenOn(); - if (!mIsVideoCaptureIntent && mThumbnail != null) { + if (!mIsVideoCaptureIntent && mThumbnail != null && !mThumbnail.fromFile()) { mThumbnail.saveTo(new File(getFilesDir(), Thumbnail.LAST_THUMB_FILENAME)); } |