canvas/source/vcl/canvasbitmaphelper.cxx | 2 - include/vcl/BitmapTools.hxx | 2 - vcl/source/bitmap/BitmapTools.cxx | 44 +++++++------------------------ 3 files changed, 13 insertions(+), 35 deletions(-)
New commits: commit 59dc7c8f1133e5687c1441c6b3b3eeda597c4f78 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Aug 15 07:24:25 2025 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Aug 15 10:41:51 2025 +0200 BitmapEx->Bitmap in CanvasExtractBitmapData now that Bitmap can handle transparency Change-Id: I70f7e0e8eaad5f8e82d5188954b5d0065b3e107e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189654 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins diff --git a/canvas/source/vcl/canvasbitmaphelper.cxx b/canvas/source/vcl/canvasbitmaphelper.cxx index 90bd4714161d..be6841582efd 100644 --- a/canvas/source/vcl/canvasbitmaphelper.cxx +++ b/canvas/source/vcl/canvasbitmaphelper.cxx @@ -115,7 +115,7 @@ namespace vclcanvas rLayout.ScanLineBytes = aBmpSize.Width()*4; rLayout.ScanLineStride = rLayout.ScanLineBytes; - uno::Sequence< sal_Int8 > aRes = vcl::bitmap::CanvasExtractBitmapData(BitmapEx(mpBackBuffer->getBitmapReference()), rect); + uno::Sequence< sal_Int8 > aRes = vcl::bitmap::CanvasExtractBitmapData(mpBackBuffer->getBitmapReference(), rect); return aRes; } diff --git a/include/vcl/BitmapTools.hxx b/include/vcl/BitmapTools.hxx index 9154c2b03ba8..ef28f445f1c7 100644 --- a/include/vcl/BitmapTools.hxx +++ b/include/vcl/BitmapTools.hxx @@ -82,7 +82,7 @@ VCL_DLLPUBLIC css::uno::Sequence< sal_Int8 > GetMaskDIB(Bitmap const & aBmp); VCL_DLLPUBLIC void CanvasCairoExtractBitmapData( BitmapEx const & rBmpEx, Bitmap const & rBitmap, unsigned char*& data, bool& bHasAlpha, tools::Long& rnWidth, tools::Long& rnHeight ); VCL_DLLPUBLIC void CanvasCairoExtractBitmapData( Bitmap const & rBitmap, unsigned char*& data, bool& bHasAlpha, tools::Long& rnWidth, tools::Long& rnHeight ); -VCL_DLLPUBLIC css::uno::Sequence< sal_Int8 > CanvasExtractBitmapData(BitmapEx const & rBitmapEx, const css::geometry::IntegerRectangle2D& rect); +VCL_DLLPUBLIC css::uno::Sequence< sal_Int8 > CanvasExtractBitmapData(Bitmap const & rBitmap, const css::geometry::IntegerRectangle2D& rect); // helper to construct historical 8x8 bitmaps with two colors diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx index ea2be0129746..7feb78098af8 100644 --- a/vcl/source/bitmap/BitmapTools.cxx +++ b/vcl/source/bitmap/BitmapTools.cxx @@ -1208,20 +1208,13 @@ void CanvasCairoExtractBitmapData( const Bitmap & aBitmap, unsigned char*& data, bHasAlpha = bIsAlpha; } - uno::Sequence< sal_Int8 > CanvasExtractBitmapData(BitmapEx const & rBitmapEx, const geometry::IntegerRectangle2D& rect) + uno::Sequence< sal_Int8 > CanvasExtractBitmapData(Bitmap const & rBitmap, const geometry::IntegerRectangle2D& rect) { - const Bitmap& aBitmap( rBitmapEx.GetBitmap() ); - Bitmap aAlpha( rBitmapEx.GetAlphaMask().GetBitmap() ); - - BitmapScopedReadAccess pReadAccess( aBitmap ); - BitmapScopedReadAccess pAlphaReadAccess; - if (!aAlpha.IsEmpty()) - pAlphaReadAccess = aAlpha; - + BitmapScopedReadAccess pReadAccess( rBitmap ); assert( pReadAccess ); // TODO(F1): Support more formats. - const Size aBmpSize( aBitmap.GetSizePixel() ); + const Size aBmpSize( rBitmap.GetSizePixel() ); // for the time being, always return as BGRA uno::Sequence< sal_Int8 > aRes( 4*aBmpSize.Width()*aBmpSize.Height() ); @@ -1232,30 +1225,15 @@ void CanvasCairoExtractBitmapData( const Bitmap & aBitmap, unsigned char*& data, y<aBmpSize.Height() && y<rect.Y2; ++y ) { - if( pAlphaReadAccess.get() != nullptr ) + for( tools::Long x=rect.X1; + x<aBmpSize.Width() && x<rect.X2; + ++x ) { - Scanline pScanlineReadAlpha = pAlphaReadAccess->GetScanline( y ); - for( tools::Long x=rect.X1; - x<aBmpSize.Width() && x<rect.X2; - ++x ) - { - pRes[ nCurrPos++ ] = pReadAccess->GetColor( y, x ).GetRed(); - pRes[ nCurrPos++ ] = pReadAccess->GetColor( y, x ).GetGreen(); - pRes[ nCurrPos++ ] = pReadAccess->GetColor( y, x ).GetBlue(); - pRes[ nCurrPos++ ] = 255 - pAlphaReadAccess->GetIndexFromData( pScanlineReadAlpha, x ); - } - } - else - { - for( tools::Long x=rect.X1; - x<aBmpSize.Width() && x<rect.X2; - ++x ) - { - pRes[ nCurrPos++ ] = pReadAccess->GetColor( y, x ).GetRed(); - pRes[ nCurrPos++ ] = pReadAccess->GetColor( y, x ).GetGreen(); - pRes[ nCurrPos++ ] = pReadAccess->GetColor( y, x ).GetBlue(); - pRes[ nCurrPos++ ] = sal_uInt8(255); - } + BitmapColor aCol = pReadAccess->GetColor( y, x ); + pRes[ nCurrPos++ ] = aCol.GetRed(); + pRes[ nCurrPos++ ] = aCol.GetGreen(); + pRes[ nCurrPos++ ] = aCol.GetBlue(); + pRes[ nCurrPos++ ] = 255 - aCol.GetAlpha(); } } return aRes;