[Libreoffice-commits] core.git: vcl/source
Chris Sherlock (via logerrit)
logerrit at kemper.freedesktop.org
Mon Dec 21 03:35:09 UTC 2020
vcl/source/gdi/bitmap3.cxx | 37 +++++++++++++++++++------------------
1 file changed, 19 insertions(+), 18 deletions(-)
New commits:
commit b8aef73735677bc8effebecc25a9a8c4ed4990a1
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
AuthorDate: Fri Dec 18 18:26:01 2020 +1100
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Dec 21 04:34:21 2020 +0100
vcl: refactor - new local function shiftScanlineColors()
Change-Id: I3e02b991efd3f5f5647b0f97d6d3f433a3246591
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107955
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 8f57aa3d958c..af9e55bf5f05 100644
--- a/vcl/source/gdi/bitmap3.cxx
+++ b/vcl/source/gdi/bitmap3.cxx
@@ -732,6 +732,16 @@ void Bitmap::AdaptBitCount(Bitmap& rNew) const
}
}
+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);
+}
+
static tools::Long* shiftColor(tools::Long* pColorArray, BitmapColor const& rColor)
{
*pColorArray++ = static_cast<tools::Long>(rColor.GetBlue()) << 12;
@@ -741,14 +751,14 @@ static tools::Long* shiftColor(tools::Long* pColorArray, BitmapColor const& rCol
return pColorArray;
}
-static BitmapColor getColor(BitmapReadAccess *pReadAcc, tools::Long nZ)
+static tools::Long* shiftScanlineColors(BitmapReadAccess* pReadAcc, tools::Long nWidth, tools::Long* pColorArray)
{
- Scanline pScanlineRead = pReadAcc->GetScanline(0);
+ for (tools::Long nZ = 0; nZ < nWidth; nZ++)
+ {
+ pColorArray = shiftColor(pColorArray, getColor(pReadAcc, nZ));
+ }
- if (pReadAcc->HasPalette())
- return pReadAcc->GetPaletteColor(pReadAcc->GetIndexFromData(pScanlineRead, nZ));
- else
- return pReadAcc->GetPixelFromData(pScanlineRead, nZ);
+ return pColorArray;
}
bool Bitmap::Dither()
@@ -779,28 +789,19 @@ bool Bitmap::Dither()
tools::Long* pTmp;
pTmp = p2T;
-
- for (tools::Long nZ = 0; nZ < nWidth; nZ++)
- {
- pTmp = shiftColor(pTmp, getColor(pReadAcc.get(), nZ));
- }
+ pTmp = shiftScanlineColors(pReadAcc.get(), nWidth, pTmp);
tools::Long nRErr, nGErr, nBErr;
tools::Long nRC, nGC, nBC;
- for( tools::Long nY = 1, nYAcc = 0; nY <= nHeight; nY++, nYAcc++ )
+ for (tools::Long nY = 1, nYAcc = 0; nY <= nHeight; nY++, nYAcc++)
{
pTmp = p1T;
p1T = p2T;
p2T = pTmp;
if (nY < nHeight)
- {
- for (tools::Long nZ = 0; nZ < nWidth; nZ++)
- {
- pTmp = shiftColor(pTmp, getColor(pReadAcc.get(), nZ));
- }
- }
+ pTmp = shiftScanlineColors(pReadAcc.get(), nWidth, pTmp);
// Examine first Pixel separately
tools::Long nX = 0;
More information about the Libreoffice-commits
mailing list