Bug 1217465 - Fill in missing pixels caused by truncated BMP files. r=seth.

This fixes failures for
image/test/reftest/bmp/bmpsuite/b/{badrle.bmp,shortfile.bmp} with the Skia
back-end.
This commit is contained in:
Nicholas Nethercote 2015-11-15 20:31:07 -08:00
parent 09b8b80cbe
commit 357de81606
2 changed files with 14 additions and 2 deletions

View File

@ -240,6 +240,17 @@ nsBMPDecoder::FinishInternal()
// Send notifications if appropriate.
if (!IsMetadataDecode() && HasSize()) {
// If it was truncated, fill in the missing pixels as black.
while (mCurrentRow > 0) {
uint32_t* dst = RowBuffer();
while (mCurrentPos < mH.mWidth) {
SetPixel(dst, 0, 0, 0);
mCurrentPos++;
}
mCurrentPos = 0;
FinishRow();
}
// Invalidate.
nsIntRect r(0, 0, mH.mWidth, AbsoluteHeight());
PostInvalidation(r);

View File

@ -230,8 +230,9 @@ private:
int32_t mCurrentRow; // Index of the row of the image that's currently
// being decoded: [height,1].
int32_t mCurrentPos; // Index into the current line; only used when
// doing RLE decoding.
int32_t mCurrentPos; // Index into the current line. Used when
// doing RLE decoding and when filling in pixels
// for truncated files.
// Only used in RLE_ABSOLUTE state: the number of pixels to read.
uint32_t mAbsoluteModeNumPixels;