vcl: move variables closer to first use in BitmapColorQuantizationFilter

Change-Id: I8a539718ef0eedfea9fadb2bd5ec321bcb8f108e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173703
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
Chris Sherlock
2024-09-20 18:49:00 +10:00
committed by Michael Weghorn
parent b7aadb5298
commit 10d8402957

View File

@@ -27,17 +27,11 @@ BitmapEx BitmapColorQuantizationFilter::execute(BitmapEx const& aBitmapEx) const
if (!pRAcc)
return BitmapEx();
auto const cappedNewColorCount = std::min(mnNewColorCount, sal_uInt16(256));
const sal_uInt32 nValidBits = 4;
const sal_uInt32 nRightShiftBits = 8 - nValidBits;
const sal_uInt32 nLeftShiftBits1 = nValidBits;
const sal_uInt32 nLeftShiftBits2 = nValidBits << 1;
const sal_uInt32 nColorsPerComponent = 1 << nValidBits;
const sal_uInt32 nColorOffset = 256 / nColorsPerComponent;
const sal_uInt32 nTotalColors = nColorsPerComponent * nColorsPerComponent * nColorsPerComponent;
const sal_Int32 nWidth = pRAcc->Width();
const sal_Int32 nHeight = pRAcc->Height();
std::unique_ptr<PopularColorCount[]> pCountTable(new PopularColorCount[nTotalColors]);
memset(pCountTable.get(), 0, nTotalColors * sizeof(PopularColorCount));
@@ -54,6 +48,13 @@ BitmapEx BitmapColorQuantizationFilter::execute(BitmapEx const& aBitmapEx) const
}
}
const sal_uInt32 nRightShiftBits = 8 - nValidBits;
const sal_uInt32 nLeftShiftBits1 = nValidBits;
const sal_uInt32 nLeftShiftBits2 = nValidBits << 1;
const sal_Int32 nWidth = pRAcc->Width();
const sal_Int32 nHeight = pRAcc->Height();
if (pRAcc->HasPalette())
{
for (sal_Int32 nY = 0; nY < nHeight; nY++)
@@ -90,6 +91,8 @@ BitmapEx BitmapColorQuantizationFilter::execute(BitmapEx const& aBitmapEx) const
}
}
auto const cappedNewColorCount = std::min(mnNewColorCount, sal_uInt16(256));
BitmapPalette aNewPal(cappedNewColorCount);
std::qsort(pCountTable.get(), nTotalColors, sizeof(PopularColorCount),