Index: src/images/SkImageDecoder_libpng.cpp |
diff --git a/src/images/SkImageDecoder_libpng.cpp b/src/images/SkImageDecoder_libpng.cpp |
index 3cc41e3f5983c81561b00dfb440c81f73ba0a459..cd09f5f980d42e0769131f8d716297a244207228 100644 |
--- a/src/images/SkImageDecoder_libpng.cpp |
+++ b/src/images/SkImageDecoder_libpng.cpp |
@@ -333,6 +333,11 @@ bool SkPNGImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* decodedBitmap, |
SkScaledBitmapSampler sampler(origWidth, origHeight, sampleSize); |
decodedBitmap->setConfig(config, sampler.scaledWidth(), sampler.scaledHeight()); |
+ // we should communicate alphaType, even if we early-return in bounds-only-mode. |
+ if (this->getRequireUnpremultipliedColors()) { |
+ decodedBitmap->setAlphaType(kUnpremul_SkAlphaType); |
+ } |
+ |
if (SkImageDecoder::kDecodeBounds_Mode == mode) { |
return true; |
} |
@@ -478,15 +483,9 @@ bool SkPNGImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* decodedBitmap, |
} |
} |
- SkAlphaType alphaType = kOpaque_SkAlphaType; |
- if (reallyHasAlpha) { |
- if (this->getRequireUnpremultipliedColors()) { |
- alphaType = kUnpremul_SkAlphaType; |
- } else { |
- alphaType = kPremul_SkAlphaType; |
- } |
+ if (!reallyHasAlpha) { |
+ decodedBitmap->setAlphaType(kOpaque_SkAlphaType); |
} |
- decodedBitmap->setAlphaType(alphaType); |
return true; |
} |