vcl/source/gdi/bitmap3.cxx | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-)
New commits: commit b8aef73735677bc8effebecc25a9a8c4ed4990a1 Author: Chris Sherlock <chris.sherloc...@gmail.com> AuthorDate: Fri Dec 18 18:26:01 2020 +1100 Commit: Tomaž Vajngerl <qui...@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 <qui...@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; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits