From 75f32461a113307f1fa515d35e7e77ae5bd97fa7 Mon Sep 17 00:00:00 2001 From: "tor%cs.brown.edu" Date: Thu, 24 Jul 2003 23:17:50 +0000 Subject: [PATCH] Bug 208622 - some animated gifs don't display properly. r=pavlov, sr=scc git-svn-id: svn://10.0.0.236/trunk@145177 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/modules/libpr0n/decoders/gif/GIF2.cpp | 18 ++----------- .../libpr0n/decoders/gif/nsGIFDecoder2.cpp | 26 +++++++------------ 2 files changed, 11 insertions(+), 33 deletions(-) diff --git a/mozilla/modules/libpr0n/decoders/gif/GIF2.cpp b/mozilla/modules/libpr0n/decoders/gif/GIF2.cpp index b921cdaf642..d0167880a90 100644 --- a/mozilla/modules/libpr0n/decoders/gif/GIF2.cpp +++ b/mozilla/modules/libpr0n/decoders/gif/GIF2.cpp @@ -301,16 +301,10 @@ static int do_lzw(gif_struct *gs, const PRUint8 *q) PRUint8 *rowp = gs->rowp; PRUint8 *rowend = gs->rowend; PRUintn rows_remaining = gs->rows_remaining; - PRUint8 max_index; if (rowp == rowend) return 0; - if (gs->is_local_colormap_defined) - max_index = gs->local_colormap_size - 1; - else - max_index = gs->global_colormap_size - 1; - #define OUTPUT_ROW(gs) \ PR_BEGIN_MACRO \ output_row(gs); \ @@ -348,11 +342,7 @@ static int do_lzw(gif_struct *gs, const PRUint8 *q) return 0; if (oldcode == -1) { - *rowp = suffix[code]; - if (*rowp > max_index) - *rowp = 0; - rowp++; - + *rowp++ = suffix[code]; if (rowp == rowend) OUTPUT_ROW(gs); @@ -406,11 +396,7 @@ static int do_lzw(gif_struct *gs, const PRUint8 *q) /* Copy the decoded data out to the scanline buffer. */ do { - *rowp = *--stackp; - if (*rowp > max_index) - *rowp = 0; - rowp++; - + *rowp++ = *--stackp; if (rowp == rowend) { OUTPUT_ROW(gs); } diff --git a/mozilla/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp b/mozilla/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp index 3fc742ebdfe..870a448f937 100644 --- a/mozilla/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp +++ b/mozilla/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp @@ -457,15 +457,22 @@ int nsGIFDecoder2::HaveDecodedRow( switch (format) { case gfxIFormats::RGB: + case gfxIFormats::BGR: { while (rowBufIndex != decoder->mGIFStruct->rowend) { - PRUint32 colorIndex = *rowBufIndex * 3; + PRUint32 colorIndex = (*rowBufIndex < cmapsize) ? (*rowBufIndex * 3) : 0; +#if defined(XP_WIN) || defined(XP_OS2) || defined(XP_BEOS) || defined(MOZ_WIDGET_PHOTON) + *rgbRowIndex++ = cmap[colorIndex + 2]; // blue + *rgbRowIndex++ = cmap[colorIndex + 1]; // green + *rgbRowIndex++ = cmap[colorIndex]; // red +#else #if defined(XP_MAC) || defined(XP_MACOSX) *rgbRowIndex++ = 0; // Mac is always 32bits per pixel, this is pad #endif *rgbRowIndex++ = cmap[colorIndex]; // red *rgbRowIndex++ = cmap[colorIndex + 1]; // green *rgbRowIndex++ = cmap[colorIndex + 2]; // blue +#endif ++rowBufIndex; } for (int i=0; imGIFStruct->rowend) { - PRUint32 colorIndex = *rowBufIndex * 3; - *rgbRowIndex++ = cmap[colorIndex + 2]; // blue - *rgbRowIndex++ = cmap[colorIndex + 1]; // green - *rgbRowIndex++ = cmap[colorIndex]; // red - ++rowBufIndex; - } - for (int i = 0; i < aDuplicateCount; ++i) { - decoder->mImageFrame->SetImageData(decoder->mRGBLine, - bpr, (aRowNumber+i)*bpr); - } - break; - } case gfxIFormats::RGB_A1: case gfxIFormats::BGR_A1: { @@ -496,7 +488,7 @@ int nsGIFDecoder2::HaveDecodedRow( memset(decoder->mAlphaLine, 0, abpr); for (PRUint32 x = 0; x < (PRUint32)width; ++x) { if (*rowBufIndex != decoder->mGIFStruct->tpixel) { - PRUint32 colorIndex = *rowBufIndex * 3; + PRUint32 colorIndex = (*rowBufIndex < cmapsize) ? (*rowBufIndex * 3) : 0; #if defined(XP_WIN) || defined(XP_OS2) || defined(XP_BEOS) || defined(MOZ_WIDGET_PHOTON) *rgbRowIndex++ = cmap[colorIndex + 2]; // blue *rgbRowIndex++ = cmap[colorIndex + 1]; // green