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>
diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx
index a6c83bb..8f57aa3 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++)
{
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));
}
}