From a4664759fea89e91f5c0f26ee47f2747925642c6 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 19 Feb 2018 09:31:58 +0200 Subject: use RawBitmap in W_META_BITBLT part of making BitmapWriteAccess an internal detail of vcl/ Change-Id: I23393872fca5a924ceb7ca70edd8e6f70a3cfc13 Reviewed-on: https://gerrit.libreoffice.org/49965 Tested-by: Jenkins Reviewed-by: Noel Grandin --- emfio/source/reader/wmfreader.cxx | 46 ++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 25 deletions(-) (limited to 'emfio/source') diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx index 233b2f5552a3..734954a6e63e 100644 --- a/emfio/source/reader/wmfreader.cxx +++ b/emfio/source/reader/wmfreader.cxx @@ -32,6 +32,7 @@ #include #include #include +#include #include // MS Windows defines @@ -714,39 +715,34 @@ namespace emfio } if (bOk) { - Bitmap aBmp( Size( nWidth, nHeight ), nBitCount ); - Bitmap::ScopedWriteAccess pAcc(aBmp); - if ( pAcc ) + vcl::bitmap::RawBitmap aBmp( Size( nWidth, nHeight ) ); + for (sal_uInt16 y = 0; y < nHeight && mpInputStream->good(); ++y) { - for (sal_uInt16 y = 0; y < nHeight && mpInputStream->good(); ++y) + sal_uInt16 x = 0; + for (sal_uInt16 scan = 0; scan < nBytesPerScan; scan++ ) { - Scanline pScanline = pAcc->GetScanline( y ); - sal_uInt16 x = 0; - for (sal_uInt16 scan = 0; scan < nBytesPerScan; scan++ ) + sal_Int8 nEightPixels = 0; + mpInputStream->ReadSChar( nEightPixels ); + for (sal_Int8 i = 7; i >= 0; i-- ) { - sal_Int8 nEightPixels = 0; - mpInputStream->ReadSChar( nEightPixels ); - for (sal_Int8 i = 7; i >= 0; i-- ) + if ( x < nWidth ) { - if ( x < nWidth ) - { - pAcc->SetPixelOnData( pScanline, x, BitmapColor((nEightPixels>>i)&1) ); - } - x++; + aBmp.SetPixel( y, x, Color(((nEightPixels>>i)&1) ? COL_BLACK : COL_WHITE) ); } + x++; } } - pAcc.reset(); - if ( nSye && nSxe && - ( nSx + nSxe <= aBmp.GetSizePixel().Width() ) && - ( nSy + nSye <= aBmp.GetSizePixel().Height() ) ) - { - tools::Rectangle aCropRect( Point( nSx, nSy ), Size( nSxe, nSye ) ); - aBmp.Crop( aCropRect ); - } - tools::Rectangle aDestRect( aPoint, Size( nSxe, nSye ) ); - maBmpSaveList.emplace_back(new BSaveStruct(aBmp, aDestRect, nWinROP)); } + BitmapEx aBitmap = vcl::bitmap::CreateFromData(std::move(aBmp)); + if ( nSye && nSxe && + ( nSx + nSxe <= nWidth ) && + ( nSy + nSye <= nHeight ) ) + { + tools::Rectangle aCropRect( Point( nSx, nSy ), Size( nSxe, nSye ) ); + aBitmap.Crop( aCropRect ); + } + tools::Rectangle aDestRect( aPoint, Size( nSxe, nSye ) ); + maBmpSaveList.emplace_back(new BSaveStruct(aBitmap, aDestRect, nWinROP)); } } break; -- cgit