[Libreoffice-commits] core.git: 2 commits - filter/source include/vcl

Noel Grandin noel.grandin at collabora.co.uk
Wed Feb 14 06:28:26 UTC 2018


 filter/source/graphicfilter/ieps/ieps.cxx |   22 +++++++---------------
 filter/source/graphicfilter/itga/itga.cxx |    2 +-
 include/vcl/BitmapTools.hxx               |    4 +++-
 3 files changed, 11 insertions(+), 17 deletions(-)

New commits:
commit f9e611478f7b5d07a6d623ee04ed3a5ea6b1156e
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Feb 12 15:16:02 2018 +0200

    use RawBitmap in ipsGraphicImport
    
    part of making Bitmap an internal detail of vcl
    
    Change-Id: Idbc44c29292e7136e6bb09b8472a396e15e5bc68
    Reviewed-on: https://gerrit.libreoffice.org/49663
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/filter/source/graphicfilter/ieps/ieps.cxx b/filter/source/graphicfilter/ieps/ieps.cxx
index 2808975ff5e1..a2d94c45faac 100644
--- a/filter/source/graphicfilter/ieps/ieps.cxx
+++ b/filter/source/graphicfilter/ieps/ieps.cxx
@@ -29,7 +29,7 @@
 #include <vcl/metaact.hxx>
 #include <vcl/virdev.hxx>
 #include <vcl/cvtgrf.hxx>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapTools.hxx>
 #include <unotools/configmgr.hxx>
 #include <unotools/tempfile.hxx>
 #include <osl/process.h>
@@ -656,16 +656,13 @@ ipsGraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* )
                     {
                         rStream.Seek( nBufStartPos + ( pDest - pBuf.get() ) );
 
-                        Bitmap aBitmap( Size( nWidth, nHeight ), 1 );
-                        BitmapWriteAccess* pAcc = aBitmap.AcquireWriteAccess();
-                        if ( pAcc )
+                        vcl::bitmap::RawBitmap aBitmap( Size( nWidth, nHeight ) );
                         {
                             bool bIsValid = true;
                             sal_uInt8 nDat = 0;
                             char nByte;
                             for (long y = 0; bIsValid && y < nHeight; ++y)
                             {
-                                Scanline pScanline = pAcc->GetScanline( y );
                                 int nBitsLeft = 0;
                                 for (long x = 0; x < nWidth; ++x)
                                 {
@@ -715,10 +712,10 @@ ipsGraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* )
                                     if (!bIsValid)
                                         break;
                                     if ( nBitDepth == 1 )
-                                        pAcc->SetPixelOnData( pScanline, x, BitmapColor(static_cast<sal_uInt8>(nDat >> nBitsLeft) & 1) );
+                                        aBitmap.SetPixel( y, x, Color(static_cast<sal_uInt8>(nDat >> nBitsLeft) & 1) );
                                     else
                                     {
-                                        pAcc->SetPixelOnData( pScanline, x, BitmapColor(nDat ? 1 : 0) );  // nBitDepth == 8
+                                        aBitmap.SetPixel( y, x, nDat ? COL_WHITE : COL_BLACK );  // nBitDepth == 8
                                         nBitsLeft = 0;
                                     }
                                 }
@@ -727,15 +724,11 @@ ipsGraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* )
                             {
                                 ScopedVclPtrInstance<VirtualDevice> pVDev;
                                 GDIMetaFile     aMtf;
-                                Size            aSize;
+                                Size            aSize( nWidth, nHeight );
                                 pVDev->EnableOutput( false );
                                 aMtf.Record( pVDev );
-                                aSize = aBitmap.GetPrefSize();
-                                if( !aSize.Width() || !aSize.Height() )
-                                    aSize = Application::GetDefaultDevice()->PixelToLogic(aBitmap.GetSizePixel(), MapMode(MapUnit::Map100thMM));
-                                else
-                                    aSize = OutputDevice::LogicToLogic(aSize, aBitmap.GetPrefMapMode(), MapMode(MapUnit::Map100thMM));
-                                pVDev->DrawBitmap( Point(), aSize, aBitmap );
+                                aSize = OutputDevice::LogicToLogic(aSize, MapMode(), MapMode(MapUnit::Map100thMM));
+                                pVDev->DrawBitmapEx( Point(), aSize, vcl::bitmap::CreateFromData(std::move(aBitmap)) );
                                 aMtf.Stop();
                                 aMtf.WindStart();
                                 aMtf.SetPrefMapMode(MapMode(MapUnit::Map100thMM));
@@ -743,7 +736,6 @@ ipsGraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* )
                                 aGraphic = aMtf;
                                 bHasPreview = bRetValue = true;
                             }
-                            Bitmap::ReleaseAccess( pAcc );
                         }
                     }
                 }
commit 83330a608d0e0be9735d00ae5d60ba262bd235c3
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Feb 12 14:07:24 2018 +0200

    use Color, not BitmapColor in RawBitmap
    
    because we don't want palette images
    
    Change-Id: If087e51503714bf8474ae320381f80196092ceb0
    Reviewed-on: https://gerrit.libreoffice.org/49662
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/filter/source/graphicfilter/itga/itga.cxx b/filter/source/graphicfilter/itga/itga.cxx
index 3a37f27b10bb..e980e3c20925 100644
--- a/filter/source/graphicfilter/itga/itga.cxx
+++ b/filter/source/graphicfilter/itga/itga.cxx
@@ -660,7 +660,7 @@ bool TGAReader::ImplReadBody()
                             m_rTGA.ReadUChar( nBlue ).ReadUChar( nGreen ).ReadUChar( nRed );
                             if ( !m_rTGA.good())
                                 return false;
-                            mpBitmap->SetPixel( nY, nX, BitmapColor( nRed, nGreen, nBlue ) );
+                            mpBitmap->SetPixel( nY, nX, Color( nRed, nGreen, nBlue ) );
                         }
                         break;
 
diff --git a/include/vcl/BitmapTools.hxx b/include/vcl/BitmapTools.hxx
index 3f9629a51905..d5c3056e8738 100644
--- a/include/vcl/BitmapTools.hxx
+++ b/include/vcl/BitmapTools.hxx
@@ -32,13 +32,15 @@ public:
           maSize(rSize)
     {
     }
-    void SetPixel(long nY, long nX, BitmapColor nColor)
+    void SetPixel(long nY, long nX, Color nColor)
     {
         long p = (nY * maSize.getWidth() + nX) * 3;
         mpData[ p++ ] = nColor.GetRed();
         mpData[ p++ ] = nColor.GetGreen();
         mpData[ p   ] = nColor.GetBlue();
     }
+    // so we don't accidentally leave any code in that uses palette color indexes
+    void SetPixel(long nY, long nX, BitmapColor nColor) = delete;
     long Height() { return maSize.Height(); }
     long Width() { return maSize.Width(); }
 };


More information about the Libreoffice-commits mailing list