vcl/inc/bitmap/ScanlineTools.hxx     |   56 -----------------------------------
 vcl/qa/cppunit/ScanlineToolsTest.cxx |   42 --------------------------
 2 files changed, 98 deletions(-)

New commits:
commit bbfe52997225a2fb387c94462c867d670954b9b4
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Wed Mar 13 14:51:47 2024 +0900
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Fri Mar 22 07:37:52 2024 +0100

    vcl: remove 4-bit scanline transformer
    
    We don't use 4-bit bitmap anymore and haven't for a long time.
    
    Change-Id: I00b55a82df4609fbddd50b35f67e338e06f02c4c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164754
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <[email protected]>

diff --git a/vcl/inc/bitmap/ScanlineTools.hxx b/vcl/inc/bitmap/ScanlineTools.hxx
index 99ce5dc33aae..1b7db0eadffc 100644
--- a/vcl/inc/bitmap/ScanlineTools.hxx
+++ b/vcl/inc/bitmap/ScanlineTools.hxx
@@ -110,60 +110,6 @@ public:
     }
 };
 
-class ScanlineTransformer_4BitPalette final : public ScanlineTransformer
-{
-private:
-    sal_uInt8* pData;
-    const BitmapPalette& mrPalette;
-    sal_uInt32 mnX;
-    sal_uInt32 mnShift;
-
-public:
-    explicit ScanlineTransformer_4BitPalette(const BitmapPalette& rPalette)
-        : pData(nullptr)
-        , mrPalette(rPalette)
-        , mnX(0)
-        , mnShift(0)
-    {
-    }
-
-    virtual void skipPixel(sal_uInt32 nPixel) override
-    {
-        mnX += nPixel;
-        if (nPixel & 1) // is nPixel an odd number
-            mnShift ^= 4;
-    }
-
-    virtual void startLine(sal_uInt8* pLine) override
-    {
-        pData = pLine;
-        mnX = 0;
-        mnShift = 4;
-    }
-
-    virtual Color readPixel() override
-    {
-        const sal_uInt32 nDataIndex = mnX / 2;
-        const sal_uInt8 nIndex((pData[nDataIndex] >> mnShift) & 0x0f);
-        mnX++;
-        mnShift ^= 4;
-
-        if (nIndex < mrPalette.GetEntryCount())
-            return mrPalette[nIndex];
-        else
-            return COL_BLACK;
-    }
-
-    virtual void writePixel(Color nColor) override
-    {
-        const sal_uInt32 nDataIndex = mnX / 2;
-        const sal_uInt8 nColorIndex = mrPalette.GetBestIndex(nColor);
-        pData[nDataIndex] |= (nColorIndex & 0x0f) << mnShift;
-        mnX++;
-        mnShift ^= 4;
-    }
-};
-
 class ScanlineTransformer_1BitPalette final : public ScanlineTransformer
 {
 private:
@@ -215,8 +161,6 @@ std::unique_ptr<ScanlineTransformer> 
getScanlineTransformer(sal_uInt16 nBits,
     {
         case 1:
             return std::make_unique<ScanlineTransformer_1BitPalette>(rPalette);
-        case 4:
-            return std::make_unique<ScanlineTransformer_4BitPalette>(rPalette);
         case 8:
             return std::make_unique<ScanlineTransformer_8BitPalette>(rPalette);
         case 24:
diff --git a/vcl/qa/cppunit/ScanlineToolsTest.cxx 
b/vcl/qa/cppunit/ScanlineToolsTest.cxx
index 97233f2692af..afb44a54f005 100644
--- a/vcl/qa/cppunit/ScanlineToolsTest.cxx
+++ b/vcl/qa/cppunit/ScanlineToolsTest.cxx
@@ -20,14 +20,12 @@ class ScanlineToolsTest : public CppUnit::TestFixture
     void ScanlineTransformer_32_ARGB();
     void ScanlineTransformer_24_BGR();
     void ScanlineTransformer_8bit_Palette();
-    void ScanlineTransformer_4bit_Palette();
     void ScanlineTransformer_1bit_Palette();
 
     CPPUNIT_TEST_SUITE(ScanlineToolsTest);
     CPPUNIT_TEST(ScanlineTransformer_32_ARGB);
     CPPUNIT_TEST(ScanlineTransformer_24_BGR);
     CPPUNIT_TEST(ScanlineTransformer_8bit_Palette);
-    CPPUNIT_TEST(ScanlineTransformer_4bit_Palette);
     CPPUNIT_TEST(ScanlineTransformer_1bit_Palette);
     CPPUNIT_TEST_SUITE_END();
 };
@@ -129,46 +127,6 @@ void ScanlineToolsTest::ScanlineTransformer_8bit_Palette()
     }
 }
 
-void ScanlineToolsTest::ScanlineTransformer_4bit_Palette()
-{
-    std::vector<Color> aColors{
-        Color(10, 250, 120), Color(30, 230, 110), Color(50, 210, 100),
-        Color(70, 190, 90),  Color(90, 170, 80),  Color(110, 150, 70),
-    };
-
-    BitmapPalette aPalette(16);
-    for (size_t i = 0; i < aColors.size(); ++i)
-    {
-        aPalette[i] = aColors[i];
-    }
-
-    std::unique_ptr<vcl::bitmap::ScanlineTransformer> pScanlineTransformer
-        = vcl::bitmap::getScanlineTransformer(4, aPalette);
-
-    std::vector<sal_uInt8> aScanLine(3, 0); // 6 * 0.5 BytesPerPixel
-    pScanlineTransformer->startLine(aScanLine.data());
-
-    for (Color const& aColor : aColors)
-    {
-        pScanlineTransformer->writePixel(aColor);
-    }
-
-    std::vector<sal_uInt8> aExpectedBytes{ 0x01, 0x23, 0x45 };
-
-    for (size_t i = 0; i < aScanLine.size(); ++i)
-    {
-        CPPUNIT_ASSERT_EQUAL(int(aExpectedBytes[i]), int(aScanLine[i]));
-    }
-
-    pScanlineTransformer->startLine(aScanLine.data());
-
-    for (Color const& rColor : aColors)
-    {
-        Color aColor = pScanlineTransformer->readPixel();
-        CPPUNIT_ASSERT_EQUAL(rColor, aColor);
-    }
-}
-
 void ScanlineToolsTest::ScanlineTransformer_1bit_Palette()
 {
     std::vector<Color> aColors{

Reply via email to