36 auto const cappedNewColorCount = std::min(
mnNewColorCount, sal_uInt16(256));
40 const sal_uInt32 nValidBits = 4;
41 const sal_uInt32 nRightShiftBits = 8 - nValidBits;
42 const sal_uInt32 nLeftShiftBits1 = nValidBits;
43 const sal_uInt32 nLeftShiftBits2 = nValidBits << 1;
44 const sal_uInt32 nColorsPerComponent = 1 << nValidBits;
45 const sal_uInt32 nColorOffset = 256 / nColorsPerComponent;
46 const sal_uInt32 nTotalColors
47 = nColorsPerComponent * nColorsPerComponent * nColorsPerComponent;
48 const sal_Int32 nWidth = pRAcc->
Width();
49 const sal_Int32 nHeight = pRAcc->
Height();
50 std::unique_ptr<PopularColorCount[]> pCountTable(
new PopularColorCount[nTotalColors]);
54 for (sal_Int32 nR = 0,
nIndex = 0; nR < 256; nR += nColorOffset)
56 for (sal_Int32 nG = 0; nG < 256; nG += nColorOffset)
58 for (sal_Int32 nB = 0; nB < 256; nB += nColorOffset)
68 for (sal_Int32 nY = 0; nY < nHeight; nY++)
71 for (sal_Int32 nX = 0; nX < nWidth; nX++)
75 pCountTable[((
static_cast<sal_uInt32
>(rCol.
GetRed()) >> nRightShiftBits)
77 | ((static_cast<sal_uInt32>(rCol.
GetGreen()) >> nRightShiftBits)
79 | (static_cast<sal_uInt32>(rCol.
GetBlue()) >> nRightShiftBits)]
86 for (sal_Int32 nY = 0; nY < nHeight; nY++)
89 for (sal_Int32 nX = 0; nX < nWidth; nX++)
92 pCountTable[((
static_cast<sal_uInt32
>(aCol.GetRed()) >> nRightShiftBits)
94 | ((static_cast<sal_uInt32>(aCol.GetGreen()) >> nRightShiftBits)
96 | (static_cast<sal_uInt32>(aCol.GetBlue()) >> nRightShiftBits)]
105 [](
const void* p1,
const void* p2) {
108 if (static_cast<PopularColorCount const*>(p1)->mnCount
111 else if (static_cast<PopularColorCount const*>(p1)->mnCount
120 for (sal_uInt16
n = 0;
n < cappedNewColorCount;
n++)
124 static_cast<sal_uInt8>((rPop.
mnIndex >> nLeftShiftBits2) << nRightShiftBits),
125 static_cast<sal_uInt8>(
126 ((rPop.
mnIndex >> nLeftShiftBits1) & (nColorsPerComponent - 1))
128 static_cast<sal_uInt8>((rPop.
mnIndex & (nColorsPerComponent - 1))
129 << nRightShiftBits));
138 std::unique_ptr<sal_uInt8[]> pIndexMap(
new sal_uInt8[nTotalColors]);
140 for (sal_Int32 nR = 0,
nIndex = 0; nR < 256; nR += nColorOffset)
142 for (sal_Int32 nG = 0; nG < 256; nG += nColorOffset)
144 for (sal_Int32 nB = 0; nB < 256; nB += nColorOffset)
147 BitmapColor(static_cast<sal_uInt8>(nR), static_cast<sal_uInt8>(nG),
148 static_cast<sal_uInt8>(nB))));
155 for (sal_Int32 nY = 0; nY < nHeight; nY++)
157 Scanline pScanline = pWAcc->GetScanline(nY);
159 for (sal_Int32 nX = 0; nX < nWidth; nX++)
163 aDstCol.
SetIndex(pIndexMap[((static_cast<sal_uInt32>(rCol.
GetRed())
166 | ((static_cast<sal_uInt32>(rCol.
GetGreen())
169 | (static_cast<sal_uInt32>(rCol.
GetBlue())
170 >> nRightShiftBits)]);
171 pWAcc->SetPixelOnData(pScanline, nX, aDstCol);
177 for (sal_Int32 nY = 0; nY < nHeight; nY++)
179 Scanline pScanline = pWAcc->GetScanline(nY);
182 for (sal_Int32 nX = 0; nX < nWidth; nX++)
185 aDstCol.
SetIndex(pIndexMap[((static_cast<sal_uInt32>(aCol.GetRed())
188 | ((static_cast<sal_uInt32>(aCol.GetGreen())
191 | (static_cast<sal_uInt32>(aCol.GetBlue())
192 >> nRightShiftBits)]);
193 pWAcc->SetPixelOnData(pScanline, nX, aDstCol);
213 aBitmap.SetPrefSize(aSize);
sal_uInt8 GetIndexFromData(const sal_uInt8 *pData, tools::Long nX) const
tools::Long Height() const
Size GetSizePixel() const
const Size & GetPrefSize() const
HashMap_OWString_Interface aMap
Scanline GetScanline(tools::Long nY) const
sal_uInt8 GetBlue() const
sal_uInt16 mnNewColorCount
const MapMode & GetPrefMapMode() const
void SetPrefMapMode(const MapMode &rMapMode)
vcl::PixelFormat getPixelFormat() const
virtual BitmapEx execute(BitmapEx const &rBitmapEx) const override
tools::Long Width() const
sal_uInt16 GetBestIndex(const BitmapColor &rCol) const
void SetIndex(sal_uInt8 cIndex)
Bitmap GetBitmap(Color aTransparentReplaceColor) const
sal_uInt8 GetGreen() const
BitmapColor GetPixelFromData(const sal_uInt8 *pData, tools::Long nX) const
const BitmapColor & GetPaletteColor(sal_uInt16 nColor) const
constexpr sal_Int64 numberOfColors(PixelFormat ePixelFormat)