40 std::shared_ptr<SalBitmap> xImpBmp(
ImplGetSVData()->mpDefInst->CreateSalBitmap());
41 if (xImpBmp->Create(*
mxSalBmp) && xImpBmp->Erase(rFillColor))
54 pWriteAcc->Erase(rFillColor);
86 pWriteAcc->SetPalette(aBmpPal);
105 Scanline pScanline = pWriteAcc->GetScanline(nY);
108 BitmapColor aBmpColor = pWriteAcc->GetPixelFromData(pScanline, nX);
110 pWriteAcc->SetPixelOnData(pScanline, nX, aBmpColor);
123template <
int bitCount>
126 constexpr int byteCount = bitCount / 8;
128 Scanline pos2 = scanline2 + (nWidth - 1) * byteCount;
132 memcpy(tmp, pos1, byteCount);
133 memcpy(pos1, pos2, byteCount);
134 memcpy(pos2, tmp, byteCount);
159 switch (pAcc->GetBitCount())
164 mirrorScanlines<32>(pAcc->GetScanline(nY),
165 pAcc->GetScanline(nY) + 4 * nSecondHalf, nWidth_2);
169 mirrorScanlines<24>(pAcc->GetScanline(nY),
170 pAcc->GetScanline(nY) + 3 * nSecondHalf, nWidth_2);
174 mirrorScanlines<8>(pAcc->GetScanline(nY),
175 pAcc->GetScanline(nY) + nSecondHalf, nWidth_2);
180 Scanline pScanline = pAcc->GetScanline(nY);
181 for (
tools::Long nX = 0, nOther = nWidth1; nX < nWidth_2; nX++, nOther--)
183 const BitmapColor aTemp(pAcc->GetPixelFromData(pScanline, nX));
185 pAcc->SetPixelOnData(pScanline, nX,
186 pAcc->GetPixelFromData(pScanline, nOther));
187 pAcc->SetPixelOnData(pScanline, nOther, aTemp);
196 else if (bVert && !bHorz)
202 const tools::Long nScanSize = pAcc->GetScanlineSize();
203 std::unique_ptr<sal_uInt8[]> pBuffer(
new sal_uInt8[nScanSize]);
208 for (
tools::Long nY = 0, nOther = nHeight1; nY < nHeight_2; nY++, nOther--)
210 memcpy(pBuffer.get(), pAcc->GetScanline(nY), nScanSize);
211 memcpy(pAcc->GetScanline(nY), pAcc->GetScanline(nOther), nScanSize);
212 memcpy(pAcc->GetScanline(nOther), pBuffer.
get(), nScanSize);
219 else if (bHorz && bVert)
232 switch (pAcc->GetBitCount())
235 for (
tools::Long nY = 0, nOtherY = nHeight - 1; nY < nHeight_2; nY++, nOtherY--)
236 mirrorScanlines<32>(pAcc->GetScanline(nY), pAcc->GetScanline(nOtherY),
239 mirrorScanlines<32>(pAcc->GetScanline(nHeight_2),
240 pAcc->GetScanline(nHeight_2) + 4 * nSecondHalf,
244 for (
tools::Long nY = 0, nOtherY = nHeight - 1; nY < nHeight_2; nY++, nOtherY--)
245 mirrorScanlines<24>(pAcc->GetScanline(nY), pAcc->GetScanline(nOtherY),
248 mirrorScanlines<24>(pAcc->GetScanline(nHeight_2),
249 pAcc->GetScanline(nHeight_2) + 3 * nSecondHalf,
253 for (
tools::Long nY = 0, nOtherY = nHeight - 1; nY < nHeight_2; nY++, nOtherY--)
254 mirrorScanlines<8>(pAcc->GetScanline(nY), pAcc->GetScanline(nOtherY),
257 mirrorScanlines<8>(pAcc->GetScanline(nHeight_2),
258 pAcc->GetScanline(nHeight_2) + nSecondHalf, nWidth_2);
261 for (
tools::Long nY = 0, nOtherY = nHeight - 1; nY < nHeight_2; nY++, nOtherY--)
263 Scanline pScanline = pAcc->GetScanline(nY);
264 Scanline pScanlineOther = pAcc->GetScanline(nOtherY);
265 for (
tools::Long nX = 0, nOtherX = nWidth1; nX < nWidth; nX++, nOtherX--)
267 const BitmapColor aTemp(pAcc->GetPixelFromData(pScanline, nX));
269 pAcc->SetPixelOnData(pScanline, nX,
270 pAcc->GetPixelFromData(pScanlineOther, nOtherX));
271 pAcc->SetPixelOnData(pScanlineOther, nOtherX, aTemp);
278 Scanline pScanline = pAcc->GetScanline(nHeight_2);
279 for (
tools::Long nX = 0, nOtherX = nWidth1; nX < nWidth_2; nX++, nOtherX--)
281 const BitmapColor aTemp(pAcc->GetPixelFromData(pScanline, nX));
282 pAcc->SetPixelOnData(pScanline, nX,
283 pAcc->GetPixelFromData(pScanline, nOtherX));
284 pAcc->SetPixelOnData(pScanline, nOtherX, aTemp);
301 nAngle10 %= 3600_deg10;
302 nAngle10 = (nAngle10 < 0_deg10) ? (
Degree10(3599) + nAngle10) : nAngle10;
306 if (nAngle10 == 1800_deg10)
317 if (nAngle10 == 900_deg10 || nAngle10 == 2700_deg10)
332 if (nAngle10 == 900_deg10)
334 for (
tools::Long nY = 0, nOtherX = nWidth1; nY < nNewHeight; nY++, nOtherX--)
336 Scanline pScanline = pWriteAcc->GetScanline(nY);
337 for (
tools::Long nX = 0, nOtherY = 0; nX < nNewWidth; nX++)
339 pWriteAcc->SetPixelOnData(pScanline, nX,
340 pReadAcc->
GetPixel(nOtherY++, nOtherX));
344 else if (nAngle10 == 2700_deg10)
346 for (
tools::Long nY = 0, nOtherX = 0; nY < nNewHeight; nY++, nOtherX++)
348 Scanline pScanline = pWriteAcc->GetScanline(nY);
349 for (
tools::Long nX = 0, nOtherY = nHeight1; nX < nNewWidth; nX++)
351 pWriteAcc->SetPixelOnData(pScanline, nX,
352 pReadAcc->
GetPixel(nOtherY--, nOtherX));
360 aRotatedBmp = aNewBmp;
367 aPoly.
Rotate(aTmpPoint, nAngle10);
376 const BitmapColor aFillColor(pWriteAcc->GetBestMatchingColor(rFillColor));
377 const double fCosAngle = cos(
toRadians(nAngle10));
378 const double fSinAngle = sin(
toRadians(nAngle10));
379 const double fXMin = aNewBound.
Left();
380 const double fYMin = aNewBound.
Top();
381 const sal_Int32 nWidth = aSizePix.
Width();
382 const sal_Int32 nHeight = aSizePix.
Height();
383 const sal_Int32 nNewWidth = aNewSizePix.
Width();
384 const sal_Int32 nNewHeight = aNewSizePix.
Height();
387 std::unique_ptr<sal_Int32[]> pCosSinX(
new sal_Int32[nNewWidth * 2]);
388 std::unique_ptr<sal_Int32[]> pCosSinY(
new sal_Int32[nNewHeight * 2]);
390 for (sal_Int32 nIdx = 0, nX = 0; nX < nNewWidth; nX++)
392 const double fTmp = (fXMin + nX) * 64;
394 pCosSinX[nIdx++] = std::round(fCosAngle * fTmp);
395 pCosSinX[nIdx++] = std::round(fSinAngle * fTmp);
398 for (sal_Int32 nIdx = 0, nY = 0; nY < nNewHeight; nY++)
400 const double fTmp = (fYMin + nY) * 64;
402 pCosSinY[nIdx++] = std::round(fCosAngle * fTmp);
403 pCosSinY[nIdx++] = std::round(fSinAngle * fTmp);
406 for (sal_Int32 nCosSinYIdx = 0, nY = 0; nY < nNewHeight; nY++)
408 sal_Int32 nCosY = pCosSinY[nCosSinYIdx++];
409 sal_Int32 nSinY = pCosSinY[nCosSinYIdx++];
410 Scanline pScanline = pWriteAcc->GetScanline(nY);
412 for (sal_Int32 nCosSinXIdx = 0, nX = 0; nX < nNewWidth; nX++)
414 sal_Int32 nRotX = (pCosSinX[nCosSinXIdx++] - nSinY) >> 6;
415 sal_Int32 nRotY = (pCosSinX[nCosSinXIdx++] + nCosY) >> 6;
417 if ((nRotX > -1) && (nRotX < nWidth) && (nRotY > -1) && (nRotY < nHeight))
419 pWriteAcc->SetPixelOnData(pScanline, nX, pReadAcc->
GetPixel(nRotY, nRotX));
423 pWriteAcc->SetPixelOnData(pScanline, nX, aFillColor);
431 aRotatedBmp = aNewBmp;
481 Scanline pDst = pWriteAcc->GetScanline(nY);
483 const tools::Long nScanlineSize = pWriteAcc->GetScanlineSize();
485 pDst[nX] = ~pSrc[nX];
496 Scanline pDst = pWriteAcc->GetScanline(nY);
499 if (cTest == pSrc[nX])
511 Scanline pScanline = pWriteAcc->GetScanline(nY);
516 pWriteAcc->SetPixelOnData(pScanline, nX, aWhite);
518 pWriteAcc->SetPixelOnData(pScanline, nX, aBlack);
559 const tools::Long nMinR = MinMax<tools::Long>(rTransColor.
GetRed() - nTol, 0, 255);
560 const tools::Long nMaxR = MinMax<tools::Long>(rTransColor.
GetRed() + nTol, 0, 255);
570 Scanline pScanline = pWriteAcc->GetScanline(nY);
579 if (nMinR <= nR && nMaxR >= nR && nMinG <= nG && nMaxG >= nG && nMinB <= nB
582 pWriteAcc->SetPixelOnData(pScanline, nX, aWhite);
586 pWriteAcc->SetPixelOnData(pScanline, nX, aBlack);
595 Scanline pScanline = pWriteAcc->GetScanline(nY);
604 if (nMinR <= nR && nMaxR >= nR && nMinG <= nG && nMaxG >= nG && nMinB <= nB
607 pWriteAcc->SetPixelOnData(pScanline, nX, aWhite);
611 pWriteAcc->SetPixelOnData(pScanline, nX, aBlack);
665 Scanline pDst = pWriteAcc->GetScanline(nY);
668 if (cTest == pSrc[nX])
669 pDst[nX] = aTransparentColor.
GetIndex();
680 Scanline pScanline = pWriteAcc->GetScanline(nY);
685 pWriteAcc->SetPixelOnData(pScanline, nX, aTransparentColor);
687 pWriteAcc->SetPixelOnData(pScanline, nX, aOpaqueColor);
727 const tools::Long nMinR = MinMax<tools::Long>(rTransColor.
GetRed() - nTol, 0, 255);
728 const tools::Long nMaxR = MinMax<tools::Long>(rTransColor.
GetRed() + nTol, 0, 255);
738 Scanline pScanline = pWriteAcc->GetScanline(nY);
747 if (nMinR <= nR && nMaxR >= nR && nMinG <= nG && nMaxG >= nG && nMinB <= nB
750 pWriteAcc->SetPixelOnData(pScanline, nX, aTransparentColor);
754 pWriteAcc->SetPixelOnData(pScanline, nX, aOpaqueColor);
763 Scanline pScanline = pWriteAcc->GetScanline(nY);
772 if (nMinR <= nR && nMaxR >= nR && nMinG <= nG && nMaxG >= nG && nMinB <= nB
775 pWriteAcc->SetPixelOnData(pScanline, nX, aTransparentColor);
779 pWriteAcc->SetPixelOnData(pScanline, nX, aOpaqueColor);
812 std::vector<tools::Long> aLine;
816 for (; nY <= nBottom; nY++)
818 std::vector<tools::Long> aNewLine;
822 for (; nX <= nRight;)
824 while ((nX <= nRight) && (aMatch != pReadAcc->
GetPixelFromData(pScanlineRead, nX)))
829 aNewLine.push_back(nX);
831 while ((nX <= nRight) && (aMatch == pReadAcc->
GetPixelFromData(pScanlineRead, nX)))
836 aNewLine.push_back(nX - 1);
840 if (aNewLine != aLine)
851 for (
size_t a(0);
a < aLine.size();)
855 aRegion.
Union(aSubRect);
874 for (
size_t a(0);
a < aLine.size();)
878 aRegion.
Union(aSubRect);
894 if (!pAcc || !pAlphaAcc || !pNewAcc)
903 Scanline pScanline = pNewAcc->GetScanline(nY);
904 Scanline pScanlineAlpha = pAlphaAcc->GetScanline(nY);
908 aCol.
Merge(rMergeColor, pAlphaAcc->GetIndexFromData(pScanlineAlpha, nX));
909 pNewAcc->SetPixelOnData(pScanline, nX, aCol);
933 std::shared_ptr<SalBitmap> xImpBmp(
ImplGetSVData()->mpDefInst->CreateSalBitmap());
934 if (xImpBmp->Create(*
mxSalBmp) && xImpBmp->Replace(rSearchColor, rReplaceColor, nTol))
947 const tools::Long nMinR = MinMax<tools::Long>(rSearchColor.
GetRed() - nTol, 0, 255);
948 const tools::Long nMaxR = MinMax<tools::Long>(rSearchColor.
GetRed() + nTol, 0, 255);
954 if (pAcc->HasPalette())
956 for (sal_uInt16
i = 0, nPalCount = pAcc->GetPaletteEntryCount();
i < nPalCount;
i++)
963 pAcc->SetPaletteColor(
i, rReplaceColor);
970 const BitmapColor aReplace(pAcc->GetBestMatchingColor(rReplaceColor));
972 for (
tools::Long nY = 0, nHeight = pAcc->Height(); nY < nHeight; nY++)
974 Scanline pScanline = pAcc->GetScanline(nY);
975 for (
tools::Long nX = 0, nWidth = pAcc->Width(); nX < nWidth; nX++)
977 aCol = pAcc->GetPixelFromData(pScanline, nX);
983 pAcc->SetPixelOnData(pScanline, nX, aReplace);
1001 std::vector<sal_uInt8> aMinR(nColorCount);
1002 std::vector<sal_uInt8> aMaxR(nColorCount);
1003 std::vector<sal_uInt8> aMinG(nColorCount);
1004 std::vector<sal_uInt8> aMaxG(nColorCount);
1005 std::vector<sal_uInt8> aMinB(nColorCount);
1006 std::vector<sal_uInt8> aMaxB(nColorCount);
1010 for (
size_t i = 0;
i < nColorCount; ++
i)
1012 const Color& rCol = pSearchColors[
i];
1015 aMinR[
i] = std::clamp(rCol.
GetRed() - nTol, 0, 255);
1016 aMaxR[
i] = std::clamp(rCol.
GetRed() + nTol, 0, 255);
1017 aMinG[
i] = std::clamp(rCol.
GetGreen() - nTol, 0, 255);
1018 aMaxG[
i] = std::clamp(rCol.
GetGreen() + nTol, 0, 255);
1019 aMinB[
i] = std::clamp(rCol.
GetBlue() - nTol, 0, 255);
1020 aMaxB[
i] = std::clamp(rCol.
GetBlue() + nTol, 0, 255);
1025 for (
size_t i = 0;
i < nColorCount; ++
i)
1027 const Color& rCol = pSearchColors[
i];
1038 if (pAcc->HasPalette())
1040 for (sal_uInt16 nEntry = 0, nPalCount = pAcc->GetPaletteEntryCount(); nEntry < nPalCount;
1043 const BitmapColor& rCol = pAcc->GetPaletteColor(nEntry);
1045 for (
size_t i = 0;
i < nColorCount; ++
i)
1051 pAcc->SetPaletteColor(nEntry, pReplaceColors[
i]);
1059 std::vector<BitmapColor> aReplaces(nColorCount);
1061 for (
size_t i = 0;
i < nColorCount; ++
i)
1062 aReplaces[
i] = pAcc->GetBestMatchingColor(pReplaceColors[
i]);
1064 for (
tools::Long nY = 0, nHeight = pAcc->Height(); nY < nHeight; nY++)
1066 Scanline pScanline = pAcc->GetScanline(nY);
1067 for (
tools::Long nX = 0, nWidth = pAcc->Width(); nX < nWidth; nX++)
1069 BitmapColor aCol = pAcc->GetPixelFromData(pScanline, nX);
1071 for (
size_t i = 0;
i < nColorCount; ++
i)
1077 pAcc->SetPixelOnData(pScanline, nX, aReplaces[
i]);
1095 if (!pMaskAcc || !pAcc)
1102 const BitmapColor aBlack(pAcc->GetBestMatchingColor(aColBlack));
1107 Scanline pScanline = pAcc->GetScanline(nY);
1112 || pAcc->GetPixelFromData(pScanline, nX) != aBlack)
1114 pAcc->SetPixelOnData(pScanline, nX, aWhite);
1118 pAcc->SetPixelOnData(pScanline, nX, aBlack);
1139 if (!pAlphaAcc || !pAcc)
1142 const tools::Long nWidth = std::min(pAlphaAcc->Width(), pAcc->Width());
1143 const tools::Long nHeight = std::min(pAlphaAcc->Height(), pAcc->Height());
1147 Scanline pScanline = pAcc->GetScanline(nY);
1148 Scanline pScanlineAlpha = pAlphaAcc->GetScanline(nY);
1151 BitmapColor aBmpColor = pAcc->GetPixelFromData(pScanline, nX);
1152 aBmpColor.
Merge(rBackgroundColor, pAlphaAcc->GetIndexFromData(pScanlineAlpha, nX));
1153 pAcc->SetPixelOnData(pScanline, nX, aBmpColor);
sal_uInt8 GetIndex() const
tools::Long Height() const
tools::Long Width() const
const BitmapPalette & GetPalette() const
BitmapColor GetBestMatchingColor(const BitmapColor &rBitmapColor) const
ScanlineFormat GetScanlineFormat() const
const BitmapColor & GetPaletteColor(sal_uInt16 nColor) const
sal_uInt32 GetScanlineSize() const
sal_uInt16 GetEntryCount() const
BitmapColor GetPixel(tools::Long nY, tools::Long nX) const
BitmapColor GetColor(tools::Long nY, tools::Long nX) const
BitmapColor GetPixelFromData(const sal_uInt8 *pData, tools::Long nX) const
sal_uInt8 GetIndexFromData(const sal_uInt8 *pData, tools::Long nX) const
Scanline GetScanline(tools::Long nY) const
bool CombineOr(const Bitmap &rMask)
Perform boolean OR operation with another bitmap.
bool Blend(const AlphaMask &rAlpha, const Color &rBackgroundColor)
Alpha-blend the given bitmap against a specified uniform background color.
bool Rotate(Degree10 nAngle10, const Color &rFillColor)
Rotate bitmap by the specified angle.
SAL_DLLPRIVATE void ImplSetSalBitmap(const std::shared_ptr< SalBitmap > &xImpBmp)
Bitmap CreateMask(const Color &rTransColor) const
Create on-off mask from bitmap.
bool Convert(BmpConversion eConversion)
Convert bitmap format.
static const BitmapPalette & GetGreyPalette(int nEntries)
SAL_DLLPRIVATE void ReassignWithSize(const Bitmap &rBitmap)
ReassignWithSize and recalculate bitmap.
bool Replace(const AlphaMask &rAlpha, const Color &rMergeColor)
Merge bitmap with given background color according to specified alpha mask.
Size GetSizePixel() const
bool Invert()
Perform the Invert operation on every pixel.
vcl::Region CreateRegion(const Color &rColor, const tools::Rectangle &rRect) const
Create region of similar colors in a given rectangle.
bool Erase(const Color &rFillColor)
Fill the entire bitmap with the given color.
vcl::PixelFormat getPixelFormat() const
AlphaMask CreateAlphaMask(const Color &rTransColor) const
Create on-off alpha mask from bitmap.
std::shared_ptr< SalBitmap > mxSalBmp
bool Mirror(BmpMirrorFlags nMirrorFlags)
Mirror the bitmap.
sal_uInt8 GetBlue() const
void Merge(const Color &rMergeColor, sal_uInt8 cTransparency)
sal_uInt8 GetGreen() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
void Union(const tools::Rectangle &rRegion)
This template handles BitmapAccess the RAII way.
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_ALPHA_OPAQUE(0xff, 0xff, 0xff)
constexpr ::Color COL_ALPHA_TRANSPARENT(0x00, 0x00, 0x00)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
constexpr bool isPalettePixelFormat(PixelFormat ePixelFormat)
Is it a pixel format that forces creation of a palette.
HashMap_OWString_Interface aMap
ImplSVData * ImplGetSVData()