summaryrefslogtreecommitdiff
path: root/vcl/source/gdi/bitmap3.cxx
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2020-12-18 17:55:54 +1100
committerTomaž Vajngerl <quikee@gmail.com>2020-12-19 04:25:36 +0100
commitdfd69eb0ce4d1bb0442d65be2fcd8741fe9cb6ef (patch)
treefa3190b6122d5fa77ec2e9180420fb5429ee2bb3 /vcl/source/gdi/bitmap3.cxx
parent641d6c35f3494f7e62d5ca3089b1f0764cfeb0a8 (diff)
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@gmail.com>
Diffstat (limited to 'vcl/source/gdi/bitmap3.cxx')
-rw-r--r--vcl/source/gdi/bitmap3.cxx49
1 files changed, 17 insertions, 32 deletions
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));
}
}