Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(609)

Unified Diff: src/images/SkImageDecoder_libpng.cpp

Issue 167763003: Fix issue in image decoders where the bitmap config was not properly set. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: comments Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/images/SkImageRef.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « no previous file | src/images/SkImageRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698