Index: src/codec/SkBmpStandardCodec.cpp |
diff --git a/src/codec/SkBmpStandardCodec.cpp b/src/codec/SkBmpStandardCodec.cpp |
index 27cea4ead0e816a9d5f77e3abba484e0c633050f..f2e4af2ac4e3394d04c9451d7c3054f09279fbc9 100644 |
--- a/src/codec/SkBmpStandardCodec.cpp |
+++ b/src/codec/SkBmpStandardCodec.cpp |
@@ -170,7 +170,8 @@ SkCodec::Result SkBmpStandardCodec::onGetPixels(const SkImageInfo& dstInfo, |
bool SkBmpStandardCodec::initializeSwizzler(const SkImageInfo& dstInfo, |
const Options& opts) { |
// Allocate space for a row buffer |
- const size_t rowBytes = SkAlign4(compute_row_bytes(dstInfo.width(), this->bitsPerPixel())); |
+ const size_t rowBytes = SkAlign4(compute_row_bytes(this->getInfo().width(), |
+ this->bitsPerPixel())); |
fSrcBuffer.reset(SkNEW_ARRAY(uint8_t, rowBytes)); |
// Get swizzler configuration |
@@ -251,10 +252,10 @@ static uint32_t get_fill_color_or_index(uint16_t bitsPerPixels, SkAlphaType alph |
* Performs the bitmap decoding for standard input format |
*/ |
SkCodec::Result SkBmpStandardCodec::decode(const SkImageInfo& dstInfo, |
- void* dst, size_t dstRowBytes, |
- const Options& opts) { |
+ void* dst, size_t dstRowBytes, |
+ const Options& opts) { |
// Set constant values |
- const int width = dstInfo.width(); |
+ const int width = this->getInfo().width(); |
const int height = dstInfo.height(); |
const size_t rowBytes = SkAlign4(compute_row_bytes(width, this->bitsPerPixel())); |
@@ -335,3 +336,23 @@ SkCodec::Result SkBmpStandardCodec::decode(const SkImageInfo& dstInfo, |
// Finished decoding the entire image |
return kSuccess; |
} |
+ |
+SkCodec::Result SkBmpStandardCodec::onStart(const SkImageInfo& dstInfo, |
+ const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputColorCount) { |
+ // 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(dstInfo.alphaType(), inputColorCount)) { |
+ SkCodecPrintf("Error: could not create color table.\n"); |
+ return SkCodec::kInvalidInput; |
+ } |
+ |
+ // Copy the color table to the client if necessary |
+ copy_color_table(dstInfo, this->fColorTable, inputColorPtr, inputColorCount); |
+ |
+ // Initialize a swizzler if necessary |
+ if (!this->initializeSwizzler(dstInfo, options)) { |
+ SkCodecPrintf("Error: cannot initialize swizzler.\n"); |
+ return SkCodec::kInvalidConversion; |
+ } |
+ return SkCodec::kSuccess; |
+} |