From 09cf2f4242250ac8d1ec6440c46dc85ba1a8dc09 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 16 Mar 2018 15:40:29 +0200 Subject: move bitmap copy code from CanvasBitmapHelper to vcl part of making GetAlpha/GetMask an internal detail of vcl Change-Id: Ie1740df3d6435d9f0f2de3297e7f224d2c6b3cc5 Reviewed-on: https://gerrit.libreoffice.org/51436 Tested-by: Jenkins Reviewed-by: Noel Grandin --- canvas/source/vcl/canvasbitmaphelper.cxx | 49 ++------------------------------ 1 file changed, 2 insertions(+), 47 deletions(-) (limited to 'canvas') diff --git a/canvas/source/vcl/canvasbitmaphelper.cxx b/canvas/source/vcl/canvasbitmaphelper.cxx index eef6258dded3..3d99a3bcbe6e 100644 --- a/canvas/source/vcl/canvasbitmaphelper.cxx +++ b/canvas/source/vcl/canvasbitmaphelper.cxx @@ -117,60 +117,15 @@ namespace vclcanvas return uno::Sequence< sal_Int8 >(); // we're disposed rLayout = getMemoryLayout(); - Bitmap aBitmap( mpBackBuffer->getBitmapReference().GetBitmap() ); - Bitmap aAlpha( mpBackBuffer->getBitmapReference().GetAlpha().GetBitmap() ); - - Bitmap::ScopedReadAccess pReadAccess( aBitmap ); - Bitmap::ScopedReadAccess pAlphaReadAccess( aAlpha.IsEmpty() ? - nullptr : aAlpha.AcquireReadAccess(), - aAlpha ); - - ENSURE_OR_THROW( pReadAccess.get() != nullptr, - "Could not acquire read access to bitmap" ); // TODO(F1): Support more formats. - const Size aBmpSize( aBitmap.GetSizePixel() ); + const Size aBmpSize( mpBackBuffer->getBitmapReference().GetSizePixel() ); rLayout.ScanLines = aBmpSize.Height(); rLayout.ScanLineBytes = aBmpSize.Width()*4; rLayout.ScanLineStride = rLayout.ScanLineBytes; - // for the time being, always return as BGRA - uno::Sequence< sal_Int8 > aRes( 4*aBmpSize.Width()*aBmpSize.Height() ); - sal_Int8* pRes = aRes.getArray(); - - int nCurrPos(0); - for( long y=rect.Y1; - yGetScanline( y ); - if( pAlphaReadAccess.get() != nullptr ) - { - for( long x=rect.X1; - xGetColor( y, x ).GetRed(); - pRes[ nCurrPos++ ] = pReadAccess->GetColor( y, x ).GetGreen(); - pRes[ nCurrPos++ ] = pReadAccess->GetColor( y, x ).GetBlue(); - pRes[ nCurrPos++ ] = pAlphaReadAccess->GetIndexFromData( pScanlineReadAlpha, x ); - } - } - else - { - for( long x=rect.X1; - xGetColor( y, x ).GetRed(); - pRes[ nCurrPos++ ] = pReadAccess->GetColor( y, x ).GetGreen(); - pRes[ nCurrPos++ ] = pReadAccess->GetColor( y, x ).GetBlue(); - pRes[ nCurrPos++ ] = sal_uInt8(255); - } - } - } - + uno::Sequence< sal_Int8 > aRes = vcl::bitmap::CanvasExtractBitmapData(mpBackBuffer->getBitmapReference(), rect); return aRes; } -- cgit