vcl/source/bitmap/BitmapDuoToneFilter.cxx |    3 ++-
 vcl/source/graphic/UnoGraphic.cxx         |   26 +++++---------------------
 2 files changed, 7 insertions(+), 22 deletions(-)

New commits:
commit df4873973ed6951ab63c59129226d18055f771fc
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Wed Aug 27 20:25:54 2025 +0200
Commit:     Noel Grandin <noelgran...@gmail.com>
CommitDate: Thu Aug 28 09:06:27 2025 +0200

    simplify Graphic::applyDuotone
    
    make the filter code preserve the alpha layer instead of
    copying it around separately.
    
    Change-Id: I2f9c2717ee4daa1f9f3f9673227ae5829c1364e0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190303
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/vcl/source/bitmap/BitmapDuoToneFilter.cxx 
b/vcl/source/bitmap/BitmapDuoToneFilter.cxx
index 30d7f9310076..2dd10459e242 100644
--- a/vcl/source/bitmap/BitmapDuoToneFilter.cxx
+++ b/vcl/source/bitmap/BitmapDuoToneFilter.cxx
@@ -27,7 +27,8 @@ Bitmap BitmapDuoToneFilter::execute(Bitmap const& rBitmap) 
const
     const sal_Int32 nWidth = aBitmap.GetSizePixel().Width();
     const sal_Int32 nHeight = aBitmap.GetSizePixel().Height();
 
-    Bitmap aResultBitmap(aBitmap.GetSizePixel(), vcl::PixelFormat::N24_BPP);
+    Bitmap aResultBitmap(aBitmap.GetSizePixel(), rBitmap.HasAlpha() ? 
vcl::PixelFormat::N32_BPP
+                                                                    : 
vcl::PixelFormat::N24_BPP);
     BitmapScopedReadAccess pReadAcc(aBitmap);
     BitmapScopedWriteAccess pWriteAcc(aResultBitmap);
     const BitmapColor aColorOne(mnColorOne);
diff --git a/vcl/source/graphic/UnoGraphic.cxx 
b/vcl/source/graphic/UnoGraphic.cxx
index 7fe036a3fd40..dd0b3c096af5 100644
--- a/vcl/source/graphic/UnoGraphic.cxx
+++ b/vcl/source/graphic/UnoGraphic.cxx
@@ -220,30 +220,14 @@ uno::Reference< graphic::XGraphic > SAL_CALL 
Graphic::applyDuotone(
     const uno::Reference< graphic::XGraphic >& rxGraphic, sal_Int32 nColorOne, 
sal_Int32 nColorTwo )
 {
     ::Graphic aGraphic(rxGraphic);
-    ::Graphic aReturnGraphic;
-
     Bitmap    aBitmap( aGraphic.GetBitmap() );
-    if (aBitmap.HasAlpha())
-    {
-        const AlphaMask   aMask( aBitmap.CreateAlphaMask() );
-
-        Bitmap    aTmpBmp(aBitmap.CreateColorBitmap());
-        BitmapFilter::Filter(aTmpBmp,
-                        BitmapDuoToneFilter(
-                            Color(ColorTransparency, nColorOne),
-                            Color(ColorTransparency, nColorTwo)));
 
-        aReturnGraphic = ::Graphic( BitmapEx( aTmpBmp, aMask ) );
-    }
-    else
-    {
-        BitmapFilter::Filter(aBitmap,
-                        BitmapDuoToneFilter(
-                            Color(ColorTransparency, nColorOne),
-                            Color(ColorTransparency, nColorTwo)));
+    BitmapFilter::Filter(aBitmap,
+                    BitmapDuoToneFilter(
+                        Color(ColorTransparency, nColorOne),
+                        Color(ColorTransparency, nColorTwo)));
 
-        aReturnGraphic = ::Graphic( aBitmap );
-    }
+    ::Graphic aReturnGraphic(aBitmap);
     aReturnGraphic.setOriginURL(aGraphic.getOriginURL());
     return aReturnGraphic.GetXGraphic();
 }

Reply via email to