26 const sal_Int32 nDivisor = 8;
36 const sal_Int32 nWidth = pWriteAcc->Width(), nWidth2 = nWidth + 2;
37 const sal_Int32 nHeight = pWriteAcc->Height(), nHeight2 = nHeight + 2;
38 std::unique_ptr<sal_Int32[]> pColm(
new sal_Int32[nWidth2]);
39 std::unique_ptr<sal_Int32[]> pRows(
new sal_Int32[nHeight2]);
40 std::unique_ptr<BitmapColor[]> pColRow1(
new BitmapColor[nWidth2]);
41 std::unique_ptr<BitmapColor[]> pColRow2(
new BitmapColor[nWidth2]);
42 std::unique_ptr<BitmapColor[]> pColRow3(
new BitmapColor[nWidth2]);
47 sal_Int32 nY, nX,
i, nSumR, nSumG, nSumB, nMatrixVal, nTmp;
48 std::array<std::array<sal_Int32, 256>, 9> aKoeff;
52 for (nY = 0; nY < 9; nY++)
54 for (nX = nTmp = 0, nMatrixVal =
mrMatrix[nY]; nX < 256; nX++, nTmp += nMatrixVal)
56 aKoeff[nY][nX] = nTmp;
61 for (
i = 0;
i < nWidth2;
i++)
63 pColm[
i] = (
i > 0) ? (
i - 1) : 0;
66 pColm[nWidth + 1] = pColm[nWidth];
69 for (
i = 0;
i < nHeight2;
i++)
71 pRows[
i] = (
i > 0) ? (
i - 1) : 0;
74 pRows[nHeight + 1] = pRows[nHeight];
77 for (
i = 0;
i < nWidth2;
i++)
79 pColRow1[
i] = pReadAcc->
GetColor(pRows[0], pColm[
i]);
80 pColRow2[
i] = pReadAcc->
GetColor(pRows[1], pColm[
i]);
81 pColRow3[
i] = pReadAcc->
GetColor(pRows[2], pColm[
i]);
85 for (nY = 0; nY < nHeight;)
87 Scanline pScanline = pWriteAcc->GetScanline(nY);
88 for (nX = 0; nX < nWidth; nX++)
91 pTmp = aKoeff[0].data();
92 pColor = pRowTmp1 + nX;
93 nSumR = pTmp[pColor->
GetRed()];
95 nSumB = pTmp[pColor->
GetBlue()];
97 pTmp = aKoeff[1].data();
98 nSumR += pTmp[(++pColor)->GetRed()];
100 nSumB += pTmp[pColor->
GetBlue()];
102 pTmp = aKoeff[2].data();
103 nSumR += pTmp[(++pColor)->GetRed()];
105 nSumB += pTmp[pColor->
GetBlue()];
108 pTmp = aKoeff[3].data();
109 pColor = pRowTmp2 + nX;
110 nSumR += pTmp[pColor->
GetRed()];
112 nSumB += pTmp[pColor->
GetBlue()];
114 pTmp = aKoeff[4].data();
115 nSumR += pTmp[(++pColor)->GetRed()];
117 nSumB += pTmp[pColor->
GetBlue()];
119 pTmp = aKoeff[5].data();
120 nSumR += pTmp[(++pColor)->GetRed()];
122 nSumB += pTmp[pColor->
GetBlue()];
125 pTmp = aKoeff[6].data();
126 pColor = pRowTmp3 + nX;
127 nSumR += pTmp[pColor->
GetRed()];
129 nSumB += pTmp[pColor->
GetBlue()];
131 pTmp = aKoeff[7].data();
132 nSumR += pTmp[(++pColor)->GetRed()];
134 nSumB += pTmp[pColor->
GetBlue()];
136 pTmp = aKoeff[8].data();
137 nSumR += pTmp[(++pColor)->GetRed()];
139 nSumB += pTmp[pColor->
GetBlue()];
142 pWriteAcc->SetPixelOnData(
151 if (pRowTmp1 == pColRow1.get())
153 pRowTmp1 = pColRow2.get();
154 pRowTmp2 = pColRow3.get();
155 pRowTmp3 = pColRow1.get();
157 else if (pRowTmp1 == pColRow2.get())
159 pRowTmp1 = pColRow3.get();
160 pRowTmp2 = pColRow1.get();
161 pRowTmp3 = pColRow2.get();
165 pRowTmp1 = pColRow1.get();
166 pRowTmp2 = pColRow2.get();
167 pRowTmp3 = pColRow3.get();
170 for (
i = 0;
i < nWidth2;
i++)
172 pRowTmp3[
i] = pReadAcc->
GetColor(pRows[nY + 2], pColm[
i]);
const sal_Int32 g_SharpenMatrix[]
Filter image based on a 3x3 convolution matrix.
virtual BitmapEx execute(BitmapEx const &rBitmapEx) const override
const sal_Int32(& mrMatrix)[9]
Bitmap GetBitmap(Color aTransparentReplaceColor) const
BitmapColor GetColor(tools::Long nY, tools::Long nX) const
void SetPrefMapMode(const MapMode &rMapMode)
const MapMode & GetPrefMapMode() const
Size GetSizePixel() const
void SetPrefSize(const Size &rSize)
const Size & GetPrefSize() const
sal_uInt8 GetBlue() const
sal_uInt8 GetGreen() const
std::enable_if< std::is_signed< T >::value||std::is_floating_point< T >::value, long >::type MinMax(T nVal, tools::Long nMin, tools::Long nMax)
HashMap_OWString_Interface aMap