avmedia/source/gstreamer/gstframegrabber.cxx | 2 avmedia/source/win/framegrabber.cxx | 4 desktop/qa/desktop_lib/test_desktop_lib.cxx | 4 emfio/qa/cppunit/emf/EmfImportTest.cxx | 4 emfio/source/reader/wmfreader.cxx | 2 filter/source/msfilter/msdffimp.cxx | 2 include/svx/xbitmap.hxx | 4 include/vcl/BitmapTools.hxx | 4 include/vcl/RawBitmap.hxx | 6 - include/vcl/bitmap.hxx | 2 lotuswordpro/source/filter/lwpbackgroundstuff.cxx | 4 oox/source/vml/vmlformatting.cxx | 2 sc/source/filter/excel/xiescher.cxx | 4 sd/qa/unit/tiledrendering/tiledrendering.cxx | 12 +- svx/inc/sdr/primitive2d/sdrprimitivetools.hxx | 4 svx/source/sdr/contact/viewobjectcontactofsdrpage.cxx | 2 svx/source/sdr/primitive2d/sdrprimitivetools.cxx | 8 - svx/source/svdraw/svddrgmt.cxx | 2 svx/source/xoutdev/xattrbmp.cxx | 6 - test/source/text/baseindex.cxx | 4 vcl/source/bitmap/BitmapTools.cxx | 94 ++++++++---------- 21 files changed, 84 insertions(+), 92 deletions(-)
New commits: commit 047eb23bb416d9ce63a8b0748b077f7302b1399a Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Tue Jul 29 16:15:03 2025 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Aug 1 09:31:43 2025 +0200 BitmapEx->Bitmap in CreateFromData now that Bitmap can handle transparency Also add a utility method Bitmap::GetPixelColor, to use in unit test code. One of the unit tests needed tweaking because we are converting back and forth a few times which adds some inaccuracy. Change-Id: I760c7da8845488e547b16ed243819fe3288b0985 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188537 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins diff --git a/avmedia/source/gstreamer/gstframegrabber.cxx b/avmedia/source/gstreamer/gstframegrabber.cxx index 1fd437e4aa0c..e53892e3d9fc 100644 --- a/avmedia/source/gstreamer/gstframegrabber.cxx +++ b/avmedia/source/gstreamer/gstframegrabber.cxx @@ -144,7 +144,7 @@ uno::Reference< graphic::XGraphic > SAL_CALL FrameGrabber::grabFrame( double fMe pData = aMapInfo.data; int nStride = GST_ROUND_UP_4( nWidth * 3 ); - BitmapEx aBmp = vcl::bitmap::CreateFromData(pData, nWidth, nHeight, nStride, /*nBitsPerPixel*/24); + Bitmap aBmp = vcl::bitmap::CreateFromData(pData, nWidth, nHeight, nStride, /*nBitsPerPixel*/24); gst_buffer_unmap( pBuf, &aMapInfo ); xRet = Graphic( aBmp ).GetXGraphic(); diff --git a/avmedia/source/win/framegrabber.cxx b/avmedia/source/win/framegrabber.cxx index 62b771c076e4..8e7ca8d32251 100644 --- a/avmedia/source/win/framegrabber.cxx +++ b/avmedia/source/win/framegrabber.cxx @@ -184,8 +184,8 @@ uno::Reference< graphic::XGraphic > SAL_CALL FrameGrabber::grabFrame( double fMe { if (SUCCEEDED(pBuffer->Lock(&pBitmapData, nullptr, &cbBitmapData)) && cbBitmapData) { - BitmapEx aBitmapEx = vcl::bitmap::CreateFromData(pBitmapData, mnFrameWidth, mnFrameHeight, mnFrameWidth * 4, /*nBitsPerPixel*/32, true); - Graphic aGraphic(aBitmapEx); + Bitmap aBitmap = vcl::bitmap::CreateFromData(pBitmapData, mnFrameWidth, mnFrameHeight, mnFrameWidth * 4, /*nBitsPerPixel*/32, true); + Graphic aGraphic(aBitmap); xRet = aGraphic.GetXGraphic(); } pBuffer->Unlock(); diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index a5be689942ec..4c01c3bfe578 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -3814,7 +3814,7 @@ void DesktopLOKTest::testRenderSearchResult_WriterNode() CPPUNIT_ASSERT_EQUAL(size_t(1440648), nByteSize); const sal_uInt8* pD = reinterpret_cast<const sal_uInt8*>(pBuffer); - BitmapEx aBitmap = vcl::bitmap::CreateFromData(pD, nWidth, nHeight, nWidth * 4, /*nBitsPerPixel*/32, true, true); + Bitmap aBitmap = vcl::bitmap::CreateFromData(pD, nWidth, nHeight, nWidth * 4, /*nBitsPerPixel*/32, true, true); if (bDumpBitmap) { @@ -3859,7 +3859,7 @@ void DesktopLOKTest::testRenderSearchResult_CommonNode() CPPUNIT_ASSERT_EQUAL(size_t(73728), nByteSize); const sal_uInt8* pD = reinterpret_cast<const sal_uInt8*>(pBuffer); - BitmapEx aBitmap = vcl::bitmap::CreateFromData(pD, nWidth, nHeight, nWidth * 4, /*nBitsPerPixel*/32, true, true); + Bitmap aBitmap = vcl::bitmap::CreateFromData(pD, nWidth, nHeight, nWidth * 4, /*nBitsPerPixel*/32, true, true); if (bDumpBitmap) { diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 1c4378c7bc42..697c27c201f2 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -1352,9 +1352,9 @@ CPPUNIT_TEST_FIXTURE(Test, testBitBltStretchBltWMF) assertXPath(pDocument, aXPathPrefix + "mask/bitmap[2]", "width", u"10"); assertXPath(pDocument, aXPathPrefix + "mask/bitmap[2]/data", 10); assertXPath(pDocument, aXPathPrefix + "mask/bitmap[2]/data[1]", "row", - u"000000,00001c,000038,000055,000071,00008d,0000aa,0000c6,0000e2,0000ff"); + u"000000,00001b,000037,000054,000071,00008d,0000aa,0000c6,0000e2,0000ff"); assertXPath(pDocument, aXPathPrefix + "mask/bitmap[2]/data[5]", "row", - u"720000,721c1c,723838,725555,727171,72728d,55728d,39728d,1d728d,00728d"); + u"720000,721d1d,723838,725555,727272,72728d,56728d,39738c,1d728d,00728d"); } CPPUNIT_TEST_FIXTURE(Test, testExtTextOutOpaqueAndClipWMF) diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx index d0774d5aad4c..de6f1ff9cd1f 100644 --- a/emfio/source/reader/wmfreader.cxx +++ b/emfio/source/reader/wmfreader.cxx @@ -897,7 +897,7 @@ namespace emfio std::unique_ptr< sal_uInt8[] > pData; pData.reset( new sal_uInt8[ nHeight * nBytesPerScan ] ); mpInputStream->ReadBytes( pData.get(), nHeight * nBytesPerScan ); - BitmapEx aBitmap = vcl::bitmap::CreateFromData( pData.get(), nWidth, nHeight, nBytesPerScan, nBitCount, true ); + Bitmap aBitmap = vcl::bitmap::CreateFromData( pData.get(), nWidth, nHeight, nBytesPerScan, nBitCount, true ); if ( nSye && nSxe && ( nXSrc + nSxe <= nWidth ) && ( nYSrc + nSye <= nHeight ) ) diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index 38ec1addcf2b..95240d7e9ee2 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -1272,7 +1272,7 @@ static void ApplyRectangularGradientAsBitmap( const SvxMSDffManager& rManager, S aBitmap.SetPixel(nY, nX, Color(static_cast<sal_Int8>(nRed), static_cast<sal_Int8>(nGreen), static_cast<sal_Int8>(nBlue))); } } - BitmapEx aBitmapEx = vcl::bitmap::CreateFromData( std::move(aBitmap) ); + Bitmap aBitmapEx = vcl::bitmap::CreateFromData( std::move(aBitmap) ); if ( nFix16Angle ) { diff --git a/include/svx/xbitmap.hxx b/include/svx/xbitmap.hxx index 575f05dfc5fd..d03799197bae 100644 --- a/include/svx/xbitmap.hxx +++ b/include/svx/xbitmap.hxx @@ -41,7 +41,7 @@ private: public: - XOBitmap( const BitmapEx& rBitmap ); + XOBitmap( const Bitmap& rBitmap ); ~XOBitmap(); void Bitmap2Array(); @@ -50,7 +50,7 @@ public: void SetPixelColor( const Color& rColor ) { m_aPixelColor = rColor; m_bGraphicDirty = true; } void SetBackgroundColor( const Color& rColor ) { m_aBckgrColor = rColor; m_bGraphicDirty = true; } - BitmapEx GetBitmap() const; + Bitmap GetBitmap() const; const Color& GetBackgroundColor() const { return m_aBckgrColor; } }; diff --git a/include/vcl/BitmapTools.hxx b/include/vcl/BitmapTools.hxx index 68014349be91..15d731b02da0 100644 --- a/include/vcl/BitmapTools.hxx +++ b/include/vcl/BitmapTools.hxx @@ -50,14 +50,14 @@ 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, +Bitmap VCL_DLLPUBLIC CreateFromData(sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int32 nStride, sal_Int8 nBitsPerPixel, bool bReversColors = false, bool bReverseAlpha = false); void VCL_DLLPUBLIC fillWithData(sal_uInt8* pData, BitmapEx const& rBitmapEx); -BitmapEx VCL_DLLPUBLIC CreateFromData( RawBitmap && data ); +Bitmap VCL_DLLPUBLIC CreateFromData( RawBitmap && data ); #if ENABLE_CAIRO_CANVAS VCL_DLLPUBLIC BitmapEx* CreateFromCairoSurface(Size size, cairo_surface_t* pSurface); diff --git a/include/vcl/RawBitmap.hxx b/include/vcl/RawBitmap.hxx index 12c924dbb8ba..9b8c5bfbbc3b 100644 --- a/include/vcl/RawBitmap.hxx +++ b/include/vcl/RawBitmap.hxx @@ -11,16 +11,16 @@ #include <o3tl/safeint.hxx> #include <vcl/BitmapColor.hxx> -#include <vcl/bitmapex.hxx> +#include <vcl/bitmap.hxx> namespace vcl::bitmap { /** - * Intended to be used to feed into CreateFromData to create a BitmapEx. RGB data format. + * Intended to be used to feed into CreateFromData to create a Bitmap. RGB data format. */ class VCL_DLLPUBLIC RawBitmap { - friend BitmapEx VCL_DLLPUBLIC CreateFromData(RawBitmap&& rawBitmap); + friend Bitmap VCL_DLLPUBLIC CreateFromData(RawBitmap&& rawBitmap); std::unique_ptr<sal_uInt8[]> mpData; Size maSize; sal_uInt8 mnBitCount; diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx index a4a8e74945ce..117bd8a078a4 100644 --- a/include/vcl/bitmap.hxx +++ b/include/vcl/bitmap.hxx @@ -374,7 +374,7 @@ public: @return true, if the operation was completed successfully. */ - SAL_DLLPRIVATE bool Rotate( Degree10 nAngle10, const Color& rFillColor ); + bool Rotate( Degree10 nAngle10, const Color& rFillColor ); /** Create on-off mask from bitmap diff --git a/lotuswordpro/source/filter/lwpbackgroundstuff.cxx b/lotuswordpro/source/filter/lwpbackgroundstuff.cxx index dc3f9194e094..c4b369e0de7f 100644 --- a/lotuswordpro/source/filter/lwpbackgroundstuff.cxx +++ b/lotuswordpro/source/filter/lwpbackgroundstuff.cxx @@ -114,7 +114,7 @@ std::unique_ptr<XFBGImage> LwpBackgroundStuff::GetFillPattern() GetPattern(m_nID, aPttnArray); // create bitmap object from the pattern array - BitmapEx aBmp = vcl::bitmap::CreateFromData(aPttnArray, 8, 8, 1, /*nBitsPerPixel*/ 1); + Bitmap aBmp = vcl::bitmap::CreateFromData(aPttnArray, 8, 8, 1, /*nBitsPerPixel*/ 1); // create XOBitmap object from bitmap object XOBitmap aXOBitmap(aBmp); @@ -145,7 +145,7 @@ std::unique_ptr<XFBGImage> LwpBackgroundStuff::GetFillPattern() // transfer image data from XOBitmap->SvStream->BYTE-Array SvMemoryStream aPicMemStream; aXOBitmap.Array2Bitmap(); - WriteDIB(aXOBitmap.GetBitmap(), aPicMemStream); + WriteDIB(BitmapEx(aXOBitmap.GetBitmap()), aPicMemStream); sal_uInt32 nSize = aPicMemStream.GetEndOfData(); std::unique_ptr<sal_uInt8[]> pImageBuff(new sal_uInt8[nSize]); memcpy(pImageBuff.get(), aPicMemStream.GetData(), nSize); diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx index 6ecdd80a4e7e..63f293592f50 100644 --- a/oox/source/vml/vmlformatting.cxx +++ b/oox/source/vml/vmlformatting.cxx @@ -880,7 +880,7 @@ void FillModel::pushToPropMap( ShapePropertyMap& rPropMap, const GraphicHelper& moOpacity, COL_LIGHTGRAY) .getColor(rGraphicHelper); - XOBitmap aXOB(aGraphic.GetBitmapEx()); + XOBitmap aXOB(Bitmap(aGraphic.GetBitmapEx())); aXOB.Bitmap2Array(); // LO uses the first pixel's color to represent background pixels if (aXOB.GetBackgroundColor() == COL_WHITE) diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx index 81edde0ac3cb..4889ed08ea01 100644 --- a/sc/source/filter/excel/xiescher.cxx +++ b/sc/source/filter/excel/xiescher.cxx @@ -750,14 +750,14 @@ void XclImpDrawObjBase::ConvertFillStyle( SdrObject& rSdrObj, const XclObjFillDa Bitmap aBitmap; (void)ReadDIB(aBitmap, aMemStrm, false); - XOBitmap aXOBitmap(( BitmapEx(aBitmap) )); + XOBitmap aXOBitmap( aBitmap ); aXOBitmap.Bitmap2Array(); if( aXOBitmap.GetBackgroundColor() == COL_BLACK ) ::std::swap( aPattColor, aBackColor ); aXOBitmap.SetPixelColor( aPattColor ); aXOBitmap.SetBackgroundColor( aBackColor ); aXOBitmap.Array2Bitmap(); - aBitmap = aXOBitmap.GetBitmap().GetBitmap(); + aBitmap = aXOBitmap.GetBitmap(); rSdrObj.SetMergedItem(XFillStyleItem(drawing::FillStyle_BITMAP)); rSdrObj.SetMergedItem(XFillBitmapItem(OUString(), Graphic(BitmapEx(aBitmap)))); diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index efca116b2917..f8c7c590be88 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -3075,7 +3075,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering) CPPUNIT_ASSERT(bIsBitmapLayer); // TODO - check JSON content - BitmapEx aBitmapEx = vcl::bitmap::CreateFromData(pBuffer.data(), nViewWidth, nViewHeight, nViewWidth * 4, /*nBitsPerPixel*/32, true, true); + Bitmap aBitmapEx = vcl::bitmap::CreateFromData(pBuffer.data(), nViewWidth, nViewHeight, nViewWidth * 4, /*nBitsPerPixel*/32, true, true); debugWriteImageToFile(1, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); // top-left corner @@ -3107,7 +3107,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering) // TODO - check JSON content debugWriteImageToFile(2, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); - BitmapEx aBitmapEx = vcl::bitmap::CreateFromData(pBuffer.data(), nViewWidth, nViewHeight, nViewWidth * 4, /*nBitsPerPixel*/32, true, true); + Bitmap aBitmapEx = vcl::bitmap::CreateFromData(pBuffer.data(), nViewWidth, nViewHeight, nViewWidth * 4, /*nBitsPerPixel*/32, true, true); // top-left corner CPPUNIT_ASSERT_EQUAL(Color(0x00, 0x50, 0x90), aBitmapEx.GetPixelColor(nLeft, nTop)); @@ -3193,7 +3193,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_WithFie debugWriteImageToFile(2, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); - BitmapEx aBitmapEx = vcl::bitmap::CreateFromData(pBuffer.data(), nViewWidth, nViewHeight, nViewWidth * 4, /*nBitsPerPixel*/32, true, true); + Bitmap aBitmapEx = vcl::bitmap::CreateFromData(pBuffer.data(), nViewWidth, nViewHeight, nViewWidth * 4, /*nBitsPerPixel*/32, true, true); // top-left corner CPPUNIT_ASSERT_EQUAL(aTransparentColor, aBitmapEx.GetPixelColor(nLeft, nTop)); @@ -3222,7 +3222,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_WithFie // TODO - check JSON content debugWriteImageToFile(3, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); - BitmapEx aBitmapEx = vcl::bitmap::CreateFromData(pBuffer.data(), nViewWidth, nViewHeight, nViewWidth * 4, /*nBitsPerPixel*/32, true, true); + Bitmap aBitmapEx = vcl::bitmap::CreateFromData(pBuffer.data(), nViewWidth, nViewHeight, nViewWidth * 4, /*nBitsPerPixel*/32, true, true); // top-left corner CPPUNIT_ASSERT_EQUAL(aTransparentColor, aBitmapEx.GetPixelColor(nLeft, nTop)); @@ -3254,7 +3254,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_WithFie debugWriteImageToFile(4, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); - BitmapEx aBitmapEx = vcl::bitmap::CreateFromData(pBuffer.data(), nViewWidth, nViewHeight, nViewWidth * 4, /*nBitsPerPixel*/32, true, true); + Bitmap aBitmapEx = vcl::bitmap::CreateFromData(pBuffer.data(), nViewWidth, nViewHeight, nViewWidth * 4, /*nBitsPerPixel*/32, true, true); // top-left corner CPPUNIT_ASSERT_EQUAL(aTransparentColor, aBitmapEx.GetPixelColor(nLeft, nTop)); @@ -3320,7 +3320,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_WithFie debugWriteImageToFile(5, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); - BitmapEx aBitmapEx = vcl::bitmap::CreateFromData(pBuffer.data(), nViewWidth, nViewHeight, nViewWidth * 4, /*nBitsPerPixel*/32, true, true); + Bitmap aBitmapEx = vcl::bitmap::CreateFromData(pBuffer.data(), nViewWidth, nViewHeight, nViewWidth * 4, /*nBitsPerPixel*/32, true, true); // top-left corner CPPUNIT_ASSERT_EQUAL(Color(0x00, 0x50, 0x90), aBitmapEx.GetPixelColor(nLeft, nTop)); diff --git a/svx/inc/sdr/primitive2d/sdrprimitivetools.hxx b/svx/inc/sdr/primitive2d/sdrprimitivetools.hxx index 1cdc28024660..891ba95bc517 100644 --- a/svx/inc/sdr/primitive2d/sdrprimitivetools.hxx +++ b/svx/inc/sdr/primitive2d/sdrprimitivetools.hxx @@ -19,7 +19,7 @@ #pragma once -#include <vcl/bitmapex.hxx> +#include <vcl/bitmap.hxx> // predefines @@ -33,7 +33,7 @@ class BColor; namespace drawinglayer::primitive2d { // create a 3x3 cross in given color as BitmapEx -BitmapEx createDefaultCross_3x3(const basegfx::BColor& rBColor); +Bitmap createDefaultCross_3x3(const basegfx::BColor& rBColor); } // end of namespace drawinglayer::primitive2d /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/contact/viewobjectcontactofsdrpage.cxx b/svx/source/sdr/contact/viewobjectcontactofsdrpage.cxx index 3cc27104c3c2..5055eab5780c 100644 --- a/svx/source/sdr/contact/viewobjectcontactofsdrpage.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofsdrpage.cxx @@ -441,7 +441,7 @@ void ViewObjectContactOfPageGrid::createPrimitive2DSequence(const DisplayInfo& / rVisitor.visit(new drawinglayer::primitive2d::GridPrimitive2D( aGridMatrix, fWidthX, fWidthY, 10.0, 3.0, nSubdivisionsX, nSubdivisionsY, aRGBGridColor, - drawinglayer::primitive2d::createDefaultCross_3x3(aRGBGridColor))); + BitmapEx(drawinglayer::primitive2d::createDefaultCross_3x3(aRGBGridColor)))); } } diff --git a/svx/source/sdr/primitive2d/sdrprimitivetools.cxx b/svx/source/sdr/primitive2d/sdrprimitivetools.cxx index a1cdeb7df6f9..9e08eab103b5 100644 --- a/svx/source/sdr/primitive2d/sdrprimitivetools.cxx +++ b/svx/source/sdr/primitive2d/sdrprimitivetools.cxx @@ -27,9 +27,9 @@ namespace drawinglayer::primitive2d { - BitmapEx createDefaultCross_3x3(const basegfx::BColor& rBColor) + Bitmap createDefaultCross_3x3(const basegfx::BColor& rBColor) { - static tools::DeleteOnDeinit< BitmapEx > aRetVal(tools::DeleteOnDeinitFlag::Empty); + static tools::DeleteOnDeinit< Bitmap > aRetVal(tools::DeleteOnDeinitFlag::Empty); static basegfx::BColor aBColor; static std::mutex aMutex; @@ -51,13 +51,13 @@ namespace drawinglayer::primitive2d r, g, b, 0, r, g, b, 0, r, g, b, 0, 0, 0, 0, a, r, g, b, 0, 0, 0, 0, a }; - BitmapEx aBitmap = vcl::bitmap::CreateFromData(cross, 3, 3, 12, /*nBitsPerPixel*/32); + Bitmap aBitmap = vcl::bitmap::CreateFromData(cross, 3, 3, 12, /*nBitsPerPixel*/32); // create and exchange at aRetVal aRetVal.set(aBitmap); } - return aRetVal.get() ? *aRetVal.get() : BitmapEx(); + return aRetVal.get() ? *aRetVal.get() : Bitmap(); } } // end of namespace diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx index 80b3b0bf6b3b..938bcefa005d 100644 --- a/svx/source/svdraw/svddrgmt.cxx +++ b/svx/source/svdraw/svddrgmt.cxx @@ -257,7 +257,7 @@ drawinglayer::primitive2d::Primitive2DContainer SdrDragEntryPointGlueDrag::creat aRetval = drawinglayer::primitive2d::Primitive2DContainer { new drawinglayer::primitive2d::MarkerArrayPrimitive2D(std::move(aTransformedPositions), - drawinglayer::primitive2d::createDefaultCross_3x3(aColor)) + BitmapEx(drawinglayer::primitive2d::createDefaultCross_3x3(aColor))) }; } else diff --git a/svx/source/xoutdev/xattrbmp.cxx b/svx/source/xoutdev/xattrbmp.cxx index 53459bfcbb84..2b4dcf90c3d5 100644 --- a/svx/source/xoutdev/xattrbmp.cxx +++ b/svx/source/xoutdev/xattrbmp.cxx @@ -42,7 +42,7 @@ using namespace ::com::sun::star; -XOBitmap::XOBitmap( const BitmapEx& rBmp ) : +XOBitmap::XOBitmap( const Bitmap& rBmp ) : m_xGraphicObject (new GraphicObject(rBmp)), m_bGraphicDirty ( false ) { @@ -52,9 +52,9 @@ XOBitmap::~XOBitmap() { } -BitmapEx XOBitmap::GetBitmap() const +Bitmap XOBitmap::GetBitmap() const { - return GetGraphicObject().GetGraphic().GetBitmapEx(); + return Bitmap(GetGraphicObject().GetGraphic().GetBitmapEx()); } const GraphicObject& XOBitmap::GetGraphicObject() const diff --git a/test/source/text/baseindex.cxx b/test/source/text/baseindex.cxx index eb0ece0659f3..f0381196e682 100644 --- a/test/source/text/baseindex.cxx +++ b/test/source/text/baseindex.cxx @@ -24,7 +24,7 @@ namespace { -BitmapEx createExampleBitmap() +Bitmap createExampleBitmap() { vcl::bitmap::RawBitmap aRawBitmap(Size(4, 4), 24); aRawBitmap.SetPixel(0, 0, COL_LIGHTBLUE); @@ -36,7 +36,7 @@ BitmapEx createExampleBitmap() void writerFileWithBitmap(OUString const& rURL) { - BitmapEx aBitmapEx = createExampleBitmap(); + Bitmap aBitmapEx = createExampleBitmap(); SvFileStream aFileStream(rURL, StreamMode::READ | StreamMode::WRITE); vcl::PngImageWriter aWriter(aFileStream); aWriter.write(aBitmapEx); diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx index 149a5f8360ca..a6753c809993 100644 --- a/vcl/source/bitmap/BitmapTools.cxx +++ b/vcl/source/bitmap/BitmapTools.cxx @@ -129,7 +129,7 @@ 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, +Bitmap CreateFromData(sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int32 nStride, sal_Int8 nBitCount, bool bReversColors, bool bReverseAlpha) { @@ -159,15 +159,28 @@ BitmapEx CreateFromData(sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHei BitmapScopedWriteAccess pWrite(aBmp); assert(pWrite.get()); if( !pWrite ) - return BitmapEx(); - std::optional<AlphaMask> pAlphaMask; - BitmapScopedWriteAccess xMaskAcc; + return Bitmap(); if (nBitCount == 32) { - pAlphaMask.emplace( Size(nWidth, nHeight) ); - xMaskAcc = *pAlphaMask; + for( tools::Long y = 0; y < nHeight; ++y ) + { + sal_uInt8 const *p = pData + (y * nStride); + Scanline pScanline = pWrite->GetScanline(y); + for (tools::Long x = 0; x < nWidth; ++x) + { + // FIXME this parameter is badly named + const sal_uInt8 nAlphaValue = bReverseAlpha ? p[3] : 0xff - p[3]; + BitmapColor col; + if ( bReversColors ) + col = BitmapColor( ColorAlpha, p[2], p[1], p[0], nAlphaValue ); + else + col = BitmapColor( ColorAlpha, p[0], p[1], p[2], nAlphaValue ); + pWrite->SetPixelOnData(pScanline, x, col); + p += 4; + } + } } - if (nBitCount == 1) + else if (nBitCount == 1) { for( tools::Long y = 0; y < nHeight; ++y ) { @@ -199,33 +212,17 @@ BitmapEx CreateFromData(sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHei pWrite->SetPixelOnData(pScanline, x, col); p += nBitCount/8; } - if (nBitCount == 32) - { - p = pData + (y * nStride) + 3; - Scanline pMaskScanLine = xMaskAcc->GetScanline(y); - for (tools::Long x = 0; x < nWidth; ++x) - { - // FIXME this parameter is badly named - const sal_uInt8 nValue = bReverseAlpha ? *p : 0xff - *p; - xMaskAcc->SetPixelOnData(pMaskScanLine, x, BitmapColor(nValue)); - p += 4; - } - } } } // Avoid further bitmap use with unfinished write access pWrite.reset(); - xMaskAcc.reset(); - if (nBitCount == 32) - return BitmapEx(aBmp, *pAlphaMask); - else - return BitmapEx(aBmp); + return aBmp; } /** Copy block of image data into the bitmap. Assumes that the Bitmap has been constructed with the desired size. */ -BitmapEx CreateFromData( RawBitmap&& rawBitmap ) +Bitmap CreateFromData( RawBitmap&& rawBitmap ) { auto nBitCount = rawBitmap.GetBitCount(); assert( nBitCount == 24 || nBitCount == 32); @@ -244,47 +241,42 @@ BitmapEx CreateFromData( RawBitmap&& rawBitmap ) BitmapScopedWriteAccess pWrite(aBmp); assert(pWrite.get()); if( !pWrite ) - return BitmapEx(); - std::optional<AlphaMask> pAlphaMask; - BitmapScopedWriteAccess xMaskAcc; - if (nBitCount == 32) - { - pAlphaMask.emplace( rawBitmap.maSize ); - xMaskAcc = *pAlphaMask; - } + return Bitmap(); auto nHeight = rawBitmap.maSize.getHeight(); auto nWidth = rawBitmap.maSize.getWidth(); auto nStride = nWidth * nBitCount / 8; - for( tools::Long y = 0; y < nHeight; ++y ) + if (nBitCount == 32) { - sal_uInt8 const *p = rawBitmap.mpData.get() + (y * nStride); - Scanline pScanline = pWrite->GetScanline(y); - for (tools::Long x = 0; x < nWidth; ++x) + for( tools::Long y = 0; y < nHeight; ++y ) { - BitmapColor col(p[0], p[1], p[2]); - pWrite->SetPixelOnData(pScanline, x, col); - p += nBitCount/8; + sal_uInt8 const *p = rawBitmap.mpData.get() + (y * nStride); + Scanline pScanline = pWrite->GetScanline(y); + for (tools::Long x = 0; x < nWidth; ++x) + { + BitmapColor col(ColorAlpha, p[0], p[1], p[2], p[3]); + pWrite->SetPixelOnData(pScanline, x, col); + p += 4; + } } - if (nBitCount == 32) + } + else + { + for( tools::Long y = 0; y < nHeight; ++y ) { - p = rawBitmap.mpData.get() + (y * nStride) + 3; - Scanline pMaskScanLine = xMaskAcc->GetScanline(y); + sal_uInt8 const *p = rawBitmap.mpData.get() + (y * nStride); + Scanline pScanline = pWrite->GetScanline(y); for (tools::Long x = 0; x < nWidth; ++x) { - xMaskAcc->SetPixelOnData(pMaskScanLine, x, BitmapColor(*p)); - p += 4; + BitmapColor col(p[0], p[1], p[2]); + pWrite->SetPixelOnData(pScanline, x, col); + p += nBitCount/8; } } } - - xMaskAcc.reset(); pWrite.reset(); - if (nBitCount == 32) - return BitmapEx(aBmp, *pAlphaMask); - else - return BitmapEx(aBmp); + return aBmp; } void fillWithData(sal_uInt8* pData, BitmapEx const& rBitmapEx)