summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2022-09-19 20:57:19 +0200
committerJulien Nabet <serval2412@yahoo.fr>2022-09-20 08:18:21 +0200
commit5a6914af4678a24c794055ba23dd9cf0857f0254 (patch)
tree48d2a77f0968f2f282381c1b8f69954af9f86c92 /vcl
parent39addcb4de4c3033adfd4155de2a79c7633aaf9a (diff)
Simplify a bit by using sal_uInt16 in vcl/BitmapPopArtFilter
Since we're in the "if (bRet)" block, it means 22 bool bRet = isPalettePixelFormat(aBitmap.getPixelFormat()) 23 || aBitmap.Convert(BmpConversion::N8BitColors); is verified. isPalettePixelFormat implementation is: 29 constexpr bool isPalettePixelFormat(PixelFormat ePixelFormat) 30 { 31 assert(ePixelFormat != PixelFormat::INVALID); 32 return sal_uInt16(ePixelFormat) <= 8; 33 } So we know we're using 8 bits max and this line: pWriteAcc->GetBitCount() can't give more than 8 and we can safely declare nEntryCount as sal_uInt16 (idem for "n" just below) Since "nFirstEntry" and "nLastEntry" are related to "nEntryCount", idem for mnIndex they can also be sal_uInt16. Thanks to these, we can avoid all sal::static_int_cast<sal_uInt16> conversions. Change-Id: I8cac2d01f00be33c86058c7a6eb7b9e25fb2635e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140206 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/bitmap/BitmapPopArtFilter.cxx21
1 files changed, 9 insertions, 12 deletions
diff --git a/vcl/source/bitmap/BitmapPopArtFilter.cxx b/vcl/source/bitmap/BitmapPopArtFilter.cxx
index ce37c91fdd58..39856cf8b6eb 100644
--- a/vcl/source/bitmap/BitmapPopArtFilter.cxx
+++ b/vcl/source/bitmap/BitmapPopArtFilter.cxx
@@ -32,14 +32,14 @@ BitmapEx BitmapPopArtFilter::execute(BitmapEx const& rBitmapEx) const
{
const sal_Int32 nWidth = pWriteAcc->Width();
const sal_Int32 nHeight = pWriteAcc->Height();
- const int nEntryCount = 1 << pWriteAcc->GetBitCount();
- int n = 0;
+ const sal_uInt16 nEntryCount = 1 << pWriteAcc->GetBitCount();
+ sal_uInt16 n = 0;
std::vector<PopArtEntry> aPopArtTable(nEntryCount);
for (n = 0; n < nEntryCount; n++)
{
PopArtEntry& rEntry = aPopArtTable[n];
- rEntry.mnIndex = static_cast<sal_uInt16>(n);
+ rEntry.mnIndex = n;
rEntry.mnCount = 0;
}
@@ -60,8 +60,8 @@ BitmapEx BitmapPopArtFilter::execute(BitmapEx const& rBitmapEx) const
});
// get last used entry
- sal_uLong nFirstEntry;
- sal_uLong nLastEntry = 0;
+ sal_uInt16 nFirstEntry;
+ sal_uInt16 nLastEntry = 0;
for (n = 0; n < nEntryCount; n++)
{
@@ -70,19 +70,16 @@ BitmapEx BitmapPopArtFilter::execute(BitmapEx const& rBitmapEx) const
}
// rotate palette (one entry)
- const BitmapColor aFirstCol(pWriteAcc->GetPaletteColor(
- sal::static_int_cast<sal_uInt16>(aPopArtTable[0].mnIndex)));
+ const BitmapColor aFirstCol(pWriteAcc->GetPaletteColor(aPopArtTable[0].mnIndex));
for (nFirstEntry = 0; nFirstEntry < nLastEntry; nFirstEntry++)
{
pWriteAcc->SetPaletteColor(
- sal::static_int_cast<sal_uInt16>(aPopArtTable[nFirstEntry].mnIndex),
- pWriteAcc->GetPaletteColor(
- sal::static_int_cast<sal_uInt16>(aPopArtTable[nFirstEntry + 1].mnIndex)));
+ aPopArtTable[nFirstEntry].mnIndex,
+ pWriteAcc->GetPaletteColor(aPopArtTable[nFirstEntry + 1].mnIndex));
}
- pWriteAcc->SetPaletteColor(
- sal::static_int_cast<sal_uInt16>(aPopArtTable[nLastEntry].mnIndex), aFirstCol);
+ pWriteAcc->SetPaletteColor(aPopArtTable[nLastEntry].mnIndex, aFirstCol);
// cleanup
pWriteAcc.reset();