Index: src/images/SkImageDecoder_libgif.cpp |
diff --git a/src/images/SkImageDecoder_libgif.cpp b/src/images/SkImageDecoder_libgif.cpp |
index 08f37efced9fc8bdee36b286dc52ad44f06ac028..ab0fbdaf3f777855d2b8621eed7a1c1c4abe7325 100644 |
--- a/src/images/SkImageDecoder_libgif.cpp |
+++ b/src/images/SkImageDecoder_libgif.cpp |
@@ -248,10 +248,13 @@ bool SkGIFImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* bm, Mode mode) { |
if (NULL == cmap) { |
return error_return(gif, *bm, "null cmap"); |
} |
- |
colorCount = cmap->ColorCount; |
- SkAutoTMalloc<SkPMColor> colorStorage(colorCount); |
- SkPMColor* colorPtr = colorStorage.get(); |
+ if (colorCount > 256) { |
+ colorCount = 256; // our kIndex8 can't support more |
+ } |
+ |
+ SkPMColor colorPtr[256]; // storage for worst-case |
+ SkAlphaType alphaType = kOpaque_SkAlphaType; |
for (int index = 0; index < colorCount; index++) { |
colorPtr[index] = SkPackARGB32(0xFF, |
cmap->Colors[index].Red, |
@@ -263,10 +266,12 @@ bool SkGIFImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* bm, Mode mode) { |
bool reallyHasAlpha = transpIndex >= 0; |
if (reallyHasAlpha) { |
colorPtr[transpIndex] = SK_ColorTRANSPARENT; // ram in a transparent SkPMColor |
+ alphaType = kPremul_SkAlphaType; |
} |
- SkAutoTUnref<SkColorTable> ctable(SkNEW_ARGS(SkColorTable, (colorPtr, colorCount))); |
- ctable->setIsOpaque(!reallyHasAlpha); |
+ SkAutoTUnref<SkColorTable> ctable(SkNEW_ARGS(SkColorTable, |
+ (colorPtr, colorCount, |
+ alphaType))); |
if (!this->allocPixelRef(bm, ctable)) { |
return error_return(gif, *bm, "allocPixelRef"); |
} |