Skip to content

Commit 9075248

Browse files
author
Romain Guy
committed
Properly resize paletted bitmaps when adjusting for density
If an app used a GIF file in the wrong density bucket, the auto-scaling code would not properly resize the bitmap. This issue affects third party applications, here is the external bug report: http://code.google.com/p/android/issues/detail?id=34619 DO NOT MERGE Change-Id: I7f99b28ad6e6c28bdbcb29bbbadcb215268ff710
1 parent 40a4ab1 commit 9075248

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

core/jni/android/graphics/BitmapFactory.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,18 @@ static jobject doDecode(JNIEnv* env, SkStream* stream, jobject padding,
327327
const float sx = scaledWidth / float(decoded->width());
328328
const float sy = scaledHeight / float(decoded->height());
329329

330-
bitmap->setConfig(decoded->getConfig(), scaledWidth, scaledHeight);
330+
SkBitmap::Config config = decoded->config();
331+
switch (config) {
332+
case SkBitmap::kNo_Config:
333+
case SkBitmap::kIndex8_Config:
334+
case SkBitmap::kRLE_Index8_Config:
335+
config = SkBitmap::kARGB_8888_Config;
336+
break;
337+
default:
338+
break;
339+
}
340+
341+
bitmap->setConfig(config, scaledWidth, scaledHeight);
331342
bitmap->setIsOpaque(decoded->isOpaque());
332343
bitmap->allocPixels(&javaAllocator, NULL);
333344
bitmap->eraseColor(0);

0 commit comments

Comments
 (0)