diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2018-09-07 15:25:33 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2018-09-07 20:07:17 +0200 |
commit | 91f2b2b88731bd083c6a5218ae4eb35126e4b872 (patch) | |
tree | cb9735e280739a8541df2524cb198254e19ea510 /vcl/source | |
parent | 0593afe5606b6388a705f3e8b19e427fcbf7555b (diff) |
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: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/bitmap/BitmapColorQuantizationFilter.cxx | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/vcl/source/bitmap/BitmapColorQuantizationFilter.cxx b/vcl/source/bitmap/BitmapColorQuantizationFilter.cxx index 13e88341c0d9..643354515f06 100644 --- a/vcl/source/bitmap/BitmapColorQuantizationFilter.cxx +++ b/vcl/source/bitmap/BitmapColorQuantizationFilter.cxx @@ -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( |