33 auto const cappedNewColorCount = std::min(
mnNewColorCount, sal_uInt16(256));
35 const sal_uInt32 nValidBits = 4;
36 const sal_uInt32 nRightShiftBits = 8 - nValidBits;
37 const sal_uInt32 nLeftShiftBits1 = nValidBits;
38 const sal_uInt32 nLeftShiftBits2 = nValidBits << 1;
39 const sal_uInt32 nColorsPerComponent = 1 << nValidBits;
40 const sal_uInt32 nColorOffset = 256 / nColorsPerComponent;
41 const sal_uInt32 nTotalColors = nColorsPerComponent * nColorsPerComponent * nColorsPerComponent;
42 const sal_Int32 nWidth = pRAcc->
Width();
43 const sal_Int32 nHeight = pRAcc->
Height();
44 std::unique_ptr<PopularColorCount[]> pCountTable(
new PopularColorCount[nTotalColors]);
48 for (sal_Int32 nR = 0,
nIndex = 0; nR < 256; nR += nColorOffset)
50 for (sal_Int32 nG = 0; nG < 256; nG += nColorOffset)
52 for (sal_Int32 nB = 0; nB < 256; nB += nColorOffset)
62 for (sal_Int32 nY = 0; nY < nHeight; nY++)
65 for (sal_Int32 nX = 0; nX < nWidth; nX++)
69 pCountTable[((
static_cast<sal_uInt32
>(rCol.
GetRed()) >> nRightShiftBits)
71 | ((
static_cast<sal_uInt32
>(rCol.
GetGreen()) >> nRightShiftBits)
73 | (
static_cast<sal_uInt32
>(rCol.
GetBlue()) >> nRightShiftBits)]
80 for (sal_Int32 nY = 0; nY < nHeight; nY++)
83 for (sal_Int32 nX = 0; nX < nWidth; nX++)
86 pCountTable[((
static_cast<sal_uInt32
>(aCol.
GetRed()) >> nRightShiftBits)
88 | ((
static_cast<sal_uInt32
>(aCol.
GetGreen()) >> nRightShiftBits)
90 | (
static_cast<sal_uInt32
>(aCol.
GetBlue()) >> nRightShiftBits)]
99 [](
const void* p1,
const void* p2) {
102 if (static_cast<PopularColorCount const*>(p1)->mnCount
103 < static_cast<PopularColorCount const*>(p2)->mnCount)
105 else if (static_cast<PopularColorCount const*>(p1)->mnCount
106 == static_cast<PopularColorCount const*>(p2)->mnCount)
114 for (sal_uInt16
n = 0;
n < cappedNewColorCount;
n++)
118 static_cast<sal_uInt8>((rPop.
mnIndex >> nLeftShiftBits2) << nRightShiftBits),
119 static_cast<sal_uInt8>(((rPop.
mnIndex >> nLeftShiftBits1) & (nColorsPerComponent - 1))
121 static_cast<sal_uInt8>((rPop.
mnIndex & (nColorsPerComponent - 1)) << nRightShiftBits));
130 std::unique_ptr<sal_uInt8[]> pIndexMap(
new sal_uInt8[nTotalColors]);
132 for (sal_Int32 nR = 0,
nIndex = 0; nR < 256; nR += nColorOffset)
134 for (sal_Int32 nG = 0; nG < 256; nG += nColorOffset)
136 for (sal_Int32 nB = 0; nB < 256; nB += nColorOffset)
147 for (sal_Int32 nY = 0; nY < nHeight; nY++)
149 Scanline pScanline = pWAcc->GetScanline(nY);
151 for (sal_Int32 nX = 0; nX < nWidth; nX++)
156 pIndexMap[((
static_cast<sal_uInt32
>(rCol.
GetRed()) >> nRightShiftBits)
158 | ((
static_cast<sal_uInt32
>(rCol.
GetGreen()) >> nRightShiftBits)
160 | (
static_cast<sal_uInt32
>(rCol.
GetBlue()) >> nRightShiftBits)]);
161 pWAcc->SetPixelOnData(pScanline, nX, aDstCol);
167 for (sal_Int32 nY = 0; nY < nHeight; nY++)
169 Scanline pScanline = pWAcc->GetScanline(nY);
172 for (sal_Int32 nX = 0; nX < nWidth; nX++)
176 pIndexMap[((
static_cast<sal_uInt32
>(aCol.
GetRed()) >> nRightShiftBits)
178 | ((
static_cast<sal_uInt32
>(aCol.
GetGreen()) >> nRightShiftBits)
180 | (
static_cast<sal_uInt32
>(aCol.
GetBlue()) >> nRightShiftBits)]);
181 pWAcc->SetPixelOnData(pScanline, nX, aDstCol);
virtual BitmapEx execute(BitmapEx const &rBitmapEx) const override
sal_uInt16 mnNewColorCount
void SetIndex(sal_uInt8 cIndex)
Bitmap GetBitmap(Color aTransparentReplaceColor) const
tools::Long Height() const
tools::Long Width() const
const BitmapColor & GetPaletteColor(sal_uInt16 nColor) const
sal_uInt16 GetBestIndex(const BitmapColor &rCol) 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
void SetPrefMapMode(const MapMode &rMapMode)
const MapMode & GetPrefMapMode() const
Size GetSizePixel() const
void SetPrefSize(const Size &rSize)
const Size & GetPrefSize() const
vcl::PixelFormat getPixelFormat() const
sal_uInt8 GetBlue() const
sal_uInt8 GetGreen() const
constexpr sal_Int64 numberOfColors(PixelFormat ePixelFormat)
HashMap_OWString_Interface aMap