Bug 157576 - PDF export: some png images are not exported
Summary: PDF export: some png images are not exported
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Printing and PDF export (show other bugs)
Version:
(earliest affected)
24.2.0.0 alpha0+
Hardware: All All
: medium normal
Assignee: Patrick Luby (volunteer)
URL:
Whiteboard: target:24.2.0
Keywords: bibisected, bisected, regression
Depends on:
Blocks: PDF-Export
  Show dependency treegraph
 
Reported: 2023-10-03 12:31 UTC by Xisco Faulí
Modified: 2023-12-11 17:28 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Strange rendering of animated image with Skia disabled on macOS (1.72 MB, image/png)
2023-10-06 20:38 UTC, Patrick Luby (volunteer)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Xisco Faulí 2023-10-03 12:31:36 UTC
Steps to reproduce:
1. Open attachment 83367 [details] from bug 67582
2. Export to PDF

-> Images in page 1 and page 4 are not exported
Reproduced in

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 0c4913e03e8427a576138601958f2dbf13b8c37b
CPU threads: 8; OS: Linux 6.1; UI render: default; VCL: gtk3
Locale: es-ES (es_ES.UTF-8); UI: en-US
Calc: threaded

[Bug found by office-interoperability-tools]
Comment 1 Xisco Faulí 2023-10-03 12:32:28 UTC
Regression introduced by:

author	Patrick Luby <plubius@neooffice.org>	2023-08-07 12:17:36 -0400
committer	Patrick Luby <plubius@neooffice.org>	2023-08-10 14:01:10 +0200
commit 12fd870113a663dde5ceb38c61f1986a34095d0e (patch)
tree 04982fbf6a4ed1de1fda1346e73385b375e76e52
parent 0d8a5f89bff51480d721395729a67e7b4260aea5 (diff)
tdf#156630 eliminate opaque parts when drawing animated PNG images

Bisected with: bibisect-linux64-24.2

Adding Cc: to Patrick Luby
Comment 2 Patrick Luby (volunteer) 2023-10-03 23:33:59 UTC
Found the line of code that causes this bug. Problem is that removing the Invert() causes the image on page 3 to be rendered incorrectly in the exported PDF. So, the question is what is unique about the animated PNGs.

diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx
index 37583d0b01d1..3b069bdf6bfd 100644
--- a/vcl/source/gdi/pdfwriter_impl2.cxx
+++ b/vcl/source/gdi/pdfwriter_impl2.cxx
@@ -811,7 +811,7 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa
                     if ( aBitmapEx.IsAlpha())
                     {
                         AlphaMask aAlpha = aBitmapEx.GetAlphaMask();
-                        aAlpha.Invert();
+                        // aAlpha.Invert();
                         aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aAlpha);
                     }
Comment 3 Commit Notification 2023-10-06 20:31:45 UTC
Patrick Luby committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/b2ca39bc5e424e67e8fc7e8a044214feb09e39f7

tdf#157576 and tdf#157635 mask out black pixels

It will be available in 24.2.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.
Comment 4 Patrick Luby (volunteer) 2023-10-06 20:38:11 UTC
Created attachment 190072 [details]
Strange rendering of animated image with Skia disabled on macOS
Comment 5 Patrick Luby (volunteer) 2023-10-06 20:40:08 UTC
I have committed a fix for the missing animated images when exporting to PDF. It  should be included in tomorrow's (07 October 2023) nightly master build.

Note: while debugging, I found that when viewing the document with Skia disabled on macOS, the animated images periodically includes a snapshot of the window's status bar:

https://bugs.documentfoundation.org/attachment.cgi?id=190072

This new bug doesn't occur with Skia/Metal or Skia/Raster but it does occur as far back as LibreOffice 7.5.7 so this is an old bug. Does anyone see this same new bug when running on Windows or Linux with Skia disabled?
Comment 6 Commit Notification 2023-10-09 12:03:30 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/4e1aec7937c0ccd9aa3c5c34091e94786f16e145

tdf#49253, tdf#157635, tdf#157576: sd_png_export: Add unittest

It will be available in 24.2.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.