summaryrefslogtreecommitdiff
path: root/canvas
diff options
context:
space:
mode:
authorHerbert Dürr <hdu@apache.org>2012-10-19 15:12:40 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-05-09 11:18:22 +0100
commit78eca44c4db67848a85b600cc40e25d41bb647df (patch)
tree70b9352af07b4ac4678d44aaa88031eb5c225be7 /canvas
parentaa0bc15b42e8d432def185089ea8fca17f3fd8c8 (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 'canvas')
-rw-r--r--canvas/source/vcl/impltools.cxx28
1 files changed, 8 insertions, 20 deletions
diff --git a/canvas/source/vcl/impltools.cxx b/canvas/source/vcl/impltools.cxx
index 298850800d2d..797fca9775f5 100644
--- a/canvas/source/vcl/impltools.cxx
+++ b/canvas/source/vcl/impltools.cxx
@@ -365,18 +365,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>(
@@ -465,17 +457,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 ) );
}
}
}