OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkBmpCodec.h" | 8 #include "SkBmpCodec.h" |
9 #include "SkBmpMaskCodec.h" | 9 #include "SkBmpMaskCodec.h" |
10 #include "SkBmpRLECodec.h" | 10 #include "SkBmpRLECodec.h" |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 // since we will need to apply a transparency mask. | 435 // since we will need to apply a transparency mask. |
436 if (inIco) { | 436 if (inIco) { |
437 color = SkEncodedInfo::kBGRA_Color; | 437 color = SkEncodedInfo::kBGRA_Color; |
438 bitsPerComponent = 8; | 438 bitsPerComponent = 8; |
439 } else { | 439 } else { |
440 color = SkEncodedInfo::kPalette_Color; | 440 color = SkEncodedInfo::kPalette_Color; |
441 bitsPerComponent = (uint8_t) bitsPerPixel; | 441 bitsPerComponent = (uint8_t) bitsPerPixel; |
442 } | 442 } |
443 break; | 443 break; |
444 case 24: | 444 case 24: |
445 color = SkEncodedInfo::kBGR_Color; | 445 // In the case of ICO, kBGRA is actually the closest match, |
| 446 // since we will need to apply a transparency mask. |
| 447 color = inIco ? SkEncodedInfo::kBGRA_Color : SkEncodedInfo::
kBGR_Color; |
446 bitsPerComponent = 8; | 448 bitsPerComponent = 8; |
447 break; | 449 break; |
448 case 32: | 450 case 32: |
449 // 32-bit BMP-in-ICOs actually use the alpha channel in plac
e of a | 451 // 32-bit BMP-in-ICOs actually use the alpha channel in plac
e of a |
450 // transparency mask. | 452 // transparency mask. |
451 if (inIco) { | 453 if (inIco) { |
452 isOpaque = false; | 454 isOpaque = false; |
453 alpha = SkEncodedInfo::kUnpremul_Alpha; | 455 alpha = SkEncodedInfo::kUnpremul_Alpha; |
454 color = SkEncodedInfo::kBGRA_Color; | 456 color = SkEncodedInfo::kBGRA_Color; |
455 } else { | 457 } else { |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 } | 620 } |
619 | 621 |
620 bool SkBmpCodec::skipRows(int count) { | 622 bool SkBmpCodec::skipRows(int count) { |
621 const size_t bytesToSkip = count * fSrcRowBytes; | 623 const size_t bytesToSkip = count * fSrcRowBytes; |
622 return this->stream()->skip(bytesToSkip) == bytesToSkip; | 624 return this->stream()->skip(bytesToSkip) == bytesToSkip; |
623 } | 625 } |
624 | 626 |
625 bool SkBmpCodec::onSkipScanlines(int count) { | 627 bool SkBmpCodec::onSkipScanlines(int count) { |
626 return this->skipRows(count); | 628 return this->skipRows(count); |
627 } | 629 } |
OLD | NEW |