Description: When I export drawings that include transparent objects as gif, the transparent objects are not displayed. Exporting those to .bmp or .png format works correct, but not to .gif. brgs, gsc Steps to Reproduce: 1. Open the attached draw document, select page 2 and mark all objects on this page. 2. Open the export dialogue in the main menu, select "selection only" and the gif file format. 3. Press ok. Actual Results: See attached gif-file. Expected Results: That it works like in the earlier days. Reproducible: Always User Profile Reset: No Additional Info: Selecting a dark red color as transparent background color in gif is a crazy idea. Normally that should be WHITE (0xFFFFFF). I have to edit the palette for each of my gifs with an ancient version of PaintShopPro to get this to white.
Created attachment 186503 [details] The two-page draw file
Created attachment 186504 [details] The produced gif
Created attachment 186505 [details] The export dialog
Code pointer: https://opengrok.libreoffice.org/xref/core/vcl/source/filter/egif/egif.cxx?r=cfb2a587#256 241 bool GIFWriter::CreateAccess( const BitmapEx& rBmpEx ) 242 { 243 if( bStatus ) 244 { 245 Bitmap aMask( rBmpEx.GetAlphaMask() ); 246 247 aAccBmp = rBmpEx.GetBitmap(); 248 bTransparent = false; 249 250 if( !aMask.IsEmpty() ) 251 { 252 if( aAccBmp.Convert( BmpConversion::N8BitTrans ) ) 253 { 254 aMask.Convert( BmpConversion::N1BitThreshold ); 255 aAccBmp.Replace( aMask, BMP_COL_TRANS ); 256 bTransparent = true; 257 } LO goes into line 256 but BMP_COL_TRANS is defined as #define BMP_COL_TRANS Color( 252, 3, 251 ) See https://opengrok.libreoffice.org/xref/core/include/vcl/bitmap.hxx?r=5244e7ca which would correspond to the red color. git grep -n BMP_COL_TRANS gives: include/vcl/bitmap.hxx:67:#define BMP_COL_TRANS Color( 252, 3, 251 ) vcl/source/bitmap/bitmap.cxx:922: Color aTrans( BMP_COL_TRANS ); vcl/source/filter/egif/egif.cxx:255: aAccBmp.Replace( aMask, BMP_COL_TRANS ); vcl/source/filter/egif/egif.cxx:395: m_rGIF.WriteUChar( m_pAcc->GetBestPaletteIndex( BMP_COL_TRANS ) ); Noel: any thoughts about this specific color for transparency?
Created attachment 186545 [details] exported gif file with test patch This patch helps: diff --git a/vcl/source/filter/egif/egif.cxx b/vcl/source/filter/egif/egif.cxx index 3aae0478cbe8..f908b6235133 100644 --- a/vcl/source/filter/egif/egif.cxx +++ b/vcl/source/filter/egif/egif.cxx @@ -392,7 +392,7 @@ void GIFWriter::WriteImageExtension( tools::Long nTimer, Disposal eDisposal ) m_rGIF.WriteUChar( 0x04 ); m_rGIF.WriteUChar( cFlags ); m_rGIF.WriteUInt16( nDelay ); - m_rGIF.WriteUChar( m_pAcc->GetBestPaletteIndex( BMP_COL_TRANS ) ); + m_rGIF.WriteUChar( static_cast<sal_uInt8>(m_pAcc->GetBestPaletteIndex( BMP_COL_TRANS )) ); m_rGIF.WriteUChar( 0x00 ); if( m_rGIF.GetError() ) GetBestPaletteIndex returns sal_uInt16 so convert it to sal_uInt8 before using WriteUChar. However it's full transparency, not mid transparency, see the attachment.
Julien's patch is correct, GIF does not (as far as I can tell) support partial transparency, it only has full or none transparency. See specs linked from https://en.wikipedia.org/wiki/GIF
(In reply to Noel Grandin from comment #6) > Julien's patch is correct, GIF does not (as far as I can tell) support > partial transparency, it only has full or none transparency. > > See specs linked from https://en.wikipedia.org/wiki/GIF Thank you Noel for the feedback, I had missed this info. I've submitted the patch here: https://gerrit.libreoffice.org/c/core/+/150184
Julien Nabet committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/3ebe2e7170b093bfd1c417b5907f713df591654a tdf#154631: fix Export as gif ignores transparence of objects It will be available in 7.6.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Fix cherry-picked on 7.5 branch waiting for feedback https://gerrit.libreoffice.org/c/core/+/150195
Julien Nabet committed a patch related to this issue. It has been pushed to "libreoffice-7-5": https://git.libreoffice.org/core/commit/6f0f99b550ea22f781ef6894e043e175c0a22fc7 tdf#154631: fix Export as gif ignores transparence of objects It will be available in 7.5.3. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.