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 #include "SkTypes.h" | 9 #include "SkTypes.h" |
10 | 10 |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 case kPNG_Type: | 299 case kPNG_Type: |
300 type = GUID_ContainerFormatPng; | 300 type = GUID_ContainerFormatPng; |
301 break; | 301 break; |
302 default: | 302 default: |
303 return false; | 303 return false; |
304 } | 304 } |
305 | 305 |
306 //Convert to 8888 if needed. | 306 //Convert to 8888 if needed. |
307 const SkBitmap* bitmap; | 307 const SkBitmap* bitmap; |
308 SkBitmap bitmapCopy; | 308 SkBitmap bitmapCopy; |
309 if (kN32_SkColorType == bitmapOrig.colorType() && bitmapOrig.isOpaque()) { | 309 if (kPMColor_SkColorType == bitmapOrig.colorType() && bitmapOrig.isOpaque())
{ |
310 bitmap = &bitmapOrig; | 310 bitmap = &bitmapOrig; |
311 } else { | 311 } else { |
312 if (!bitmapOrig.copyTo(&bitmapCopy, kN32_SkColorType)) { | 312 if (!bitmapOrig.copyTo(&bitmapCopy, kPMColor_SkColorType)) { |
313 return false; | 313 return false; |
314 } | 314 } |
315 bitmap = &bitmapCopy; | 315 bitmap = &bitmapCopy; |
316 } | 316 } |
317 | 317 |
318 // We cannot use PBGRA so we need to unpremultiply ourselves | 318 // We cannot use PBGRA so we need to unpremultiply ourselves |
319 if (!bitmap->isOpaque()) { | 319 if (!bitmap->isOpaque()) { |
320 SkAutoLockPixels alp(*bitmap); | 320 SkAutoLockPixels alp(*bitmap); |
321 | 321 |
322 uint8_t* pixels = reinterpret_cast<uint8_t*>(bitmap->getPixels()); | 322 uint8_t* pixels = reinterpret_cast<uint8_t*>(bitmap->getPixels()); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 static SkImageDecoder::Format get_format_wic(SkStreamRewindable* stream) { | 455 static SkImageDecoder::Format get_format_wic(SkStreamRewindable* stream) { |
456 SkImageDecoder::Format format; | 456 SkImageDecoder::Format format; |
457 SkImageDecoder_WIC codec; | 457 SkImageDecoder_WIC codec; |
458 if (!codec.decodeStream(stream, NULL, SkImageDecoder_WIC::kDecodeFormat_WICM
ode, &format)) { | 458 if (!codec.decodeStream(stream, NULL, SkImageDecoder_WIC::kDecodeFormat_WICM
ode, &format)) { |
459 format = SkImageDecoder::kUnknown_Format; | 459 format = SkImageDecoder::kUnknown_Format; |
460 } | 460 } |
461 return format; | 461 return format; |
462 } | 462 } |
463 | 463 |
464 static SkImageDecoder_FormatReg gFormatReg(get_format_wic); | 464 static SkImageDecoder_FormatReg gFormatReg(get_format_wic); |
OLD | NEW |