| Index: src/codec/SkBmpRLECodec.cpp
|
| diff --git a/src/codec/SkBmpRLECodec.cpp b/src/codec/SkBmpRLECodec.cpp
|
| index 3dc0e54fc1ebd82daf402cf6856755e319224a18..00b91c6dcf72c71fd71c32303a8ee145b36aa085 100644
|
| --- a/src/codec/SkBmpRLECodec.cpp
|
| +++ b/src/codec/SkBmpRLECodec.cpp
|
| @@ -70,7 +70,7 @@ SkCodec::Result SkBmpRLECodec::onGetPixels(const SkImageInfo& dstInfo,
|
| /*
|
| * Process the color table for the bmp input
|
| */
|
| - bool SkBmpRLECodec::createColorTable(int* numColors) {
|
| + bool SkBmpRLECodec::createColorTable(int* numColors, SkColorType dstColorType) {
|
| // Allocate memory for color table
|
| uint32_t colorBytes = 0;
|
| SkPMColor colorTable[256];
|
| @@ -96,12 +96,13 @@ SkCodec::Result SkBmpRLECodec::onGetPixels(const SkImageInfo& dstInfo,
|
| }
|
|
|
| // Fill in the color table
|
| + PackColorProc packARGB = choose_pack_color_proc(false, dstColorType);
|
| uint32_t i = 0;
|
| for (; i < numColorsToRead; i++) {
|
| uint8_t blue = get_byte(cBuffer.get(), i*fBytesPerColor);
|
| uint8_t green = get_byte(cBuffer.get(), i*fBytesPerColor + 1);
|
| uint8_t red = get_byte(cBuffer.get(), i*fBytesPerColor + 2);
|
| - colorTable[i] = SkPackARGB32NoCheck(0xFF, red, green, blue);
|
| + colorTable[i] = packARGB(0xFF, red, green, blue);
|
| }
|
|
|
| // To avoid segmentation faults on bad pixel data, fill the end of the
|
| @@ -208,7 +209,8 @@ void SkBmpRLECodec::setPixel(void* dst, size_t dstRowBytes,
|
| // Set the pixel based on destination color type
|
| const int dstX = get_dst_coord(x, fSampleX);
|
| switch (dstInfo.colorType()) {
|
| - case kN32_SkColorType: {
|
| + case kRGBA_8888_SkColorType:
|
| + case kBGRA_8888_SkColorType: {
|
| SkPMColor* dstRow = SkTAddOffset<SkPMColor>(dst, row * (int) dstRowBytes);
|
| dstRow[dstX] = fColorTable->operator[](index);
|
| break;
|
| @@ -241,9 +243,14 @@ void SkBmpRLECodec::setRGBPixel(void* dst, size_t dstRowBytes,
|
| // Set the pixel based on destination color type
|
| const int dstX = get_dst_coord(x, fSampleX);
|
| switch (dstInfo.colorType()) {
|
| - case kN32_SkColorType: {
|
| + case kRGBA_8888_SkColorType: {
|
| SkPMColor* dstRow = SkTAddOffset<SkPMColor>(dst, row * (int) dstRowBytes);
|
| - dstRow[dstX] = SkPackARGB32NoCheck(0xFF, red, green, blue);
|
| + dstRow[dstX] = SkPackARGB_as_RGBA(0xFF, red, green, blue);
|
| + break;
|
| + }
|
| + case kBGRA_8888_SkColorType: {
|
| + SkPMColor* dstRow = SkTAddOffset<SkPMColor>(dst, row * (int) dstRowBytes);
|
| + dstRow[dstX] = SkPackARGB_as_BGRA(0xFF, red, green, blue);
|
| break;
|
| }
|
| case kRGB_565_SkColorType: {
|
| @@ -275,7 +282,7 @@ SkCodec::Result SkBmpRLECodec::prepareToDecode(const SkImageInfo& dstInfo,
|
|
|
| // Create the color table if necessary and prepare the stream for decode
|
| // Note that if it is non-NULL, inputColorCount will be modified
|
| - if (!this->createColorTable(inputColorCount)) {
|
| + if (!this->createColorTable(inputColorCount, dstInfo.colorType())) {
|
| SkCodecPrintf("Error: could not create color table.\n");
|
| return SkCodec::kInvalidInput;
|
| }
|
| @@ -315,7 +322,8 @@ int SkBmpRLECodec::decodeRows(const SkImageInfo& info, void* dst, size_t dstRowB
|
| // the skipped pixels will be transparent.
|
| // Because of the need for transparent pixels, kN32 is the only color
|
| // type that makes sense for the destination format.
|
| - SkASSERT(kN32_SkColorType == dstInfo.colorType());
|
| + SkASSERT(kRGBA_8888_SkColorType == dstInfo.colorType() ||
|
| + kBGRA_8888_SkColorType == dstInfo.colorType());
|
| if (dst) {
|
| SkSampler::Fill(dstInfo, dst, dstRowBytes, SK_ColorTRANSPARENT, opts.fZeroInitialized);
|
| }
|
|
|