diff options
author | Herbert Dürr <hdu@apache.org> | 2012-10-19 15:12:40 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-05-09 11:18:22 +0100 |
commit | 78eca44c4db67848a85b600cc40e25d41bb647df (patch) | |
tree | 70b9352af07b4ac4678d44aaa88031eb5c225be7 /svtools | |
parent | aa0bc15b42e8d432def185089ea8fca17f3fd8c8 (diff) |
make conversions between BitmapColor and sal_uInt8 explicit
Implicit conversions are a dangerous cause of confusion as seen
in http://markmail.org/thread/a4copx2di7cxeowg and require tricky
rewrites to work around them, this change cleans them up and
disables them.
(cherry picked from commit 2d9d5c8d6beb7fb0a7dafa0c1c4d10a25d7200fd)
Conflicts:
filter/source/graphicfilter/egif/egif.cxx
filter/source/graphicfilter/epbm/epbm.cxx
filter/source/graphicfilter/epgm/epgm.cxx
filter/source/graphicfilter/ipbm/ipbm.cxx
filter/source/graphicfilter/ipsd/ipsd.cxx
sd/source/ui/slidesorter/view/SlsButtonBar.cxx
svtools/source/filter/igif/gifread.cxx
svtools/source/filter/jpeg/jpeg.cxx
svtools/source/filter/wmf/winwmf.cxx
svtools/source/graphic/grfmgr2.cxx
vcl/inc/vcl/bmpacc.hxx
vcl/inc/vcl/salbtype.hxx
vcl/source/gdi/bitmap.cxx
vcl/source/gdi/bitmap3.cxx
vcl/source/gdi/outdev2.cxx
Change-Id: I1d163c66782c2750aeee00725dbb2b614507c0d4
(cherry picked from commit ff80c37b18b941712fb967a0c1d48813b47c0583)
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/graphic/grfmgr2.cxx | 14 | ||||
-rw-r--r-- | svtools/source/graphic/transformer.cxx | 18 |
2 files changed, 15 insertions, 17 deletions
diff --git a/svtools/source/graphic/grfmgr2.cxx b/svtools/source/graphic/grfmgr2.cxx index 7eb8233fb9fa..45c368612b2c 100644 --- a/svtools/source/graphic/grfmgr2.cxx +++ b/svtools/source/graphic/grfmgr2.cxx @@ -423,14 +423,14 @@ sal_Bool ImplCreateRotatedScaled( const BitmapEx& rBmpEx, const GraphicAttr& rAt nTmpX = pMapIX[ nUnRotX ]; nTmpFX = pMapFX[ nUnRotX ]; nTmpY = pMapIY[ nUnRotY ], nTmpFY = pMapFY[ nUnRotY ]; - const BitmapColor& rCol0 = pReadAccess->GetPaletteColor( pReadAccess->GetPixel( nTmpY, nTmpX ) ); - const BitmapColor& rCol1 = pReadAccess->GetPaletteColor( pReadAccess->GetPixel( nTmpY, ++nTmpX ) ); + const BitmapColor& rCol0 = pReadAccess->GetPaletteColor( pReadAccess->GetPixelIndex( nTmpY, nTmpX ) ); + const BitmapColor& rCol1 = pReadAccess->GetPaletteColor( pReadAccess->GetPixelIndex( nTmpY, ++nTmpX ) ); cR0 = MAP( rCol0.GetRed(), rCol1.GetRed(), nTmpFX ); cG0 = MAP( rCol0.GetGreen(), rCol1.GetGreen(), nTmpFX ); cB0 = MAP( rCol0.GetBlue(), rCol1.GetBlue(), nTmpFX ); - const BitmapColor& rCol3 = pReadAccess->GetPaletteColor( pReadAccess->GetPixel( ++nTmpY, nTmpX ) ); - const BitmapColor& rCol2 = pReadAccess->GetPaletteColor( pReadAccess->GetPixel( nTmpY, --nTmpX ) ); + const BitmapColor& rCol3 = pReadAccess->GetPaletteColor( pReadAccess->GetPixelIndex( ++nTmpY, nTmpX ) ); + const BitmapColor& rCol2 = pReadAccess->GetPaletteColor( pReadAccess->GetPixelIndex( nTmpY, --nTmpX ) ); cR1 = MAP( rCol2.GetRed(), rCol3.GetRed(), nTmpFX ); cG1 = MAP( rCol2.GetGreen(), rCol3.GetGreen(), nTmpFX ); cB1 = MAP( rCol2.GetBlue(), rCol3.GetBlue(), nTmpFX ); @@ -527,10 +527,10 @@ sal_Bool ImplCreateRotatedScaled( const BitmapEx& rBmpEx, const GraphicAttr& rAt { for (int xIn = xStart; xIn <= xEnd; xIn++) { - aColor = pReadAccess->GetPixel( yIn, xIn ); - if( pReadAccess->HasPalette() ) - aColor = pReadAccess->GetPaletteColor( aColor ); + aColor = pReadAccess->GetPaletteColor( pReadAccess->GetPixelIndex( yIn, xIn ) ); + else + aColor = pReadAccess->GetPixel( yIn, xIn ); aSumRed += aColor.GetRed(); aSumGreen += aColor.GetGreen(); diff --git a/svtools/source/graphic/transformer.cxx b/svtools/source/graphic/transformer.cxx index 874bb346e59d..1b8e3c2eef1e 100644 --- a/svtools/source/graphic/transformer.cxx +++ b/svtools/source/graphic/transformer.cxx @@ -54,22 +54,19 @@ GraphicTransformer::~GraphicTransformer() // ------------------------------------------------------------------------------ -void setAlpha( Bitmap& rBitmap, AlphaMask& rAlpha, sal_Int32 nColorFrom, sal_Int8 nAlphaTo ) +void setAlpha( Bitmap& rBitmap, AlphaMask& rAlpha, sal_uInt8 cIndexFrom, sal_Int8 nAlphaTo ) { BitmapWriteAccess* pWriteAccess = rAlpha.AcquireWriteAccess(); BitmapReadAccess* pReadAccess = rBitmap.AcquireReadAccess(); - BitmapColor aColorFrom( static_cast< sal_uInt8 >( nColorFrom >> 16 ), - static_cast< sal_uInt8 >( nColorFrom >> 8 ), - static_cast< sal_uInt8 >( nColorFrom ) ); if ( pReadAccess && pWriteAccess ) { for ( sal_Int32 nY = 0; nY < pReadAccess->Height(); nY++ ) { for ( sal_Int32 nX = 0; nX < pReadAccess->Width(); nX++ ) { - BitmapColor aColor( pReadAccess->GetPixel( nY, nX ) ); - if ( aColor == aColorFrom ) - pWriteAccess->SetPixel( nY, nX, nAlphaTo ); + const sal_uInt8 cIndex = pReadAccess->GetPixelIndex( nY, nX ); + if ( cIndex == cIndexFrom ) + pWriteAccess->SetPixelIndex( nY, nX, nAlphaTo ); } } } @@ -87,6 +84,7 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange( BitmapColor aColorFrom( static_cast< sal_uInt8 >( nColorFrom ), static_cast< sal_uInt8 >( nColorFrom >> 8 ), static_cast< sal_uInt8 >( nColorFrom >> 16 ) ); BitmapColor aColorTo( static_cast< sal_uInt8 >( nColorTo ), static_cast< sal_uInt8 >( nColorTo >> 8 ), static_cast< sal_uInt8 >( nColorTo >> 16 ) ); + const sal_uInt8 cIndexFrom = aColorFrom.GetBlueOrIndex(); if ( aGraphic.GetType() == GRAPHIC_BITMAP ) { @@ -96,7 +94,7 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange( if ( aBitmapEx.IsAlpha() ) { AlphaMask aAlphaMask( aBitmapEx.GetAlpha() ); - setAlpha( aBitmap, aAlphaMask, aColorFrom, nAlphaTo ); + setAlpha( aBitmap, aAlphaMask, cIndexFrom, nAlphaTo ); aBitmap.Replace( aColorFrom, aColorTo, nTolerance ); aGraphic = ::Graphic( BitmapEx( aBitmap, aAlphaMask ) ); } @@ -113,7 +111,7 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange( else { AlphaMask aAlphaMask( aBitmapEx.GetMask() ); - setAlpha( aBitmap, aAlphaMask, aColorFrom, nAlphaTo ); + setAlpha( aBitmap, aAlphaMask, cIndexFrom, nAlphaTo ); aBitmap.Replace( aColorFrom, aColorTo, nTolerance ); aGraphic = ::Graphic( BitmapEx( aBitmap, aAlphaMask ) ); } @@ -129,7 +127,7 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange( else { AlphaMask aAlphaMask( aBitmapEx.GetSizePixel() ); - setAlpha( aBitmap, aAlphaMask, aColorFrom, nAlphaTo ); + setAlpha( aBitmap, aAlphaMask, cIndexFrom, nAlphaTo ); aBitmap.Replace( aColorFrom, aColorTo, nTolerance ); aGraphic = ::Graphic( BitmapEx( aBitmap, aAlphaMask ) ); } |