[Libreoffice-commits] core.git: emfio/source

Noel Grandin noel.grandin at collabora.co.uk
Mon Feb 19 09:14:08 UTC 2018


 emfio/source/reader/wmfreader.cxx |   46 +++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 25 deletions(-)

New commits:
commit a4664759fea89e91f5c0f26ee47f2747925642c6
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Feb 19 09:31:58 2018 +0200

    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 <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

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 <tools/fract.hxx>
 #include <o3tl/make_unique.hxx>
 #include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapTools.hxx>
 #include <osl/thread.h>
 
 // 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;


More information about the Libreoffice-commits mailing list