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

Unified Diff: src/codec/SkBmpStandardCodec.cpp

Issue 1663303002: Fix bugs in SkBmpCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « no previous file | src/codec/SkMaskSwizzler.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkBmpStandardCodec.cpp
diff --git a/src/codec/SkBmpStandardCodec.cpp b/src/codec/SkBmpStandardCodec.cpp
index e73d55ebba500bc2b39279bb7dbc89bbbf1a72be..203e7da654568c0de1e8e33e427e96a41fd64ca4 100644
--- a/src/codec/SkBmpStandardCodec.cpp
+++ b/src/codec/SkBmpStandardCodec.cpp
@@ -67,7 +67,7 @@ SkCodec::Result SkBmpStandardCodec::onGetPixels(const SkImageInfo& dstInfo,
/*
* Process the color table for the bmp input
*/
- bool SkBmpStandardCodec::createColorTable(SkAlphaType alphaType, int* numColors) {
+ bool SkBmpStandardCodec::createColorTable(SkAlphaType dstAlphaType, int* numColors) {
// Allocate memory for color table
uint32_t colorBytes = 0;
SkPMColor colorTable[256];
@@ -94,21 +94,11 @@ SkCodec::Result SkBmpStandardCodec::onGetPixels(const SkImageInfo& dstInfo,
// Choose the proper packing function
SkPMColor (*packARGB) (uint32_t, uint32_t, uint32_t, uint32_t);
- switch (alphaType) {
- case kOpaque_SkAlphaType:
- case kUnpremul_SkAlphaType:
- packARGB = &SkPackARGB32NoCheck;
- break;
- case kPremul_SkAlphaType:
- packARGB = &SkPreMultiplyARGB;
- break;
- default:
- // This should not be reached because conversion possible
- // should fail if the alpha type is not one of the above
- // values.
- SkASSERT(false);
- packARGB = nullptr;
- break;
+ SkAlphaType encodedAlphaType = this->getInfo().alphaType();
+ if (kOpaque_SkAlphaType == encodedAlphaType || kUnpremul_SkAlphaType == dstAlphaType) {
+ packARGB = &SkPackARGB32NoCheck;
+ } else {
+ packARGB = &SkPremultiplyARGBInline;
}
// Fill in the color table
@@ -118,7 +108,7 @@ SkCodec::Result SkBmpStandardCodec::onGetPixels(const SkImageInfo& dstInfo,
uint8_t green = get_byte(cBuffer.get(), i*fBytesPerColor + 1);
uint8_t red = get_byte(cBuffer.get(), i*fBytesPerColor + 2);
uint8_t alpha;
- if (kOpaque_SkAlphaType == alphaType) {
+ if (kOpaque_SkAlphaType == encodedAlphaType) {
alpha = 0xFF;
} else {
alpha = get_byte(cBuffer.get(), i*fBytesPerColor + 3);
« no previous file with comments | « no previous file | src/codec/SkMaskSwizzler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698