summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorPatrick Luby <guibmacdev@gmail.com>2024-05-12 14:04:30 -0400
committerAndras Timar <andras.timar@collabora.com>2024-05-17 19:57:44 +0200
commit91ef48ca9d30bf134719a28bfc4a6b23ec9e27d9 (patch)
treebaceb2cfe77803badfcc9701c8771fd90cede016 /vcl
parent1aa90b5a2d10e77e88782de85facf447b6e09697 (diff)
tdf#160690 set an opaque alpha mask for non-transparent frames
Due to the switch from transparency to alpha in commit 81994cb2b8b32453a92bcb011830fcb884f22ff3, an empty alpha mask is treated as a completely transparent bitmap. So revert all of the previous commits for tdf#157576, tdf#157635, and tdf#157793 and create a completely opaque bitmap instead. Note: this fix also fixes tdf#157576, tdf#157635, and tdf#157793. Change-Id: Ic2ccad6ab94e4d43b1b66013f85955d474dc0151 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167563 Reviewed-by: Patrick Luby <guibomacdev@gmail.com> Tested-by: Jenkins (cherry picked from commit 2a9eb581f0edfae8123018006df5cc9de1e1fd45) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167674 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/filter/igif/gifread.cxx36
1 files changed, 20 insertions, 16 deletions
diff --git a/vcl/source/filter/igif/gifread.cxx b/vcl/source/filter/igif/gifread.cxx
index 8f56edaee77f..95b70568d9c7 100644
--- a/vcl/source/filter/igif/gifread.cxx
+++ b/vcl/source/filter/igif/gifread.cxx
@@ -99,7 +99,7 @@ class GIFReader : public GraphicReader
sal_uInt8 nGCDisposalMethod; // 'Disposal Method' (see GIF docs)
sal_uInt8 cTransIndex1;
sal_uInt8 cNonTransIndex1;
- bool bEnhance;
+ sal_uLong nPaletteSize;
void ReadPaletteEntries( BitmapPalette* pPal, sal_uLong nCount );
void ClearImageExtensions();
@@ -157,7 +157,7 @@ GIFReader::GIFReader( SvStream& rStm )
, nGCTransparentIndex ( 0 )
, cTransIndex1 ( 0 )
, cNonTransIndex1 ( 0 )
- , bEnhance( false )
+ , nPaletteSize( 0 )
{
maUpperName = "SVIGIF";
aSrcBuf.resize(256); // Memory buffer for ReadNextBlock
@@ -328,12 +328,7 @@ void GIFReader::ReadPaletteEntries( BitmapPalette* pPal, sal_uLong nCount )
(*pPal)[ 254UL ] = COL_BLACK;
}
- // 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.
- // Also, fix tdf#158047 by allowing the tdf#157635 fix for
- // palettes with 64 entries.
- bEnhance = (nCount > 16);
+ nPaletteSize = nCount;
}
bool GIFReader::ReadExtension()
@@ -674,16 +669,25 @@ void GIFReader::CreateNewBitmaps()
aAlphaMask.Invert(); // convert from transparency to alpha
aAnimationFrame.maBitmapEx = BitmapEx( aBmp8, aAlphaMask );
}
- else
+ else if( nPaletteSize > 2 )
{
- // tdf#157576 and tdf#157635 mask out black pixels
+ // tdf#160690 set an opaque alpha mask for non-transparent frames
// Due to the switch from transparency to alpha in commit
- // 81994cb2b8b32453a92bcb011830fcb884f22ff3, mask out black
- // pixels in bitmap.
- if (bEnhance)
- aAnimationFrame.maBitmapEx = BitmapEx( aBmp8, aBmp8 );
- else
- aAnimationFrame.maBitmapEx = BitmapEx( aBmp8 );
+ // 81994cb2b8b32453a92bcb011830fcb884f22ff3, an empty alpha mask
+ // is treated as a completely transparent bitmap. So revert all
+ // of the previous commits for tdf#157576, tdf#157635, and tdf#157793
+ // and create a completely opaque bitmap instead.
+ // Note: this fix also fixes tdf#157576, tdf#157635, and tdf#157793.
+ AlphaMask aAlphaMask(aBmp8.GetSizePixel());
+ aAnimationFrame.maBitmapEx = BitmapEx( aBmp8, aAlphaMask );
+ }
+ else
+ {
+ // Don't apply the fix for tdf#160690 as it will cause 1 bit bitmaps
+ // in Word documents like the following test document to fail to be
+ // parsed correctly:
+ // sw/qa/extras/tiledrendering/data/tdf159626_yellowPatternFill.docx
+ aAnimationFrame.maBitmapEx = BitmapEx( aBmp8 );
}
aAnimationFrame.maPositionPixel = Point( nImagePosX, nImagePosY );