include/svx/bmpmask.hxx | 6 ++-- include/vcl/bitmap.hxx | 8 ++--- include/vcl/bitmapex.hxx | 2 - svx/source/dialog/_bmpmask.cxx | 18 ++++++------- vcl/headless/svpbmp.cxx | 2 - vcl/inc/headless/svpbmp.hxx | 2 - vcl/inc/impbmp.hxx | 2 - vcl/inc/opengl/salbmp.hxx | 2 - vcl/inc/quartz/salbmp.h | 2 - vcl/inc/salbmp.hxx | 2 - vcl/inc/unx/salbmp.h | 2 - vcl/inc/win/salbmp.h | 2 - vcl/opengl/salbmp.cxx | 2 - vcl/quartz/salbmp.cxx | 2 - vcl/source/gdi/bitmap.cxx | 56 +++++++++++++++++++++-------------------- vcl/source/gdi/bitmapex.cxx | 4 +- vcl/source/gdi/impbmp.cxx | 2 - vcl/unx/generic/gdi/salbmp.cxx | 2 - vcl/win/gdi/salbmp.cxx | 2 - 19 files changed, 62 insertions(+), 58 deletions(-)
New commits: commit b0fd921441e1e1066e232282843317514375c8ec Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Fri Jan 5 13:24:28 2018 +0200 convert tolerance params to sal_uInt8 (second try) first attempt was in commit e75abe6e0a4ea250366bb29c0ece697e9b1b80a1, reverted in 7accac097688832d8682a88a0176c3e1482ffade Change-Id: I460e9ab5fcca3a99656e5d8434fa04c2387d7183 Reviewed-on: https://gerrit.libreoffice.org/47463 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/svx/bmpmask.hxx b/include/svx/bmpmask.hxx index 7231742d4753..a471ffcf880a 100644 --- a/include/svx/bmpmask.hxx +++ b/include/svx/bmpmask.hxx @@ -130,15 +130,15 @@ class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxBmpMask : public SfxDockingWindow virtual bool Close() override; - sal_uInt16 InitColorArrays( Color* pSrcCols, Color* pDstCols, - sal_uIntPtr* pTols ); + sal_uInt16 InitColorArrays( Color* pSrcCols, Color* pDstCols, + sal_uInt8* pTols ); Bitmap ImpMask( const Bitmap& rBitmap ); GDIMetaFile ImpMask( const GDIMetaFile& rMtf ); Animation ImpMask( const Animation& rAnimation ); BitmapEx ImpMaskTransparent( const BitmapEx& rBitmapEx, const Color& rColor, - const long nTol ); + const sal_uInt8 nTol ); GDIMetaFile GetMetaFile(const Graphic& rGraphic); diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx index f2cd512b3158..c4a5a3f56cbf 100644 --- a/include/vcl/bitmap.hxx +++ b/include/vcl/bitmap.hxx @@ -492,11 +492,11 @@ public: @param nTol Tolerance value. Specifies the maximal difference between rTransColor and the individual pixel values, such that the - corresponding pixel is still regarded transparent. + corresponding pixel is still regarded as transparent. @return the resulting bitmask. */ - Bitmap CreateMask( const Color& rTransColor, sal_uLong nTol = 0 ) const; + Bitmap CreateMask( const Color& rTransColor, sal_uInt8 nTol = 0 ) const; /** Create region of similar colors in a given rectangle @@ -550,7 +550,7 @@ public: @return true, if the operation was completed successfully. */ - bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol = 0 ); + bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol = 0 ); /** Replace all pixel having one the search colors with the corresponding replace color @@ -574,7 +574,7 @@ public: const Color* pSearchColors, const Color* rReplaceColors, sal_uLong nColorCount, - sal_uLong* pTols ); + sal_uInt8 const * pTols ); /** Convert the bitmap to a meta file diff --git a/include/vcl/bitmapex.hxx b/include/vcl/bitmapex.hxx index 3cef293b4e11..a850572357e9 100644 --- a/include/vcl/bitmapex.hxx +++ b/include/vcl/bitmapex.hxx @@ -293,7 +293,7 @@ public: const Color* pSearchColors, const Color* pReplaceColors, sal_uLong nColorCount, - const sal_uLong* pTols = nullptr ); + const sal_uInt8* pTols = nullptr ); /** Change various global color characteristics diff --git a/svx/source/dialog/_bmpmask.cxx b/svx/source/dialog/_bmpmask.cxx index f989dce82bab..19fdd5474194 100644 --- a/svx/source/dialog/_bmpmask.cxx +++ b/svx/source/dialog/_bmpmask.cxx @@ -574,7 +574,7 @@ void SvxBmpMask::SetExecState( bool bEnable ) } -sal_uInt16 SvxBmpMask::InitColorArrays( Color* pSrcCols, Color* pDstCols, sal_uIntPtr* pTols ) +sal_uInt16 SvxBmpMask::InitColorArrays( Color* pSrcCols, Color* pDstCols, sal_uInt8* pTols ) { sal_uInt16 nCount = 0; @@ -614,8 +614,8 @@ Bitmap SvxBmpMask::ImpMask( const Bitmap& rBitmap ) Bitmap aBitmap( rBitmap ); Color pSrcCols[4]; Color pDstCols[4]; - sal_uIntPtr pTols[4]; - const sal_uInt16 nCount = InitColorArrays( pSrcCols, pDstCols, pTols ); + sal_uInt8 pTols[4]; + const sal_uInt16 nCount = InitColorArrays( pSrcCols, pDstCols, pTols ); EnterWait(); aBitmap.Replace( pSrcCols, pDstCols, nCount, pTols ); @@ -624,7 +624,7 @@ Bitmap SvxBmpMask::ImpMask( const Bitmap& rBitmap ) return aBitmap; } -BitmapEx SvxBmpMask::ImpMaskTransparent( const BitmapEx& rBitmapEx, const Color& rColor, const long nTol ) +BitmapEx SvxBmpMask::ImpMaskTransparent( const BitmapEx& rBitmapEx, const Color& rColor, const sal_uInt8 nTol ) { EnterWait(); @@ -646,9 +646,9 @@ Animation SvxBmpMask::ImpMask( const Animation& rAnimation ) Animation aAnimation( rAnimation ); Color pSrcCols[4]; Color pDstCols[4]; - sal_uIntPtr pTols[4]; + sal_uInt8 pTols[4]; InitColorArrays( pSrcCols, pDstCols, pTols ); - sal_uInt16 nAnimationCount = aAnimation.Count(); + sal_uInt16 nAnimationCount = aAnimation.Count(); for( sal_uInt16 i = 0; i < nAnimationCount; i++ ) { @@ -666,8 +666,8 @@ GDIMetaFile SvxBmpMask::ImpMask( const GDIMetaFile& rMtf ) GDIMetaFile aMtf; Color pSrcCols[4]; Color pDstCols[4]; - sal_uIntPtr pTols[4]; - sal_uInt16 nCount = InitColorArrays( pSrcCols, pDstCols, pTols ); + sal_uInt8 pTols[4]; + sal_uInt16 nCount = InitColorArrays( pSrcCols, pDstCols, pTols ); // If no color is selected, we copy only the Mtf if( !nCount ) @@ -1021,7 +1021,7 @@ Graphic SvxBmpMask::Mask( const Graphic& rGraphic ) { Color pSrcCols[4]; Color pDstCols[4]; - sal_uIntPtr pTols[4]; + sal_uInt8 pTols[4]; sal_uInt16 nCount = InitColorArrays( pSrcCols, pDstCols, pTols ); if( nCount ) diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx index 6f94814b3576..0ba815998d8f 100644 --- a/vcl/headless/svpbmp.cxx +++ b/vcl/headless/svpbmp.cxx @@ -291,7 +291,7 @@ bool SvpSalBitmap::Scale( const double& /*rScaleX*/, const double& /*rScaleY*/, return false; } -bool SvpSalBitmap::Replace( const ::Color& /*rSearchColor*/, const ::Color& /*rReplaceColor*/, sal_uLong /*nTol*/ ) +bool SvpSalBitmap::Replace( const ::Color& /*rSearchColor*/, const ::Color& /*rReplaceColor*/, sal_uInt8 /*nTol*/ ) { return false; } diff --git a/vcl/inc/headless/svpbmp.hxx b/vcl/inc/headless/svpbmp.hxx index 884d9d13aecc..efdd2c2bb2af 100644 --- a/vcl/inc/headless/svpbmp.hxx +++ b/vcl/inc/headless/svpbmp.hxx @@ -59,7 +59,7 @@ public: virtual bool ScalingSupported() const override; virtual bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) override; - virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) override; + virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol ) override; }; #endif // INCLUDED_VCL_INC_HEADLESS_SVPBMP_HXX diff --git a/vcl/inc/impbmp.hxx b/vcl/inc/impbmp.hxx index a6212693498e..9465771332e8 100644 --- a/vcl/inc/impbmp.hxx +++ b/vcl/inc/impbmp.hxx @@ -69,7 +69,7 @@ public: bool ImplScalingSupported() const; bool ImplScale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ); - bool ImplReplace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ); + bool ImplReplace( const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol ); bool ImplConvert( BmpConversion eConversion ); }; diff --git a/vcl/inc/opengl/salbmp.hxx b/vcl/inc/opengl/salbmp.hxx index 999df6b321a2..5c4fcd053464 100644 --- a/vcl/inc/opengl/salbmp.hxx +++ b/vcl/inc/opengl/salbmp.hxx @@ -76,7 +76,7 @@ public: bool ScalingSupported() const override; bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) override; - bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) override; + bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol ) override; bool ConvertToGreyscale() override; public: diff --git a/vcl/inc/quartz/salbmp.h b/vcl/inc/quartz/salbmp.h index a4dca65c0ee3..d7c2fb74db51 100644 --- a/vcl/inc/quartz/salbmp.h +++ b/vcl/inc/quartz/salbmp.h @@ -76,7 +76,7 @@ public: bool ScalingSupported() const override; bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) override; - bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) override; + bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol ) override; private: // quartz helper diff --git a/vcl/inc/salbmp.hxx b/vcl/inc/salbmp.hxx index a1014700a68a..a9bddd078004 100644 --- a/vcl/inc/salbmp.hxx +++ b/vcl/inc/salbmp.hxx @@ -66,7 +66,7 @@ public: virtual bool ScalingSupported() const = 0; virtual bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) = 0; - virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) = 0; + virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol ) = 0; virtual bool ConvertToGreyscale() { diff --git a/vcl/inc/unx/salbmp.h b/vcl/inc/unx/salbmp.h index a2dd587a4964..3f45cd5d853c 100644 --- a/vcl/inc/unx/salbmp.h +++ b/vcl/inc/unx/salbmp.h @@ -146,7 +146,7 @@ public: virtual bool ScalingSupported() const override; virtual bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) override; - virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) override; + virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol ) override; }; diff --git a/vcl/inc/win/salbmp.h b/vcl/inc/win/salbmp.h index 33d88bb92a30..f139a8608b30 100644 --- a/vcl/inc/win/salbmp.h +++ b/vcl/inc/win/salbmp.h @@ -97,7 +97,7 @@ public: virtual bool ScalingSupported() const override; virtual bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) override; - virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) override; + virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol ) override; }; #endif // INCLUDED_VCL_INC_WIN_SALBMP_H diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx index 36896fafe305..93fcf0e670c2 100644 --- a/vcl/opengl/salbmp.cxx +++ b/vcl/opengl/salbmp.cxx @@ -873,7 +873,7 @@ bool OpenGLSalBitmap::GetSystemData( BitmapSystemData& /*rData*/ ) #endif } -bool OpenGLSalBitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) +bool OpenGLSalBitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol ) { VCL_GL_INFO("::Replace"); diff --git a/vcl/quartz/salbmp.cxx b/vcl/quartz/salbmp.cxx index b96e25421686..8082621cc5f9 100644 --- a/vcl/quartz/salbmp.cxx +++ b/vcl/quartz/salbmp.cxx @@ -1058,7 +1058,7 @@ bool QuartzSalBitmap::Scale( const double& /*rScaleX*/, const double& /*rScaleY* return false; } -bool QuartzSalBitmap::Replace( const Color& /*rSearchColor*/, const Color& /*rReplaceColor*/, sal_uLong /*nTol*/ ) +bool QuartzSalBitmap::Replace( const Color& /*rSearchColor*/, const Color& /*rReplaceColor*/, sal_uInt8 /*nTol*/ ) { return false; } diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx index ad70291b08be..373974f0f925 100644 --- a/vcl/source/gdi/bitmap.cxx +++ b/vcl/source/gdi/bitmap.cxx @@ -1112,7 +1112,7 @@ bool Bitmap::Expand( sal_uLong nDX, sal_uLong nDY, const Color* pInitColor ) return bRet; } -Bitmap Bitmap::CreateMask( const Color& rTransColor, sal_uLong nTol ) const +Bitmap Bitmap::CreateMask( const Color& rTransColor, sal_uInt8 nTol ) const { ScopedReadAccess pReadAcc(const_cast<Bitmap&>(*this)); @@ -1534,7 +1534,7 @@ bool Bitmap::Replace( const AlphaMask& rAlpha, const Color& rMergeColor ) return bRet; } -bool Bitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) +bool Bitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol ) { if( mxImpBmp ) { @@ -1609,7 +1609,7 @@ bool Bitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, sal } bool Bitmap::Replace( const Color* pSearchColors, const Color* pReplaceColors, - sal_uLong nColorCount, sal_uLong* _pTols ) + sal_uLong nColorCount, sal_uInt8 const * pTols ) { // Bitmaps with 1 bit color depth can cause problems // if they have other entries than black/white in their palette @@ -1627,28 +1627,35 @@ bool Bitmap::Replace( const Color* pSearchColors, const Color* pReplaceColors, std::unique_ptr<long[]> pMaxG(new long[ nColorCount ]); std::unique_ptr<long[]> pMinB(new long[ nColorCount ]); std::unique_ptr<long[]> pMaxB(new long[ nColorCount ]); - long* pTols; - sal_uLong i; - if( !_pTols ) + if( pTols ) { - pTols = new long[ nColorCount ]; - memset( pTols, 0, nColorCount * sizeof( long ) ); + for( sal_uLong i = 0; i < nColorCount; i++ ) + { + const Color& rCol = pSearchColors[ i ]; + const sal_uInt8 nTol = pTols[ i ]; + + pMinR[ i ] = MinMax<long>(rCol.GetRed() - nTol, 0, 255); + pMaxR[ i ] = MinMax<long>(rCol.GetRed() + nTol, 0, 255); + pMinG[ i ] = MinMax<long>(rCol.GetGreen() - nTol, 0, 255); + pMaxG[ i ] = MinMax<long>(rCol.GetGreen() + nTol, 0, 255); + pMinB[ i ] = MinMax<long>(rCol.GetBlue() - nTol, 0, 255); + pMaxB[ i ] = MinMax<long>(rCol.GetBlue() + nTol, 0, 255); + } } else - pTols = reinterpret_cast<long*>(_pTols); - - for( i = 0; i < nColorCount; i++ ) { - const Color& rCol = pSearchColors[ i ]; - const long nTol = pTols[ i ]; - - pMinR[ i ] = MinMax<long>(rCol.GetRed() - nTol, 0, 255); - pMaxR[ i ] = MinMax<long>(rCol.GetRed() + nTol, 0, 255); - pMinG[ i ] = MinMax<long>(rCol.GetGreen() - nTol, 0, 255); - pMaxG[ i ] = MinMax<long>(rCol.GetGreen() + nTol, 0, 255); - pMinB[ i ] = MinMax<long>(rCol.GetBlue() - nTol, 0, 255); - pMaxB[ i ] = MinMax<long>(rCol.GetBlue() + nTol, 0, 255); + for( sal_uLong i = 0; i < nColorCount; i++ ) + { + const Color& rCol = pSearchColors[ i ]; + + pMinR[ i ] = rCol.GetRed(); + pMaxR[ i ] = rCol.GetRed(); + pMinG[ i ] = rCol.GetGreen(); + pMaxG[ i ] = rCol.GetGreen(); + pMinB[ i ] = rCol.GetBlue(); + pMaxB[ i ] = rCol.GetBlue(); + } } if( pAcc->HasPalette() ) @@ -1657,7 +1664,7 @@ bool Bitmap::Replace( const Color* pSearchColors, const Color* pReplaceColors, { const BitmapColor& rCol = pAcc->GetPaletteColor( nEntry ); - for( i = 0; i < nColorCount; i++ ) + for( sal_uLong i = 0; i < nColorCount; i++ ) { if( pMinR[ i ] <= rCol.GetRed() && pMaxR[ i ] >= rCol.GetRed() && pMinG[ i ] <= rCol.GetGreen() && pMaxG[ i ] >= rCol.GetGreen() && @@ -1674,7 +1681,7 @@ bool Bitmap::Replace( const Color* pSearchColors, const Color* pReplaceColors, BitmapColor aCol; std::unique_ptr<BitmapColor[]> pReplaces(new BitmapColor[ nColorCount ]); - for( i = 0; i < nColorCount; i++ ) + for( sal_uLong i = 0; i < nColorCount; i++ ) pReplaces[ i ] = pAcc->GetBestMatchingColor( pReplaceColors[ i ] ); for( long nY = 0, nHeight = pAcc->Height(); nY < nHeight; nY++ ) @@ -1683,7 +1690,7 @@ bool Bitmap::Replace( const Color* pSearchColors, const Color* pReplaceColors, { aCol = pAcc->GetPixel( nY, nX ); - for( i = 0; i < nColorCount; i++ ) + for( sal_uLong i = 0; i < nColorCount; i++ ) { if( pMinR[ i ] <= aCol.GetRed() && pMaxR[ i ] >= aCol.GetRed() && pMinG[ i ] <= aCol.GetGreen() && pMaxG[ i ] >= aCol.GetGreen() && @@ -1697,9 +1704,6 @@ bool Bitmap::Replace( const Color* pSearchColors, const Color* pReplaceColors, } } - if( !_pTols ) - delete[] pTols; - pAcc.reset(); bRet = true; } diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx index 658a53a5e429..59e519a83b95 100644 --- a/vcl/source/gdi/bitmapex.cxx +++ b/vcl/source/gdi/bitmapex.cxx @@ -617,9 +617,9 @@ bool BitmapEx::Replace( const Color& rSearchColor, const Color& rReplaceColor ) return !!aBitmap && aBitmap.Replace( rSearchColor, rReplaceColor ); } -bool BitmapEx::Replace( const Color* pSearchColors, const Color* pReplaceColors, sal_uLong nColorCount, const sal_uLong* pTols ) +bool BitmapEx::Replace( const Color* pSearchColors, const Color* pReplaceColors, sal_uLong nColorCount, const sal_uInt8* pTols ) { - return !!aBitmap && aBitmap.Replace( pSearchColors, pReplaceColors, nColorCount, const_cast<sal_uLong*>(pTols) ); + return !!aBitmap && aBitmap.Replace( pSearchColors, pReplaceColors, nColorCount, pTols ); } bool BitmapEx::Adjust( short nLuminancePercent, short nContrastPercent, diff --git a/vcl/source/gdi/impbmp.cxx b/vcl/source/gdi/impbmp.cxx index 9a7d388f2f7a..97b5182a7927 100644 --- a/vcl/source/gdi/impbmp.cxx +++ b/vcl/source/gdi/impbmp.cxx @@ -112,7 +112,7 @@ bool ImpBitmap::ImplScale( const double& rScaleX, const double& rScaleY, BmpScal return mpSalBitmap->Scale( rScaleX, rScaleY, nScaleFlag ); } -bool ImpBitmap::ImplReplace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) +bool ImpBitmap::ImplReplace( const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol ) { return mpSalBitmap->Replace( rSearchColor, rReplaceColor, nTol ); } diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx index 69b9fd1ca3e9..d599a39aaf1d 100644 --- a/vcl/unx/generic/gdi/salbmp.cxx +++ b/vcl/unx/generic/gdi/salbmp.cxx @@ -916,7 +916,7 @@ bool X11SalBitmap::Scale( const double& /*rScaleX*/, const double& /*rScaleY*/, return false; } -bool X11SalBitmap::Replace( const Color& /*rSearchColor*/, const Color& /*rReplaceColor*/, sal_uLong /*nTol*/ ) +bool X11SalBitmap::Replace( const Color& /*rSearchColor*/, const Color& /*rReplaceColor*/, sal_uInt8 /*nTol*/ ) { return false; } diff --git a/vcl/win/gdi/salbmp.cxx b/vcl/win/gdi/salbmp.cxx index 3cef654924f3..e8110226ce2b 100644 --- a/vcl/win/gdi/salbmp.cxx +++ b/vcl/win/gdi/salbmp.cxx @@ -1077,7 +1077,7 @@ bool WinSalBitmap::Scale( const double& /*rScaleX*/, const double& /*rScaleY*/, return false; } -bool WinSalBitmap::Replace( const Color& /*rSearchColor*/, const Color& /*rReplaceColor*/, sal_uLong /*nTol*/ ) +bool WinSalBitmap::Replace( const Color& /*rSearchColor*/, const Color& /*rReplaceColor*/, sal_uInt8 /*nTol*/ ) { return false; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits