Bug 169934 - Transparency is lost when applying a duotone filter to images in Excel files
Summary: Transparency is lost when applying a duotone filter to images in Excel files
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Printing and PDF export (show other bugs)
Version:
(earliest affected)
26.2.0.0 alpha0+ master
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:26.8.0 target:26.2.1 target:26...
Keywords: bisected, regression
Depends on:
Blocks:
 
Reported: 2025-12-11 07:17 UTC by shinbird
Modified: 2026-01-26 10:50 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Sample Excel file to reproduce the issue (12.83 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2025-12-11 07:24 UTC, shinbird
Details
Test LBO 25.8.3.2 vs 26.2.0.0-b1 (50.40 KB, image/png)
2025-12-11 12:29 UTC, steve.contrib@gmail.com
Details

Note You need to log in before you can comment on or make changes to this bug.
Description shinbird 2025-12-11 07:17:10 UTC
Description:
When exporting an Excel document to PDF using the command-line option `--convert-to pdf`, images that have a duotone filter applied lose their transparency. In the resulting PDF, the affected images appear fully opaque instead of preserving their original transparency.


Steps to Reproduce:
1. Prepare an Excel file that contains an image with a duotone filter applied.
2. Export it using: `soffice --headless --convert-to pdf filename.xlsx`
3. Open the generated PDF.


Actual Results:
The transparency of the duotone-filtered image is lost, and the image is rendered as fully opaque in the PDF output.

Expected Results:
Transparency should be preserved when exporting duotone-filtered images to PDF.


Reproducible: Always


User Profile Reset: No

Additional Info:
The issue appears to originate from the duotone conversion logic in
`BitmapDuoToneFilter::execute()`.
The alpha channel is not propagated to the output color, causing the resulting bitmap to lose transparency.
A minimal fix is shown below:

diff --git a/vcl/source/bitmap/BitmapDuoToneFilter.cxx b/vcl/source/bitmap/BitmapDuoToneFilter.cxx
index 2dd10459e242..d0bb35cf6863 100644
--- a/vcl/source/bitmap/BitmapDuoToneFilter.cxx
+++ b/vcl/source/bitmap/BitmapDuoToneFilter.cxx
@@ -41,10 +41,12 @@ Bitmap BitmapDuoToneFilter::execute(Bitmap const& rBitmap) const
             BitmapColor aColor = pReadAcc->GetColor(y, x);
             sal_uInt8 nLuminance = aColor.GetLuminance();
             BitmapColor aResultColor(
+                ColorAlphaTag::ColorAlpha,
                 lcl_getDuotoneColorComponent(nLuminance, aColorOne.GetRed(), aColorTwo.GetRed()),
                 lcl_getDuotoneColorComponent(nLuminance, aColorOne.GetGreen(),
                                              aColorTwo.GetGreen()),
-                lcl_getDuotoneColorComponent(nLuminance, aColorOne.GetBlue(), aColorTwo.GetBlue()));
+                lcl_getDuotoneColorComponent(nLuminance, aColorOne.GetBlue(), aColorTwo.GetBlue()),
+                aColor.GetAlpha());
             pWriteAcc->SetPixel(y, x, aResultColor);
         }
     }
Comment 1 shinbird 2025-12-11 07:24:17 UTC
Created attachment 204572 [details]
Sample Excel file to reproduce the issue

This file demonstrates the issue where applying a duotone filter causes the alpha channel to be lost in the resulting image.
Comment 2 steve.contrib@gmail.com 2025-12-11 12:29:42 UTC
Created attachment 204579 [details]
Test LBO 25.8.3.2 vs 26.2.0.0-b1

Test image not consistent between LBO 25.8.3.2 vs 26.2.0.0-b1
Comment 3 Chris Sherlock 2025-12-23 21:20:02 UTC
I'm struggling to reproduce this. To set the duotone, I set the image to greyscale, then I change the color value of the red channel to something like 10%. I then export the pdf per the instructions, but it does show fine. 

I'm doing this on macOS, but I can't see how that would make much of a difference.
Comment 4 shinbird 2026-01-14 07:36:17 UTC
Thanks for checking.

This issue was discovered when the output result changed after updating the LibreOffice version, using the attached file.
I suspect this is a side effect of the integration of `BitmapEx` into `Bitmap`.

Please note that the duotone setting in the attached Excel file was most likely created in Microsoft Excel.
I have not verified whether the same duotone configuration can be reproduced within LibreOffice itself, so it may differ from the settings you described.

It may be useful to test specifically with the attached file, as the behavior seems to depend on how the duotone was originally defined.
Comment 5 raal 2026-01-14 16:31:11 UTC
Confirm Version: 26.8.0.0.alpha0+ (X86_64)
Build ID: 7f660cc7544889a3171e29a6d5c9100ed7f41448
CPU threads: 4; OS: Linux 6.8; UI render: default; VCL: gtk3
Locale: cs-CZ (cs_CZ.UTF-8); UI: en-US
Calc: threaded
Comment 6 raal 2026-01-14 16:39:49 UTC
This seems to have begun at the below commit in bibisect repository/OS linux-64-26.2.
Adding Cc: to Noel Grandin ; Could you possibly take a look at this one?
Thanks
 8ebd2b4e46ef510c93c9f69cec47f86484e71740 is the first bad commit
commit 8ebd2b4e46ef510c93c9f69cec47f86484e71740
Author: Jenkins Build User <tdf@maggie.tdf>
Date:   Tue Dec 2 20:46:34 2025 +0100

    source df4873973ed6951ab63c59129226d18055f771fc

190303: simplify Graphic::applyDuotone | https://gerrit.libreoffice.org/c/core/+/190303
Comment 7 Commit Notification 2026-01-15 06:07:24 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/0c1df806d965609b46a0c7cec08752c0234b2538

tdf#169934 Transparency is lost when applying a duotone filter

It will be available in 26.8.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 8 Commit Notification 2026-01-15 11:47:05 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "libreoffice-26-2":

https://git.libreoffice.org/core/commit/32d2478a3d11ae4bd2030d0fafe4e882c91cb264

tdf#169934 Transparency is lost when applying a duotone filter

It will be available in 26.2.1.

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 9 Commit Notification 2026-01-16 07:41:10 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/5ccf49826eb51efa763bcfba1a256386cb1c5a7d

tdf#169934: vcl_bitmap_test: Add test

It will be available in 26.8.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 10 Commit Notification 2026-01-26 10:50:05 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "libreoffice-26-2-0":

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

tdf#169934 Transparency is lost when applying a duotone filter

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