From 3ed72781a0b155a88e52c8d295f50daab8cfb9ae Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Thu, 15 Aug 2013 12:54:53 -0700 Subject: [PATCH] Convert 4444 bitmaps to 8888 Bug #10206452 Change-Id: I928c9189b0d80741490b01a739959d8c2d5312a7 (cherry picked from commit a2cdb59b186d0ee51f110c1a7d358911573d48bf) --- core/jni/android/graphics/Bitmap.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp index b03d12aa2057b..0ea3bf733c900 100644 --- a/core/jni/android/graphics/Bitmap.cpp +++ b/core/jni/android/graphics/Bitmap.cpp @@ -222,8 +222,12 @@ static jobject Bitmap_creator(JNIEnv* env, jobject, jintArray jColors, } } - SkBitmap bitmap; + // ARGB_4444 is a deprecated format, convert automatically to 8888 + if (config == SkBitmap::kARGB_4444_Config) { + config = SkBitmap::kARGB_8888_Config; + } + SkBitmap bitmap; bitmap.setConfig(config, width, height); jbyteArray buff = GraphicsJNI::allocateJavaPixelRef(env, &bitmap, NULL); @@ -232,8 +236,7 @@ static jobject Bitmap_creator(JNIEnv* env, jobject, jintArray jColors, } if (jColors != NULL) { - GraphicsJNI::SetPixels(env, jColors, offset, stride, - 0, 0, width, height, bitmap); + GraphicsJNI::SetPixels(env, jColors, offset, stride, 0, 0, width, height, bitmap); } return GraphicsJNI::createBitmap(env, new SkBitmap(bitmap), buff, isMutable, NULL, NULL);