Index: src/images/SkImageDecoder_libpng.cpp |
diff --git a/src/images/SkImageDecoder_libpng.cpp b/src/images/SkImageDecoder_libpng.cpp |
index 5fc9350b519e23d691bb368aac9cef8d3a0d726b..e54387af34cf960f143a9963d857fd100e7bba73 100644 |
--- a/src/images/SkImageDecoder_libpng.cpp |
+++ b/src/images/SkImageDecoder_libpng.cpp |
@@ -466,7 +466,16 @@ bool SkPNGImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* decodedBitmap, |
if (SkBitmap::kA8_Config == decodedBitmap->config()) { |
reallyHasAlpha = true; |
} |
- decodedBitmap->setIsOpaque(!reallyHasAlpha); |
+ |
+ SkAlphaType alphaType = kOpaque_SkAlphaType; |
+ if (reallyHasAlpha) { |
+ if (this->getRequireUnpremultipliedColors()) { |
+ alphaType = kUnpremul_SkAlphaType; |
+ } else { |
+ alphaType = kPremul_SkAlphaType; |
+ } |
+ } |
+ decodedBitmap->setAlphaType(alphaType); |
return true; |
} |
@@ -939,7 +948,15 @@ bool SkPNGImageDecoder::onDecodeSubset(SkBitmap* bm, const SkIRect& region) { |
if (SkBitmap::kA8_Config == decodedBitmap.config()) { |
reallyHasAlpha = true; |
} |
- decodedBitmap.setIsOpaque(!reallyHasAlpha); |
+ SkAlphaType alphaType = kOpaque_SkAlphaType; |
+ if (reallyHasAlpha) { |
+ if (this->getRequireUnpremultipliedColors()) { |
+ alphaType = kUnpremul_SkAlphaType; |
+ } else { |
+ alphaType = kPremul_SkAlphaType; |
+ } |
+ } |
+ decodedBitmap.setAlphaType(alphaType); |
if (swapOnly) { |
bm->swap(decodedBitmap); |