vcl/inc/bitmap/Octree.hxx    |    2 +-
 vcl/source/bitmap/Octree.cxx |    8 ++++----
 vcl/source/bitmap/bitmap.cxx |    6 +++---
 3 files changed, 8 insertions(+), 8 deletions(-)

New commits:
commit b166bfdef9555c4d021551a91317a8831274ed05
Author:     Rafał Dobrakowski <dobrakowskira...@gmail.com>
AuthorDate: Thu May 29 11:50:09 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Mon Jun 2 15:51:46 2025 +0200

    tdf#114441 sal_uLong to better integer type
    
    Changed the type returned from the ‘InverseColorMap::GetBestPaletteIndex’ 
method.
    The data is stored in ‘sal_uInt8’ format.
    Converted to ‘sal_uInt16’ unnecessarily each time before use.
    
    Change-Id: I107f8d472a4d714e1d0b857f99835a58da8ca72e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185992
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/inc/bitmap/Octree.hxx b/vcl/inc/bitmap/Octree.hxx
index eff1d1b292e4..144ed6b85d12 100644
--- a/vcl/inc/bitmap/Octree.hxx
+++ b/vcl/inc/bitmap/Octree.hxx
@@ -74,7 +74,7 @@ public:
     explicit InverseColorMap(const BitmapPalette& rPal);
     ~InverseColorMap();
 
-    sal_uInt16 GetBestPaletteIndex(const BitmapColor& rColor);
+    sal_uInt8 GetBestPaletteIndex(const BitmapColor& rColor);
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/bitmap/Octree.cxx b/vcl/source/bitmap/Octree.cxx
index 98ad8c9fcf5d..b84f14e41bfa 100644
--- a/vcl/source/bitmap/Octree.cxx
+++ b/vcl/source/bitmap/Octree.cxx
@@ -270,11 +270,11 @@ void InverseColorMap::ImplCreateBuffers()
     mpBuffer.resize(nSize, 0xff);
 }
 
-sal_uInt16 InverseColorMap::GetBestPaletteIndex(const BitmapColor& rColor)
+sal_uInt8 InverseColorMap::GetBestPaletteIndex(const BitmapColor& rColor)
 {
-    return mpMap[((static_cast<sal_uLong>(rColor.GetRed()) >> gnBits) << 
OCTREE_BITS_1)
-                 | ((static_cast<sal_uLong>(rColor.GetGreen()) >> gnBits) << 
OCTREE_BITS)
-                 | (static_cast<sal_uLong>(rColor.GetBlue()) >> gnBits)];
+    return mpMap[((static_cast<sal_uInt32>(rColor.GetRed()) >> gnBits) << 
OCTREE_BITS_1)
+                 | ((static_cast<sal_uInt32>(rColor.GetGreen()) >> gnBits) << 
OCTREE_BITS)
+                 | (static_cast<sal_uInt32>(rColor.GetBlue()) >> gnBits)];
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/bitmap/bitmap.cxx b/vcl/source/bitmap/bitmap.cxx
index cca49e45b3ea..28b2181201a1 100644
--- a/vcl/source/bitmap/bitmap.cxx
+++ b/vcl/source/bitmap/bitmap.cxx
@@ -1270,7 +1270,7 @@ bool Bitmap::ImplConvertDown8BPP(Color const * pExtColor)
     for (tools::Long nY = 0; nY < nHeight; nY++, nYTmp++)
     {
         // first pixel in the line
-        cIndex = 
static_cast<sal_uInt8>(aColorMap.GetBestPaletteIndex(pQLine1[0].ImplGetColor()));
+        cIndex = aColorMap.GetBestPaletteIndex(pQLine1[0].ImplGetColor());
         Scanline pScanline = pWriteAcc->GetScanline(nY);
         pWriteAcc->SetPixelOnData(pScanline, 0, BitmapColor(cIndex));
 
@@ -1278,7 +1278,7 @@ bool Bitmap::ImplConvertDown8BPP(Color const * pExtColor)
         for (nX = 1; nX < nWidth1; nX++)
         {
             aColor = pQLine1[nX].ImplGetColor();
-            cIndex = 
static_cast<sal_uInt8>(aColorMap.GetBestPaletteIndex(aColor));
+            cIndex = aColorMap.GetBestPaletteIndex(aColor);
             aErrQuad = (ImpErrorQuad(aColor) -= 
pWriteAcc->GetPaletteColor(cIndex));
             pQLine1[++nX].ImplAddColorError7(aErrQuad);
             pQLine2[nX--].ImplAddColorError1(aErrQuad);
@@ -1290,7 +1290,7 @@ bool Bitmap::ImplConvertDown8BPP(Color const * pExtColor)
         // Last RowPixel
         if (nX < nWidth)
         {
-            cIndex = 
static_cast<sal_uInt8>(aColorMap.GetBestPaletteIndex(pQLine1[nWidth1].ImplGetColor()));
+            cIndex = 
aColorMap.GetBestPaletteIndex(pQLine1[nWidth1].ImplGetColor());
             pWriteAcc->SetPixelOnData(pScanline, nX, BitmapColor(cIndex));
         }
 

Reply via email to