[Libreoffice-commits] core.git: include/vcl vcl/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Sun Jul 25 23:53:45 UTC 2021


 include/vcl/BitmapTools.hxx       |    5 ++++-
 vcl/source/bitmap/BitmapTools.cxx |    7 +++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

New commits:
commit 2a151d1d5bc055d5e0011460b6ec42ea9f34f880
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Fri Jul 9 14:08:39 2021 +0900
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Jul 26 01:53:09 2021 +0200

    vcl: bitmap::CreateFromData add option to reverse alpha (0xff - a)
    
    Change-Id: If69225f86afb315ad432789178188a66264ab3ac
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118669
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/include/vcl/BitmapTools.hxx b/include/vcl/BitmapTools.hxx
index 8b1a81413d01..7ca5891f5f90 100644
--- a/include/vcl/BitmapTools.hxx
+++ b/include/vcl/BitmapTools.hxx
@@ -46,7 +46,10 @@ void loadFromSvg(SvStream& rStream, const OUString& sPath, BitmapEx& rBitmapEx,
     @param nStride
     The number of bytes in a scanline, must be >= (width * bitcount / 8)
 */
-BitmapEx VCL_DLLPUBLIC CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int32 nStride, vcl::PixelFormat ePixelFormat, bool bReversColors = false);
+BitmapEx VCL_DLLPUBLIC CreateFromData(sal_uInt8 const *pData,
+                                      sal_Int32 nWidth, sal_Int32 nHeight, sal_Int32 nStride,
+                                      vcl::PixelFormat ePixelFormat,
+                                      bool bReversColors = false, bool bReverseAlpha = false);
 
 BitmapEx VCL_DLLPUBLIC CreateFromData( RawBitmap && data );
 
diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx
index 92b3175143f2..eddef22cfb53 100644
--- a/vcl/source/bitmap/BitmapTools.cxx
+++ b/vcl/source/bitmap/BitmapTools.cxx
@@ -128,7 +128,9 @@ void loadFromSvg(SvStream& rStream, const OUString& sPath, BitmapEx& rBitmapEx,
     @param bReversColors
     In case the endianness of pData is wrong, you could reverse colors
 */
-BitmapEx CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int32 nStride, vcl::PixelFormat ePixelFormat, bool bReversColors )
+BitmapEx CreateFromData(sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHeight,
+                        sal_Int32 nStride, vcl::PixelFormat ePixelFormat,
+                        bool bReversColors, bool bReverseAlpha)
 {
     auto nBitCount = sal_uInt16(ePixelFormat);
 
@@ -184,7 +186,8 @@ BitmapEx CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHe
                 Scanline pMaskScanLine = xMaskAcc->GetScanline(y);
                 for (tools::Long x = 0; x < nWidth; ++x)
                 {
-                    xMaskAcc->SetPixelOnData(pMaskScanLine, x, BitmapColor(*p));
+                    const sal_uInt8 nValue = bReverseAlpha ? 0xff - *p : *p;
+                    xMaskAcc->SetPixelOnData(pMaskScanLine, x, BitmapColor(nValue));
                     p += 4;
                 }
             }


More information about the Libreoffice-commits mailing list