[Libreoffice-commits] core.git: canvas/source include/vcl vcl/qa vcl/source

Chris Sherlock chris.sherlock79 at gmail.com
Mon Feb 26 19:52:10 UTC 2018


 canvas/source/vcl/canvashelper.cxx |    2 
 canvas/source/vcl/spritehelper.cxx |    2 
 include/vcl/bitmap.hxx             |    3 -
 vcl/qa/cppunit/BitmapTest.cxx      |    2 
 vcl/source/gdi/bitmap.cxx          |   75 ++++++++++++++++++++++++++++++++-
 vcl/source/gdi/bitmap3.cxx         |   82 +------------------------------------
 vcl/source/gdi/bitmapex.cxx        |    6 +-
 vcl/source/outdev/bitmap.cxx       |    2 
 8 files changed, 84 insertions(+), 90 deletions(-)

New commits:
commit 7ab5e5c8902de8cc7429d863b4ab6e40ad4b3bbc
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date:   Sun Feb 25 22:16:39 2018 +1100

    vcl: Bitmap::MakeMono() -> Bitmap::MakeMonochrome()
    
    Change-Id: I6b5259d56e8fe5855f8a1125bb87a3dea8e5f425
    Reviewed-on: https://gerrit.libreoffice.org/50301
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/canvas/source/vcl/canvashelper.cxx b/canvas/source/vcl/canvashelper.cxx
index 761a2fdc22b1..1576419716e6 100644
--- a/canvas/source/vcl/canvashelper.cxx
+++ b/canvas/source/vcl/canvashelper.cxx
@@ -742,7 +742,7 @@ namespace vclcanvas
                     if( aBmpEx.IsAlpha() )
                     {
                         Bitmap aMask( aBmpEx.GetAlpha().GetBitmap() );
-                        aMask.MakeMono( 253 );
+                        aMask.MakeMonochrome(253);
                         aBmpEx = BitmapEx( aBmpEx.GetBitmap(), aMask );
                     }
                     else if( aBmpEx.IsTransparent() )
diff --git a/canvas/source/vcl/spritehelper.cxx b/canvas/source/vcl/spritehelper.cxx
index 1b7d3c3cde72..366d0a5b9829 100644
--- a/canvas/source/vcl/spritehelper.cxx
+++ b/canvas/source/vcl/spritehelper.cxx
@@ -153,7 +153,7 @@ namespace vclcanvas
                     {
                         OSL_FAIL("CanvasCustomSprite::redraw(): Mask bitmap is not "
                                    "monochrome (performance!)");
-                        aMask.MakeMono(255);
+                        aMask.MakeMonochrome(255);
                     }
 #endif
 
diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx
index d4f290e35793..cc105600094d 100644
--- a/include/vcl/bitmap.hxx
+++ b/include/vcl/bitmap.hxx
@@ -263,7 +263,7 @@ public:
 
 public:
 
-    void                    MakeMono( sal_uInt8 cThreshold );
+    bool                    MakeMonochrome(sal_uInt8 cThreshold);
 
 
     /** Convert bitmap format
@@ -669,7 +669,6 @@ public:
                                 int const * pPixels,
                                 const int* pCount );
 
-    SAL_DLLPRIVATE bool     ImplMakeMono( sal_uInt8 cThreshold );
     SAL_DLLPRIVATE bool     ImplMakeGreyscales( sal_uInt16 nGreyscales );
     SAL_DLLPRIVATE bool     ImplConvertUp( sal_uInt16 nBitCount, Color const * pExtColor = nullptr );
     SAL_DLLPRIVATE bool     ImplConvertDown( sal_uInt16 nBitCount, Color const * pExtColor = nullptr );
diff --git a/vcl/qa/cppunit/BitmapTest.cxx b/vcl/qa/cppunit/BitmapTest.cxx
index 357df0905f5c..cfb527e0d2e3 100644
--- a/vcl/qa/cppunit/BitmapTest.cxx
+++ b/vcl/qa/cppunit/BitmapTest.cxx
@@ -197,7 +197,7 @@ void BitmapTest::testMonochrome()
     aBmpAccess.SetPixel(3, 2, BitmapColor(Color(COL_YELLOW)));
     aBmpAccess.SetPixel(3, 3, BitmapColor(Color(COL_WHITE)));
 
-    aBmp.MakeMono(63);
+    aBmp.MakeMonochrome(63);
     BitmapReadAccess aBmpReadAccess(aBmp);
 
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Black pixel wrong monochrome value",
diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx
index 27088cc5465c..c9619a2fb40b 100644
--- a/vcl/source/gdi/bitmap.cxx
+++ b/vcl/source/gdi/bitmap.cxx
@@ -1913,9 +1913,80 @@ bool Bitmap::Blend( const AlphaMask& rAlpha, const Color& rBackgroundColor )
     return bRet;
 }
 
-void Bitmap::MakeMono( sal_uInt8 cThreshold )
+bool Bitmap::MakeMonochrome(sal_uInt8 cThreshold)
 {
-    ImplMakeMono( cThreshold );
+    ScopedReadAccess pReadAcc(*this);
+    bool bRet = false;
+
+    if( pReadAcc )
+    {
+        Bitmap aNewBmp( GetSizePixel(), 1 );
+        ScopedWriteAccess pWriteAcc(aNewBmp);
+
+        if( pWriteAcc )
+        {
+            const BitmapColor aBlack( pWriteAcc->GetBestMatchingColor( Color( COL_BLACK ) ) );
+            const BitmapColor aWhite( pWriteAcc->GetBestMatchingColor( Color( COL_WHITE ) ) );
+            const long nWidth = pWriteAcc->Width();
+            const long nHeight = pWriteAcc->Height();
+
+            if( pReadAcc->HasPalette() )
+            {
+                for( long nY = 0; nY < nHeight; nY++ )
+                {
+                    Scanline pScanline = pWriteAcc->GetScanline(nY);
+                    Scanline pScanlineRead = pReadAcc->GetScanline(nY);
+                    for( long nX = 0; nX < nWidth; nX++ )
+                    {
+                        const sal_uInt8 cIndex = pReadAcc->GetIndexFromData( pScanlineRead, nX );
+                        if( pReadAcc->GetPaletteColor( cIndex ).GetLuminance() >=
+                            cThreshold )
+                        {
+                            pWriteAcc->SetPixelOnData( pScanline, nX, aWhite );
+                        }
+                        else
+                            pWriteAcc->SetPixelOnData( pScanline, nX, aBlack );
+                    }
+                }
+            }
+            else
+            {
+                for( long nY = 0; nY < nHeight; nY++ )
+                {
+                    Scanline pScanline = pWriteAcc->GetScanline(nY);
+                    Scanline pScanlineRead = pReadAcc->GetScanline(nY);
+                    for( long nX = 0; nX < nWidth; nX++ )
+                    {
+                        if( pReadAcc->GetPixelFromData( pScanlineRead, nX ).GetLuminance() >=
+                            cThreshold )
+                        {
+                            pWriteAcc->SetPixelOnData( pScanline, nX, aWhite );
+                        }
+                        else
+                            pWriteAcc->SetPixelOnData( pScanline, nX, aBlack );
+                    }
+                }
+            }
+
+            pWriteAcc.reset();
+            bRet = true;
+        }
+
+        pReadAcc.reset();
+
+        if( bRet )
+        {
+            const MapMode aMap( maPrefMapMode );
+            const Size aSize( maPrefSize );
+
+            *this = aNewBmp;
+
+            maPrefMapMode = aMap;
+            maPrefSize = aSize;
+        }
+    }
+
+    return bRet;
 }
 
 bool Bitmap::GetSystemData( BitmapSystemData& rData ) const
diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx
index 72f640a6b9c4..0380e85ca37d 100644
--- a/vcl/source/gdi/bitmap3.cxx
+++ b/vcl/source/gdi/bitmap3.cxx
@@ -235,7 +235,7 @@ bool Bitmap::Convert( BmpConversion eConversion )
     switch( eConversion )
     {
         case BmpConversion::N1BitThreshold:
-            bRet = ImplMakeMono( 128 );
+            bRet = MakeMonochrome(128);
         break;
 
         case BmpConversion::N4BitGreys:
@@ -300,82 +300,6 @@ bool Bitmap::Convert( BmpConversion eConversion )
     return bRet;
 }
 
-bool Bitmap::ImplMakeMono( sal_uInt8 cThreshold )
-{
-    ScopedReadAccess pReadAcc(*this);
-    bool bRet = false;
-
-    if( pReadAcc )
-    {
-        Bitmap aNewBmp( GetSizePixel(), 1 );
-        ScopedWriteAccess pWriteAcc(aNewBmp);
-
-        if( pWriteAcc )
-        {
-            const BitmapColor aBlack( pWriteAcc->GetBestMatchingColor( Color( COL_BLACK ) ) );
-            const BitmapColor aWhite( pWriteAcc->GetBestMatchingColor( Color( COL_WHITE ) ) );
-            const long nWidth = pWriteAcc->Width();
-            const long nHeight = pWriteAcc->Height();
-
-            if( pReadAcc->HasPalette() )
-            {
-                for( long nY = 0; nY < nHeight; nY++ )
-                {
-                    Scanline pScanline = pWriteAcc->GetScanline(nY);
-                    Scanline pScanlineRead = pReadAcc->GetScanline(nY);
-                    for( long nX = 0; nX < nWidth; nX++ )
-                    {
-                        const sal_uInt8 cIndex = pReadAcc->GetIndexFromData( pScanlineRead, nX );
-                        if( pReadAcc->GetPaletteColor( cIndex ).GetLuminance() >=
-                            cThreshold )
-                        {
-                            pWriteAcc->SetPixelOnData( pScanline, nX, aWhite );
-                        }
-                        else
-                            pWriteAcc->SetPixelOnData( pScanline, nX, aBlack );
-                    }
-                }
-            }
-            else
-            {
-                for( long nY = 0; nY < nHeight; nY++ )
-                {
-                    Scanline pScanline = pWriteAcc->GetScanline(nY);
-                    Scanline pScanlineRead = pReadAcc->GetScanline(nY);
-                    for( long nX = 0; nX < nWidth; nX++ )
-                    {
-                        if( pReadAcc->GetPixelFromData( pScanlineRead, nX ).GetLuminance() >=
-                            cThreshold )
-                        {
-                            pWriteAcc->SetPixelOnData( pScanline, nX, aWhite );
-                        }
-                        else
-                            pWriteAcc->SetPixelOnData( pScanline, nX, aBlack );
-                    }
-                }
-            }
-
-            pWriteAcc.reset();
-            bRet = true;
-        }
-
-        pReadAcc.reset();
-
-        if( bRet )
-        {
-            const MapMode aMap( maPrefMapMode );
-            const Size aSize( maPrefSize );
-
-            *this = aNewBmp;
-
-            maPrefMapMode = aMap;
-            maPrefSize = aSize;
-        }
-    }
-
-    return bRet;
-}
-
 bool Bitmap::ImplMakeGreyscales( sal_uInt16 nGreys )
 {
     SAL_WARN_IF( nGreys != 16 && nGreys != 256, "vcl", "Only 16 or 256 greyscales are supported!" );
@@ -817,7 +741,7 @@ bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag n
     //
     //If we start with a 1 bit image, then after scaling it in any mode except
     //BmpScaleFlag::Fast we have a 24bit image which is perfectly correct, but we
-    //are going to down-shift it to mono again and Bitmap::ImplMakeMono just
+    //are going to down-shift it to mono again and Bitmap::MakeMonochrome just
     //has "Bitmap aNewBmp( GetSizePixel(), 1 );" to create a 1 bit bitmap which
     //will default to black/white and the colors mapped to which ever is closer
     //to black/white
@@ -825,7 +749,7 @@ bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag n
     //So the easiest thing to do to retain the colors of 1 bit bitmaps is to
     //just use the fast scale rather than attempting to count unique colors in
     //the other converters and pass all the info down through
-    //Bitmap::ImplMakeMono
+    //Bitmap::MakeMonochrome
     if (nStartCount == 1)
         nScaleFlag = BmpScaleFlag::Fast;
 
diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx
index 962f75cc03f4..9e4d5b78d7a2 100644
--- a/vcl/source/gdi/bitmapex.cxx
+++ b/vcl/source/gdi/bitmapex.cxx
@@ -128,8 +128,8 @@ BitmapEx::BitmapEx( const Bitmap& rBmp, const Bitmap& rMask ) :
     // Ensure a mask is exactly one bit deep
     if( !!aMask && aMask.GetBitCount() != 1 )
     {
-        SAL_WARN( "vcl", "BitmapEx: forced mask to monochrome");
-        aMask.ImplMakeMono( 255 );
+        SAL_WARN("vcl", "BitmapEx: forced mask to monochrome");
+        aMask.MakeMonochrome(255);
     }
 
     if(!!aBitmap && !!aMask && aBitmap.GetSizePixel() != aMask.GetSizePixel())
@@ -267,7 +267,7 @@ Bitmap BitmapEx::GetMask() const
     Bitmap aRet( aMask );
 
     if( IsAlpha() )
-        aRet.ImplMakeMono( 255 );
+        aRet.MakeMonochrome(255);
 
     return aRet;
 }
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index c8a52cac435d..8006bd823032 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -327,7 +327,7 @@ void OutputDevice::DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
                     // output, having alpha-induced grey levels is not
                     // acceptable.
                     Bitmap aMask( aBmpEx.GetAlpha().GetBitmap() );
-                    aMask.MakeMono( 129 );
+                    aMask.MakeMonochrome(129);
                     aBmpEx = BitmapEx( aColorBmp, aMask );
                 }
                 else


More information about the Libreoffice-commits mailing list