| Index: src/codec/SkCodec_libbmp.cpp
|
| diff --git a/src/codec/SkCodec_libbmp.cpp b/src/codec/SkCodec_libbmp.cpp
|
| index b553deae6f8c0b14f669d19ee76aa4f8536f19d4..0ca15be5b54749cfb82adb0f3eeb20c728bf8cb8 100644
|
| --- a/src/codec/SkCodec_libbmp.cpp
|
| +++ b/src/codec/SkCodec_libbmp.cpp
|
| @@ -701,6 +701,9 @@ SkCodec::Result SkBmpCodec::onGetPixels(const SkImageInfo& dstInfo,
|
| for (; i < maxColors; i++) {
|
| colorTable[i] = SkPackARGB32NoCheck(0xFF, 0, 0, 0);
|
| }
|
| +
|
| + // Set the color table
|
| + fColorTable.reset(SkNEW_ARGS(SkColorTable, (colorTable, maxColors)));
|
| }
|
|
|
| // Bmp-in-Ico files do not use an offset to indicate where the pixel data
|
| @@ -724,8 +727,7 @@ SkCodec::Result SkBmpCodec::onGetPixels(const SkImageInfo& dstInfo,
|
| }
|
| }
|
|
|
| - // Set the color table and return true on success
|
| - fColorTable.reset(SkNEW_ARGS(SkColorTable, (colorTable, maxColors)));
|
| + // Return true on success
|
| return true;
|
| }
|
|
|
| @@ -757,6 +759,12 @@ SkCodec::Result SkBmpCodec::decodeMask(const SkImageInfo& dstInfo,
|
| // Read a row of the input
|
| if (stream()->read(srcRow, rowBytes) != rowBytes) {
|
| SkCodecPrintf("Warning: incomplete input stream.\n");
|
| + // Fill the destination image on failure
|
| + // By using zero as the fill value, we will fill with transparent
|
| + // pixels for non-opaque images and white for opaque images.
|
| + // These are arbitrary choices but allow for consistent behavior.
|
| + SkSwizzler::Fill(dst, dstInfo, dstRowBytes, y, 0, NULL,
|
| + fRowOrder == kBottomUp_RowOrder);
|
| return kIncompleteInput;
|
| }
|
|
|
| @@ -1096,9 +1104,12 @@ SkCodec::Result SkBmpCodec::decode(const SkImageInfo& dstInfo,
|
| return kInvalidInput;
|
| }
|
|
|
| + // Get a pointer to the color table if it exists
|
| + const SkPMColor* colorPtr = NULL != fColorTable.get() ? fColorTable->readColors() : NULL;
|
| +
|
| // Create swizzler
|
| SkAutoTDelete<SkSwizzler> swizzler(SkSwizzler::CreateSwizzler(config,
|
| - fColorTable->readColors(), dstInfo, dst, dstRowBytes,
|
| + colorPtr, dstInfo, dst, dstRowBytes,
|
| SkImageGenerator::kNo_ZeroInitialized));
|
|
|
| // Allocate space for a row buffer and a source for the swizzler
|
| @@ -1110,6 +1121,13 @@ SkCodec::Result SkBmpCodec::decode(const SkImageInfo& dstInfo,
|
| // Read a row of the input
|
| if (stream()->read(srcBuffer.get(), rowBytes) != rowBytes) {
|
| SkCodecPrintf("Warning: incomplete input stream.\n");
|
| + // Fill the destination image on failure
|
| + // By using zero as the fill value, we will fill with the first
|
| + // color in the color table for palette images, transparent
|
| + // pixels for non-opaque images, and white for opaque images.
|
| + // These are arbitrary choices but allow for consistent behavior.
|
| + SkSwizzler::Fill(dst, dstInfo, dstRowBytes, y, 0, colorPtr,
|
| + fRowOrder == kBottomUp_RowOrder);
|
| return kIncompleteInput;
|
| }
|
|
|
|
|