include/vcl/BitmapConvolutionMatrixFilter.hxx | 5 - vcl/source/bitmap/BitmapConvolutionMatrixFilter.cxx | 68 ++++++++++---------- 2 files changed, 37 insertions(+), 36 deletions(-)
New commits: commit bacaa3e5243e4aabc7fad795af2b25d79611f18c Author: Chris Sherlock <chris.sherloc...@gmail.com> AuthorDate: Sat Sep 7 02:20:32 2024 +1000 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Tue Sep 10 13:30:17 2024 +0200 tdf#143148 Use pragma once in BitmapConvolutionMatrixFilter.hxx Change-Id: If220df8a3bba570e00ba7891f7141892d80da3bc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172974 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/include/vcl/BitmapConvolutionMatrixFilter.hxx b/include/vcl/BitmapConvolutionMatrixFilter.hxx index a504ff0eebbe..34b0b03c8ad5 100644 --- a/include/vcl/BitmapConvolutionMatrixFilter.hxx +++ b/include/vcl/BitmapConvolutionMatrixFilter.hxx @@ -8,8 +8,7 @@ * */ -#ifndef INCLUDED_VCL_BITMAPCONVOLUTIONMATRIXFILTER_HXX -#define INCLUDED_VCL_BITMAPCONVOLUTIONMATRIXFILTER_HXX +#pragma once #include <vcl/BitmapFilter.hxx> @@ -31,6 +30,4 @@ private: const sal_Int32 (&mrMatrix)[9]; }; -#endif - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit eb3d1b3cade22c323d83973e8a087fe2d1b7bff0 Author: Chris Sherlock <chris.sherloc...@gmail.com> AuthorDate: Sun Sep 1 03:08:27 2024 +1000 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Tue Sep 10 13:30:04 2024 +0200 vcl: variable refactoring BitmapConvolutionMatrixFilter::execute() Renamed variables, moved to declare closer to first use. Change-Id: I60b909c79d7c12c81247af2013228be84b42991e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172916 Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> Tested-by: Jenkins diff --git a/vcl/source/bitmap/BitmapConvolutionMatrixFilter.cxx b/vcl/source/bitmap/BitmapConvolutionMatrixFilter.cxx index ea11a1c0a2c5..4caed2b7b3be 100644 --- a/vcl/source/bitmap/BitmapConvolutionMatrixFilter.cxx +++ b/vcl/source/bitmap/BitmapConvolutionMatrixFilter.cxx @@ -22,7 +22,6 @@ BitmapEx BitmapConvolutionMatrixFilter::execute(BitmapEx const& rBitmapEx) const { Bitmap aBitmap(rBitmapEx.GetBitmap()); - const sal_Int32 nDivisor = 8; BitmapScopedReadAccess pReadAcc(aBitmap); if (!pReadAcc) return BitmapEx(); @@ -32,66 +31,69 @@ BitmapEx BitmapConvolutionMatrixFilter::execute(BitmapEx const& rBitmapEx) const if (!pWriteAcc) return BitmapEx(); - const sal_Int32 nWidth = pWriteAcc->Width(), nWidth2 = nWidth + 2; - const sal_Int32 nHeight = pWriteAcc->Height(), nHeight2 = nHeight + 2; - std::unique_ptr<sal_Int32[]> pColm(new sal_Int32[nWidth2]); - std::unique_ptr<sal_Int32[]> pRows(new sal_Int32[nHeight2]); - std::unique_ptr<BitmapColor[]> pColRow1(new BitmapColor[nWidth2]); - std::unique_ptr<BitmapColor[]> pColRow2(new BitmapColor[nWidth2]); - std::unique_ptr<BitmapColor[]> pColRow3(new BitmapColor[nWidth2]); - BitmapColor* pRowTmp1 = pColRow1.get(); - BitmapColor* pRowTmp2 = pColRow2.get(); - BitmapColor* pRowTmp3 = pColRow3.get(); - BitmapColor* pColor; - sal_Int32 nY, nX, i, nSumR, nSumG, nSumB, nMatrixVal, nTmp; std::array<std::array<sal_Int32, 256>, 9> aKoeff; - sal_Int32* pTmp; // create LUT of products of matrix value and possible color component values - for (nY = 0; nY < 9; nY++) + for (sal_Int32 nY = 0; nY < 9; nY++) { - for (nX = nTmp = 0, nMatrixVal = mrMatrix[nY]; nX < 256; nX++, nTmp += nMatrixVal) + for (sal_Int32 nX = 0, nTmp = 0, nMatrixVal = mrMatrix[nY]; nX < 256; + nX++, nTmp += nMatrixVal) { aKoeff[nY][nX] = nTmp; } } + const sal_Int32 nWidth = pWriteAcc->Width(); + const sal_Int32 nWidth2 = nWidth + 2; + std::unique_ptr<sal_Int32[]> pColm(new sal_Int32[nWidth2]); + // create column LUT - for (i = 0; i < nWidth2; i++) + for (sal_Int32 nColIdx = 0; nColIdx < nWidth2; nColIdx++) { - pColm[i] = (i > 0) ? (i - 1) : 0; + pColm[nColIdx] = (nColIdx > 0) ? (nColIdx - 1) : 0; } pColm[nWidth + 1] = pColm[nWidth]; + const sal_Int32 nHeight = pWriteAcc->Height(); + const sal_Int32 nHeight2 = nHeight + 2; + std::unique_ptr<sal_Int32[]> pRows(new sal_Int32[nHeight2]); + // create row LUT - for (i = 0; i < nHeight2; i++) + for (sal_Int32 nRowIdx = 0; nRowIdx < nHeight2; nRowIdx++) { - pRows[i] = (i > 0) ? (i - 1) : 0; + pRows[nRowIdx] = (nRowIdx > 0) ? (nRowIdx - 1) : 0; } pRows[nHeight + 1] = pRows[nHeight]; + std::unique_ptr<BitmapColor[]> pColRow1(new BitmapColor[nWidth2]); + std::unique_ptr<BitmapColor[]> pColRow2(new BitmapColor[nWidth2]); + std::unique_ptr<BitmapColor[]> pColRow3(new BitmapColor[nWidth2]); + BitmapColor* pRowTmp1 = pColRow1.get(); + BitmapColor* pRowTmp2 = pColRow2.get(); + BitmapColor* pRowTmp3 = pColRow3.get(); + // read first three rows of bitmap color - for (i = 0; i < nWidth2; i++) + for (sal_Int32 nRowIdx = 0; nRowIdx < nWidth2; nRowIdx++) { - pColRow1[i] = pReadAcc->GetColor(pRows[0], pColm[i]); - pColRow2[i] = pReadAcc->GetColor(pRows[1], pColm[i]); - pColRow3[i] = pReadAcc->GetColor(pRows[2], pColm[i]); + pColRow1[nRowIdx] = pReadAcc->GetColor(pRows[0], pColm[nRowIdx]); + pColRow2[nRowIdx] = pReadAcc->GetColor(pRows[1], pColm[nRowIdx]); + pColRow3[nRowIdx] = pReadAcc->GetColor(pRows[2], pColm[nRowIdx]); } // do convolution - for (nY = 0; nY < nHeight;) + for (sal_Int32 nY = 0; nY < nHeight;) { Scanline pScanline = pWriteAcc->GetScanline(nY); - for (nX = 0; nX < nWidth; nX++) + for (sal_Int32 nX = 0; nX < nWidth; nX++) { // first row - pTmp = aKoeff[0].data(); - pColor = pRowTmp1 + nX; - nSumR = pTmp[pColor->GetRed()]; - nSumG = pTmp[pColor->GetGreen()]; - nSumB = pTmp[pColor->GetBlue()]; + sal_Int32* pTmp = aKoeff[0].data(); + BitmapColor* pColor = pRowTmp1 + nX; + sal_Int32 nSumR = pTmp[pColor->GetRed()]; + sal_Int32 nSumG = pTmp[pColor->GetGreen()]; + sal_Int32 nSumB = pTmp[pColor->GetBlue()]; pTmp = aKoeff[1].data(); nSumR += pTmp[(++pColor)->GetRed()]; @@ -137,6 +139,8 @@ BitmapEx BitmapConvolutionMatrixFilter::execute(BitmapEx const& rBitmapEx) const nSumG += pTmp[pColor->GetGreen()]; nSumB += pTmp[pColor->GetBlue()]; + const sal_Int32 nDivisor = 8; + // calculate destination color pWriteAcc->SetPixelOnData( pScanline, nX, @@ -169,7 +173,7 @@ BitmapEx BitmapConvolutionMatrixFilter::execute(BitmapEx const& rBitmapEx) const pRowTmp3 = pColRow3.get(); } - for (i = 0; i < nWidth2; i++) + for (sal_Int32 i = 0; i < nWidth2; i++) { pRowTmp3[i] = pReadAcc->GetColor(pRows[nY + 2], pColm[i]); }