| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #define WIN32_LEAN_AND_MEAN | 10 #define WIN32_LEAN_AND_MEAN |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 ); | 159 ); |
| 160 } | 160 } |
| 161 | 161 |
| 162 //Get the size of the bitmap. | 162 //Get the size of the bitmap. |
| 163 UINT width; | 163 UINT width; |
| 164 UINT height; | 164 UINT height; |
| 165 if (SUCCEEDED(hr)) { | 165 if (SUCCEEDED(hr)) { |
| 166 hr = piBitmapSourceOriginal->GetSize(&width, &height); | 166 hr = piBitmapSourceOriginal->GetSize(&width, &height); |
| 167 } | 167 } |
| 168 | 168 |
| 169 bool premul; |
| 170 GUID destinationPixelFormat; |
| 171 if (this->getRequestUnpremultipliedColors()) { |
| 172 premul = false; |
| 173 destinationPixelFormat = GUID_WICPixelFormat32bppBGRA; |
| 174 } else { |
| 175 premul = true; |
| 176 destinationPixelFormat = GUID_WICPixelFormat32bppPBGRA; |
| 177 } |
| 178 |
| 169 //Exit early if we're only looking for the bitmap bounds. | 179 //Exit early if we're only looking for the bitmap bounds. |
| 170 if (SUCCEEDED(hr)) { | 180 if (SUCCEEDED(hr)) { |
| 171 bm->setConfig(SkBitmap::kARGB_8888_Config, width, height); | 181 bm->setConfig(SkBitmap::kARGB_8888_Config, width, height, 0, premul); |
| 172 if (kDecodeBounds_WICMode == wicMode) { | 182 if (kDecodeBounds_WICMode == wicMode) { |
| 173 return true; | 183 return true; |
| 174 } | 184 } |
| 175 if (!this->allocPixelRef(bm, NULL)) { | 185 if (!this->allocPixelRef(bm, NULL)) { |
| 176 return false; | 186 return false; |
| 177 } | 187 } |
| 178 } | 188 } |
| 179 | 189 |
| 180 //Create a format converter. | 190 //Create a format converter. |
| 181 SkTScopedComPtr<IWICFormatConverter> piFormatConverter; | 191 SkTScopedComPtr<IWICFormatConverter> piFormatConverter; |
| 182 if (SUCCEEDED(hr)) { | 192 if (SUCCEEDED(hr)) { |
| 183 hr = piImagingFactory->CreateFormatConverter(&piFormatConverter); | 193 hr = piImagingFactory->CreateFormatConverter(&piFormatConverter); |
| 184 } | 194 } |
| 185 | 195 |
| 186 if (SUCCEEDED(hr)) { | 196 if (SUCCEEDED(hr)) { |
| 187 hr = piFormatConverter->Initialize( | 197 hr = piFormatConverter->Initialize( |
| 188 piBitmapSourceOriginal.get() //Input bitmap to convert | 198 piBitmapSourceOriginal.get() //Input bitmap to convert |
| 189 , GUID_WICPixelFormat32bppPBGRA //Destination pixel format | 199 , destinationPixelFormat //Destination pixel format |
| 190 , WICBitmapDitherTypeNone //Specified dither patterm | 200 , WICBitmapDitherTypeNone //Specified dither patterm |
| 191 , NULL //Specify a particular palette | 201 , NULL //Specify a particular palette |
| 192 , 0.f //Alpha threshold | 202 , 0.f //Alpha threshold |
| 193 , WICBitmapPaletteTypeCustom //Palette translation type | 203 , WICBitmapPaletteTypeCustom //Palette translation type |
| 194 ); | 204 ); |
| 195 } | 205 } |
| 196 | 206 |
| 197 //Get the BitmapSource interface of the format converter. | 207 //Get the BitmapSource interface of the format converter. |
| 198 SkTScopedComPtr<IWICBitmapSource> piBitmapSourceConverted; | 208 SkTScopedComPtr<IWICBitmapSource> piBitmapSourceConverted; |
| 199 if (SUCCEEDED(hr)) { | 209 if (SUCCEEDED(hr)) { |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 static SkImageDecoder::Format get_format_wic(SkStream* stream) { | 439 static SkImageDecoder::Format get_format_wic(SkStream* stream) { |
| 430 SkImageDecoder::Format format; | 440 SkImageDecoder::Format format; |
| 431 SkImageDecoder_WIC codec; | 441 SkImageDecoder_WIC codec; |
| 432 if (!codec.decodeStream(stream, NULL, SkImageDecoder_WIC::kDecodeFormat_WICM
ode, &format)) { | 442 if (!codec.decodeStream(stream, NULL, SkImageDecoder_WIC::kDecodeFormat_WICM
ode, &format)) { |
| 433 format = SkImageDecoder::kUnknown_Format; | 443 format = SkImageDecoder::kUnknown_Format; |
| 434 } | 444 } |
| 435 return format; | 445 return format; |
| 436 } | 446 } |
| 437 | 447 |
| 438 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_wic)
; | 448 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_wic)
; |
| OLD | NEW |