[Libreoffice-commits] core.git: canvas/source cui/source drawinglayer/source filter/source include/vcl sc/source vcl/qa vcl/source vcl/unx

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 2 04:29:20 UTC 2021


 canvas/source/directx/dx_vcltools.cxx                     |    2 
 canvas/source/vcl/spritehelper.cxx                        |    4 
 cui/source/dialogs/cuigrfflt.cxx                          |    2 
 drawinglayer/source/processor2d/vclprocessor2d.cxx        |    2 
 filter/source/msfilter/msdffimp.cxx                       |    4 
 include/vcl/bitmap.hxx                                    |   14 --
 include/vcl/bitmap/BitmapTypes.hxx                        |   10 +
 include/vcl/bitmapex.hxx                                  |    5 
 sc/source/filter/excel/xeescher.cxx                       |    2 
 vcl/qa/cppunit/BitmapFilterTest.cxx                       |    4 
 vcl/qa/cppunit/BitmapScaleTest.cxx                        |    4 
 vcl/qa/cppunit/BitmapTest.cxx                             |   31 ++---
 vcl/qa/cppunit/XpmFilterTest.cxx                          |    6 -
 vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx          |    6 -
 vcl/qa/cppunit/canvasbitmaptest.cxx                       |    8 -
 vcl/qa/cppunit/pdfexport/pdfexport.cxx                    |    6 -
 vcl/qa/cppunit/skia/skia.cxx                              |   14 +-
 vcl/source/bitmap/BitmapColorQuantizationFilter.cxx       |    2 
 vcl/source/bitmap/BitmapEx.cxx                            |    9 -
 vcl/source/bitmap/BitmapInfoAccess.cxx                    |    2 
 vcl/source/bitmap/BitmapMosaicFilter.cxx                  |    2 
 vcl/source/bitmap/BitmapPopArtFilter.cxx                  |    3 
 vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx |    2 
 vcl/source/bitmap/BitmapTools.cxx                         |    4 
 vcl/source/bitmap/alpha.cxx                               |    2 
 vcl/source/bitmap/bitmap.cxx                              |   78 +++++---------
 vcl/source/bitmap/bitmappaint.cxx                         |    6 -
 vcl/source/bitmap/dibtools.cxx                            |    2 
 vcl/source/filter/etiff/etiff.cxx                         |    2 
 vcl/source/filter/png/pngwrite.cxx                        |    4 
 vcl/source/gdi/mtfxmldump.cxx                             |   15 ++
 vcl/source/gdi/pdfextoutdevdata.cxx                       |    4 
 vcl/source/gdi/pdfwriter_impl.cxx                         |   53 +++++----
 vcl/source/gdi/pdfwriter_impl2.cxx                        |    6 -
 vcl/source/gdi/print.cxx                                  |    4 
 vcl/source/graphic/UnoGraphicDescriptor.cxx               |    5 
 vcl/source/outdev/bitmap.cxx                              |    2 
 vcl/source/outdev/transparent.cxx                         |    2 
 vcl/unx/generic/dtrans/bmp.cxx                            |    4 
 39 files changed, 165 insertions(+), 172 deletions(-)

New commits:
commit 88a177f827eba204dea92b631032411de8213ee4
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sat Mar 27 10:14:13 2021 +0900
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Fri Apr 2 06:28:39 2021 +0200

    vcl: remove GetBitCount and GetColorCount from Bitmap{Ex}
    
    We can cast the PixelFormat enum to int for the same information
    and we can use the enum to reduce ambiguity when possible.
    
    Change-Id: I6ea648139465568cdeb12e5f5f75c7b609365bf4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113188
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/canvas/source/directx/dx_vcltools.cxx b/canvas/source/directx/dx_vcltools.cxx
index 707d358e5869..d29043070ef3 100644
--- a/canvas/source/directx/dx_vcltools.cxx
+++ b/canvas/source/directx/dx_vcltools.cxx
@@ -166,7 +166,7 @@ namespace dxcanvas::tools
                                   "::dxcanvas::tools::bitmapFromVCLBitmapEx(): "
                                   "Unable to acquire read access to bitmap" );
 
-                if( rBmpEx.IsAlpha() || rBmpEx.GetMask().GetBitCount() == 8 )
+                if (rBmpEx.IsAlpha() || rBmpEx.GetMask().getPixelFormat() == vcl::PixelFormat::N8_BPP)
                 {
                     Bitmap aAlpha( rBmpEx.IsAlpha() ? rBmpEx.GetAlpha().GetBitmap() : rBmpEx.GetMask());
 
diff --git a/canvas/source/vcl/spritehelper.cxx b/canvas/source/vcl/spritehelper.cxx
index e8d4fa726e10..7f7035769db2 100644
--- a/canvas/source/vcl/spritehelper.cxx
+++ b/canvas/source/vcl/spritehelper.cxx
@@ -147,7 +147,7 @@ namespace vclcanvas
 
                 // bitmasks are much faster than alphamasks on some platforms
                 // so convert to bitmask if useful
-                bool convertTo1Bpp = aMask.GetBitCount() != 1;
+                bool convertTo1Bpp = aMask.getPixelFormat() != vcl::PixelFormat::N1_BPP;
 #ifdef MACOSX
                 convertTo1Bpp = false;
 #endif
@@ -166,7 +166,7 @@ namespace vclcanvas
                 // Note: since we retrieved aBmp and aMask
                 // directly from an OutDev, it's already a
                 // 'display bitmap' on windows.
-                if( aMask.GetBitCount() == 1 )
+                if (aMask.getPixelFormat() == vcl::PixelFormat::N1_BPP)
                     maContent = BitmapEx( aBmp.GetBitmap(), aMask.GetBitmap() );
                 else
                     maContent = BitmapEx( aBmp.GetBitmap(), AlphaMask( aMask.GetBitmap()) );
diff --git a/cui/source/dialogs/cuigrfflt.cxx b/cui/source/dialogs/cuigrfflt.cxx
index 2e162b4b3f4a..01a5ad0786ac 100644
--- a/cui/source/dialogs/cuigrfflt.cxx
+++ b/cui/source/dialogs/cuigrfflt.cxx
@@ -361,7 +361,7 @@ GraphicFilterPoster::GraphicFilterPoster(weld::Window* pParent, const Graphic& r
     : GraphicFilterDialog(pParent, "cui/ui/posterdialog.ui", "PosterDialog", rGraphic)
     , mxNumPoster(m_xBuilder->weld_spin_button("value"))
 {
-    mxNumPoster->set_range(2, rGraphic.GetBitmapEx().GetBitCount());
+    mxNumPoster->set_range(2, vcl::pixelFormatBitCount(rGraphic.GetBitmapEx().getPixelFormat()));
     mxNumPoster->set_value(nPosterCount);
     mxNumPoster->connect_value_changed(LINK(this, GraphicFilterPoster, EditModifyHdl));
 }
diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx
index 80c7fbdb6556..5bd7e0194b66 100644
--- a/drawinglayer/source/processor2d/vclprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx
@@ -470,7 +470,7 @@ void VclProcessor2D::RenderFillGraphicPrimitive2D(
                             // if color depth is below 24bit, expand before scaling for better quality.
                             // This is even needed for low colors, else the scale will produce
                             // a bitmap in gray or Black/White (!)
-                            if (aBitmapEx.GetBitCount() < 24)
+                            if (isPalettePixelFormat(aBitmapEx.getPixelFormat()))
                             {
                                 aBitmapEx.Convert(BmpConversion::N24Bit);
                             }
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 5ed426de2ab6..9b81426f27db 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -1395,7 +1395,9 @@ void DffPropertyReader::ApplyFillAttributes( SvStream& rIn, SfxItemSet& rSet, co
                     if ( eMSO_FillType == mso_fillPattern )
                     {
                         Bitmap aBmp( aGraf.GetBitmapEx().GetBitmap() );
-                        if( aBmp.GetSizePixel().Width() == 8 && aBmp.GetSizePixel().Height() == 8 && aBmp.GetColorCount() == 2)
+                        if (aBmp.GetSizePixel().Width() == 8 &&
+                            aBmp.GetSizePixel().Height() == 8 &&
+                            aBmp.getPixelFormat() == vcl::PixelFormat::N1_BPP)
                         {
                             Color aCol1( COL_WHITE ), aCol2( COL_WHITE );
 
diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx
index eaec09ad7037..e24e7255a6e0 100644
--- a/include/vcl/bitmap.hxx
+++ b/include/vcl/bitmap.hxx
@@ -134,8 +134,6 @@ public:
     Size                    GetSizePixel() const;
 
     vcl::PixelFormat getPixelFormat() const;
-    sal_uInt16              GetBitCount() const;
-    inline sal_Int64        GetColorCount() const;
     inline sal_uLong        GetSizeBytes() const;
     bool                    HasGreyPalette8Bit() const;
     bool                    HasGreyPaletteAny() const;
@@ -544,7 +542,6 @@ private:
     std::shared_ptr<SalBitmap> mxSalBmp;
     MapMode maPrefMapMode;
     Size maPrefSize;
-
 };
 
 inline bool Bitmap::IsEmpty() const
@@ -572,15 +569,12 @@ inline void Bitmap::SetPrefSize( const Size& rSize )
     maPrefSize = rSize;
 }
 
-inline sal_Int64 Bitmap::GetColorCount() const
-{
-    return sal_Int64(1) << sal_Int64(GetBitCount());
-}
-
 inline sal_uLong Bitmap::GetSizeBytes() const
 {
-    const Size aSizePix( GetSizePixel() );
-    return( ( static_cast<sal_uLong>(aSizePix.Width()) * aSizePix.Height() * GetBitCount() ) >> 3 );
+    const auto aSizePixel = GetSizePixel();
+    const sal_uInt64 aBitCount = vcl::pixelFormatBitCount(getPixelFormat());
+    sal_uInt64 aSizeInBytes = (aSizePixel.Width() * aSizePixel.Height() * aBitCount) / 8;
+    return sal_uLong(aSizeInBytes);
 }
 
 #endif // INCLUDED_VCL_BITMAP_HXX
diff --git a/include/vcl/bitmap/BitmapTypes.hxx b/include/vcl/bitmap/BitmapTypes.hxx
index 7ebf9fc8dafc..25eda29cbe80 100644
--- a/include/vcl/bitmap/BitmapTypes.hxx
+++ b/include/vcl/bitmap/BitmapTypes.hxx
@@ -29,6 +29,16 @@ constexpr bool isPalettePixelFormat(PixelFormat ePixelFormat)
     return sal_uInt16(ePixelFormat) <= 8;
 }
 
+constexpr sal_uInt16 pixelFormatBitCount(PixelFormat ePixelFormat)
+{
+    return sal_uInt16(ePixelFormat);
+}
+
+constexpr sal_Int64 numberOfColors(PixelFormat ePixelFormat)
+{
+    return sal_Int64(1) << sal_Int64(ePixelFormat);
+}
+
 constexpr PixelFormat bitDepthToPixelFormat(sal_uInt16 nBitDepth)
 {
     switch (nBitDepth)
diff --git a/include/vcl/bitmapex.hxx b/include/vcl/bitmapex.hxx
index 5cc5939f0001..707b9ade9ec2 100644
--- a/include/vcl/bitmapex.hxx
+++ b/include/vcl/bitmapex.hxx
@@ -89,11 +89,6 @@ public:
     const MapMode&      GetPrefMapMode() const { return maBitmap.GetPrefMapMode(); }
     void                SetPrefMapMode( const MapMode& rPrefMapMode ) { maBitmap.SetPrefMapMode( rPrefMapMode ); }
 
-    sal_uInt16          GetBitCount() const
-    {
-        return maBitmap.GetBitCount();
-    }
-
     vcl::PixelFormat getPixelFormat() const
     {
         return maBitmap.getPixelFormat();
diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx
index eea83fbeaf70..7ba8e4268727 100644
--- a/sc/source/filter/excel/xeescher.cxx
+++ b/sc/source/filter/excel/xeescher.cxx
@@ -394,7 +394,7 @@ XclExpImgData::XclExpImgData( const Graphic& rGraphic, sal_uInt16 nRecId ) :
 void XclExpImgData::Save( XclExpStream& rStrm )
 {
     Bitmap aBmp = maGraphic.GetBitmapEx().GetBitmap();
-    if( aBmp.GetBitCount() != 24 )
+    if (aBmp.getPixelFormat() != vcl::PixelFormat::N24_BPP)
         aBmp.Convert( BmpConversion::N24Bit );
 
     Bitmap::ScopedReadAccess pAccess(aBmp);
diff --git a/vcl/qa/cppunit/BitmapFilterTest.cxx b/vcl/qa/cppunit/BitmapFilterTest.cxx
index 4bf651855937..a2aa37ceb900 100644
--- a/vcl/qa/cppunit/BitmapFilterTest.cxx
+++ b/vcl/qa/cppunit/BitmapFilterTest.cxx
@@ -80,7 +80,7 @@ void BitmapFilterTest::testBlurCorrectness()
     Bitmap aBitmap24Bit(aSize, vcl::PixelFormat::N24_BPP);
 
     ScanlineFormat scanlineFormat = ScanlineFormat::NONE;
-    sal_uInt16 nBPP = aBitmap24Bit.GetBitCount();
+    auto ePixelFormat = aBitmap24Bit.getPixelFormat();
 
     {
         tools::Long aMargin1 = 1;
@@ -124,7 +124,7 @@ void BitmapFilterTest::testBlurCorrectness()
     CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(41), aBitmap24Bit.GetSizePixel().Width());
     CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(31), aBitmap24Bit.GetSizePixel().Height());
 
-    CPPUNIT_ASSERT_EQUAL(nBPP, aBitmap24Bit.GetBitCount());
+    CPPUNIT_ASSERT_EQUAL(ePixelFormat, aBitmap24Bit.getPixelFormat());
 
     // Check that the bitmap is horizontally and vertically symmetrical
     CPPUNIT_ASSERT(BitmapSymmetryCheck::check(aBitmap24Bit));
diff --git a/vcl/qa/cppunit/BitmapScaleTest.cxx b/vcl/qa/cppunit/BitmapScaleTest.cxx
index c6da34c6d2c6..0cf65ca798da 100644
--- a/vcl/qa/cppunit/BitmapScaleTest.cxx
+++ b/vcl/qa/cppunit/BitmapScaleTest.cxx
@@ -203,7 +203,7 @@ void BitmapScaleTest::testScale2()
     const bool bExportBitmap(false);
 
     Bitmap aBitmap24Bit(Size(4096, 4096), vcl::PixelFormat::N24_BPP);
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(24), aBitmap24Bit.GetBitCount());
+    CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N24_BPP, aBitmap24Bit.getPixelFormat());
     Color aBitmapColor = COL_YELLOW;
     {
         BitmapScopedWriteAccess aWriteAccess(aBitmap24Bit);
@@ -274,7 +274,7 @@ void BitmapScaleTest::testScaleSymmetry()
     const bool bExportBitmap(false);
 
     Bitmap aBitmap24Bit(Size(10, 10), vcl::PixelFormat::N24_BPP);
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(24), aBitmap24Bit.GetBitCount());
+    CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N24_BPP, aBitmap24Bit.getPixelFormat());
 
     {
         BitmapScopedWriteAccess aWriteAccess(aBitmap24Bit);
diff --git a/vcl/qa/cppunit/BitmapTest.cxx b/vcl/qa/cppunit/BitmapTest.cxx
index 655e76dc21fc..962b06e8e977 100644
--- a/vcl/qa/cppunit/BitmapTest.cxx
+++ b/vcl/qa/cppunit/BitmapTest.cxx
@@ -89,9 +89,8 @@ void BitmapTest::testCreation()
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong height", static_cast<tools::Long>(0), aSize.Height());
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong pref size", Size(), aBmp.GetPrefSize());
         CPPUNIT_ASSERT_MESSAGE("Not empty", aBmp.IsEmpty());
-        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong bit count", static_cast<sal_uInt16>(0),
-                                     aBmp.GetBitCount());
-        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong color count", sal_Int64(1), aBmp.GetColorCount());
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong pixel format", vcl::PixelFormat::INVALID,
+                                     aBmp.getPixelFormat());
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong byte size", static_cast<sal_uLong>(0),
                                      aBmp.GetSizeBytes());
     }
@@ -103,9 +102,8 @@ void BitmapTest::testCreation()
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong height", static_cast<tools::Long>(10), aSize.Height());
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong pref size", Size(), aBmp.GetPrefSize());
         CPPUNIT_ASSERT_MESSAGE("Empty bitmap", !aBmp.IsEmpty());
-        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong bit count", static_cast<sal_uInt16>(1),
-                                     aBmp.GetBitCount());
-        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong color count", sal_Int64(2), aBmp.GetColorCount());
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong pixel format", vcl::PixelFormat::N1_BPP,
+                                     aBmp.getPixelFormat());
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong byte size", static_cast<sal_uLong>(12),
                                      aBmp.GetSizeBytes());
     }
@@ -117,9 +115,8 @@ void BitmapTest::testCreation()
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong height", static_cast<tools::Long>(10), aSize.Height());
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong pref size", Size(), aBmp.GetPrefSize());
         CPPUNIT_ASSERT_MESSAGE("Empty bitmap", !aBmp.IsEmpty());
-        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong bit count", static_cast<sal_uInt16>(8),
-                                     aBmp.GetBitCount());
-        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong color count", sal_Int64(256), aBmp.GetColorCount());
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong pixel format", vcl::PixelFormat::N8_BPP,
+                                     aBmp.getPixelFormat());
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong byte size", static_cast<sal_uLong>(100),
                                      aBmp.GetSizeBytes());
     }
@@ -131,10 +128,8 @@ void BitmapTest::testCreation()
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong height", static_cast<tools::Long>(10), aSize.Height());
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong pref size", Size(), aBmp.GetPrefSize());
         CPPUNIT_ASSERT_MESSAGE("Empty bitmap", !aBmp.IsEmpty());
-        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong bit count", static_cast<sal_uInt16>(24),
-                                     aBmp.GetBitCount());
-        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong color count", sal_Int64(16777216),
-                                     aBmp.GetColorCount());
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong pixel format", vcl::PixelFormat::N24_BPP,
+                                     aBmp.getPixelFormat());
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong byte size", static_cast<sal_uLong>(300),
                                      aBmp.GetSizeBytes());
     }
@@ -150,10 +145,8 @@ void BitmapTest::testCreation()
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong height", static_cast<tools::Long>(10), aSize.Height());
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong pref size", Size(), aBmp.GetPrefSize());
         CPPUNIT_ASSERT_MESSAGE("Empty bitmap", !aBmp.IsEmpty());
-
-        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong bit count", sal_uInt16(32), aBmp.GetBitCount());
-        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong color count", sal_Int64(4294967296ull),
-                                     aBmp.GetColorCount());
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong pixel format", vcl::PixelFormat::N32_BPP,
+                                     aBmp.getPixelFormat());
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong byte size", sal_uLong(400), aBmp.GetSizeBytes());
     }
 }
@@ -292,7 +285,7 @@ void BitmapTest::testConvert()
 
     aBitmap.Erase(COL_LIGHTGRAYBLUE);
 
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(8), aBitmap.GetBitCount());
+    CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N8_BPP, aBitmap.getPixelFormat());
     {
         Bitmap::ScopedReadAccess pReadAccess(aBitmap);
         CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(8), pReadAccess->GetBitCount());
@@ -312,7 +305,7 @@ void BitmapTest::testConvert()
 
     aBitmap.Convert(BmpConversion::N24Bit);
 
-    CPPUNIT_ASSERT_EQUAL(sal_uInt16(24), aBitmap.GetBitCount());
+    CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N24_BPP, aBitmap.getPixelFormat());
     {
         Bitmap::ScopedReadAccess pReadAccess(aBitmap);
         // 24 bit Bitmap on SVP backend can now use 24bit RGB everywhere.
diff --git a/vcl/qa/cppunit/XpmFilterTest.cxx b/vcl/qa/cppunit/XpmFilterTest.cxx
index 20a272b7a6ce..1c24de1e131e 100644
--- a/vcl/qa/cppunit/XpmFilterTest.cxx
+++ b/vcl/qa/cppunit/XpmFilterTest.cxx
@@ -36,7 +36,7 @@ CPPUNIT_TEST_FIXTURE(XpmFilterTest, testXPM_8bit)
     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(sal_uInt16(8), aBitmap.GetBitCount());
+    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));
     CPPUNIT_ASSERT_EQUAL(COL_YELLOW, aBitmap.GetPixelColor(0, 2));
@@ -51,7 +51,7 @@ CPPUNIT_TEST_FIXTURE(XpmFilterTest, testXPM_4bit)
     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(sal_uInt16(8), aBitmap.GetBitCount());
+    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));
     CPPUNIT_ASSERT_EQUAL(COL_YELLOW, aBitmap.GetPixelColor(0, 2));
@@ -66,7 +66,7 @@ CPPUNIT_TEST_FIXTURE(XpmFilterTest, testXPM_1bit)
     auto aBitmap = aGraphic.GetBitmapEx();
     CPPUNIT_ASSERT_EQUAL(tools::Long(10), aBitmap.GetSizePixel().Width());
     CPPUNIT_ASSERT_EQUAL(tools::Long(10), aBitmap.GetSizePixel().Height());
-    CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), aBitmap.GetBitCount());
+    CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N1_BPP, aBitmap.getPixelFormat());
     CPPUNIT_ASSERT_EQUAL(Color(0xffffff), aBitmap.GetPixelColor(0, 0));
     CPPUNIT_ASSERT_EQUAL(Color(0x72d1c8), aBitmap.GetPixelColor(1, 1));
     CPPUNIT_ASSERT_EQUAL(Color(0x72d1c8), aBitmap.GetPixelColor(8, 8));
diff --git a/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx b/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx
index 5da8cb643849..d4cb8ed1532b 100644
--- a/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx
+++ b/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx
@@ -147,13 +147,13 @@ void BitmapRenderTest::testDrawAlphaBitmapEx()
     auto pBackendCapabilities = ImplGetSVData()->mpDefInst->GetBackendCapabilities();
     if (pBackendCapabilities->mbSupportsBitmap32)
     {
-        CPPUNIT_ASSERT_EQUAL(sal_uInt16(32), aBitmapEx.GetBitmap().GetBitCount());
+        CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N32_BPP, aBitmapEx.GetBitmap().getPixelFormat());
     }
     else
     {
-        CPPUNIT_ASSERT_EQUAL(sal_uInt16(24), aBitmapEx.GetBitmap().GetBitCount());
+        CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N24_BPP, aBitmapEx.GetBitmap().getPixelFormat());
         CPPUNIT_ASSERT_EQUAL(true, aBitmapEx.IsAlpha());
-        CPPUNIT_ASSERT_EQUAL(sal_uInt16(8), aBitmapEx.GetAlpha().GetBitCount());
+        CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N8_BPP, aBitmapEx.GetAlpha().getPixelFormat());
     }
 
     // Check the bitmap has pixels we expect
diff --git a/vcl/qa/cppunit/canvasbitmaptest.cxx b/vcl/qa/cppunit/canvasbitmaptest.cxx
index cfa6b418c958..a1185ab1f7ad 100644
--- a/vcl/qa/cppunit/canvasbitmaptest.cxx
+++ b/vcl/qa/cppunit/canvasbitmaptest.cxx
@@ -723,8 +723,8 @@ void CanvasBitmapTest::runTest()
                             !aBmp.IsTransparent());
     CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bitmap does not have size (10,10)",
                             Size(10,10), aBmp.GetSizePixel());
-    CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bitmap does not have bitcount of 8",
-                            static_cast<sal_uInt16>(8),  aBmp.GetBitCount());
+    CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bitmap does not have the expected pixel format",
+                            vcl::PixelFormat::N8_BPP,  aBmp.getPixelFormat());
     {
         Bitmap aBitmap = aBmp.GetBitmap();
         BitmapReadAccess* pBmpAcc   = aBitmap.AcquireReadAccess();
@@ -751,8 +751,8 @@ void CanvasBitmapTest::runTest()
                             aBmp.IsAlpha());
     CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bitmap does not have size (10,10)",
                             Size(10,10), aBmp.GetSizePixel());
-    CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bitmap has bitcount of 24",
-                            static_cast<sal_uInt16>(24), aBmp.GetBitCount());
+    CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bitmap does not have the expected pixel format",
+                            vcl::PixelFormat::N24_BPP,  aBmp.getPixelFormat());
     {
         Bitmap aBitmap = aBmp.GetBitmap();
         BitmapReadAccess* pBmpAcc   = aBitmap.AcquireReadAccess();
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 75832ec20324..8e089ded9d95 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -1804,7 +1804,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf121615)
     BitmapEx aBitmap = aGraphic.GetBitmapEx();
     CPPUNIT_ASSERT_EQUAL(tools::Long(200), aBitmap.GetSizePixel().Width());
     CPPUNIT_ASSERT_EQUAL(tools::Long(300), aBitmap.GetSizePixel().Height());
-    CPPUNIT_ASSERT_EQUAL(8, int(aBitmap.GetBitCount()));
+    CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N8_BPP, aBitmap.getPixelFormat());
     // tdf#121615 was caused by broken handling of data width with 8bit color,
     // so the test image has some black in the bottomright corner, check it's there
     CPPUNIT_ASSERT_EQUAL(COL_WHITE, aBitmap.GetPixelColor(0, 0));
@@ -1853,7 +1853,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf141171)
     Size aSize = aBitmap.GetSizePixel();
     CPPUNIT_ASSERT_EQUAL(tools::Long(878), aSize.Width());
     CPPUNIT_ASSERT_EQUAL(tools::Long(127), aSize.Height());
-    CPPUNIT_ASSERT_EQUAL(8, int(aBitmap.GetBitCount()));
+    CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N8_BPP, aBitmap.getPixelFormat());
 
     for (tools::Long nX = 0; nX < aSize.Width(); ++nX)
     {
@@ -1908,7 +1908,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf129085)
     BitmapEx aBitmap = aGraphic.GetBitmapEx();
     CPPUNIT_ASSERT_EQUAL(tools::Long(884), aBitmap.GetSizePixel().Width());
     CPPUNIT_ASSERT_EQUAL(tools::Long(925), aBitmap.GetSizePixel().Height());
-    CPPUNIT_ASSERT_EQUAL(24, int(aBitmap.GetBitCount()));
+    CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N24_BPP, aBitmap.getPixelFormat());
 }
 
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testTocLink)
diff --git a/vcl/qa/cppunit/skia/skia.cxx b/vcl/qa/cppunit/skia/skia.cxx
index 2ca53bbdc2a9..67c1b4f274ef 100644
--- a/vcl/qa/cppunit/skia/skia.cxx
+++ b/vcl/qa/cppunit/skia/skia.cxx
@@ -197,11 +197,11 @@ void SkiaTest::testInterpretAs8Bit()
     bitmap.Erase(Color(33, 33, 33));
     SkiaSalBitmap* skiaBitmap = dynamic_cast<SkiaSalBitmap*>(bitmap.ImplGetSalBitmap().get());
     CPPUNIT_ASSERT(skiaBitmap->unittestHasEraseColor());
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(24), bitmap.GetBitCount());
+    CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N24_BPP, bitmap.getPixelFormat());
     bitmap.Convert(BmpConversion::N8BitNoConversion);
     skiaBitmap = dynamic_cast<SkiaSalBitmap*>(bitmap.ImplGetSalBitmap().get());
     CPPUNIT_ASSERT(skiaBitmap->unittestHasEraseColor());
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(8), bitmap.GetBitCount());
+    CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N8_BPP, bitmap.getPixelFormat());
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>(33), BitmapReadAccess(bitmap).GetPixelIndex(0, 0));
 
     // Test with image.
@@ -212,11 +212,11 @@ void SkiaTest::testInterpretAs8Bit()
     skiaBitmap->GetSkImage();
     CPPUNIT_ASSERT(!skiaBitmap->unittestHasEraseColor());
     CPPUNIT_ASSERT(skiaBitmap->unittestHasImage());
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(24), bitmap.GetBitCount());
+    CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N24_BPP, bitmap.getPixelFormat());
     bitmap.Convert(BmpConversion::N8BitNoConversion);
     skiaBitmap = dynamic_cast<SkiaSalBitmap*>(bitmap.ImplGetSalBitmap().get());
     CPPUNIT_ASSERT(skiaBitmap->unittestHasImage());
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(8), bitmap.GetBitCount());
+    CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N8_BPP, bitmap.getPixelFormat());
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>(34), BitmapReadAccess(bitmap).GetPixelIndex(0, 0));
 }
 
@@ -236,7 +236,7 @@ void SkiaTest::testAlphaBlendWith()
     alpha.BlendWith(bitmap);
     skiaAlpha = dynamic_cast<SkiaSalBitmap*>(alpha.ImplGetSalBitmap().get());
     CPPUNIT_ASSERT(skiaAlpha->unittestHasEraseColor());
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(8), alpha.GetBitCount());
+    CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N8_BPP, alpha.getPixelFormat());
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>(112),
                          AlphaMask::ScopedReadAccess(alpha)->GetPixelIndex(0, 0));
 
@@ -256,7 +256,7 @@ void SkiaTest::testAlphaBlendWith()
     alpha.BlendWith(bitmap);
     skiaAlpha = dynamic_cast<SkiaSalBitmap*>(alpha.ImplGetSalBitmap().get());
     CPPUNIT_ASSERT(skiaAlpha->unittestHasImage());
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(8), alpha.GetBitCount());
+    CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N8_BPP, alpha.getPixelFormat());
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>(112),
                          AlphaMask::ScopedReadAccess(alpha)->GetPixelIndex(0, 0));
 
@@ -273,7 +273,7 @@ void SkiaTest::testAlphaBlendWith()
     alpha.BlendWith(bitmap);
     skiaAlpha = dynamic_cast<SkiaSalBitmap*>(alpha.ImplGetSalBitmap().get());
     CPPUNIT_ASSERT(skiaAlpha->unittestHasImage());
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(8), alpha.GetBitCount());
+    CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N8_BPP, alpha.getPixelFormat());
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>(112),
                          AlphaMask::ScopedReadAccess(alpha)->GetPixelIndex(0, 0));
 }
diff --git a/vcl/source/bitmap/BitmapColorQuantizationFilter.cxx b/vcl/source/bitmap/BitmapColorQuantizationFilter.cxx
index 2205f1ca98f0..faafd64b81b9 100644
--- a/vcl/source/bitmap/BitmapColorQuantizationFilter.cxx
+++ b/vcl/source/bitmap/BitmapColorQuantizationFilter.cxx
@@ -25,7 +25,7 @@ BitmapEx BitmapColorQuantizationFilter::execute(BitmapEx const& aBitmapEx) const
 
     bool bRet = false;
 
-    if (aBitmap.GetColorCount() <= sal_Int64(mnNewColorCount))
+    if (vcl::numberOfColors(aBitmap.getPixelFormat()) <= sal_Int64(mnNewColorCount))
     {
         bRet = true;
     }
diff --git a/vcl/source/bitmap/BitmapEx.cxx b/vcl/source/bitmap/BitmapEx.cxx
index 0464cbd47f8a..2aa41de865ba 100644
--- a/vcl/source/bitmap/BitmapEx.cxx
+++ b/vcl/source/bitmap/BitmapEx.cxx
@@ -127,7 +127,8 @@ BitmapEx::BitmapEx( const Bitmap& rBmp, const Bitmap& rMask ) :
 {
     // Ensure a mask is exactly one bit deep,
     // alternatively also allow 8bpp masks.
-    if( !maMask.IsEmpty() && maMask.GetBitCount() != 1 && !(maMask.GetBitCount() == 8 && maMask.HasGreyPalette8Bit()))
+    if (!maMask.IsEmpty() && maMask.getPixelFormat() != vcl::PixelFormat::N1_BPP
+                && !(maMask.getPixelFormat() == vcl::PixelFormat::N8_BPP && maMask.HasGreyPalette8Bit()))
     {
         SAL_WARN( "vcl", "BitmapEx: forced mask to monochrome");
         BitmapEx aMaskEx(maMask);
@@ -665,7 +666,7 @@ sal_uInt8 BitmapEx::GetAlpha(sal_Int32 nX, sal_Int32 nY) const
     if (nX < 0 || nX >= GetSizePixel().Width() || nY < 0 || nY >= GetSizePixel().Height())
         return 0;
 
-    if (maBitmap.GetBitCount() == 32)
+    if (maBitmap.getPixelFormat() == vcl::PixelFormat::N32_BPP)
         return GetPixelColor(nX, nY).GetAlpha();
 
     sal_uInt8 nAlpha(0);
@@ -722,7 +723,7 @@ Color BitmapEx::GetPixelColor(sal_Int32 nX, sal_Int32 nY) const
         AlphaMask::ScopedReadAccess pAlphaReadAccess(aAlpha);
         aColor.SetAlpha(255 - pAlphaReadAccess->GetPixel(nY, nX).GetIndex());
     }
-    else if (maBitmap.GetBitCount() != 32)
+    else if (maBitmap.getPixelFormat() != vcl::PixelFormat::N32_BPP)
     {
         aColor.SetAlpha(255);
     }
@@ -992,7 +993,7 @@ BitmapEx BitmapEx::ModifyBitmapEx(const basegfx::BColorModifierStack& rBColorMod
             if(IsTransparent())
             {
                 // clear bitmap with dest color
-                if(aChangedBitmap.GetBitCount() <= 8)
+                if (vcl::isPalettePixelFormat(aChangedBitmap.getPixelFormat()))
                 {
                     // For e.g. 8bit Bitmaps, the nearest color to the given erase color is
                     // determined and used -> this may be different from what is wanted here.
diff --git a/vcl/source/bitmap/BitmapInfoAccess.cxx b/vcl/source/bitmap/BitmapInfoAccess.cxx
index 8c90e8fb8d25..1914755cc692 100644
--- a/vcl/source/bitmap/BitmapInfoAccess.cxx
+++ b/vcl/source/bitmap/BitmapInfoAccess.cxx
@@ -49,7 +49,7 @@ BitmapInfoAccess::BitmapInfoAccess(Bitmap& rBitmap, BitmapAccessMode nMode)
     if (!mpBuffer)
     {
         std::shared_ptr<SalBitmap> xNewImpBmp(ImplGetSVData()->mpDefInst->CreateSalBitmap());
-        if (xNewImpBmp->Create(*xImpBmp, rBitmap.GetBitCount()))
+        if (xNewImpBmp->Create(*xImpBmp, vcl::pixelFormatBitCount(rBitmap.getPixelFormat())))
         {
             xImpBmp = xNewImpBmp;
             rBitmap.ImplSetSalBitmap(xImpBmp);
diff --git a/vcl/source/bitmap/BitmapMosaicFilter.cxx b/vcl/source/bitmap/BitmapMosaicFilter.cxx
index d04321c0bcee..8dfa4519e05a 100644
--- a/vcl/source/bitmap/BitmapMosaicFilter.cxx
+++ b/vcl/source/bitmap/BitmapMosaicFilter.cxx
@@ -26,7 +26,7 @@ BitmapEx BitmapMosaicFilter::execute(BitmapEx const& rBitmapEx) const
         BitmapReadAccess* pReadAcc;
         BitmapWriteAccess* pWriteAcc;
 
-        if (aBitmap.GetBitCount() > 8)
+        if (!isPalettePixelFormat(aBitmap.getPixelFormat()))
         {
             pReadAcc = pWriteAcc = aBitmap.AcquireWriteAccess();
         }
diff --git a/vcl/source/bitmap/BitmapPopArtFilter.cxx b/vcl/source/bitmap/BitmapPopArtFilter.cxx
index 54e0aa2d2f15..81a3d22c76f0 100644
--- a/vcl/source/bitmap/BitmapPopArtFilter.cxx
+++ b/vcl/source/bitmap/BitmapPopArtFilter.cxx
@@ -18,7 +18,8 @@ BitmapEx BitmapPopArtFilter::execute(BitmapEx const& rBitmapEx) const
 {
     Bitmap aBitmap(rBitmapEx.GetBitmap());
 
-    bool bRet = (aBitmap.GetBitCount() <= 8) || aBitmap.Convert(BmpConversion::N8BitColors);
+    bool bRet = isPalettePixelFormat(aBitmap.getPixelFormat())
+                || aBitmap.Convert(BmpConversion::N8BitColors);
 
     if (bRet)
     {
diff --git a/vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx b/vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx
index 281a2d066fd5..b44c7daba85f 100644
--- a/vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx
+++ b/vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx
@@ -21,7 +21,7 @@ BitmapEx BitmapSimpleColorQuantizationFilter::execute(BitmapEx const& aBitmapEx)
 
     bool bRet = false;
 
-    if (aBitmap.GetColorCount() <= sal_Int64(mnNewColorCount))
+    if (vcl::numberOfColors(aBitmap.getPixelFormat()) <= sal_Int64(mnNewColorCount))
     {
         bRet = true;
     }
diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx
index 89d97c953886..8bd24f1d5706 100644
--- a/vcl/source/bitmap/BitmapTools.cxx
+++ b/vcl/source/bitmap/BitmapTools.cxx
@@ -1008,7 +1008,7 @@ void CanvasCairoExtractBitmapData( BitmapEx const & aBmpEx, Bitmap & aBitmap, un
 
             if(8 == aBitmap.GetSizePixel().Width() && 8 == aBitmap.GetSizePixel().Height())
             {
-                if(2 == aBitmap.GetColorCount())
+                if (aBitmap.getPixelFormat() == vcl::PixelFormat::N1_BPP)
                 {
                     BitmapReadAccess* pRead = aBitmap.AcquireReadAccess();
 
@@ -1080,7 +1080,7 @@ void CanvasCairoExtractBitmapData( BitmapEx const & aBmpEx, Bitmap & aBitmap, un
 bool convertBitmap32To24Plus8(BitmapEx const & rInput, BitmapEx & rResult)
 {
     Bitmap aBitmap(rInput.GetBitmap());
-    if (aBitmap.GetBitCount() != 32)
+    if (aBitmap.getPixelFormat() != vcl::PixelFormat::N32_BPP)
         return false;
 
     Size aSize = aBitmap.GetSizePixel();
diff --git a/vcl/source/bitmap/alpha.cxx b/vcl/source/bitmap/alpha.cxx
index aee39e63c329..0f0547166a3b 100644
--- a/vcl/source/bitmap/alpha.cxx
+++ b/vcl/source/bitmap/alpha.cxx
@@ -65,7 +65,7 @@ const Bitmap& AlphaMask::ImplGetBitmap() const
 
 void AlphaMask::ImplSetBitmap( const Bitmap& rBitmap )
 {
-    SAL_WARN_IF( 8 != rBitmap.GetBitCount(), "vcl.gdi", "Bitmap should be 8bpp, not " << rBitmap.GetBitCount() << "bpp" );
+    SAL_WARN_IF(rBitmap.getPixelFormat() != vcl::PixelFormat::N8_BPP, "vcl.gdi", "Bitmap should be 8bpp, not " << vcl::pixelFormatBitCount(rBitmap.getPixelFormat()) << "bpp" );
     SAL_WARN_IF( !rBitmap.HasGreyPalette8Bit(), "vcl.gdi", "Bitmap isn't greyscale" );
     *static_cast<Bitmap*>(this) = rBitmap;
 }
diff --git a/vcl/source/bitmap/bitmap.cxx b/vcl/source/bitmap/bitmap.cxx
index e9bf5554169c..592ae0b213fe 100644
--- a/vcl/source/bitmap/bitmap.cxx
+++ b/vcl/source/bitmap/bitmap.cxx
@@ -321,43 +321,26 @@ Size Bitmap::GetSizePixel() const
 }
 
 vcl::PixelFormat Bitmap::getPixelFormat() const
-{
-    switch (GetBitCount())
-    {
-        case 1: return vcl::PixelFormat::N1_BPP;
-        case 4: assert(false); break;
-        case 8: return vcl::PixelFormat::N8_BPP;
-        case 24: return vcl::PixelFormat::N24_BPP;
-        case 32: return vcl::PixelFormat::N32_BPP;
-        default:
-            break;
-    }
-    return vcl::PixelFormat::INVALID;
-}
-
-sal_uInt16 Bitmap::GetBitCount() const
 {
     if (!mxSalBmp)
-        return 0;
+        return vcl::PixelFormat::INVALID;
 
     sal_uInt16 nBitCount = mxSalBmp->GetBitCount();
     if (nBitCount <= 1)
-        return 1;
-    if (nBitCount <= 4)
-        return 4;
+        return vcl::PixelFormat::N1_BPP;
     if (nBitCount <= 8)
-        return 8;
+        return vcl::PixelFormat::N8_BPP;
     if (nBitCount <= 24)
-        return 24;
+        return vcl::PixelFormat::N24_BPP;
     if (nBitCount <= 32)
-        return 32;
-    return 0;
+        return vcl::PixelFormat::N32_BPP;
+
+    return vcl::PixelFormat::INVALID;
 }
 
 bool Bitmap::HasGreyPaletteAny() const
 {
-    const sal_uInt16    nBitCount = GetBitCount();
-    bool            bRet = nBitCount == 1;
+    bool bRet = getPixelFormat() == vcl::PixelFormat::N1_BPP;
 
     ScopedInfoAccess pIAcc(const_cast<Bitmap&>(*this));
 
@@ -397,7 +380,7 @@ BitmapChecksum Bitmap::GetChecksum() const
             // so, we need to update the imp bitmap for this bitmap instance
             // as we do in BitmapInfoAccess::ImplCreate
             std::shared_ptr<SalBitmap> xNewImpBmp(ImplGetSVData()->mpDefInst->CreateSalBitmap());
-            if (xNewImpBmp->Create(*mxSalBmp, GetBitCount()))
+            if (xNewImpBmp->Create(*mxSalBmp, vcl::pixelFormatBitCount(getPixelFormat())))
             {
                 Bitmap* pThis = const_cast<Bitmap*>(this);
                 pThis->mxSalBmp = xNewImpBmp;
@@ -551,8 +534,8 @@ bool Bitmap::CopyPixel( const tools::Rectangle& rRectDst,
             Bitmap*         pSrc = const_cast<Bitmap*>(pBmpSrc);
             const Size      aCopySizePix( pSrc->GetSizePixel() );
             tools::Rectangle       aRectSrc( rRectSrc );
-            const sal_uInt16    nSrcBitCount = pBmpSrc->GetBitCount();
-            const sal_uInt16    nDstBitCount = GetBitCount();
+            const sal_uInt16 nSrcBitCount = vcl::pixelFormatBitCount(pBmpSrc->getPixelFormat());
+            const sal_uInt16 nDstBitCount = vcl::pixelFormatBitCount(getPixelFormat());
 
             if( nSrcBitCount > nDstBitCount )
             {
@@ -983,7 +966,7 @@ bool Bitmap::Convert( BmpConversion eConversion )
         }
     }
 
-    const sal_uInt16 nBitCount = GetBitCount ();
+    const sal_uInt16 nBitCount = vcl::pixelFormatBitCount(getPixelFormat());
     bool bRet = false;
 
     switch( eConversion )
@@ -1168,7 +1151,7 @@ bool Bitmap::ImplMakeGreyscales()
 
 bool Bitmap::ImplConvertUp(vcl::PixelFormat ePixelFormat, Color const * pExtColor)
 {
-    SAL_WARN_IF(sal_Int32(ePixelFormat) <= GetBitCount(), "vcl", "New BitCount must be greater!" );
+    SAL_WARN_IF(ePixelFormat <= getPixelFormat(), "vcl", "New pixel format must be greater!" );
 
     Bitmap::ScopedReadAccess pReadAcc(*this);
     bool bRet = false;
@@ -1188,9 +1171,9 @@ bool Bitmap::ImplConvertUp(vcl::PixelFormat ePixelFormat, Color const * pExtColo
             {
                 const BitmapPalette& rOldPalette = pReadAcc->GetPalette();
                 const sal_uInt16 nOldCount = rOldPalette.GetEntryCount();
-                assert(nOldCount <= (1 << GetBitCount()));
-                sal_Int16 nNewBitCount = sal_Int16(ePixelFormat);
-                aPalette.SetEntryCount(1 << nNewBitCount);
+                assert(nOldCount <= (1 << vcl::pixelFormatBitCount(getPixelFormat())));
+
+                aPalette.SetEntryCount(1 << vcl::pixelFormatBitCount(ePixelFormat));
 
                 for (sal_uInt16 i = 0; i < nOldCount; i++)
                     aPalette[i] = rOldPalette[i];
@@ -1257,7 +1240,7 @@ bool Bitmap::ImplConvertUp(vcl::PixelFormat ePixelFormat, Color const * pExtColo
 
 bool Bitmap::ImplConvertDown(vcl::PixelFormat ePixelFormat, Color const * pExtColor)
 {
-    SAL_WARN_IF(sal_Int32(ePixelFormat) > GetBitCount(), "vcl", "New BitCount must be lower ( or equal when pExtColor is set )!");
+    SAL_WARN_IF(ePixelFormat > getPixelFormat(), "vcl", "New pixelformat must be lower ( or equal when pExtColor is set )!");
 
     Bitmap::ScopedReadAccess pReadAcc(*this);
     bool bRet = false;
@@ -1397,7 +1380,7 @@ bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag n
         return true;
     }
 
-    const sal_uInt16 nStartCount(GetBitCount());
+    const auto eStartPixelFormat = getPixelFormat();
 
     if (mxSalBmp && mxSalBmp->ScalingSupported())
     {
@@ -1426,7 +1409,7 @@ bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag n
     // just use the fast scale rather than attempting to count unique colors in
     // the other converters and pass all the info down through
     // Bitmap::MakeMonochrome
-    if (nStartCount == 1)
+    if (eStartPixelFormat == vcl::PixelFormat::N1_BPP)
         nScaleFlag = BmpScaleFlag::Fast;
 
     BitmapEx aBmpEx(*this);
@@ -1470,7 +1453,7 @@ bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag n
     if (bRetval)
         *this = aBmpEx.GetBitmap();
 
-    OSL_ENSURE(!bRetval || nStartCount == GetBitCount(), "Bitmap::Scale has changed the ColorDepth, this should *not* happen (!)");
+    OSL_ENSURE(!bRetval || eStartPixelFormat == getPixelFormat(), "Bitmap::Scale has changed the ColorDepth, this should *not* happen (!)");
     return bRetval;
 }
 
@@ -1503,22 +1486,17 @@ bool Bitmap::HasFastScale()
 void Bitmap::AdaptBitCount(Bitmap& rNew) const
 {
     // aNew is the result of some operation; adapt it's BitCount to the original (this)
-    if(GetBitCount() == rNew.GetBitCount())
+    if (getPixelFormat() == rNew.getPixelFormat())
         return;
 
-    switch(GetBitCount())
+    switch (getPixelFormat())
     {
-        case 1:
+        case vcl::PixelFormat::N1_BPP:
         {
             rNew.Convert(BmpConversion::N1BitThreshold);
             break;
         }
-        case 4:
-        {
-            assert(false);
-            break;
-        }
-        case 8:
+        case vcl::PixelFormat::N8_BPP:
         {
             if(HasGreyPaletteAny())
             {
@@ -1530,19 +1508,19 @@ void Bitmap::AdaptBitCount(Bitmap& rNew) const
             }
             break;
         }
-        case 24:
+        case vcl::PixelFormat::N24_BPP:
         {
             rNew.Convert(BmpConversion::N24Bit);
             break;
         }
-        case 32:
+        case vcl::PixelFormat::N32_BPP:
         {
             rNew.Convert(BmpConversion::N32Bit);
             break;
         }
-        default:
+        case vcl::PixelFormat::INVALID:
         {
-            SAL_WARN("vcl", "BitDepth adaptation failed, from " << rNew.GetBitCount() << " to " << GetBitCount());
+            SAL_WARN("vcl", "Can't adapt the pixelformat as it is invalid.");
             break;
         }
     }
diff --git a/vcl/source/bitmap/bitmappaint.cxx b/vcl/source/bitmap/bitmappaint.cxx
index 201f05e74a79..e8a2a03c57b1 100644
--- a/vcl/source/bitmap/bitmappaint.cxx
+++ b/vcl/source/bitmap/bitmappaint.cxx
@@ -888,7 +888,7 @@ bool Bitmap::Replace(const Color& rSearchColor, const Color& rReplaceColor, sal_
 
     // Bitmaps with 1 bit color depth can cause problems if they have other entries than black/white
     // in their palette
-    if (GetBitCount() == 1)
+    if (getPixelFormat() == vcl::PixelFormat::N1_BPP)
         Convert(BmpConversion::N8BitColors);
 
     BitmapScopedWriteAccess pAcc(*this);
@@ -951,7 +951,7 @@ bool Bitmap::Replace(const Color* pSearchColors, const Color* pReplaceColors, si
 {
     // Bitmaps with 1 bit color depth can cause problems if they have other entries than black/white
     // in their palette
-    if (GetBitCount() == 1)
+    if (getPixelFormat() == vcl::PixelFormat::N1_BPP)
         Convert(BmpConversion::N8BitColors);
 
     BitmapScopedWriteAccess pAcc(*this);
@@ -1124,7 +1124,7 @@ bool Bitmap::Blend(const AlphaMask& rAlpha, const Color& rBackgroundColor)
 {
     // Convert to a truecolor bitmap, if we're a paletted one. There's room for tradeoff decision here,
     // maybe later for an overload (or a flag)
-    if (GetBitCount() <= 8)
+    if (vcl::isPalettePixelFormat(getPixelFormat()))
         Convert(BmpConversion::N24Bit);
 
     AlphaMask::ScopedReadAccess pAlphaAcc(const_cast<AlphaMask&>(rAlpha));
diff --git a/vcl/source/bitmap/dibtools.cxx b/vcl/source/bitmap/dibtools.cxx
index 94341bad56f6..f583ca0b332e 100644
--- a/vcl/source/bitmap/dibtools.cxx
+++ b/vcl/source/bitmap/dibtools.cxx
@@ -1748,7 +1748,7 @@ bool ReadDIBBitmapEx(
                             if(!aMask.IsEmpty())
                             {
                                 // do we have an alpha mask?
-                                if((8 == aMask.GetBitCount()) && aMask.HasGreyPalette8Bit())
+                                if (aMask.getPixelFormat() == vcl::PixelFormat::N8_BPP && aMask.HasGreyPalette8Bit())
                                 {
                                     AlphaMask aAlpha;
 
diff --git a/vcl/source/filter/etiff/etiff.cxx b/vcl/source/filter/etiff/etiff.cxx
index 65a90cd160da..ca5b7934ab84 100644
--- a/vcl/source/filter/etiff/etiff.cxx
+++ b/vcl/source/filter/etiff/etiff.cxx
@@ -183,7 +183,7 @@ bool TIFFWriter::WriteTIFF( const Graphic& rGraphic, FilterConfigItem const * pF
             mpAcc = aBmp.AcquireReadAccess();
             if ( mpAcc )
             {
-                mnBitsPerPixel = aBmp.GetBitCount();
+                mnBitsPerPixel = vcl::pixelFormatBitCount(aBmp.getPixelFormat());
 
                 // export code below only handles four discrete cases
                 mnBitsPerPixel =
diff --git a/vcl/source/filter/png/pngwrite.cxx b/vcl/source/filter/png/pngwrite.cxx
index 092629b686e9..379c805f313b 100644
--- a/vcl/source/filter/png/pngwrite.cxx
+++ b/vcl/source/filter/png/pngwrite.cxx
@@ -112,7 +112,7 @@ PNGWriterImpl::PNGWriterImpl(const BitmapEx& rBitmapEx,
 
     BitmapEx aBitmapEx;
 
-    if (rBitmapEx.GetBitmap().GetBitCount() == 32)
+    if (rBitmapEx.GetBitmap().getPixelFormat() == vcl::PixelFormat::N32_BPP)
     {
         if (!vcl::bitmap::convertBitmap32To24Plus8(rBitmapEx, aBitmapEx))
             return;
@@ -142,7 +142,7 @@ PNGWriterImpl::PNGWriterImpl(const BitmapEx& rBitmapEx,
             }
         }
     }
-    mnBitsPerPixel = static_cast<sal_uInt8>(aBmp.GetBitCount());
+    mnBitsPerPixel = sal_uInt8(vcl::pixelFormatBitCount(aBmp.getPixelFormat()));
 
     if (aBitmapEx.IsTransparent())
     {
diff --git a/vcl/source/gdi/mtfxmldump.cxx b/vcl/source/gdi/mtfxmldump.cxx
index 8b1fa773eb27..d920724cde32 100644
--- a/vcl/source/gdi/mtfxmldump.cxx
+++ b/vcl/source/gdi/mtfxmldump.cxx
@@ -421,6 +421,19 @@ OUString convertWallpaperStyleToString(WallpaperStyle eWallpaperStyle)
     return OUString();
 }
 
+OUString convertPixelFormatToString(vcl::PixelFormat ePixelFormat)
+{
+    switch (ePixelFormat)
+    {
+        case vcl::PixelFormat::INVALID: return "INVALID";
+        case vcl::PixelFormat::N1_BPP: return "1BPP";
+        case vcl::PixelFormat::N8_BPP: return "8BPP";
+        case vcl::PixelFormat::N24_BPP: return "24BPP";
+        case vcl::PixelFormat::N32_BPP: return "32BPP";
+    }
+    return OUString();
+}
+
 OUString hex32(sal_uInt32 nNumber)
 {
     std::stringstream ss;
@@ -990,7 +1003,7 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r
                     BitmapEx const & rBitmapEx = rWallpaper.GetBitmap();
                     rWriter.attribute("crc", hex32(rBitmapEx.GetChecksum()));
                     rWriter.attribute("transparenttype", convertBitmapExTransparentType(rBitmapEx.GetTransparentType()));
-                    rWriter.attribute("bitcount", hex32(rBitmapEx.GetBitmap().GetBitCount()));
+                    rWriter.attribute("pixelformat", convertPixelFormatToString(rBitmapEx.GetBitmap().getPixelFormat()));
                     rWriter.attribute("width", hex32(rBitmapEx.GetSizePixel().Width()));
                     rWriter.attribute("height", hex32(rBitmapEx.GetSizePixel().Height()));
                     rWriter.endElement();
diff --git a/vcl/source/gdi/pdfextoutdevdata.cxx b/vcl/source/gdi/pdfextoutdevdata.cxx
index 8ba808e21579..fc431c7e65a2 100644
--- a/vcl/source/gdi/pdfextoutdevdata.cxx
+++ b/vcl/source/gdi/pdfextoutdevdata.cxx
@@ -482,8 +482,8 @@ bool PageSyncData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAc
                                     aOutputRect.SetSize(pA->GetSize());
                                 }
                             }
-
-                            rWriter.DrawJPGBitmap( aTmp, aGraphic.GetBitmapEx().GetBitCount() > 8, aGraphic.GetSizePixel(), aOutputRect, aMask, aGraphic );
+                            auto ePixelFormat = aGraphic.GetBitmapEx().getPixelFormat();
+                            rWriter.DrawJPGBitmap(aTmp, ePixelFormat > vcl::PixelFormat::N8_BPP, aGraphic.GetSizePixel(), aOutputRect, aMask, aGraphic);
                         }
 
                         if ( bClippingNeeded )
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 2142aeac8808..ad9c1e0935e4 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -8370,9 +8370,10 @@ void PDFWriterImpl::writeJPG( JPGEmit& rObject )
     sal_Int32 nMaskObject = 0;
     if( !rObject.m_aMask.IsEmpty() )
     {
-        if( rObject.m_aMask.GetBitCount() == 1 ||
-            ( rObject.m_aMask.GetBitCount() == 8 && m_aContext.Version >= PDFWriter::PDFVersion::PDF_1_4 && !m_bIsPDF_A1 )
-            )
+        if (rObject.m_aMask.getPixelFormat() == vcl::PixelFormat::N1_BPP
+            || (rObject.m_aMask.getPixelFormat() == vcl::PixelFormat::N8_BPP
+                && m_aContext.Version >= PDFWriter::PDFVersion::PDF_1_4
+                && !m_bIsPDF_A1))
         {
             nMaskObject = createObject();
         }
@@ -8403,7 +8404,7 @@ void PDFWriterImpl::writeJPG( JPGEmit& rObject )
     aLine.append( nLength );
     if( nMaskObject )
     {
-        aLine.append( rObject.m_aMask.GetBitCount() == 1 ? " /Mask " : " /SMask " );
+        aLine.append(rObject.m_aMask.getPixelFormat() == vcl::PixelFormat::N1_BPP ? " /Mask " : " /SMask ");
         aLine.append( nMaskObject );
         aLine.append( " 0 R " );
     }
@@ -8422,9 +8423,9 @@ void PDFWriterImpl::writeJPG( JPGEmit& rObject )
     {
         BitmapEmit aEmit;
         aEmit.m_nObject = nMaskObject;
-        if( rObject.m_aMask.GetBitCount() == 1 )
+        if (rObject.m_aMask.getPixelFormat() == vcl::PixelFormat::N1_BPP)
             aEmit.m_aBitmap = BitmapEx( rObject.m_aMask, rObject.m_aMask );
-        else if( rObject.m_aMask.GetBitCount() == 8 )
+        else if(rObject.m_aMask.getPixelFormat() == vcl::PixelFormat::N8_BPP)
             aEmit.m_aBitmap = BitmapEx( rObject.m_aMask, AlphaMask( rObject.m_aMask ) );
         writeBitmapObject( aEmit, true );
     }
@@ -8725,33 +8726,35 @@ bool PDFWriterImpl::writeBitmapObject( BitmapEmit& rObject, bool bMask )
         {
             aBitmap = getExportBitmap(rObject.m_aBitmap.GetMask());
             aBitmap.Convert( BmpConversion::N1BitThreshold );
-            SAL_WARN_IF( aBitmap.GetBitCount() != 1, "vcl.pdfwriter", "mask conversion failed" );
+            SAL_WARN_IF(aBitmap.getPixelFormat() != vcl::PixelFormat::N1_BPP, "vcl.pdfwriter", "mask conversion failed" );
         }
-        else if( aBitmap.GetBitCount() != 8 )
+        else if (aBitmap.getPixelFormat() != vcl::PixelFormat::N8_BPP)
         {
             aBitmap = getExportBitmap(rObject.m_aBitmap.GetAlpha().GetBitmap());
             aBitmap.Convert( BmpConversion::N8BitGreys );
-            SAL_WARN_IF( aBitmap.GetBitCount() != 8, "vcl.pdfwriter", "alpha mask conversion failed" );
+            SAL_WARN_IF(aBitmap.getPixelFormat() != vcl::PixelFormat::N8_BPP, "vcl.pdfwriter", "alpha mask conversion failed" );
         }
     }
 
     Bitmap::ScopedReadAccess pAccess(aBitmap);
 
-    bool bTrueColor;
-    sal_Int32 nBitsPerComponent;
-    switch( aBitmap.GetBitCount() )
+    bool bTrueColor = true;
+    sal_Int32 nBitsPerComponent = 0;
+    auto const ePixelFormat = aBitmap.getPixelFormat();
+    switch (ePixelFormat)
     {
-        case 1:
-        case 2:
-        case 4:
-        case 8:
+        case vcl::PixelFormat::N1_BPP:
+        case vcl::PixelFormat::N8_BPP:
             bTrueColor = false;
-            nBitsPerComponent = aBitmap.GetBitCount();
+            nBitsPerComponent = vcl::pixelFormatBitCount(ePixelFormat);
             break;
-        default:
+        case vcl::PixelFormat::N24_BPP:
+        case vcl::PixelFormat::N32_BPP:
             bTrueColor = true;
             nBitsPerComponent = 8;
             break;
+        case vcl::PixelFormat::INVALID:
+            return false;
     }
 
     sal_Int32 nStreamLengthObject   = createObject();
@@ -8794,7 +8797,7 @@ bool PDFWriterImpl::writeBitmapObject( BitmapEmit& rObject, bool bMask )
         else if( aBitmap.HasGreyPaletteAny() )
         {
             aLine.append( "/DeviceGray\n" );
-            if( aBitmap.GetBitCount() == 1 )
+            if (aBitmap.getPixelFormat() == vcl::PixelFormat::N1_BPP)
             {
                 // #i47395# 1 bit bitmaps occasionally have an inverted grey palette
                 sal_uInt16 nBlackIndex = pAccess->GetBestPaletteIndex( BitmapColor( COL_BLACK ) );
@@ -8867,7 +8870,7 @@ bool PDFWriterImpl::writeBitmapObject( BitmapEmit& rObject, bool bMask )
     }
     else
     {
-        if( aBitmap.GetBitCount() == 1 )
+        if (aBitmap.getPixelFormat() == vcl::PixelFormat::N1_BPP)
         {
             aLine.append( "/ImageMask true\n" );
             sal_Int32 nBlackIndex = pAccess->GetBestPaletteIndex( BitmapColor( COL_BLACK ) );
@@ -8877,7 +8880,7 @@ bool PDFWriterImpl::writeBitmapObject( BitmapEmit& rObject, bool bMask )
             else
                 aLine.append( "/Decode[ 0 1 ]\n" );
         }
-        else if( aBitmap.GetBitCount() == 8 )
+        else if (aBitmap.getPixelFormat() == vcl::PixelFormat::N8_BPP)
         {
             aLine.append( "/ColorSpace/DeviceGray\n"
                           "/Decode [ 1 0 ]\n" );
@@ -9124,15 +9127,15 @@ void PDFWriterImpl::drawBitmap( const Point& rDestPoint, const Size& rDestSize,
 const BitmapEmit& PDFWriterImpl::createBitmapEmit( const BitmapEx& i_rBitmap, const Graphic& rGraphic )
 {
     BitmapEx aBitmap( i_rBitmap );
+    auto ePixelFormat = aBitmap.GetBitmap().getPixelFormat();
     if( m_aContext.ColorMode == PDFWriter::DrawGreyscale )
     {
-        int nDepth = aBitmap.GetBitmap().GetBitCount();
-        if( nDepth > 1 )
-            aBitmap.Convert( BmpConversion::N8BitGreys );
+        if (ePixelFormat != vcl::PixelFormat::N1_BPP)
+            aBitmap.Convert(BmpConversion::N8BitGreys);
     }
     BitmapID aID;
     aID.m_aPixelSize        = aBitmap.GetSizePixel();
-    aID.m_nSize             = aBitmap.GetBitCount();
+    aID.m_nSize             = vcl::pixelFormatBitCount(ePixelFormat);
     aID.m_nChecksum         = aBitmap.GetBitmap().GetChecksum();
     aID.m_nMaskChecksum     = 0;
     if( aBitmap.IsAlpha() )
diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx
index 1aacbce99934..a0a4fb828995 100644
--- a/vcl/source/gdi/pdfwriter_impl2.cxx
+++ b/vcl/source/gdi/pdfwriter_impl2.cxx
@@ -163,9 +163,9 @@ void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSiz
 
     if( m_aContext.ColorMode == PDFWriter::DrawGreyscale )
     {
-        int nDepth = aBitmapEx.GetBitmap().GetBitCount();
-        if( nDepth > 1 )
-            aBitmapEx.Convert( BmpConversion::N8BitGreys );
+        auto ePixelFormat = aBitmapEx.GetBitmap().getPixelFormat();
+        if (ePixelFormat != vcl::PixelFormat::N1_BPP)
+            aBitmapEx.Convert(BmpConversion::N8BitGreys);
     }
     bool bUseJPGCompression = !i_rContext.m_bOnlyLosslessCompression;
     if ( bIsPng || ( aSizePixel.Width() < 32 ) || ( aSizePixel.Height() < 32 ) )
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx
index c5e29a47cd74..e88592f225a5 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -197,7 +197,7 @@ void Printer::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask,
     Bitmap  aPaint( rBmp ), aMask( rMask );
     BmpMirrorFlags nMirrFlags = BmpMirrorFlags::NONE;
 
-    if( aMask.GetBitCount() > 1 )
+    if (aMask.getPixelFormat() > vcl::PixelFormat::N1_BPP)
         aMask.Convert( BmpConversion::N1BitThreshold );
 
     // mirrored horizontally
@@ -792,7 +792,7 @@ void Printer::DrawDeviceMask( const Bitmap& rMask, const Color& rMaskColor,
     Bitmap  aMask( rMask );
     BmpMirrorFlags nMirrFlags = BmpMirrorFlags::NONE;
 
-    if( aMask.GetBitCount() > 1 )
+    if (aMask.getPixelFormat() > vcl::PixelFormat::N1_BPP)
         aMask.Convert( BmpConversion::N1BitThreshold );
 
     // mirrored horizontally
diff --git a/vcl/source/graphic/UnoGraphicDescriptor.cxx b/vcl/source/graphic/UnoGraphicDescriptor.cxx
index 6f65828fe992..eabb64a41ca5 100644
--- a/vcl/source/graphic/UnoGraphicDescriptor.cxx
+++ b/vcl/source/graphic/UnoGraphicDescriptor.cxx
@@ -370,7 +370,10 @@ void GraphicDescriptor::_getPropertyValues( const comphelper::PropertyMapEntry**
                 if( mpGraphic )
                 {
                     if( mpGraphic->GetType() == GraphicType::Bitmap )
-                        nBitsPerPixel = mpGraphic->GetBitmapEx().GetBitmap().GetBitCount();
+                    {
+                        auto ePixelFormat = mpGraphic->GetBitmapEx().GetBitmap().getPixelFormat();
+                        nBitsPerPixel = vcl::pixelFormatBitCount(ePixelFormat);
+                    }
                 }
                 else
                     nBitsPerPixel = mnBitsPerPixel;
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index 20c5998c185e..db73c38dabdf 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -496,7 +496,7 @@ BitmapEx OutputDevice::GetBitmapEx( const Point& rSrcPt, const Size& rSize ) con
         Bitmap aAlphaBitmap( mpAlphaVDev->GetBitmap( rSrcPt, rSize ) );
 
         // ensure 8 bit alpha
-        if( aAlphaBitmap.GetBitCount() > 8 )
+        if (aAlphaBitmap.getPixelFormat() > vcl::PixelFormat::N8_BPP)
             aAlphaBitmap.Convert( BmpConversion::N8BitNoConversion );
 
         return BitmapEx(GetBitmap( rSrcPt, rSize ), AlphaMask( aAlphaBitmap ) );
diff --git a/vcl/source/outdev/transparent.cxx b/vcl/source/outdev/transparent.cxx
index a9712a22ee2d..415e3f1597a9 100644
--- a/vcl/source/outdev/transparent.cxx
+++ b/vcl/source/outdev/transparent.cxx
@@ -418,7 +418,7 @@ void OutputDevice::EmulateDrawTransparent ( const tools::PolyPolygon& rPolyPoly,
                         const tools::Long nB = aFillCol.GetBlue();
                         tools::Long nX, nY;
 
-                        if( aPaint.GetBitCount() <= 8 )
+                        if (vcl::isPalettePixelFormat(aPaint.getPixelFormat()))
                         {
                             const BitmapPalette& rPal = pW->GetPalette();
                             const sal_uInt16 nCount = rPal.GetEntryCount();
diff --git a/vcl/unx/generic/dtrans/bmp.cxx b/vcl/unx/generic/dtrans/bmp.cxx
index 0b5f6f85c236..87328c8712f0 100644
--- a/vcl/unx/generic/dtrans/bmp.cxx
+++ b/vcl/unx/generic/dtrans/bmp.cxx
@@ -748,10 +748,10 @@ css::uno::Sequence<sal_Int8> x11::convertBitmapDepth(
         StreamMode::READ);
     Bitmap bm;
     ReadDIB(bm, in, true);
-    if (bm.GetBitCount() == 24 && depth <= 8) {
+    if (bm.getPixelFormat() == vcl::PixelFormat::N24_BPP && depth <= 8) {
         bm.Dither();
     }
-    if (bm.GetBitCount() != depth) {
+    if (vcl::pixelFormatBitCount(bm.getPixelFormat()) != depth) {
         switch (depth) {
         case 1:
             bm.Convert(BmpConversion::N1BitThreshold);


More information about the Libreoffice-commits mailing list