[Libreoffice-commits] core.git: vcl/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Sep 7 18:07:43 UTC 2018
vcl/source/bitmap/BitmapColorQuantizationFilter.cxx | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
New commits:
commit 91f2b2b88731bd083c6a5218ae4eb35126e4b872
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Fri Sep 7 15:25:33 2018 +0200
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Fri Sep 7 20:07:17 2018 +0200
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 at redhat.com>
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(
More information about the Libreoffice-commits
mailing list