fix WBMP image will get null color table when draw in RGB565 Canvas
authorDerek Sollenberger <djsollen@google.com>
Tue, 8 Jul 2014 12:23:31 +0000 (08:23 -0400)
committerDerek Sollenberger <djsollen@google.com>
Tue, 8 Jul 2014 12:23:31 +0000 (08:23 -0400)
Symptom: draw Index8 to RGB565 will using SkColorTable::lock16BitCache and return a null array.
Root Cause:lock16BitCache return null pointer because default type is kPremul_SkAlphaType
Solution: WBMP color table should be kOpaque_SkAlphaType
Reproduce steps: draw a WBMP with a matrix that apply rotate and transform

This patch was proposed by arthur_hung at htc.com to the AOSP project.

R=reed@google.com, scroggo@google.com

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

src/images/SkImageDecoder_wbmp.cpp

index 0bf138940da8a50242aab08ea8a3384245eb6e3a..ddb7c3df026287d76b3632e5623fab630cf2e25d 100644 (file)
@@ -119,7 +119,7 @@ bool SkWBMPImageDecoder::onDecode(SkStream* stream, SkBitmap* decodedBitmap,
     }
 
     const SkPMColor colors[] = { SK_ColorBLACK, SK_ColorWHITE };
-    SkColorTable* ct = SkNEW_ARGS(SkColorTable, (colors, 2));
+    SkColorTable* ct = SkNEW_ARGS(SkColorTable, (colors, 2, kOpaque_SkAlphaType));
     SkAutoUnref   aur(ct);
 
     if (!this->allocPixelRef(decodedBitmap, ct)) {