summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/photoeditor
diff options
context:
space:
mode:
authorYuli Huang <yuli@google.com>2011-10-26 20:10:06 +0800
committerYuli Huang <yuli@google.com>2011-10-27 01:05:14 +0800
commit1f96795daee8d21bf41847a59428b4f25837898f (patch)
tree26bd7aca0e13445102059a69dfc5e10a3df6dd63 /src/com/android/gallery3d/photoeditor
parent960647247705f2c3e375061d234424b71c286e4d (diff)
downloadandroid_packages_apps_Snap-1f96795daee8d21bf41847a59428b4f25837898f.tar.gz
android_packages_apps_Snap-1f96795daee8d21bf41847a59428b4f25837898f.tar.bz2
android_packages_apps_Snap-1f96795daee8d21bf41847a59428b4f25837898f.zip
Fix b/5501285 by ensuring bitmap in ARGB8888 format.
Change-Id: I48ece547543207ba92276962fc6131859f615313
Diffstat (limited to 'src/com/android/gallery3d/photoeditor')
-rw-r--r--src/com/android/gallery3d/photoeditor/BitmapUtils.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/com/android/gallery3d/photoeditor/BitmapUtils.java b/src/com/android/gallery3d/photoeditor/BitmapUtils.java
index ef01e4868..a9fa758ec 100644
--- a/src/com/android/gallery3d/photoeditor/BitmapUtils.java
+++ b/src/com/android/gallery3d/photoeditor/BitmapUtils.java
@@ -60,7 +60,7 @@ public class BitmapUtils {
/**
* Creates a mutable bitmap from subset of source bitmap, transformed by the optional matrix.
*/
- public static Bitmap createBitmap(
+ private static Bitmap createBitmap(
Bitmap source, int x, int y, int width, int height, Matrix m) {
// Re-implement Bitmap createBitmap() to always return a mutable bitmap.
Canvas canvas = new Canvas();
@@ -168,8 +168,15 @@ public class BitmapUtils {
closeStream(is);
}
- // Scale down the sampled bitmap if it's still larger than the desired dimension.
+ // Ensure bitmap in 8888 format, good for editing as well as GL compatible.
+ if ((bitmap != null) && (bitmap.getConfig() != Bitmap.Config.ARGB_8888)) {
+ Bitmap copy = bitmap.copy(Bitmap.Config.ARGB_8888, true);
+ bitmap.recycle();
+ bitmap = copy;
+ }
+
if (bitmap != null) {
+ // Scale down the sampled bitmap if it's still larger than the desired dimension.
float scale = Math.min((float) width / bitmap.getWidth(),
(float) height / bitmap.getHeight());
scale = Math.max(scale, Math.min((float) height / bitmap.getWidth(),