From e1d1bce72be34eb7ea4e3c72642736b378388c98 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 6 Feb 2018 12:00:16 +0200 Subject: move Bitmap::SetToData to BitmapTools MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I0fc62d29d2044c2aa8af3742d4aeb9d782793713 Reviewed-on: https://gerrit.libreoffice.org/49280 Reviewed-by: Tomaž Vajngerl Tested-by: Tomaž Vajngerl --- vcl/source/bitmap/BitmapTools.cxx | 34 ++++++++++++++++++++++++++++++++++ vcl/source/gdi/bitmap4.cxx | 26 -------------------------- 2 files changed, 34 insertions(+), 26 deletions(-) (limited to 'vcl') diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx index f0aa8ccecf33..94974f57746d 100644 --- a/vcl/source/bitmap/BitmapTools.cxx +++ b/vcl/source/bitmap/BitmapTools.cxx @@ -24,6 +24,8 @@ #include #include #include +#include +#include using namespace css; @@ -101,6 +103,38 @@ void loadFromSvg(SvStream& rStream, const OUString& sPath, BitmapEx& rBitmapEx, } +/** Copy block of image data into the bitmap. + Assumes that the Bitmap has been constructed with the desired size. + + @param pData + The block of data to copy + @param nStride + The number of bytes in a scanline, must >= width +*/ +BitmapEx CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int32 nStride, sal_uInt16 nBitCount ) +{ + assert(nStride >= nWidth); + Bitmap aBmp( Size( nWidth, nHeight ), nBitCount ); + + Bitmap::ScopedWriteAccess pWrite(aBmp); + assert(pWrite.get()); + if( pWrite.get() ) + { + for( long y = 0; y < nHeight; ++y ) + { + sal_uInt8 const *p = pData + y * nStride; + Scanline pScanline = pWrite->GetScanline(y); + for (long x = 0; x < nWidth; ++x) + { + BitmapColor col(p[0], p[1], p[2]); + pWrite->SetPixelOnData(pScanline, x, col); + p += 3; + } + } + } + return aBmp; +} + }} // end vcl::bitmap /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/gdi/bitmap4.cxx b/vcl/source/gdi/bitmap4.cxx index f71f48f31bbf..118fdf8916c4 100644 --- a/vcl/source/gdi/bitmap4.cxx +++ b/vcl/source/gdi/bitmap4.cxx @@ -112,32 +112,6 @@ bool Bitmap::Filter( BmpFilter eFilter, const BmpFilterParam* pFilterParam ) return bRet; } -void Bitmap::SetToData( sal_uInt8 const *pData, sal_Int32 nStride ) -{ - assert(mxImpBmp); - auto nWidth = mxImpBmp->ImplGetSize().getWidth(); - auto nHeight = mxImpBmp->ImplGetSize().getHeight(); - assert(nStride >= nWidth); - - BitmapWriteAccess *pWrite = AcquireWriteAccess(); - assert(pWrite); - if( pWrite ) - { - for( long y = 0; y < nHeight; ++y ) - { - sal_uInt8 const *p = pData + y * nStride; - Scanline pScanline = pWrite->GetScanline(y); - for (long x = 0; x < nWidth; ++x) - { - BitmapColor col(p[0], p[1], p[2]); - pWrite->SetPixelOnData(pScanline, x, col); - p += 3; - } - } - } - ReleaseAccess( pWrite ); -} - bool Bitmap::ImplConvolute3( const long* pMatrix ) { const long nDivisor = 8; -- cgit