Do not convert non gray PNG to A8.
authorscroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 2 Oct 2013 15:50:19 +0000 (15:50 +0000)
committerscroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 2 Oct 2013 15:50:19 +0000 (15:50 +0000)
If the user requested A8, but the source is not gray, switch to
ARGB8888.

BUG=https://b.corp.google.com/issue?id=9189955
R=reed@google.com

Review URL: https://codereview.chromium.org/24882002

git-svn-id: http://skia.googlecode.com/svn/trunk@11573 2bbb7eff-a529-9590-31e7-b0007b416f81

src/images/SkImageDecoder_libpng.cpp

index e942f21..fc220ea 100644 (file)
@@ -532,9 +532,13 @@ bool SkPNGImageDecoder::getBitmapConfig(png_structp png_ptr, png_infop info_ptr,
                 *configp = SkBitmap::kARGB_8888_Config;
             }
         } else {
-            if (*configp != SkBitmap::kRGB_565_Config &&
-                *configp != SkBitmap::kARGB_4444_Config &&
-                *configp != SkBitmap::kA8_Config) {
+            if (SkBitmap::kA8_Config == *configp) {
+                if (k8BitGray_SrcDepth != srcDepth) {
+                    // Converting a non grayscale image to A8 is not currently supported.
+                    *configp = SkBitmap::kARGB_8888_Config;
+                }
+            } else if (*configp != SkBitmap::kRGB_565_Config &&
+                       *configp != SkBitmap::kARGB_4444_Config) {
                 *configp = SkBitmap::kARGB_8888_Config;
             }
         }