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

Unified Diff: src/ports/SkImageDecoder_WIC.cpp

Issue 16410009: Add an option to create unpremultiplied bitmaps. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 6 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
Index: src/ports/SkImageDecoder_WIC.cpp
diff --git a/src/ports/SkImageDecoder_WIC.cpp b/src/ports/SkImageDecoder_WIC.cpp
index cd7f29fae480c4a3d6ba28765aec68608dfc10c9..de88b410d533a95ddc80f891e0d236846f6abbb4 100644
--- a/src/ports/SkImageDecoder_WIC.cpp
+++ b/src/ports/SkImageDecoder_WIC.cpp
@@ -166,9 +166,19 @@ bool SkImageDecoder_WIC::decodeStream(SkStream* stream, SkBitmap* bm, WICModes w
hr = piBitmapSourceOriginal->GetSize(&width, &height);
}
+ bool premul;
+ GUID destinationPixelFormat;
+ if (this->getRequestUnpremultipliedColors()) {
+ premul = false;
+ destinationPixelFormat = GUID_WICPixelFormat32bppBGRA;
+ } else {
+ premul = true;
+ destinationPixelFormat = GUID_WICPixelFormat32bppPBGRA;
+ }
+
//Exit early if we're only looking for the bitmap bounds.
if (SUCCEEDED(hr)) {
- bm->setConfig(SkBitmap::kARGB_8888_Config, width, height);
+ bm->setConfig(SkBitmap::kARGB_8888_Config, width, height, 0, premul);
if (kDecodeBounds_WICMode == wicMode) {
return true;
}
@@ -186,7 +196,7 @@ bool SkImageDecoder_WIC::decodeStream(SkStream* stream, SkBitmap* bm, WICModes w
if (SUCCEEDED(hr)) {
hr = piFormatConverter->Initialize(
piBitmapSourceOriginal.get() //Input bitmap to convert
- , GUID_WICPixelFormat32bppPBGRA //Destination pixel format
+ , destinationPixelFormat //Destination pixel format
, WICBitmapDitherTypeNone //Specified dither patterm
, NULL //Specify a particular palette
, 0.f //Alpha threshold

Powered by Google App Engine
This is Rietveld 408576698