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 |