[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - include/vcl vcl/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Thu Sep 2 06:37:40 UTC 2021


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

New commits:
commit f2f260c97b3483355c9ff6e09add4f88737d74ea
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: Thu Sep 2 08:37:06 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>
    (cherry picked from commit 2a151d1d5bc055d5e0011460b6ec42ea9f34f880)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121487
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>

diff --git a/include/vcl/BitmapTools.hxx b/include/vcl/BitmapTools.hxx
index 12cdb1947b2c..db0e32f68c8c 100644
--- a/include/vcl/BitmapTools.hxx
+++ b/include/vcl/BitmapTools.hxx
@@ -46,7 +46,7 @@ void loadFromSvg(SvStream& rStream, const OUString& sPath, BitmapEx& rBitmapEx,
     @param nStride
     The number of bytes in a scanline, must be >= (width * nBitCount / 8)
 */
-BitmapEx VCL_DLLPUBLIC CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int32 nStride, sal_uInt16 nBitCount );
+BitmapEx VCL_DLLPUBLIC CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int32 nStride, sal_uInt16 nBitCount, bool bReverseAlpha = false);
 
 BitmapEx VCL_DLLPUBLIC CreateFromData( RawBitmap && data );
 
diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx
index 2fc8b1c96386..7fc0025b720b 100644
--- a/vcl/source/bitmap/BitmapTools.cxx
+++ b/vcl/source/bitmap/BitmapTools.cxx
@@ -122,7 +122,7 @@ void loadFromSvg(SvStream& rStream, const OUString& sPath, BitmapEx& rBitmapEx,
     @param nStride
     The number of bytes in a scanline, must >= (width * nBitCount / 8)
 */
-BitmapEx CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int32 nStride, sal_uInt16 nBitCount )
+BitmapEx CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int32 nStride, sal_uInt16 nBitCount, bool bReverseAlpha)
 {
     assert(nStride >= (nWidth * nBitCount / 8));
     assert( nBitCount == 1 || nBitCount == 24 || nBitCount == 32);
@@ -170,7 +170,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