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, 125 insertions, 118 deletions
diff --git a/include/svx/bmpmask.hxx b/include/svx/bmpmask.hxx index 10d3383367fb..7231742d4753 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_uInt8* pTols ); + sal_uIntPtr* pTols ); Bitmap ImpMask( const Bitmap& rBitmap ); GDIMetaFile ImpMask( const GDIMetaFile& rMtf ); Animation ImpMask( const Animation& rAnimation ); BitmapEx ImpMaskTransparent( const BitmapEx& rBitmapEx, const Color& rColor, - sal_uInt8 nTol ); + const long nTol ); GDIMetaFile GetMetaFile(const Graphic& rGraphic); diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx index f6600ecdac9a..f2cd512b3158 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 as transparent. + corresponding pixel is still regarded transparent. @return the resulting bitmask. */ - Bitmap CreateMask( const Color& rTransColor, sal_uInt8 nTol = 0 ) const; + Bitmap CreateMask( const Color& rTransColor, sal_uLong 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_uInt8 nTol = 0 ); + bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong 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, - const sal_uInt8* pTols ); + sal_uLong* pTols ); /** Convert the bitmap to a meta file diff --git a/include/vcl/bitmapex.hxx b/include/vcl/bitmapex.hxx index a850572357e9..3cef293b4e11 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_uInt8* pTols = nullptr ); + const sal_uLong* pTols = nullptr ); /** Change various global color characteristics diff --git a/svtools/source/graphic/transformer.cxx b/svtools/source/graphic/transformer.cxx index 72cc863bee20..dbb6bfc0160a 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 a59662979ffd..f989dce82bab 100644 --- a/svx/source/dialog/_bmpmask.cxx +++ b/svx/source/dialog/_bmpmask.cxx @@ -41,9 +41,7 @@ #define TEST_COLS() \ { \ - sal_uInt8 nR = aCol.GetRed(); \ - sal_uInt8 nG = aCol.GetGreen(); \ - sal_uInt8 nB = aCol.GetBlue(); \ + nR = aCol.GetRed(); nG = aCol.GetGreen(); nB = aCol.GetBlue(); \ for( i = 0; i < nCount; i++ ) \ { \ if ( ( pMinR[i] <= nR ) && ( pMaxR[i] >= nR ) && \ @@ -576,7 +574,7 @@ void SvxBmpMask::SetExecState( bool bEnable ) } -sal_uInt16 SvxBmpMask::InitColorArrays( Color* pSrcCols, Color* pDstCols, sal_uInt8* pTols ) +sal_uInt16 SvxBmpMask::InitColorArrays( Color* pSrcCols, Color* pDstCols, sal_uIntPtr* pTols ) { sal_uInt16 nCount = 0; @@ -584,28 +582,28 @@ sal_uInt16 SvxBmpMask::InitColorArrays( Color* pSrcCols, Color* pDstCols, sal_uI { pSrcCols[nCount] = m_pQSet1->GetItemColor( 1 ); pDstCols[nCount] = m_pLbColor1->GetSelectEntryColor(); - pTols[nCount++] = sal_uInt8(m_pSp1->GetValue()); + pTols[nCount++] = static_cast<sal_uIntPtr>(m_pSp1->GetValue()); } if ( m_pCbx2->IsChecked() ) { pSrcCols[nCount] = m_pQSet2->GetItemColor( 1 ); pDstCols[nCount] = m_pLbColor2->GetSelectEntryColor(); - pTols[nCount++] = sal_uInt8(m_pSp2->GetValue()); + pTols[nCount++] = static_cast<sal_uIntPtr>(m_pSp2->GetValue()); } if ( m_pCbx3->IsChecked() ) { pSrcCols[nCount] = m_pQSet3->GetItemColor( 1 ); pDstCols[nCount] = m_pLbColor3->GetSelectEntryColor(); - pTols[nCount++] = sal_uInt8(m_pSp3->GetValue()); + pTols[nCount++] = static_cast<sal_uIntPtr>(m_pSp3->GetValue()); } if ( m_pCbx4->IsChecked() ) { pSrcCols[nCount] = m_pQSet4->GetItemColor( 1 ); pDstCols[nCount] = m_pLbColor4->GetSelectEntryColor(); - pTols[nCount++] = sal_uInt8(m_pSp4->GetValue()); + pTols[nCount++] = static_cast<sal_uIntPtr>(m_pSp4->GetValue()); } return nCount; @@ -616,7 +614,7 @@ Bitmap SvxBmpMask::ImpMask( const Bitmap& rBitmap ) Bitmap aBitmap( rBitmap ); Color pSrcCols[4]; Color pDstCols[4]; - sal_uInt8 pTols[4]; + sal_uIntPtr pTols[4]; const sal_uInt16 nCount = InitColorArrays( pSrcCols, pDstCols, pTols ); EnterWait(); @@ -626,7 +624,7 @@ Bitmap SvxBmpMask::ImpMask( const Bitmap& rBitmap ) return aBitmap; } -BitmapEx SvxBmpMask::ImpMaskTransparent( const BitmapEx& rBitmapEx, const Color& rColor, sal_uInt8 nTol ) +BitmapEx SvxBmpMask::ImpMaskTransparent( const BitmapEx& rBitmapEx, const Color& rColor, const long nTol ) { EnterWait(); @@ -646,7 +644,11 @@ BitmapEx SvxBmpMask::ImpMaskTransparent( const BitmapEx& rBitmapEx, const Color& Animation SvxBmpMask::ImpMask( const Animation& rAnimation ) { Animation aAnimation( rAnimation ); - sal_uInt16 nAnimationCount = aAnimation.Count(); + Color pSrcCols[4]; + Color pDstCols[4]; + sal_uIntPtr pTols[4]; + InitColorArrays( pSrcCols, pDstCols, pTols ); + sal_uInt16 nAnimationCount = aAnimation.Count(); for( sal_uInt16 i = 0; i < nAnimationCount; i++ ) { @@ -664,7 +666,7 @@ GDIMetaFile SvxBmpMask::ImpMask( const GDIMetaFile& rMtf ) GDIMetaFile aMtf; Color pSrcCols[4]; Color pDstCols[4]; - sal_uInt8 pTols[4]; + sal_uIntPtr pTols[4]; sal_uInt16 nCount = InitColorArrays( pSrcCols, pDstCols, pTols ); // If no color is selected, we copy only the Mtf @@ -674,12 +676,15 @@ GDIMetaFile SvxBmpMask::ImpMask( const GDIMetaFile& rMtf ) { bool pTrans[4]; Color aCol; - 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]); + 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]); sal_uInt16 i; aMtf.SetPrefSize( rMtf.GetPrefSize() ); @@ -688,19 +693,19 @@ GDIMetaFile SvxBmpMask::ImpMask( const GDIMetaFile& rMtf ) // Prepare Color comparison array for( i = 0; i < nCount; i++ ) { - sal_uInt8 nTol = ( pTols[i] * 255 ) / 100; + long nTol = ( pTols[i] * 255L ) / 100L; - sal_uInt8 nVal = pSrcCols[i].GetRed(); - pMinR[i] = std::max<sal_uInt8>( nVal - nTol, 0 ); - pMaxR[i] = std::min<sal_uInt8>( nVal + nTol, 255 ); + long nVal = (long) pSrcCols[i].GetRed(); + pMinR[i] = std::max( nVal - nTol, 0L ); + pMaxR[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].GetGreen() ); + pMinG[i] = std::max( nVal - nTol, 0L ); + pMaxG[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 ); + nVal = ( (long) pSrcCols[i].GetBlue() ); + pMinB[i] = std::max( nVal - nTol, 0L ); + pMaxB[i] = std::min( nVal + nTol, 255L ); pTrans[ i ] = (pDstCols[ i ] == COL_TRANSPARENT); } @@ -1016,7 +1021,7 @@ Graphic SvxBmpMask::Mask( const Graphic& rGraphic ) { Color pSrcCols[4]; Color pDstCols[4]; - sal_uInt8 pTols[4]; + sal_uIntPtr 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 9059030fc3ca..3ab740b5dfab 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 sal_uInt8 nTol(m_pMtfTolerance->GetValue() * 255L / 100L); + const long nTol = static_cast<long>(m_pMtfTolerance->GetValue() * 255L / 100L); aMask = aBmp.CreateMask( rColor, nTol ); diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx index 0ba815998d8f..6f94814b3576 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_uInt8 /*nTol*/ ) +bool SvpSalBitmap::Replace( const ::Color& /*rSearchColor*/, const ::Color& /*rReplaceColor*/, sal_uLong /*nTol*/ ) { return false; } diff --git a/vcl/inc/headless/svpbmp.hxx b/vcl/inc/headless/svpbmp.hxx index efdd2c2bb2af..884d9d13aecc 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_uInt8 nTol ) override; + virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) override; }; #endif // INCLUDED_VCL_INC_HEADLESS_SVPBMP_HXX diff --git a/vcl/inc/impbmp.hxx b/vcl/inc/impbmp.hxx index 9465771332e8..a6212693498e 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_uInt8 nTol ); + bool ImplReplace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ); bool ImplConvert( BmpConversion eConversion ); }; diff --git a/vcl/inc/opengl/salbmp.hxx b/vcl/inc/opengl/salbmp.hxx index 5c4fcd053464..999df6b321a2 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_uInt8 nTol ) override; + bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) override; bool ConvertToGreyscale() override; public: diff --git a/vcl/inc/quartz/salbmp.h b/vcl/inc/quartz/salbmp.h index d7c2fb74db51..a4dca65c0ee3 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_uInt8 nTol ) override; + bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) override; private: // quartz helper diff --git a/vcl/inc/salbmp.hxx b/vcl/inc/salbmp.hxx index 6053ab3d6ebd..a1014700a68a 100644 --- a/vcl/inc/salbmp.hxx +++ b/vcl/inc/salbmp.hxx @@ -23,7 +23,6 @@ #include <tools/gen.hxx> #include <vcl/checksum.hxx> #include <vcl/salbtype.hxx> -#include <vcl/bitmap.hxx> #include <com/sun/star/rendering/XBitmapCanvas.hpp> @@ -67,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_uInt8 nTol ) = 0; + virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) = 0; virtual bool ConvertToGreyscale() { diff --git a/vcl/inc/unx/salbmp.h b/vcl/inc/unx/salbmp.h index 3f45cd5d853c..a2dd587a4964 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_uInt8 nTol ) override; + virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) override; }; diff --git a/vcl/inc/win/salbmp.h b/vcl/inc/win/salbmp.h index f139a8608b30..33d88bb92a30 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_uInt8 nTol ) override; + virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) override; }; #endif // INCLUDED_VCL_INC_WIN_SALBMP_H diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx index 93fcf0e670c2..36896fafe305 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_uInt8 nTol ) +bool OpenGLSalBitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) { VCL_GL_INFO("::Replace"); diff --git a/vcl/quartz/salbmp.cxx b/vcl/quartz/salbmp.cxx index 8082621cc5f9..b96e25421686 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_uInt8 /*nTol*/ ) +bool QuartzSalBitmap::Replace( const Color& /*rSearchColor*/, const Color& /*rReplaceColor*/, sal_uLong /*nTol*/ ) { return false; } diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx index e977ceea9bed..ad70291b08be 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_uInt8 nTol ) const +Bitmap Bitmap::CreateMask( const Color& rTransColor, sal_uLong nTol ) const { ScopedReadAccess pReadAcc(const_cast<Bitmap&>(*this)); @@ -1244,12 +1244,14 @@ Bitmap Bitmap::CreateMask( const Color& rTransColor, sal_uInt8 nTol ) const } else { - 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); + 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); if( pReadAcc->HasPalette() ) { @@ -1257,10 +1259,10 @@ Bitmap Bitmap::CreateMask( const Color& rTransColor, sal_uInt8 nTol ) const { for( long nX = 0; nX < nWidth; nX++ ) { - BitmapColor aCol = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, nX ) ); - sal_uInt8 nR = aCol.GetRed(); - sal_uInt8 nG = aCol.GetGreen(); - sal_uInt8 nB = aCol.GetBlue(); + aCol = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, nX ) ); + nR = aCol.GetRed(); + nG = aCol.GetGreen(); + nB = aCol.GetBlue(); if( nMinR <= nR && nMaxR >= nR && nMinG <= nG && nMaxG >= nG && @@ -1279,10 +1281,10 @@ Bitmap Bitmap::CreateMask( const Color& rTransColor, sal_uInt8 nTol ) const { for( long nX = 0; nX < nWidth; nX++ ) { - BitmapColor aCol = pReadAcc->GetPixel( nY, nX ); - sal_uInt8 nR = aCol.GetRed(); - sal_uInt8 nG = aCol.GetGreen(); - sal_uInt8 nB = aCol.GetBlue(); + aCol = pReadAcc->GetPixel( nY, nX ); + nR = aCol.GetRed(); + nG = aCol.GetGreen(); + nB = aCol.GetBlue(); if( nMinR <= nR && nMaxR >= nR && nMinG <= nG && nMaxG >= nG && @@ -1532,7 +1534,7 @@ bool Bitmap::Replace( const AlphaMask& rAlpha, const Color& rMergeColor ) return bRet; } -bool Bitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol ) +bool Bitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) { if( mxImpBmp ) { @@ -1557,12 +1559,12 @@ bool Bitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, sal if( pAcc ) { - 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); + 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); if( pAcc->HasPalette() ) { @@ -1607,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, const sal_uInt8* _pTols ) + sal_uLong nColorCount, sal_uLong* _pTols ) { // Bitmaps with 1 bit color depth can cause problems // if they have other entries than black/white in their palette @@ -1619,35 +1621,34 @@ bool Bitmap::Replace( const Color* pSearchColors, const Color* pReplaceColors, if( pAcc ) { - 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; + 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; sal_uLong i; if( !_pTols ) { - auto p = new sal_uInt8[ nColorCount ]; - memset( p, 0, nColorCount * sizeof( sal_uInt8 ) ); - pTols = p; + pTols = new long[ nColorCount ]; + memset( pTols, 0, nColorCount * sizeof( long ) ); } else - pTols = _pTols; + pTols = reinterpret_cast<long*>(_pTols); for( i = 0; i < nColorCount; i++ ) { const Color& rCol = pSearchColors[ i ]; - 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); + 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); } if( pAcc->HasPalette() ) diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx index 59e519a83b95..658a53a5e429 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_uInt8* pTols ) +bool BitmapEx::Replace( const Color* pSearchColors, const Color* pReplaceColors, sal_uLong nColorCount, const sal_uLong* pTols ) { - return !!aBitmap && aBitmap.Replace( pSearchColors, pReplaceColors, nColorCount, pTols ); + return !!aBitmap && aBitmap.Replace( pSearchColors, pReplaceColors, nColorCount, const_cast<sal_uLong*>(pTols) ); } bool BitmapEx::Adjust( short nLuminancePercent, short nContrastPercent, diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index 7450276e978a..8f65412faba3 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -96,12 +96,12 @@ struct ImplBmpMonoParam struct ImplColReplaceParam { - sal_uInt8* pMinR; - sal_uInt8* pMaxR; - sal_uInt8* pMinG; - sal_uInt8* pMaxG; - sal_uInt8* pMinB; - sal_uInt8* pMaxB; + sal_uLong* pMinR; + sal_uLong* pMaxR; + sal_uLong* pMinG; + sal_uLong* pMaxG; + sal_uLong* pMinB; + sal_uLong* pMaxB; const Color* pDstCols; sal_uLong nCount; }; @@ -110,7 +110,8 @@ struct ImplBmpReplaceParam { const Color* pSrcCols; const Color* pDstCols; - sal_uLong nCount; + sal_uLong nCount; + const sal_uLong* pTols; }; GDIMetaFile::GDIMetaFile() : @@ -1797,7 +1798,7 @@ BitmapEx GDIMetaFile::ImplBmpMonoFnc( const BitmapEx& rBmpEx, const void* pBmpPa Color GDIMetaFile::ImplColReplaceFnc( const Color& rColor, const void* pColParam ) { - const sal_uInt8 nR = rColor.GetRed(), nG = rColor.GetGreen(), nB = rColor.GetBlue(); + const sal_uLong nR = rColor.GetRed(), nG = rColor.GetGreen(), nB = rColor.GetBlue(); for( sal_uLong i = 0; i < static_cast<const ImplColReplaceParam*>(pColParam)->nCount; i++ ) { @@ -1820,7 +1821,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, nullptr ); + aRet.Replace( p->pSrcCols, p->pDstCols, p->nCount, p->pTols ); return aRet; } @@ -2191,28 +2192,28 @@ void GDIMetaFile::ReplaceColors( const Color* pSearchColors, const Color* pRepla ImplColReplaceParam aColParam; ImplBmpReplaceParam aBmpParam; - 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 ]; + 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 ]; for( sal_uLong i = 0; i < nColorCount; i++ ) { - sal_uInt8 nVal; + long nVal; nVal = pSearchColors[ i ].GetRed(); - aColParam.pMinR[ i ] = std::max<sal_uInt8>( nVal, 0L ); - aColParam.pMaxR[ i ] = std::min<sal_uInt8>( nVal, 255L ); + aColParam.pMinR[ i ] = (sal_uLong) std::max( nVal, 0L ); + aColParam.pMaxR[ i ] = (sal_uLong) std::min( nVal, 255L ); nVal = pSearchColors[ i ].GetGreen(); - aColParam.pMinG[ i ] = std::max<sal_uInt8>( nVal, 0L ); - aColParam.pMaxG[ i ] = std::min<sal_uInt8>( nVal, 255L ); + aColParam.pMinG[ i ] = (sal_uLong) std::max( nVal, 0L ); + aColParam.pMaxG[ i ] = (sal_uLong) std::min( nVal, 255L ); nVal = pSearchColors[ i ].GetBlue(); - aColParam.pMinB[ i ] = std::max<sal_uInt8>( nVal, 0L ); - aColParam.pMaxB[ i ] = std::min<sal_uInt8>( nVal, 255L ); + aColParam.pMinB[ i ] = (sal_uLong) std::max( nVal, 0L ); + aColParam.pMaxB[ i ] = (sal_uLong) std::min( nVal, 255L ); } aColParam.pDstCols = pReplaceColors; @@ -2221,6 +2222,7 @@ 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 97b5182a7927..9a7d388f2f7a 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_uInt8 nTol ) +bool ImpBitmap::ImplReplace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) { return mpSalBitmap->Replace( rSearchColor, rReplaceColor, nTol ); } diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx index d599a39aaf1d..69b9fd1ca3e9 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_uInt8 /*nTol*/ ) +bool X11SalBitmap::Replace( const Color& /*rSearchColor*/, const Color& /*rReplaceColor*/, sal_uLong /*nTol*/ ) { return false; } diff --git a/vcl/win/gdi/salbmp.cxx b/vcl/win/gdi/salbmp.cxx index e8110226ce2b..3cef654924f3 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_uInt8 /*nTol*/ ) +bool WinSalBitmap::Replace( const Color& /*rSearchColor*/, const Color& /*rReplaceColor*/, sal_uLong /*nTol*/ ) { return false; } |