From efecaf03adff75aa88be7862eb2c4f1261df5e60 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 6 May 2015 10:52:59 +0200 Subject: convert BMP_DITHER flags to scoped enum Change-Id: I652faacf39a32fc8803147819ec9366948ff12b9 Reviewed-on: https://gerrit.libreoffice.org/15646 Tested-by: Jenkins Reviewed-by: Noel Grandin --- include/vcl/bitmap.hxx | 17 ++++++++++++----- include/vcl/bitmapex.hxx | 2 +- svtools/source/graphic/grfmgr2.cxx | 2 +- svx/source/xoutdev/_xoutbmp.cxx | 2 +- vcl/source/gdi/bitmap3.cxx | 8 ++++---- vcl/source/gdi/bitmapex.cxx | 2 +- vcl/unx/generic/dtrans/bmp.cxx | 2 +- 7 files changed, 21 insertions(+), 14 deletions(-) diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx index 5e75b69626d9..8ee2c872fd7b 100644 --- a/include/vcl/bitmap.hxx +++ b/include/vcl/bitmap.hxx @@ -59,10 +59,17 @@ enum class BmpScaleFlag }; -#define BMP_DITHER_NONE 0x00000000UL -#define BMP_DITHER_MATRIX 0x00000001UL -#define BMP_DITHER_FLOYD 0x00000002UL -#define BMP_DITHER_FLOYD_16 0x00000004UL +enum class BmpDitherFlags +{ + NONE = 0x0000, + Matrix = 0x0001, + Floyd = 0x0002, + Floyd16 = 0x0004, +}; +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} #define BMP_VECTORIZE_INNER 0x00000001UL #define BMP_VECTORIZE_OUTER 0x00000002UL @@ -417,7 +424,7 @@ public: @param nDitherFlags The algorithm to be used for dithering */ - bool Dither( sal_uLong nDitherFlags = BMP_DITHER_MATRIX ); + bool Dither( BmpDitherFlags nDitherFlags = BmpDitherFlags::Matrix ); /** Crop the bitmap diff --git a/include/vcl/bitmapex.hxx b/include/vcl/bitmapex.hxx index 13afdcd46153..096e2a050905 100644 --- a/include/vcl/bitmapex.hxx +++ b/include/vcl/bitmapex.hxx @@ -132,7 +132,7 @@ public: @param nDitherFlags The algorithm to be used for dithering */ - bool Dither( sal_uLong nDitherFlags = BMP_DITHER_MATRIX ); + bool Dither( BmpDitherFlags nDitherFlags = BmpDitherFlags::Matrix ); /** Crop the bitmap diff --git a/svtools/source/graphic/grfmgr2.cxx b/svtools/source/graphic/grfmgr2.cxx index 202528d2e42e..9022bdcd9445 100644 --- a/svtools/source/graphic/grfmgr2.cxx +++ b/svtools/source/graphic/grfmgr2.cxx @@ -1002,7 +1002,7 @@ bool GraphicManager::ImplCreateOutput( OutputDevice* pOutputDevice, // OutDev adjustment if necessary if( pOutputDevice->GetOutDevType() != OUTDEV_PRINTER && pOutputDevice->GetBitCount() <= 8 && aOutBmpEx.GetBitCount() >= 8 ) - aOutBmpEx.Dither( BMP_DITHER_MATRIX ); + aOutBmpEx.Dither( BmpDitherFlags::Matrix ); } } diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx index 6a477489a776..758e324a548e 100644 --- a/svx/source/xoutdev/_xoutbmp.cxx +++ b/svx/source/xoutdev/_xoutbmp.cxx @@ -619,7 +619,7 @@ bool DitherBitmap( Bitmap& rBitmap ) bool bRet = false; if( ( rBitmap.GetBitCount() >= 8 ) && ( Application::GetDefaultDevice()->GetColorCount() < 257 ) ) - bRet = rBitmap.Dither( BMP_DITHER_FLOYD ); + bRet = rBitmap.Dither( BmpDitherFlags::Floyd ); else bRet = false; diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx index 3ad2c18fd01c..4ed1aab1143f 100644 --- a/vcl/source/gdi/bitmap3.cxx +++ b/vcl/source/gdi/bitmap3.cxx @@ -1668,7 +1668,7 @@ bool Bitmap::ImplScaleConvolution( return bResult; } -bool Bitmap::Dither( sal_uLong nDitherFlags ) +bool Bitmap::Dither( BmpDitherFlags nDitherFlags ) { bool bRet = false; @@ -1676,11 +1676,11 @@ bool Bitmap::Dither( sal_uLong nDitherFlags ) if( aSizePix.Width() == 1 || aSizePix.Height() == 1 ) bRet = true; - else if( nDitherFlags & BMP_DITHER_MATRIX ) + else if( nDitherFlags & BmpDitherFlags::Matrix ) bRet = ImplDitherMatrix(); - else if( nDitherFlags & BMP_DITHER_FLOYD ) + else if( nDitherFlags & BmpDitherFlags::Floyd ) bRet = ImplDitherFloyd(); - else if( ( nDitherFlags & BMP_DITHER_FLOYD_16 ) && ( GetBitCount() == 24 ) ) + else if( ( nDitherFlags & BmpDitherFlags::Floyd16 ) && ( GetBitCount() == 24 ) ) bRet = ImplDitherFloyd16(); return bRet; diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx index 537c7dc8feff..e6fa951a0927 100644 --- a/vcl/source/gdi/bitmapex.cxx +++ b/vcl/source/gdi/bitmapex.cxx @@ -625,7 +625,7 @@ bool BitmapEx::Erase( const Color& rFillColor ) return bRet; } -bool BitmapEx::Dither( sal_uLong nDitherFlags ) +bool BitmapEx::Dither( BmpDitherFlags nDitherFlags ) { return !!aBitmap && aBitmap.Dither( nDitherFlags ); } diff --git a/vcl/unx/generic/dtrans/bmp.cxx b/vcl/unx/generic/dtrans/bmp.cxx index 621243e5a11f..b4dcc04d5e10 100644 --- a/vcl/unx/generic/dtrans/bmp.cxx +++ b/vcl/unx/generic/dtrans/bmp.cxx @@ -739,7 +739,7 @@ css::uno::Sequence x11::convertBitmapDepth( Bitmap bm; ReadDIB(bm, in, true); if (bm.GetBitCount() == 24 && depth <= 8) { - bm.Dither(BMP_DITHER_FLOYD); + bm.Dither(BmpDitherFlags::Floyd); } if (bm.GetBitCount() != depth) { switch (depth) { -- cgit