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

Chris Sherlock (via logerrit) logerrit at kemper.freedesktop.org
Sat Dec 19 03:21:05 UTC 2020


 vcl/source/gdi/bitmap3.cxx |   31 +++++++++++--------------------
 1 file changed, 11 insertions(+), 20 deletions(-)

New commits:
commit 0920491fef0f20cea19d31547589e66a0d0912d7
Author:     Chris Sherlock <chris.sherlock79 at gmail.com>
AuthorDate: Fri Dec 18 17:27:59 2020 +1100
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Sat Dec 19 04:20:32 2020 +0100

    vcl: refactor - new local function shiftColor()
    
    Change-Id: Ie1ee4dd3741e69dffe655f8c9c4035b980d59375
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107952
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx
index 293f1682e00c..5c27100ef50a 100644
--- a/vcl/source/gdi/bitmap3.cxx
+++ b/vcl/source/gdi/bitmap3.cxx
@@ -732,6 +732,13 @@ void Bitmap::AdaptBitCount(Bitmap& rNew) const
     }
 }
 
+static void shiftColor(tools::Long* pColorArray, BitmapColor const& rColor)
+{
+    *pColorArray++ = static_cast<tools::Long>(rColor.GetBlue()) << 12;
+    *pColorArray++ = static_cast<tools::Long>(rColor.GetGreen()) << 12;
+    *pColorArray++ = static_cast<tools::Long>(rColor.GetRed()) << 12;
+}
+
 bool Bitmap::Dither()
 {
     const Size aSize( GetSizePixel() );
@@ -767,11 +774,7 @@ bool Bitmap::Dither()
                 Scanline pScanlineRead = pReadAcc->GetScanline(0);
                 for( tools::Long nZ = 0; nZ < nWidth; nZ++ )
                 {
-                    aColor = pReadAcc->GetPaletteColor( pReadAcc->GetIndexFromData( pScanlineRead, nZ ) );
-
-                    *pTmp++ = static_cast<tools::Long>(aColor.GetBlue()) << 12;
-                    *pTmp++ = static_cast<tools::Long>(aColor.GetGreen()) << 12;
-                    *pTmp++ = static_cast<tools::Long>(aColor.GetRed()) << 12;
+                    shiftColor(pTmp, pReadAcc->GetPaletteColor(pReadAcc->GetIndexFromData(pScanlineRead, nZ)));
                 }
             }
             else
@@ -779,11 +782,7 @@ bool Bitmap::Dither()
                 Scanline pScanlineRead = pReadAcc->GetScanline(0);
                 for( tools::Long nZ = 0; nZ < nWidth; nZ++ )
                 {
-                    aColor = pReadAcc->GetPixelFromData( pScanlineRead, nZ );
-
-                    *pTmp++ = static_cast<tools::Long>(aColor.GetBlue()) << 12;
-                    *pTmp++ = static_cast<tools::Long>(aColor.GetGreen()) << 12;
-                    *pTmp++ = static_cast<tools::Long>(aColor.GetRed()) << 12;
+                    shiftColor(pTmp, pReadAcc->GetPixelFromData(pScanlineRead, nZ));
                 }
             }
 
@@ -803,11 +802,7 @@ bool Bitmap::Dither()
                         Scanline pScanlineRead = pReadAcc->GetScanline(nY);
                         for( tools::Long nZ = 0; nZ < nWidth; nZ++ )
                         {
-                            aColor = pReadAcc->GetPaletteColor( pReadAcc->GetIndexFromData( pScanlineRead, nZ ) );
-
-                            *pTmp++ = static_cast<tools::Long>(aColor.GetBlue()) << 12;
-                            *pTmp++ = static_cast<tools::Long>(aColor.GetGreen()) << 12;
-                            *pTmp++ = static_cast<tools::Long>(aColor.GetRed()) << 12;
+                            shiftColor(pTmp, pReadAcc->GetPaletteColor(pReadAcc->GetIndexFromData(pScanlineRead, nZ)));
                         }
                     }
                     else
@@ -815,11 +810,7 @@ bool Bitmap::Dither()
                         Scanline pScanlineRead = pReadAcc->GetScanline(nY);
                         for( tools::Long nZ = 0; nZ < nWidth; nZ++ )
                         {
-                            aColor = pReadAcc->GetPixelFromData( pScanlineRead, nZ );
-
-                            *pTmp++ = static_cast<tools::Long>(aColor.GetBlue()) << 12;
-                            *pTmp++ = static_cast<tools::Long>(aColor.GetGreen()) << 12;
-                            *pTmp++ = static_cast<tools::Long>(aColor.GetRed()) << 12;
+                            shiftColor(pTmp, pReadAcc->GetPixelFromData(pScanlineRead, nZ));
                         }
                     }
                 }


More information about the Libreoffice-commits mailing list