diff options
-rw-r--r-- | include/svx/bmpmask.hxx | 4 | ||||
-rw-r--r-- | include/vcl/bitmap.hxx | 8 | ||||
-rw-r--r-- | include/vcl/bitmapex.hxx | 2 | ||||
-rw-r--r-- | svtools/source/graphic/transformer.cxx | 2 | ||||
-rw-r--r-- | svx/source/dialog/_bmpmask.cxx | 63 | ||||
-rw-r--r-- | svx/source/dialog/_contdlg.cxx | 2 | ||||
-rw-r--r-- | vcl/headless/svpbmp.cxx | 2 | ||||
-rw-r--r-- | vcl/inc/headless/svpbmp.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/impbmp.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/opengl/salbmp.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/quartz/salbmp.h | 2 | ||||
-rw-r--r-- | vcl/inc/salbmp.hxx | 3 | ||||
-rw-r--r-- | vcl/inc/unx/salbmp.h | 2 | ||||
-rw-r--r-- | vcl/inc/win/salbmp.h | 2 | ||||
-rw-r--r-- | vcl/opengl/salbmp.cxx | 2 | ||||
-rw-r--r-- | vcl/quartz/salbmp.cxx | 2 | ||||
-rw-r--r-- | vcl/source/gdi/bitmap.cxx | 85 | ||||
-rw-r--r-- | vcl/source/gdi/bitmapex.cxx | 4 | ||||
-rw-r--r-- | vcl/source/gdi/gdimtf.cxx | 46 | ||||
-rw-r--r-- | vcl/source/gdi/impbmp.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/salbmp.cxx | 2 | ||||
-rw-r--r-- | vcl/win/gdi/salbmp.cxx | 2 |
22 files changed, 118 insertions, 125 deletions
diff --git a/include/svx/bmpmask.hxx b/include/svx/bmpmask.hxx index 7231742d4753..10d3383367fb 100644 --- a/include/svx/bmpmask.hxx +++ b/include/svx/bmpmask.hxx @@ -131,14 +131,14 @@ class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxBmpMask : public SfxDockingWindow virtual bool Close() override; sal_uInt16 InitColorArrays( Color* pSrcCols, Color* pDstCols, - sal_uIntPtr* pTols ); + 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 ); + sal_uInt8 nTol ); GDIMetaFile GetMetaFile(const Graphic& rGraphic); diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx index f2cd512b3158..f6600ecdac9a 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 ); + const sal_uInt8* pTols ); /** Convert the bitmap to a meta file diff --git a/include/vcl/bitmapex.hxx b/include/vcl/bitmapex.hxx index 705109e2203a..c7a7bc7e2e59 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/svtools/source/graphic/transformer.cxx b/svtools/source/graphic/transformer.cxx index dbb6bfc0160a..72cc863bee20 100644 --- a/svtools/source/graphic/transformer.cxx +++ b/svtools/source/graphic/transformer.cxx @@ -112,7 +112,7 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange( if ( ( nAlphaTo == 0 ) || ( nAlphaTo == sal::static_int_cast<sal_Int8>(0xff) ) ) { Bitmap aMask( aBitmap.CreateMask( aColorFrom, nTolerance ) ); - aBitmap.Replace( aColorFrom, aColorTo, nTolerance ); + aBitmap.Replace( aColorFrom, aColorTo, nTolerance ); aGraphic = ::Graphic( BitmapEx( aBitmap, aMask ) ); } else diff --git a/svx/source/dialog/_bmpmask.cxx b/svx/source/dialog/_bmpmask.cxx index f989dce82bab..a59662979ffd 100644 --- a/svx/source/dialog/_bmpmask.cxx +++ b/svx/source/dialog/_bmpmask.cxx @@ -41,7 +41,9 @@ #define TEST_COLS() \ { \ - nR = aCol.GetRed(); nG = aCol.GetGreen(); nB = aCol.GetBlue(); \ + sal_uInt8 nR = aCol.GetRed(); \ + sal_uInt8 nG = aCol.GetGreen(); \ + sal_uInt8 nB = aCol.GetBlue(); \ for( i = 0; i < nCount; i++ ) \ { \ if ( ( pMinR[i] <= nR ) && ( pMaxR[i] >= nR ) && \ @@ -574,7 +576,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; @@ -582,28 +584,28 @@ sal_uInt16 SvxBmpMask::InitColorArrays( Color* pSrcCols, Color* pDstCols, sal_uI { pSrcCols[nCount] = m_pQSet1->GetItemColor( 1 ); pDstCols[nCount] = m_pLbColor1->GetSelectEntryColor(); - pTols[nCount++] = static_cast<sal_uIntPtr>(m_pSp1->GetValue()); + pTols[nCount++] = sal_uInt8(m_pSp1->GetValue()); } if ( m_pCbx2->IsChecked() ) { pSrcCols[nCount] = m_pQSet2->GetItemColor( 1 ); pDstCols[nCount] = m_pLbColor2->GetSelectEntryColor(); - pTols[nCount++] = static_cast<sal_uIntPtr>(m_pSp2->GetValue()); + pTols[nCount++] = sal_uInt8(m_pSp2->GetValue()); } if ( m_pCbx3->IsChecked() ) { pSrcCols[nCount] = m_pQSet3->GetItemColor( 1 ); pDstCols[nCount] = m_pLbColor3->GetSelectEntryColor(); - pTols[nCount++] = static_cast<sal_uIntPtr>(m_pSp3->GetValue()); + pTols[nCount++] = sal_uInt8(m_pSp3->GetValue()); } if ( m_pCbx4->IsChecked() ) { pSrcCols[nCount] = m_pQSet4->GetItemColor( 1 ); pDstCols[nCount] = m_pLbColor4->GetSelectEntryColor(); - pTols[nCount++] = static_cast<sal_uIntPtr>(m_pSp4->GetValue()); + pTols[nCount++] = sal_uInt8(m_pSp4->GetValue()); } return nCount; @@ -614,7 +616,7 @@ Bitmap SvxBmpMask::ImpMask( const Bitmap& rBitmap ) Bitmap aBitmap( rBitmap ); Color pSrcCols[4]; Color pDstCols[4]; - sal_uIntPtr pTols[4]; + sal_uInt8 pTols[4]; const sal_uInt16 nCount = InitColorArrays( pSrcCols, pDstCols, pTols ); EnterWait(); @@ -624,7 +626,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, sal_uInt8 nTol ) { EnterWait(); @@ -644,11 +646,7 @@ BitmapEx SvxBmpMask::ImpMaskTransparent( const BitmapEx& rBitmapEx, const Color& Animation SvxBmpMask::ImpMask( const Animation& rAnimation ) { Animation aAnimation( rAnimation ); - Color pSrcCols[4]; - Color pDstCols[4]; - sal_uIntPtr 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,7 +664,7 @@ GDIMetaFile SvxBmpMask::ImpMask( const GDIMetaFile& rMtf ) GDIMetaFile aMtf; Color pSrcCols[4]; Color pDstCols[4]; - sal_uIntPtr pTols[4]; + sal_uInt8 pTols[4]; sal_uInt16 nCount = InitColorArrays( pSrcCols, pDstCols, pTols ); // If no color is selected, we copy only the Mtf @@ -676,15 +674,12 @@ GDIMetaFile SvxBmpMask::ImpMask( const GDIMetaFile& rMtf ) { bool pTrans[4]; Color aCol; - long nR; - long nG; - long nB; - std::unique_ptr<long[]> pMinR(new long[nCount]); - std::unique_ptr<long[]> pMaxR(new long[nCount]); - std::unique_ptr<long[]> pMinG(new long[nCount]); - std::unique_ptr<long[]> pMaxG(new long[nCount]); - std::unique_ptr<long[]> pMinB(new long[nCount]); - std::unique_ptr<long[]> pMaxB(new long[nCount]); + std::unique_ptr<sal_uInt8[]> pMinR(new sal_uInt8[nCount]); + std::unique_ptr<sal_uInt8[]> pMaxR(new sal_uInt8[nCount]); + std::unique_ptr<sal_uInt8[]> pMinG(new sal_uInt8[nCount]); + std::unique_ptr<sal_uInt8[]> pMaxG(new sal_uInt8[nCount]); + std::unique_ptr<sal_uInt8[]> pMinB(new sal_uInt8[nCount]); + std::unique_ptr<sal_uInt8[]> pMaxB(new sal_uInt8[nCount]); sal_uInt16 i; aMtf.SetPrefSize( rMtf.GetPrefSize() ); @@ -693,19 +688,19 @@ GDIMetaFile SvxBmpMask::ImpMask( const GDIMetaFile& rMtf ) // Prepare Color comparison array for( i = 0; i < nCount; i++ ) { - long nTol = ( pTols[i] * 255L ) / 100L; + sal_uInt8 nTol = ( pTols[i] * 255 ) / 100; - long nVal = (long) pSrcCols[i].GetRed(); - pMinR[i] = std::max( nVal - nTol, 0L ); - pMaxR[i] = std::min( nVal + nTol, 255L ); + sal_uInt8 nVal = pSrcCols[i].GetRed(); + pMinR[i] = std::max<sal_uInt8>( nVal - nTol, 0 ); + pMaxR[i] = std::min<sal_uInt8>( nVal + nTol, 255 ); - nVal = ( (long) pSrcCols[i].GetGreen() ); - pMinG[i] = std::max( nVal - nTol, 0L ); - pMaxG[i] = std::min( nVal + nTol, 255L ); + nVal = pSrcCols[i].GetGreen(); + pMinG[i] = std::max<sal_uInt8>( nVal - nTol, 0 ); + pMaxG[i] = std::min<sal_uInt8>( nVal + nTol, 255 ); - nVal = ( (long) pSrcCols[i].GetBlue() ); - pMinB[i] = std::max( nVal - nTol, 0L ); - pMaxB[i] = std::min( nVal + nTol, 255L ); + nVal = pSrcCols[i].GetBlue(); + pMinB[i] = std::max<sal_uInt8>( nVal - nTol, 0 ); + pMaxB[i] = std::min<sal_uInt8>( nVal + nTol, 255 ); pTrans[ i ] = (pDstCols[ i ] == COL_TRANSPARENT); } @@ -1021,7 +1016,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/svx/source/dialog/_contdlg.cxx b/svx/source/dialog/_contdlg.cxx index 692e8face2cd..22c8321d964d 100644 --- a/svx/source/dialog/_contdlg.cxx +++ b/svx/source/dialog/_contdlg.cxx @@ -685,7 +685,7 @@ IMPL_LINK( SvxSuperContourDlg, PipetteClickHdl, ContourWindow&, rWnd, void ) if( aGraphic.GetType() == GraphicType::Bitmap ) { Bitmap aBmp( aGraphic.GetBitmap() ); - const long nTol = static_cast<long>(m_pMtfTolerance->GetValue() * 255L / 100L); + const sal_uInt8 nTol(m_pMtfTolerance->GetValue() * 255L / 100L); aMask = aBmp.CreateMask( rColor, nTol ); diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx index ef907ccb5aeb..cb7a8654798a 100644 --- a/vcl/headless/svpbmp.cxx +++ b/vcl/headless/svpbmp.cxx @@ -290,7 +290,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 3f7f57aff1bd..a060f09bdcb4 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 47d0c0280400..574e6272d700 100644 --- a/vcl/inc/salbmp.hxx +++ b/vcl/inc/salbmp.hxx @@ -23,6 +23,7 @@ #include <tools/gen.hxx> #include <vcl/checksum.hxx> #include <vcl/salbtype.hxx> +#include <vcl/bitmap.hxx> #include <com/sun/star/rendering/XBitmapCanvas.hpp> @@ -68,7 +69,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 6a032200670e..b3f8f54c960f 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..e977ceea9bed 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)); @@ -1244,14 +1244,12 @@ Bitmap Bitmap::CreateMask( const Color& rTransColor, sal_uLong nTol ) const } else { - BitmapColor aCol; - long nR, nG, nB; - const long nMinR = MinMax<long>(rTransColor.GetRed() - nTol, 0, 255); - const long nMaxR = MinMax<long>(rTransColor.GetRed() + nTol, 0, 255); - const long nMinG = MinMax<long>(rTransColor.GetGreen() - nTol, 0, 255); - const long nMaxG = MinMax<long>(rTransColor.GetGreen() + nTol, 0, 255); - const long nMinB = MinMax<long>(rTransColor.GetBlue() - nTol, 0, 255); - const long nMaxB = MinMax<long>(rTransColor.GetBlue() + nTol, 0, 255); + const sal_uInt8 nMinR = MinMax<sal_uInt8>(rTransColor.GetRed() - nTol, 0, 255); + const sal_uInt8 nMaxR = MinMax<sal_uInt8>(rTransColor.GetRed() + nTol, 0, 255); + const sal_uInt8 nMinG = MinMax<sal_uInt8>(rTransColor.GetGreen() - nTol, 0, 255); + const sal_uInt8 nMaxG = MinMax<sal_uInt8>(rTransColor.GetGreen() + nTol, 0, 255); + const sal_uInt8 nMinB = MinMax<sal_uInt8>(rTransColor.GetBlue() - nTol, 0, 255); + const sal_uInt8 nMaxB = MinMax<sal_uInt8>(rTransColor.GetBlue() + nTol, 0, 255); if( pReadAcc->HasPalette() ) { @@ -1259,10 +1257,10 @@ Bitmap Bitmap::CreateMask( const Color& rTransColor, sal_uLong nTol ) const { for( long nX = 0; nX < nWidth; nX++ ) { - aCol = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, nX ) ); - nR = aCol.GetRed(); - nG = aCol.GetGreen(); - nB = aCol.GetBlue(); + BitmapColor aCol = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, nX ) ); + sal_uInt8 nR = aCol.GetRed(); + sal_uInt8 nG = aCol.GetGreen(); + sal_uInt8 nB = aCol.GetBlue(); if( nMinR <= nR && nMaxR >= nR && nMinG <= nG && nMaxG >= nG && @@ -1281,10 +1279,10 @@ Bitmap Bitmap::CreateMask( const Color& rTransColor, sal_uLong nTol ) const { for( long nX = 0; nX < nWidth; nX++ ) { - aCol = pReadAcc->GetPixel( nY, nX ); - nR = aCol.GetRed(); - nG = aCol.GetGreen(); - nB = aCol.GetBlue(); + BitmapColor aCol = pReadAcc->GetPixel( nY, nX ); + sal_uInt8 nR = aCol.GetRed(); + sal_uInt8 nG = aCol.GetGreen(); + sal_uInt8 nB = aCol.GetBlue(); if( nMinR <= nR && nMaxR >= nR && nMinG <= nG && nMaxG >= nG && @@ -1534,7 +1532,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 ) { @@ -1559,12 +1557,12 @@ bool Bitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, sal if( pAcc ) { - const long nMinR = MinMax<long>(rSearchColor.GetRed() - nTol, 0, 255); - const long nMaxR = MinMax<long>(rSearchColor.GetRed() + nTol, 0, 255); - const long nMinG = MinMax<long>(rSearchColor.GetGreen() - nTol, 0, 255); - const long nMaxG = MinMax<long>(rSearchColor.GetGreen() + nTol, 0, 255); - const long nMinB = MinMax<long>(rSearchColor.GetBlue() - nTol, 0, 255); - const long nMaxB = MinMax<long>(rSearchColor.GetBlue() + nTol, 0, 255); + const sal_uInt8 nMinR = MinMax<sal_uInt8>(rSearchColor.GetRed() - nTol, 0, 255); + const sal_uInt8 nMaxR = MinMax<sal_uInt8>(rSearchColor.GetRed() + nTol, 0, 255); + const sal_uInt8 nMinG = MinMax<sal_uInt8>(rSearchColor.GetGreen() - nTol, 0, 255); + const sal_uInt8 nMaxG = MinMax<sal_uInt8>(rSearchColor.GetGreen() + nTol, 0, 255); + const sal_uInt8 nMinB = MinMax<sal_uInt8>(rSearchColor.GetBlue() - nTol, 0, 255); + const sal_uInt8 nMaxB = MinMax<sal_uInt8>(rSearchColor.GetBlue() + nTol, 0, 255); if( pAcc->HasPalette() ) { @@ -1609,7 +1607,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, const sal_uInt8* _pTols ) { // Bitmaps with 1 bit color depth can cause problems // if they have other entries than black/white in their palette @@ -1621,34 +1619,35 @@ bool Bitmap::Replace( const Color* pSearchColors, const Color* pReplaceColors, if( pAcc ) { - std::unique_ptr<long[]> pMinR(new long[ nColorCount ]); - std::unique_ptr<long[]> pMaxR(new long[ nColorCount ]); - std::unique_ptr<long[]> pMinG(new long[ nColorCount ]); - 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; + std::unique_ptr<sal_uInt8[]> pMinR(new sal_uInt8[ nColorCount ]); + std::unique_ptr<sal_uInt8[]> pMaxR(new sal_uInt8[ nColorCount ]); + std::unique_ptr<sal_uInt8[]> pMinG(new sal_uInt8[ nColorCount ]); + std::unique_ptr<sal_uInt8[]> pMaxG(new sal_uInt8[ nColorCount ]); + std::unique_ptr<sal_uInt8[]> pMinB(new sal_uInt8[ nColorCount ]); + std::unique_ptr<sal_uInt8[]> pMaxB(new sal_uInt8[ nColorCount ]); + sal_uInt8 const * pTols; sal_uLong i; if( !_pTols ) { - pTols = new long[ nColorCount ]; - memset( pTols, 0, nColorCount * sizeof( long ) ); + auto p = new sal_uInt8[ nColorCount ]; + memset( p, 0, nColorCount * sizeof( sal_uInt8 ) ); + pTols = p; } else - pTols = reinterpret_cast<long*>(_pTols); + pTols = _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); + const sal_uInt8 nTol = pTols[ i ]; + + pMinR[ i ] = MinMax<sal_uInt8>(rCol.GetRed() - nTol, 0, 255); + pMaxR[ i ] = MinMax<sal_uInt8>(rCol.GetRed() + nTol, 0, 255); + pMinG[ i ] = MinMax<sal_uInt8>(rCol.GetGreen() - nTol, 0, 255); + pMaxG[ i ] = MinMax<sal_uInt8>(rCol.GetGreen() + nTol, 0, 255); + pMinB[ i ] = MinMax<sal_uInt8>(rCol.GetBlue() - nTol, 0, 255); + pMaxB[ i ] = MinMax<sal_uInt8>(rCol.GetBlue() + nTol, 0, 255); } if( pAcc->HasPalette() ) 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/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index 779bcbdcddc3..6bdea38bcb3e 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -95,12 +95,12 @@ struct ImplBmpMonoParam struct ImplColReplaceParam { - sal_uLong* pMinR; - sal_uLong* pMaxR; - sal_uLong* pMinG; - sal_uLong* pMaxG; - sal_uLong* pMinB; - sal_uLong* pMaxB; + sal_uInt8* pMinR; + sal_uInt8* pMaxR; + sal_uInt8* pMinG; + sal_uInt8* pMaxG; + sal_uInt8* pMinB; + sal_uInt8* pMaxB; const Color* pDstCols; sal_uLong nCount; }; @@ -109,8 +109,7 @@ struct ImplBmpReplaceParam { const Color* pSrcCols; const Color* pDstCols; - sal_uLong nCount; - const sal_uLong* pTols; + sal_uLong nCount; }; GDIMetaFile::GDIMetaFile() : @@ -1797,7 +1796,7 @@ BitmapEx GDIMetaFile::ImplBmpMonoFnc( const BitmapEx& rBmpEx, const void* pBmpPa Color GDIMetaFile::ImplColReplaceFnc( const Color& rColor, const void* pColParam ) { - const sal_uLong nR = rColor.GetRed(), nG = rColor.GetGreen(), nB = rColor.GetBlue(); + const sal_uInt8 nR = rColor.GetRed(), nG = rColor.GetGreen(), nB = rColor.GetBlue(); for( sal_uLong i = 0; i < static_cast<const ImplColReplaceParam*>(pColParam)->nCount; i++ ) { @@ -1820,7 +1819,7 @@ BitmapEx GDIMetaFile::ImplBmpReplaceFnc( const BitmapEx& rBmpEx, const void* pBm const ImplBmpReplaceParam* p = static_cast<const ImplBmpReplaceParam*>(pBmpParam); BitmapEx aRet( rBmpEx ); - aRet.Replace( p->pSrcCols, p->pDstCols, p->nCount, p->pTols ); + aRet.Replace( p->pSrcCols, p->pDstCols, p->nCount, nullptr ); return aRet; } @@ -2191,28 +2190,28 @@ void GDIMetaFile::ReplaceColors( const Color* pSearchColors, const Color* pRepla ImplColReplaceParam aColParam; ImplBmpReplaceParam aBmpParam; - aColParam.pMinR = new sal_uLong[ nColorCount ]; - aColParam.pMaxR = new sal_uLong[ nColorCount ]; - aColParam.pMinG = new sal_uLong[ nColorCount ]; - aColParam.pMaxG = new sal_uLong[ nColorCount ]; - aColParam.pMinB = new sal_uLong[ nColorCount ]; - aColParam.pMaxB = new sal_uLong[ nColorCount ]; + aColParam.pMinR = new sal_uInt8[ nColorCount ]; + aColParam.pMaxR = new sal_uInt8[ nColorCount ]; + aColParam.pMinG = new sal_uInt8[ nColorCount ]; + aColParam.pMaxG = new sal_uInt8[ nColorCount ]; + aColParam.pMinB = new sal_uInt8[ nColorCount ]; + aColParam.pMaxB = new sal_uInt8[ nColorCount ]; for( sal_uLong i = 0; i < nColorCount; i++ ) { - long nVal; + sal_uInt8 nVal; nVal = pSearchColors[ i ].GetRed(); - aColParam.pMinR[ i ] = (sal_uLong) std::max( nVal, 0L ); - aColParam.pMaxR[ i ] = (sal_uLong) std::min( nVal, 255L ); + aColParam.pMinR[ i ] = std::max<sal_uInt8>( nVal, 0L ); + aColParam.pMaxR[ i ] = std::min<sal_uInt8>( nVal, 255L ); nVal = pSearchColors[ i ].GetGreen(); - aColParam.pMinG[ i ] = (sal_uLong) std::max( nVal, 0L ); - aColParam.pMaxG[ i ] = (sal_uLong) std::min( nVal, 255L ); + aColParam.pMinG[ i ] = std::max<sal_uInt8>( nVal, 0L ); + aColParam.pMaxG[ i ] = std::min<sal_uInt8>( nVal, 255L ); nVal = pSearchColors[ i ].GetBlue(); - aColParam.pMinB[ i ] = (sal_uLong) std::max( nVal, 0L ); - aColParam.pMaxB[ i ] = (sal_uLong) std::min( nVal, 255L ); + aColParam.pMinB[ i ] = std::max<sal_uInt8>( nVal, 0L ); + aColParam.pMaxB[ i ] = std::min<sal_uInt8>( nVal, 255L ); } aColParam.pDstCols = pReplaceColors; @@ -2221,7 +2220,6 @@ void GDIMetaFile::ReplaceColors( const Color* pSearchColors, const Color* pRepla aBmpParam.pSrcCols = pSearchColors; aBmpParam.pDstCols = pReplaceColors; aBmpParam.nCount = nColorCount; - aBmpParam.pTols = nullptr; ImplExchangeColors( ImplColReplaceFnc, &aColParam, ImplBmpReplaceFnc, &aBmpParam ); diff --git a/vcl/source/gdi/impbmp.cxx b/vcl/source/gdi/impbmp.cxx index 4342bc8e6402..5950da46d7cc 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; } |