diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2021-03-27 10:14:13 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-04-02 06:28:39 +0200 |
commit | 88a177f827eba204dea92b631032411de8213ee4 (patch) | |
tree | 3107896970ac35f9fd1cb3804634efdef78c2313 /include/vcl | |
parent | 465b8b0e9ad4b0c9c7701dee2820a99c5d00b5bf (diff) |
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@gmail.com>
Diffstat (limited to 'include/vcl')
-rw-r--r-- | include/vcl/bitmap.hxx | 14 | ||||
-rw-r--r-- | include/vcl/bitmap/BitmapTypes.hxx | 10 | ||||
-rw-r--r-- | include/vcl/bitmapex.hxx | 5 |
3 files changed, 14 insertions, 15 deletions
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(); |