[Libreoffice-commits] core.git: vcl/qa vcl/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Fri Mar 26 07:30:28 UTC 2021


 vcl/qa/cppunit/BmpFilterTest.cxx |    2 -
 vcl/qa/cppunit/svm/svmtest.cxx   |    2 -
 vcl/source/bitmap/dibtools.cxx   |   40 +++------------------------------------
 3 files changed, 6 insertions(+), 38 deletions(-)

New commits:
commit 54c0e87c6ad4df012dbf338458ef156a8c846226
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Thu Mar 25 22:30:44 2021 +0900
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Fri Mar 26 08:29:10 2021 +0100

    vcl: remove writing and reading 4-bit bitmaps for BMP format
    
    This removes writing 4-bit palette bitmaps when writing to the
    BMP format and reading from a 4-bit BMP uses 8-bit palette
    instead.
    This also changes the tests with the new expectations, but at
    the same time it makes sure old BMP files and SVM files are still
    compatible.
    
    Change-Id: Ia5611a1f36ffa0a27ef5973296674f743fe80f65
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113137
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/vcl/qa/cppunit/BmpFilterTest.cxx b/vcl/qa/cppunit/BmpFilterTest.cxx
index 5cc2abac3d54..20be739d0e98 100644
--- a/vcl/qa/cppunit/BmpFilterTest.cxx
+++ b/vcl/qa/cppunit/BmpFilterTest.cxx
@@ -116,7 +116,7 @@ CPPUNIT_TEST_FIXTURE(BmpFilterTest, testBMP_Index_4BPP)
     auto aBitmap = aGraphic.GetBitmapEx();
     CPPUNIT_ASSERT_EQUAL(tools::Long(4), aBitmap.GetSizePixel().Width());
     CPPUNIT_ASSERT_EQUAL(tools::Long(4), aBitmap.GetSizePixel().Height());
-    CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N4_BPP, aBitmap.getPixelFormat());
+    CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N8_BPP, aBitmap.getPixelFormat());
 
     CPPUNIT_ASSERT_EQUAL(COL_LIGHTBLUE, aBitmap.GetPixelColor(0, 0));
     CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, aBitmap.GetPixelColor(2, 0));
diff --git a/vcl/qa/cppunit/svm/svmtest.cxx b/vcl/qa/cppunit/svm/svmtest.cxx
index beb70c614791..29254fe9c323 100644
--- a/vcl/qa/cppunit/svm/svmtest.cxx
+++ b/vcl/qa/cppunit/svm/svmtest.cxx
@@ -985,7 +985,7 @@ void SvmTest::checkBitmapExs(const GDIMetaFile& rMetaFile)
         "5e01ddcc",
         "4df0e464",
         "4322ee3a",
-        "794c92a9",
+        "3c80d829", // 4-bit color bitmap - same as 8-bit color bitmap
         "3c80d829",
         "71efc447",
     });
diff --git a/vcl/source/bitmap/dibtools.cxx b/vcl/source/bitmap/dibtools.cxx
index c8d15815bd59..31277fd6a031 100644
--- a/vcl/source/bitmap/dibtools.cxx
+++ b/vcl/source/bitmap/dibtools.cxx
@@ -139,7 +139,6 @@ struct DIBV5Header : public DIBInfoHeader
 vcl::PixelFormat convertToBPP(sal_uInt16 nCount)
 {
     return (nCount <= 1) ? vcl::PixelFormat::N1_BPP :
-           (nCount <= 4) ? vcl::PixelFormat::N4_BPP :
            (nCount <= 8) ? vcl::PixelFormat::N8_BPP :
                            vcl::PixelFormat::N24_BPP;
 }
@@ -1283,7 +1282,7 @@ bool ImplWriteDIBBits(SvStream& rOStm, BitmapReadAccess const & rAcc, BitmapRead
         // formats != *_TC_*). Note that this very problem might cause
         // trouble at other places - the introduction of 32 bit RGBA
         // bitmaps is relatively recent.
-        // #i59239# discretize bitcount for aligned width to 1,4,8,24
+        // #i59239# discretize bitcount for aligned width to 1,8,24
         // (other cases are not written below)
         const auto ePixelFormat(pAccAlpha ? vcl::PixelFormat::N32_BPP : convertToBPP(rAcc.GetBitCount()));
         const sal_uLong nAlignedWidth(AlignedWidth4Bytes(rAcc.Width() * sal_Int32(ePixelFormat)));
@@ -1353,35 +1352,6 @@ bool ImplWriteDIBBits(SvStream& rOStm, BitmapReadAccess const & rAcc, BitmapRead
                 }
                 break;
 
-                case vcl::PixelFormat::N4_BPP:
-                {
-                    //valgrind, zero out the trailing unused alignment bytes
-                    size_t nUnusedBytes = nAlignedWidth - ((nWidth+1) / 2);
-                    memset(aBuf.data() + nAlignedWidth - nUnusedBytes, 0, nUnusedBytes);
-
-                    for( tools::Long nY = nHeight - 1; nY >= 0; nY-- )
-                    {
-                        sal_uInt8* pTmp = aBuf.data();
-                        sal_uInt8 cTmp = 0;
-                        Scanline pScanline = rAcc.GetScanline( nY );
-
-                        for( tools::Long nX = 0, nShift = 2; nX < nWidth; nX++ )
-                        {
-                            if( !nShift )
-                            {
-                                nShift = 2;
-                                *pTmp++ = cTmp;
-                                cTmp = 0;
-                            }
-
-                            cTmp |= rAcc.GetIndexFromData( pScanline, nX ) << ( --nShift << 2 );
-                        }
-                        *pTmp = cTmp;
-                        rOStm.WriteBytes(aBuf.data(), nAlignedWidth);
-                    }
-                }
-                break;
-
                 case vcl::PixelFormat::N8_BPP:
                 {
                     for( tools::Long nY = nHeight - 1; nY >= 0; nY-- )
@@ -1473,17 +1443,15 @@ bool ImplWriteDIBBody(const Bitmap& rBitmap, SvStream& rOStm, BitmapReadAccess c
         // problem might cause trouble at other places - the
         // introduction of 32 bit RGBA bitmaps is relatively
         // recent.
-        // #i59239# discretize bitcount to 1,4,8,24 (other cases
+        // #i59239# discretize bitcount to 1,8,24 (other cases
         // are not written below)
         const auto ePixelFormat(pAccAlpha ? vcl::PixelFormat::N32_BPP : convertToBPP(rAcc.GetBitCount()));
         aHeader.nBitCount = sal_uInt16(ePixelFormat);
         aHeader.nSizeImage = rAcc.Height() * AlignedWidth4Bytes(rAcc.Width() * aHeader.nBitCount);
 
-        if(bCompressed)
+        if (bCompressed)
         {
-            if (ePixelFormat == vcl::PixelFormat::N4_BPP)
-                nCompression = RLE_4;
-            else if (ePixelFormat == vcl::PixelFormat::N8_BPP)
+            if (ePixelFormat == vcl::PixelFormat::N8_BPP)
                 nCompression = RLE_8;
         }
     }


More information about the Libreoffice-commits mailing list