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 /include/vcl/bmpacc.hxx | |
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 'include/vcl/bmpacc.hxx')
-rw-r--r-- | include/vcl/bmpacc.hxx | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/include/vcl/bmpacc.hxx b/include/vcl/bmpacc.hxx index 097fd7cf57e3..306f28a5b0b2 100644 --- a/include/vcl/bmpacc.hxx +++ b/include/vcl/bmpacc.hxx @@ -156,7 +156,8 @@ public: inline void SetPixelOnData( sal_uInt8* pData, long nX, const BitmapColor& rBitmapColor ); inline BitmapColor GetPixel( long nY, long nX ) const; inline BitmapColor GetColor( long nY, long nX ) const; - inline sal_uInt8 GetLuminance( long nY, long nX ) const; + inline sal_uInt8 GetPixelIndex( long nY, long nX ) const; + inline sal_uInt8 GetLuminance( long nY, long nX ) const; }; // --------------------- @@ -181,6 +182,7 @@ public: inline void SetPaletteColor( sal_uInt16 nColor, const BitmapColor& rBitmapColor ); inline void SetPixel( long nY, long nX, const BitmapColor& rBitmapColor ); + inline void SetPixelIndex( long nY, long nX, sal_uInt8 cIndex ); void SetLineColor( const Color& rColor ); @@ -378,6 +380,11 @@ inline BitmapColor BitmapReadAccess::GetPixel( long nY, long nX ) const return mFncGetPixel( mpScanBuf[ nY ], nX, maColorMask ); } +inline sal_uInt8 BitmapReadAccess::GetPixelIndex( long nY, long nX ) const +{ + return GetPixel( nY, nX ).GetBlueOrIndex(); +} + // ------------------------------------------------------------------ inline BitmapColor BitmapReadAccess::GetPixelFromData( const sal_uInt8* pData, long nX ) const @@ -398,11 +405,8 @@ inline void BitmapReadAccess::SetPixelOnData( sal_uInt8* pData, long nX, const B inline BitmapColor BitmapReadAccess::GetColor( long nY, long nX ) const { - if( !!mpBuffer->maPalette ) - { - DBG_ASSERT( mpBuffer, "Access is not valid!" ); - return mpBuffer->maPalette[ GetPixel( nY, nX ).GetIndex() ]; - } + if( HasPalette() ) + return mpBuffer->maPalette[ GetPixelIndex( nY, nX ) ]; else return GetPixel( nY, nX ); } @@ -449,6 +453,13 @@ inline void BitmapWriteAccess::SetPixel( long nY, long nX, const BitmapColor& rB mFncSetPixel( mpScanBuf[ nY ], nX, rBitmapColor, maColorMask ); } +inline void BitmapWriteAccess::SetPixelIndex( long nY, long nX, sal_uInt8 cIndex ) +{ + SetPixel( nY, nX, BitmapColor( cIndex )); +} + +// ------------------------------------------------------------------ + #endif // _SV_BMPACC_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |