Bug 157636 - FILEOPEN: PPT: Images have no background
Summary: FILEOPEN: PPT: Images have no background
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Impress (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
: 157570 (view as bug list)
Depends on:
Blocks: Image-Caching
  Show dependency treegraph
 
Reported: 2023-10-06 11:53 UTC by Xisco Faulí
Modified: 2023-10-16 10:41 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
sample file (161.50 KB, application/vnd.ms-powerpoint)
2023-10-06 11:54 UTC, Xisco Faulí
Details
comparison before and after (31.45 KB, image/png)
2023-10-06 11:56 UTC, Xisco Faulí
Details
another example affected by the same issue (147.00 KB, application/vnd.ms-powerpoint)
2023-10-06 12:01 UTC, Xisco Faulí
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Xisco Faulí 2023-10-06 11:53:42 UTC

    
Comment 1 Xisco Faulí 2023-10-06 11:54:48 UTC
Created attachment 190062 [details]
sample file
Comment 2 Xisco Faulí 2023-10-06 11:55:36 UTC
Steps to reproduce:
1. Open attached document

-> The logo has no fill. See comparison

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 3 Xisco Faulí 2023-10-06 11:56:42 UTC
Created attachment 190063 [details]
comparison before and after
Comment 4 Xisco Faulí 2023-10-06 11:58:22 UTC
Regression introduced by:

author	Noel Grandin <noelgrandin@gmail.com>	2021-04-16 20:33:10 +0200
committer	Noel Grandin <noel.grandin@collabora.co.uk>	2023-07-25 08:38:12 +0200
commit 81994cb2b8b32453a92bcb011830fcb884f22ff3 (patch)
tree ae1750e92421ad2e0ec3f50351c3be6581841598
parent dabedcaf27b0af1e38a611b8d8e48444f848e01d (diff)
Convert internal vcl bitmap formats transparency->alpha (II)

Bisected with: bibisect-linux64-24.2

Adding Cc: to Noel Grandin
Comment 5 Xisco Faulí 2023-10-06 12:01:58 UTC
Created attachment 190064 [details]
another example affected by the same issue
Comment 6 Stéphane Guillou (stragu) 2023-10-06 12:39:40 UTC
Confirmed. Might be the same as bug 157502.
Comment 7 Patrick Luby (volunteer) 2023-10-06 12:49:23 UTC
One possible commonality in the recent wave of semi-transparent image bugs is that they are images in MS Office formats (both OOXML and pre-OOXML formats).

I don't have any familiarity with loading those file formats but my first guess is that MS Office stores transparency instead of alpha in its image masks.

I will see if I can find the code where images are loaded from MS Office. I would think that if I can find that point, I might be able to add an AlphaMask::Invert().

We definitely need to commit 81994cb2b8b32453a92bcb011830fcb884f22ff3 to properly render .png images in ODF files or loaded directly so I think the AlphaMask::Invert() will need to be done immediately after loading.
Comment 8 Patrick Luby (volunteer) 2023-10-10 13:06:20 UTC
I have narrowed down the cause of this bug for all of the attached and linked documents with the following debug patch.

This debug patch works but it might affect other cases since it is so late in the rendering process so I need find where the AlphaMask is constructed for these images and apply the invert there:

diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx
index 2c3521ace0dd..d194febbdf28 100644
--- a/drawinglayer/source/processor2d/vclprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx
@@ -476,6 +476,9 @@ void VclProcessor2D::RenderPolygonHairlinePrimitive2D(
 void VclProcessor2D::RenderBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D& rBitmapCandidate)
 {
     BitmapEx aBitmapEx(rBitmapCandidate.getBitmap());
+    AlphaMask aMask = aBitmapEx.GetAlphaMask();
+    aMask.Invert();
+    aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aMask);
     const basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation
                                                 * rBitmapCandidate.getTransform());
Comment 9 Noel Grandin 2023-10-11 10:56:23 UTC
Thanks Patrick for narrowing down the search a whole bunch.
Fix here:
   https://gerrit.libreoffice.org/c/core/+/157824
Comment 10 Patrick Luby (volunteer) 2023-10-11 14:06:32 UTC
*** Bug 157570 has been marked as a duplicate of this bug. ***
Comment 11 Commit Notification 2023-10-12 05:57:51 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/3622404f09448b82c095256140afe6240b522ece

tdf#157636 FILEOPEN: PPT: Images have no background

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 12 Commit Notification 2023-10-12 22:13:35 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

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

tdf#157636: 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.