37 auto const cappedNewColorCount = std::min(
mnNewColorCount, sal_uInt16(256));
39 if (cappedNewColorCount < 17)
46 const sal_uInt32 nValidBits = 4;
47 const sal_uInt32 nRightShiftBits = 8 - nValidBits;
48 const sal_uInt32 nLeftShiftBits1 = nValidBits;
49 const sal_uInt32 nLeftShiftBits2 = nValidBits << 1;
50 const sal_uInt32 nColorsPerComponent = 1 << nValidBits;
51 const sal_uInt32 nColorOffset = 256 / nColorsPerComponent;
52 const sal_uInt32 nTotalColors
53 = nColorsPerComponent * nColorsPerComponent * nColorsPerComponent;
56 std::unique_ptr<PopularColorCount[]> pCountTable(
new PopularColorCount[nTotalColors]);
62 for (
tools::Long nG = 0; nG < 256; nG += nColorOffset)
64 for (
tools::Long nB = 0; nB < 256; nB += nColorOffset)
81 pCountTable[((
static_cast<sal_uInt32
>(rCol.
GetRed()) >> nRightShiftBits)
83 | ((static_cast<sal_uInt32>(rCol.
GetGreen()) >> nRightShiftBits)
85 | (static_cast<sal_uInt32>(rCol.
GetBlue()) >> nRightShiftBits)]
98 pCountTable[((
static_cast<sal_uInt32
>(aCol.GetRed()) >> nRightShiftBits)
100 | ((static_cast<sal_uInt32>(aCol.GetGreen()) >> nRightShiftBits)
102 | (static_cast<sal_uInt32>(aCol.GetBlue()) >> nRightShiftBits)]
111 [](
const void* p1,
const void* p2) {
114 if (static_cast<PopularColorCount const*>(p1)->mnCount
117 else if (static_cast<PopularColorCount const*>(p1)->mnCount
126 for (sal_uInt16
n = 0;
n < cappedNewColorCount;
n++)
130 static_cast<sal_uInt8>((rPop.
mnIndex >> nLeftShiftBits2) << nRightShiftBits),
131 static_cast<sal_uInt8>(
132 ((rPop.
mnIndex >> nLeftShiftBits1) & (nColorsPerComponent - 1))
134 static_cast<sal_uInt8>((rPop.
mnIndex & (nColorsPerComponent - 1))
135 << nRightShiftBits));
144 std::unique_ptr<sal_uInt8[]> pIndexMap(
new sal_uInt8[nTotalColors]);
148 for (
tools::Long nG = 0; nG < 256; nG += nColorOffset)
150 for (
tools::Long nB = 0; nB < 256; nB += nColorOffset)
153 BitmapColor(static_cast<sal_uInt8>(nR), static_cast<sal_uInt8>(nG),
154 static_cast<sal_uInt8>(nB))));
163 Scanline pScanline = pWAcc->GetScanline(nY);
169 aDstCol.
SetIndex(pIndexMap[((static_cast<sal_uInt32>(rCol.
GetRed())
172 | ((static_cast<sal_uInt32>(rCol.
GetGreen())
175 | (static_cast<sal_uInt32>(rCol.
GetBlue())
176 >> nRightShiftBits)]);
177 pWAcc->SetPixelOnData(pScanline, nX, aDstCol);
185 Scanline pScanline = pWAcc->GetScanline(nY);
191 aDstCol.
SetIndex(pIndexMap[((static_cast<sal_uInt32>(aCol.GetRed())
194 | ((static_cast<sal_uInt32>(aCol.GetGreen())
197 | (static_cast<sal_uInt32>(aCol.GetBlue())
198 >> nRightShiftBits)]);
199 pWAcc->SetPixelOnData(pScanline, nX, aDstCol);
219 aBitmap.SetPrefSize(aSize);
sal_uInt8 GetIndexFromData(const sal_uInt8 *pData, tools::Long nX) const
tools::Long Height() const
sal_Int64 GetColorCount() 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)
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