[Libreoffice-commits] core.git: vcl/source
Chris Sherlock (via logerrit)
logerrit at kemper.freedesktop.org
Sat Dec 19 03:26:11 UTC 2020
vcl/source/gdi/bitmap3.cxx | 49 +++++++++++++++------------------------------
1 file changed, 17 insertions(+), 32 deletions(-)
New commits:
commit dfd69eb0ce4d1bb0442d65be2fcd8741fe9cb6ef
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
AuthorDate: Fri Dec 18 17:55:54 2020 +1100
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Sat Dec 19 04:25:36 2020 +0100
vcl: refactor - new local function getColor()
Change-Id: I80548cc0ecb08385aea9bc049bd2c3034680a3f6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107954
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 a6c83bb52cc1..8f57aa3d958c 100644
--- a/vcl/source/gdi/bitmap3.cxx
+++ b/vcl/source/gdi/bitmap3.cxx
@@ -732,11 +732,23 @@ void Bitmap::AdaptBitCount(Bitmap& rNew) const
}
}
-static void shiftColor(tools::Long* pColorArray, BitmapColor const& rColor)
+static tools::Long* 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;
+
+ return pColorArray;
+}
+
+static BitmapColor getColor(BitmapReadAccess *pReadAcc, tools::Long nZ)
+{
+ Scanline pScanlineRead = pReadAcc->GetScanline(0);
+
+ if (pReadAcc->HasPalette())
+ return pReadAcc->GetPaletteColor(pReadAcc->GetIndexFromData(pScanlineRead, nZ));
+ else
+ return pReadAcc->GetPixelFromData(pScanlineRead, nZ);
}
bool Bitmap::Dither()
@@ -766,26 +778,11 @@ bool Bitmap::Dither()
tools::Long* p2T = p2.get();
tools::Long* pTmp;
- bool bPal = pReadAcc->HasPalette();
pTmp = p2T;
+ for (tools::Long nZ = 0; nZ < nWidth; nZ++)
{
- Scanline pScanlineRead = pReadAcc->GetScanline(0);
-
- if( bPal )
- {
- for (tools::Long nZ = 0; nZ < nWidth; nZ++)
- {
- shiftColor(pTmp, pReadAcc->GetPaletteColor(pReadAcc->GetIndexFromData(pScanlineRead, nZ)));
- }
- }
- else
- {
- for (tools::Long nZ = 0; nZ < nWidth; nZ++)
- {
- shiftColor(pTmp, pReadAcc->GetPixelFromData(pScanlineRead, nZ));
- }
- }
+ pTmp = shiftColor(pTmp, getColor(pReadAcc.get(), nZ));
}
tools::Long nRErr, nGErr, nBErr;
@@ -799,21 +796,9 @@ bool Bitmap::Dither()
if (nY < nHeight)
{
- Scanline pScanlineRead = pReadAcc->GetScanline(nY);
-
- if( bPal )
- {
- for( tools::Long nZ = 0; nZ < nWidth; nZ++ )
- {
- shiftColor(pTmp, pReadAcc->GetPaletteColor(pReadAcc->GetIndexFromData(pScanlineRead, nZ)));
- }
- }
- else
+ for (tools::Long nZ = 0; nZ < nWidth; nZ++)
{
- for( tools::Long nZ = 0; nZ < nWidth; nZ++ )
- {
- shiftColor(pTmp, pReadAcc->GetPixelFromData(pScanlineRead, nZ));
- }
+ pTmp = shiftColor(pTmp, getColor(pReadAcc.get(), nZ));
}
}
More information about the Libreoffice-commits
mailing list