Kaydet (Commit) 91f2b2b8 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Multiple calls of BitmapColorQuantizationFilter::execute

...should probably be independent of each other

Change-Id: I22fb860a5a197d5f3f0f8706782e25d07511a1d9
Reviewed-on: https://gerrit.libreoffice.org/60153
Tested-by: Jenkins
Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 0593afe5
......@@ -8,6 +8,10 @@
*
*/
#include <sal/config.h>
#include <algorithm>
#include <vcl/bitmap.hxx>
#include <vcl/bitmapex.hxx>
#include <vcl/BitmapColorQuantizationFilter.hxx>
......@@ -32,10 +36,9 @@ BitmapEx BitmapColorQuantizationFilter::execute(BitmapEx const& aBitmapEx)
Bitmap::ScopedReadAccess pRAcc(aBitmap);
sal_uInt16 nBitCount;
if (mnNewColorCount > 256)
mnNewColorCount = 256;
auto const cappedNewColorCount = std::min(mnNewColorCount, sal_uInt16(256));
if (mnNewColorCount < 17)
if (cappedNewColorCount < 17)
nBitCount = 4;
else
nBitCount = 8;
......@@ -104,7 +107,7 @@ BitmapEx BitmapColorQuantizationFilter::execute(BitmapEx const& aBitmapEx)
}
}
BitmapPalette aNewPal(mnNewColorCount);
BitmapPalette aNewPal(cappedNewColorCount);
std::qsort(pCountTable.get(), nTotalColors, sizeof(PopularColorCount),
[](const void* p1, const void* p2) {
......@@ -122,7 +125,7 @@ BitmapEx BitmapColorQuantizationFilter::execute(BitmapEx const& aBitmapEx)
return nRet;
});
for (sal_uInt16 n = 0; n < mnNewColorCount; n++)
for (sal_uInt16 n = 0; n < cappedNewColorCount; n++)
{
const PopularColorCount& rPop = pCountTable[n];
aNewPal[n] = BitmapColor(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment