include/vcl/BitmapTools.hxx | 3 include/vcl/alpha.hxx | 1 include/vcl/bitmapex.hxx | 5 - include/vcl/dibtools.hxx | 21 ----- vcl/source/bitmap/BitmapTools.cxx | 11 --- vcl/source/bitmap/dibtools.cxx | 139 +++++++------------------------------- 6 files changed, 30 insertions(+), 150 deletions(-)
New commits: commit c6fc4b1bee6765da2ccf92f4169cfac1aea81dd2 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Sep 5 11:25:53 2025 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Sep 5 15:17:27 2025 +0200 drop BitmapEx support in dibtools now that all the call sites can use Bitmap Change-Id: I7013da15eb18e200db389d6139c3ba65b162aac4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190614 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins diff --git a/include/vcl/BitmapTools.hxx b/include/vcl/BitmapTools.hxx index 3172218797af..a1e5ed307408 100644 --- a/include/vcl/BitmapTools.hxx +++ b/include/vcl/BitmapTools.hxx @@ -13,7 +13,7 @@ #include <config_cairo_canvas.h> #include <config_wasm_strip.h> -#include <vcl/bitmapex.hxx> +#include <vcl/bitmap.hxx> #include <vcl/ImageTree.hxx> #if ENABLE_CAIRO_CANVAS #include <vcl/cairo.hxx> @@ -72,7 +72,6 @@ VCL_DLLPUBLIC void DrawAlphaBitmapAndAlphaGradient(Bitmap & rBitmap, bool bFixed VCL_DLLPUBLIC void DrawAndClipBitmap(const Point& rPos, const Size& rSize, const Bitmap& rBitmap, Bitmap & aBmp, basegfx::B2DPolyPolygon const & rClipPath); -VCL_DLLPUBLIC css::uno::Sequence< sal_Int8 > GetMaskDIB(BitmapEx const & aBmpEx); VCL_DLLPUBLIC css::uno::Sequence< sal_Int8 > GetMaskDIB(Bitmap const & aBmp); /** diff --git a/include/vcl/alpha.hxx b/include/vcl/alpha.hxx index 9c7d5ee86fff..83cd7606cfb2 100644 --- a/include/vcl/alpha.hxx +++ b/include/vcl/alpha.hxx @@ -111,7 +111,6 @@ public: private: friend class BitmapEx; friend class ::OutputDevice; - friend bool VCL_DLLPUBLIC ReadDIBBitmapEx(BitmapEx& rTarget, SvStream& rIStm, bool bFileHeader, bool bMSOFormat); Bitmap maBitmap; }; diff --git a/include/vcl/bitmapex.hxx b/include/vcl/bitmapex.hxx index ee8d374a5609..0b1a14e77fff 100644 --- a/include/vcl/bitmapex.hxx +++ b/include/vcl/bitmapex.hxx @@ -445,11 +445,6 @@ public: private: friend class ImpGraphic; friend class OutputDevice; - friend bool VCL_DLLPUBLIC WriteDIBBitmapEx(const BitmapEx& rSource, SvStream& rOStm); - friend bool VCL_DLLPUBLIC ReadRawDIB(BitmapEx& rTarget, const unsigned char* pBuf, - const ScanlineFormat nFormat, - const int nHeight, - const int nStride); Bitmap maBitmap; AlphaMask maAlphaMask; diff --git a/include/vcl/dibtools.hxx b/include/vcl/dibtools.hxx index 4e2b24f96370..9009a1494372 100644 --- a/include/vcl/dibtools.hxx +++ b/include/vcl/dibtools.hxx @@ -25,7 +25,6 @@ // predefines class SvStream; -class BitmapEx; class Bitmap; class AlphaMask; @@ -43,12 +42,6 @@ bool VCL_DLLPUBLIC ReadDIB( // ReadDIB(rBitmap, rIStm, true); bool bFileHeader, bool bMSOFormat=false); -bool VCL_DLLPUBLIC ReadDIBBitmapEx( - BitmapEx& rTarget, - SvStream& rIStm, - bool bFileHeader = true, - bool bMSOFormat = false); - bool VCL_DLLPUBLIC ReadDIBBitmapEx( Bitmap& rTarget, SvStream& rIStm, @@ -60,12 +53,6 @@ bool VCL_DLLPUBLIC ReadDIBV5( AlphaMask& rTargetAlpha, SvStream& rIStm); -bool VCL_DLLPUBLIC ReadRawDIB( - BitmapEx& rTarget, - const unsigned char* pBuf, - const ScanlineFormat nFormat, - const int nHeight, - const int nStride); bool VCL_DLLPUBLIC ReadRawDIB( Bitmap& rTarget, const unsigned char* pBuf, @@ -81,19 +68,11 @@ bool VCL_DLLPUBLIC WriteDIB( bool bFileHeader); // compressed, with file header -bool VCL_DLLPUBLIC WriteDIB( - const BitmapEx& rSource, - SvStream& rOStm, - bool bCompressed = true); bool VCL_DLLPUBLIC WriteDIB( const Bitmap& rSource, SvStream& rOStm, bool bCompressed = true); -bool VCL_DLLPUBLIC WriteDIBBitmapEx( - const BitmapEx& rSource, - SvStream& rOStm); - bool VCL_DLLPUBLIC WriteDIBBitmapEx( const Bitmap& rSource, SvStream& rOStm); diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx index dfeba08ffc6a..5acb3321e487 100644 --- a/vcl/source/bitmap/BitmapTools.cxx +++ b/vcl/source/bitmap/BitmapTools.cxx @@ -624,12 +624,12 @@ void DrawAndClipBitmap(const Point& rPos, const Size& rSize, const Bitmap& rBitm } } -css::uno::Sequence< sal_Int8 > GetMaskDIB(BitmapEx const & aBmpEx) +css::uno::Sequence< sal_Int8 > GetMaskDIB(Bitmap const & aBmp) { - if ( aBmpEx.IsAlpha() ) + if ( aBmp.HasAlpha() ) { SvMemoryStream aMem; - AlphaMask aMask = aBmpEx.GetAlphaMask(); + AlphaMask aMask = aBmp.CreateAlphaMask(); // for backwards compatibility for extensions, we need to convert from alpha to transparency aMask.Invert(); WriteDIB(aMask.GetBitmap(), aMem, false, true); @@ -639,11 +639,6 @@ css::uno::Sequence< sal_Int8 > GetMaskDIB(BitmapEx const & aBmpEx) return css::uno::Sequence< sal_Int8 >(); } -css::uno::Sequence< sal_Int8 > GetMaskDIB(Bitmap const & rBmp) -{ - return GetMaskDIB(BitmapEx(rBmp)); -} - /** * This returns data formatted the way Cairo wants it, i.e. either CAIRO_FORMAT_ARGB32 or CAIRO_FORMAT_RGB24 * diff --git a/vcl/source/bitmap/dibtools.cxx b/vcl/source/bitmap/dibtools.cxx index ba14e5292dda..a0c3ab95df70 100644 --- a/vcl/source/bitmap/dibtools.cxx +++ b/vcl/source/bitmap/dibtools.cxx @@ -1615,80 +1615,6 @@ bool ReadDIB( return ImplReadDIB(rTarget, nullptr, rIStm, bFileHeader, bMSOFormat); } -bool ReadDIBBitmapEx( - BitmapEx& rTarget, - SvStream& rIStm, - bool bFileHeader, - bool bMSOFormat) -{ - Bitmap aBmp; - bool bRetval(ImplReadDIB(aBmp, nullptr, rIStm, bFileHeader, bMSOFormat) && !rIStm.GetError()); - - if(bRetval) - { - // base bitmap was read, set as return value and try to read alpha extra-data - const sal_uInt64 nStmPos(rIStm.Tell()); - sal_uInt32 nMagic1(0); - sal_uInt32 nMagic2(0); - - rTarget = BitmapEx(aBmp); - if (rIStm.remainingSize() >= 4) - rIStm.ReadUInt32( nMagic1 ).ReadUInt32( nMagic2 ); - bRetval = (0x25091962 == nMagic1) && (0xACB20201 == nMagic2) && !rIStm.GetError(); - - if(bRetval) - { - sal_uInt8 tmp = 0; - rIStm.ReadUChar( tmp ); - bRetval = !rIStm.GetError(); - - if(bRetval) - { - switch (tmp) - { - case 2: // TransparentType::Bitmap - { - Bitmap aMask; - - bRetval = ImplReadDIB(aMask, nullptr, rIStm, true); - - if(bRetval && !aMask.IsEmpty()) - rTarget = BitmapEx(aBmp, aMask); - - break; - } - case 1: // backwards compat for old option TransparentType::Color - { - Color aTransparentColor; - - tools::GenericTypeSerializer aSerializer(rIStm); - aSerializer.readColor(aTransparentColor); - - bRetval = rIStm.good(); - - if(bRetval) - { - rTarget = BitmapEx(aBmp, aTransparentColor); - } - break; - } - default: break; - } - } - } - - if(!bRetval) - { - // alpha extra data could not be read; reset, but use base bitmap as result - rIStm.ResetError(); - rIStm.Seek(nStmPos); - bRetval = true; - } - } - - return bRetval; -} - bool ReadDIBBitmapEx( Bitmap& rTarget, SvStream& rIStm, @@ -1774,35 +1700,37 @@ bool ReadDIBV5( } bool ReadRawDIB( - BitmapEx& rTarget, + Bitmap& rTarget, const unsigned char* pBuf, const ScanlineFormat nFormat, const int nHeight, const int nStride) { - BitmapScopedWriteAccess pWriteAccess(rTarget.maBitmap); - for (int nRow = 0; nRow < nHeight; ++nRow) + if (rTarget.HasAlpha()) { - pWriteAccess->CopyScanline(nRow, pBuf + (nStride * nRow), nFormat, nStride); + // Need to preserve the targets alpha information + Bitmap aTmp(rTarget.CreateColorBitmap()); + AlphaMask aTmpMask(rTarget.CreateAlphaMask()); + { + BitmapScopedWriteAccess pWriteAccess(aTmp); + for (int nRow = 0; nRow < nHeight; ++nRow) + { + pWriteAccess->CopyScanline(nRow, pBuf + (nStride * nRow), nFormat, nStride); + } + } + rTarget = Bitmap(aTmp, aTmpMask); + } + else + { + BitmapScopedWriteAccess pWriteAccess(rTarget); + for (int nRow = 0; nRow < nHeight; ++nRow) + { + pWriteAccess->CopyScanline(nRow, pBuf + (nStride * nRow), nFormat, nStride); + } } - return true; } -bool ReadRawDIB( - Bitmap& rTarget, - const unsigned char* pBuf, - const ScanlineFormat nFormat, - const int nHeight, - const int nStride) -{ - BitmapEx aTmp; - bool bRet = ReadRawDIB(aTmp, pBuf, nFormat, nHeight, nStride); - if (bRet) - rTarget = Bitmap(aTmp); - return bRet; -} - bool WriteDIB( const Bitmap& rSource, SvStream& rOStm, @@ -1812,14 +1740,6 @@ bool WriteDIB( return ImplWriteDIB(rSource, rOStm, bCompressed, bFileHeader); } -bool WriteDIB( - const BitmapEx& rSource, - SvStream& rOStm, - bool bCompressed) -{ - return ImplWriteDIB(rSource.GetBitmap(), rOStm, bCompressed, /*bFileHeader*/true); -} - bool WriteDIB( const Bitmap& rSource, SvStream& rOStm, @@ -1829,19 +1749,19 @@ bool WriteDIB( } bool WriteDIBBitmapEx( - const BitmapEx& rSource, + const Bitmap& rSource, SvStream& rOStm) { - if(ImplWriteDIB(rSource.GetBitmap(), rOStm, true, true)) + if(ImplWriteDIB(rSource.CreateColorBitmap(), rOStm, true, true)) { rOStm.WriteUInt32( 0x25091962 ); rOStm.WriteUInt32( 0xACB20201 ); - rOStm.WriteUChar( rSource.IsAlpha() ? 2 : 0 ); // Used to be TransparentType enum + rOStm.WriteUChar( rSource.HasAlpha() ? 2 : 0 ); // Used to be TransparentType enum - if(rSource.IsAlpha()) + if(rSource.HasAlpha()) { // invert the alpha because the other routines actually want transparency - AlphaMask tmpAlpha = rSource.maAlphaMask; + AlphaMask tmpAlpha = rSource.CreateAlphaMask(); tmpAlpha.Invert(); return ImplWriteDIB(tmpAlpha.GetBitmap(), rOStm, true, true); } @@ -1850,13 +1770,6 @@ bool WriteDIBBitmapEx( return false; } -bool WriteDIBBitmapEx( - const Bitmap& rSource, - SvStream& rOStm) -{ - return WriteDIBBitmapEx(BitmapEx(rSource), rOStm); -} - sal_uInt32 getDIBV5HeaderSize() { return DIBV5HEADERSIZE;