diff options
author | Herbert Dürr <hdu@apache.org> | 2012-10-19 15:12:40 +0000 |
---|---|---|
committer | Herbert Dürr <hdu@apache.org> | 2012-10-19 15:12:40 +0000 |
commit | 2d9d5c8d6beb7fb0a7dafa0c1c4d10a25d7200fd (patch) | |
tree | 15a68700c164567baace3aa5dc175aa588ed9134 /canvas/source | |
parent | b0a48fbbaa2d3d530743672186618a468cce694a (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 for all code outside of the immutable binfilter.
Notes
Notes:
merged as: 78eca44c4db67848a85b600cc40e25d41bb647df
Diffstat (limited to 'canvas/source')
-rw-r--r-- | canvas/source/vcl/impltools.cxx | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/canvas/source/vcl/impltools.cxx b/canvas/source/vcl/impltools.cxx index 67972f8e3450..63ca62f13a45 100644 --- a/canvas/source/vcl/impltools.cxx +++ b/canvas/source/vcl/impltools.cxx @@ -382,18 +382,10 @@ namespace vclcanvas // (invert 'alpha' pixel value, // to get the standard alpha // channel behaviour) - pAlphaWriteAccess->SetPixel( y, x, - BitmapColor( - 255U - - static_cast<sal_uInt8>( - nAlphaModulation* - (255U - - aAlphaMap[ pAlphaReadAccess->GetPixel( - nSrcY, - nSrcX ).GetIndex() ] ) + .5 ) ) ); - - BitmapColor aColor( pReadAccess->GetPixel( nSrcY, - nSrcX ) ); + const sal_uInt8 cMappedAlphaIdx = aAlphaMap[ pAlphaReadAccess->GetPixelIndex( nSrcY, nSrcX ) ]; + const sal_uInt8 cModulatedAlphaIdx = 255U - static_cast<sal_uInt8>( nAlphaModulation* (255U - cMappedAlphaIdx) + .5 ); + pAlphaWriteAccess->SetPixelIndex( y, x, cModulatedAlphaIdx ); + BitmapColor aColor( pReadAccess->GetPixel( nSrcY, nSrcX ) ); aColor.SetRed( static_cast<sal_uInt8>( @@ -482,17 +474,13 @@ namespace vclcanvas if( nSrcX < 0 || nSrcX >= aBmpSize.Width() || nSrcY < 0 || nSrcY >= aBmpSize.Height() ) { - pAlphaWriteAccess->SetPixel( y, x, BitmapColor(255) ); + pAlphaWriteAccess->SetPixelIndex( y, x, 255 ); } else { - pAlphaWriteAccess->SetPixel( y, x, - aAlphaMap[ - pAlphaReadAccess->GetPixel( nSrcY, - nSrcX ) ] ); - - pWriteAccess->SetPixel( y, x, pReadAccess->GetPixel( nSrcY, - nSrcX ) ); + const sal_uInt8 cAlphaIdx = pAlphaReadAccess->GetPixelIndex( nSrcY, nSrcX ); + pAlphaWriteAccess->SetPixelIndex( y, x, aAlphaMap[ cAlphaIdx ] ); + pWriteAccess->SetPixel( y, x, pReadAccess->GetPixel( nSrcY, nSrcX ) ); } } } |