vcl/source/filter/igif/gifread.cxx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
New commits: commit a98000c028a3c68329fdb2047f51f8d271b2290c Author: Patrick Luby <plub...@neooffice.org> AuthorDate: Thu Oct 19 20:01:16 2023 -0400 Commit: Patrick Luby <plub...@neooffice.org> CommitDate: Fri Oct 20 14:41:04 2023 +0200 tdf#157793 limit tdf#157635 fix to only larger palettes I don't know why, but the fix for tdf#157635 causes images with a palette of 16 entries to be inverted. Is this the only condition for masking out black pixels in non-transparent animation frames? Change-Id: I9550baab4dc4d9b75a21c8af2f6c0b5eb8e46c12 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158214 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Reviewed-by: Patrick Luby <plub...@neooffice.org> diff --git a/vcl/source/filter/igif/gifread.cxx b/vcl/source/filter/igif/gifread.cxx index afbf084f4f31..78d3190a0c85 100644 --- a/vcl/source/filter/igif/gifread.cxx +++ b/vcl/source/filter/igif/gifread.cxx @@ -99,6 +99,7 @@ class GIFReader : public GraphicReader sal_uInt8 nGCDisposalMethod; // 'Disposal Method' (see GIF docs) sal_uInt8 cTransIndex1; sal_uInt8 cNonTransIndex1; + bool bEnhance; void ReadPaletteEntries( BitmapPalette* pPal, sal_uLong nCount ); void ClearImageExtensions(); @@ -156,6 +157,7 @@ GIFReader::GIFReader( SvStream& rStm ) , nGCTransparentIndex ( 0 ) , cTransIndex1 ( 0 ) , cNonTransIndex1 ( 0 ) + , bEnhance( false ) { maUpperName = "SVIGIF"; aSrcBuf.resize(256); // Memory buffer for ReadNextBlock @@ -317,6 +319,8 @@ void GIFReader::ReadPaletteEntries( BitmapPalette* pPal, sal_uLong nCount ) rColor.SetBlue( *pTmp++ ); } + bEnhance = false; + // if possible accommodate some standard colours if( nCount < 256 ) { @@ -325,6 +329,15 @@ void GIFReader::ReadPaletteEntries( BitmapPalette* pPal, sal_uLong nCount ) if( nCount < 255 ) (*pPal)[ 254UL ] = COL_BLACK; } + else + { + // tdf#157793 limit tdf#157635 fix to only larger palettes + // I don't know why, but the fix for tdf#157635 causes + // images with a palette of 16 entries to be inverted. + // Is this the only condition for masking out black + // pixels in non-transparent animation frames? + bEnhance = true; + } } bool GIFReader::ReadExtension() @@ -671,7 +684,10 @@ void GIFReader::CreateNewBitmaps() // Due to the switch from transparency to alpha in commit // 81994cb2b8b32453a92bcb011830fcb884f22ff3, mask out black // pixels in bitmap. - aAnimationFrame.maBitmapEx = BitmapEx( aBmp8, aBmp8 ); + if (bEnhance) + aAnimationFrame.maBitmapEx = BitmapEx( aBmp8, aBmp8 ); + else + aAnimationFrame.maBitmapEx = BitmapEx( aBmp8 ); } aAnimationFrame.maPositionPixel = Point( nImagePosX, nImagePosY );