diff options
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/vcl/alpha.hxx | 125 | ||||
-rw-r--r-- | vcl/source/gdi/alpha.cxx | 119 |
2 files changed, 85 insertions, 159 deletions
diff --git a/vcl/inc/vcl/alpha.hxx b/vcl/inc/vcl/alpha.hxx index c6f5dd8043fe..6e51a8a2440e 100644 --- a/vcl/inc/vcl/alpha.hxx +++ b/vcl/inc/vcl/alpha.hxx @@ -59,45 +59,82 @@ public: ~AlphaMask(); AlphaMask& operator=( const Bitmap& rBitmap ); - AlphaMask& operator=( const AlphaMask& rAlphaMask ) { return (AlphaMask&) Bitmap::operator=( rAlphaMask ); } - sal_Bool operator!() const { return Bitmap::operator!(); } - sal_Bool operator==( const AlphaMask& rAlphaMask ) const { return Bitmap::operator==( rAlphaMask ); } - sal_Bool operator!=( const AlphaMask& rAlphaMask ) const { return Bitmap::operator!=( rAlphaMask ); } - - const MapMode& GetPrefMapMode() const { return Bitmap::GetPrefMapMode(); } - void SetPrefMapMode( const MapMode& rMapMode ) { Bitmap::SetPrefMapMode( rMapMode ); } - - const Size& GetPrefSize() const { return Bitmap::GetPrefSize(); } - void SetPrefSize( const Size& rSize ) { Bitmap::SetPrefSize( rSize ); } - - Size GetSizePixel() const { return Bitmap::GetSizePixel(); } - void SetSizePixel( const Size& rNewSize ) { Bitmap::SetSizePixel( rNewSize ); } - - sal_uLong GetSizeBytes() const { return Bitmap::GetSizeBytes(); } - sal_uLong GetChecksum() const { return Bitmap::GetChecksum(); } + AlphaMask& operator=( const AlphaMask& rAlphaMask ) + { + return (AlphaMask&) Bitmap::operator=( rAlphaMask ); + } + sal_Bool operator!() const + { + return Bitmap::operator!(); + } + sal_Bool operator==( const AlphaMask& rAlphaMask ) const + { + return Bitmap::operator==( rAlphaMask ); + } + sal_Bool operator!=( const AlphaMask& rAlphaMask ) const + { + return Bitmap::operator!=( rAlphaMask ); + } + + const MapMode& GetPrefMapMode() const + { + return Bitmap::GetPrefMapMode(); + } + void SetPrefMapMode( const MapMode& rMapMode ) + { + Bitmap::SetPrefMapMode( rMapMode ); + } + + const Size& GetPrefSize() const + { + return Bitmap::GetPrefSize(); + } + void SetPrefSize( const Size& rSize ) + { + Bitmap::SetPrefSize( rSize ); + } + + Size GetSizePixel() const + { + return Bitmap::GetSizePixel(); + } + void SetSizePixel( const Size& rNewSize ) + { + Bitmap::SetSizePixel( rNewSize ); + } + + sal_uLong GetSizeBytes() const + { + return Bitmap::GetSizeBytes(); + } + sal_uLong GetChecksum() const + { + return Bitmap::GetChecksum(); + } Bitmap GetBitmap() const; -public: - - sal_Bool Crop( const Rectangle& rRectPixel ); - sal_Bool Expand( sal_uLong nDX, sal_uLong nDY, sal_uInt8* pInitTransparency = NULL ); - sal_Bool CopyPixel( const Rectangle& rRectDst, const Rectangle& rRectSrc, const AlphaMask* pAlphaSrc = NULL ); - sal_Bool Erase( sal_uInt8 cTransparency ); - sal_Bool Invert(); - sal_Bool Mirror( sal_uLong nMirrorFlags ); - sal_Bool Scale( const Size& rNewSize, sal_uLong nScaleFlag = BMP_SCALE_FAST ); - sal_Bool Scale( const double& rScaleX, const double& rScaleY, sal_uLong nScaleFlag = BMP_SCALE_FAST ); - sal_Bool Rotate( long nAngle10, sal_uInt8 cFillTransparency ); - sal_Bool Replace( const Bitmap& rMask, sal_uInt8 rReplaceTransparency ); - sal_Bool Replace( sal_uInt8 cSearchTransparency, sal_uInt8 cReplaceTransparency, sal_uLong nTol = 0UL ); - sal_Bool Replace( sal_uInt8* pSearchTransparencies, sal_uInt8* pReplaceTransparencies, - sal_uLong nColorCount, sal_uLong* pTols = NULL ); - -public: - - BitmapReadAccess* AcquireReadAccess() { return Bitmap::AcquireReadAccess(); } - BitmapWriteAccess* AcquireWriteAccess() { return Bitmap::AcquireWriteAccess(); } + sal_Bool CopyPixel( + const Rectangle& rRectDst, + const Rectangle& rRectSrc, + const AlphaMask* pAlphaSrc = NULL + ); + sal_Bool Erase( sal_uInt8 cTransparency ); + sal_Bool Replace( const Bitmap& rMask, sal_uInt8 rReplaceTransparency ); + sal_Bool Replace( + sal_uInt8 cSearchTransparency, + sal_uInt8 cReplaceTransparency, + sal_uLong nTol = 0UL + ); + + BitmapReadAccess* AcquireReadAccess() + { + return Bitmap::AcquireReadAccess(); + } + BitmapWriteAccess* AcquireWriteAccess() + { + return Bitmap::AcquireWriteAccess(); + } void ReleaseAccess( BitmapReadAccess* pAccess ); typedef vcl::ScopedBitmapAccess< BitmapReadAccess, AlphaMask, &AlphaMask::AcquireReadAccess > @@ -105,10 +142,18 @@ public: typedef vcl::ScopedBitmapAccess< BitmapWriteAccess, AlphaMask, &AlphaMask::AcquireWriteAccess > ScopedWriteAccess; -public: - - sal_Bool Read( SvStream& rIStm, sal_Bool bFileHeader = sal_True ) { return Bitmap::Read( rIStm, bFileHeader ); } - sal_Bool Write( SvStream& rOStm, sal_Bool bCompressed = sal_True, sal_Bool bFileHeader = sal_True ) const { return Bitmap::Write( rOStm, bCompressed, bFileHeader ); } + sal_Bool Read( SvStream& rIStm, sal_Bool bFileHeader = sal_True ) + { + return Bitmap::Read( rIStm, bFileHeader ); + } + sal_Bool Write( + SvStream& rOStm, + sal_Bool bCompressed = sal_True, + sal_Bool bFileHeader = sal_True + ) const + { + return Bitmap::Write( rOStm, bCompressed, bFileHeader ); + } friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const BitmapEx& rBitmapEx ); friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, BitmapEx& rBitmapEx ); diff --git a/vcl/source/gdi/alpha.cxx b/vcl/source/gdi/alpha.cxx index 6107affaf4e9..7a256dd74b9c 100644 --- a/vcl/source/gdi/alpha.cxx +++ b/vcl/source/gdi/alpha.cxx @@ -108,25 +108,6 @@ Bitmap AlphaMask::GetBitmap() const // ----------------------------------------------------------------------------- -sal_Bool AlphaMask::Crop( const Rectangle& rRectPixel ) -{ - return Bitmap::Crop( rRectPixel ); -} - -// ----------------------------------------------------------------------------- - -sal_Bool AlphaMask::Expand( sal_uLong nDX, sal_uLong nDY, sal_uInt8* pInitTransparency ) -{ - Color aColor; - - if( pInitTransparency ) - aColor = Color( *pInitTransparency, *pInitTransparency, *pInitTransparency ); - - return Bitmap::Expand( nDX, nDY, pInitTransparency ? &aColor : NULL ); -} - -// ----------------------------------------------------------------------------- - sal_Bool AlphaMask::CopyPixel( const Rectangle& rRectDst, const Rectangle& rRectSrc, const AlphaMask* pAlphaSrc ) { @@ -245,79 +226,6 @@ sal_Bool AlphaMask::Erase( sal_uInt8 cTransparency ) // ----------------------------------------------------------------------------- -sal_Bool AlphaMask::Invert() -{ - BitmapWriteAccess* pAcc = AcquireWriteAccess(); - sal_Bool bRet = sal_False; - - if( pAcc && pAcc->GetBitCount() == 8 ) - { - BitmapColor aCol( 0 ); - const long nWidth = pAcc->Width(), nHeight = pAcc->Height(); - sal_uInt8* pMap = new sal_uInt8[ 256 ]; - - for( long i = 0; i < 256; i++ ) - pMap[ i ] = ~(sal_uInt8) i; - - for( long nY = 0L; nY < nHeight; nY++ ) - { - for( long nX = 0L; nX < nWidth; nX++ ) - { - aCol.SetIndex( pMap[ pAcc->GetPixel( nY, nX ).GetIndex() ] ); - pAcc->SetPixel( nY, nX, aCol ); - } - } - - delete[] pMap; - bRet = sal_True; - } - - if( pAcc ) - ReleaseAccess( pAcc ); - - return bRet; -} - -// ----------------------------------------------------------------------------- - -sal_Bool AlphaMask::Mirror( sal_uLong nMirrorFlags ) -{ - return Bitmap::Mirror( nMirrorFlags ); -} - -// ----------------------------------------------------------------------------- - -sal_Bool AlphaMask::Scale( const Size& rNewSize, sal_uLong nScaleFlag ) -{ - sal_Bool bRet = Bitmap::Scale( rNewSize, nScaleFlag ); - - if( bRet && ( nScaleFlag == BMP_SCALE_INTERPOLATE ) ) - Bitmap::Convert( BMP_CONVERSION_8BIT_GREYS ); - - return bRet; -} - -// ----------------------------------------------------------------------------- - -sal_Bool AlphaMask::Scale( const double& rScaleX, const double& rScaleY, sal_uLong nScaleFlag ) -{ - sal_Bool bRet = Bitmap::Scale( rScaleX, rScaleY, nScaleFlag ); - - if( bRet && ( nScaleFlag == BMP_SCALE_INTERPOLATE ) ) - Bitmap::Convert( BMP_CONVERSION_8BIT_GREYS ); - - return bRet; -} - -// ----------------------------------------------------------------------------- - -sal_Bool AlphaMask::Rotate( long nAngle10, sal_uInt8 cFillTransparency ) -{ - return Bitmap::Rotate( nAngle10, Color( cFillTransparency, cFillTransparency, cFillTransparency ) ); -} - -// ----------------------------------------------------------------------------- - sal_Bool AlphaMask::Replace( const Bitmap& rMask, sal_uInt8 cReplaceTransparency ) { BitmapReadAccess* pMaskAcc = ( (Bitmap&) rMask ).AcquireReadAccess(); @@ -398,33 +306,6 @@ nTol // ----------------------------------------------------------------------------- -sal_Bool AlphaMask::Replace( sal_uInt8* pSearchTransparencies, sal_uInt8* pReplaceTransparencies, - sal_uLong nColorCount, sal_uLong* pTols ) -{ - Color* pSearchColors = new Color[ nColorCount ]; - Color* pReplaceColors = new Color[ nColorCount ]; - sal_Bool bRet; - - for( sal_uLong i = 0; i < nColorCount; i++ ) - { - const sal_uInt8 cSearchTransparency = pSearchTransparencies[ i ]; - const sal_uInt8 cReplaceTransparency = pReplaceTransparencies[ i ]; - - pSearchColors[ i ] = Color( cSearchTransparency, cSearchTransparency, cSearchTransparency ); - pReplaceColors[ i ] = Color( cReplaceTransparency, cReplaceTransparency, cReplaceTransparency ); - } - - bRet = Bitmap::Replace( pSearchColors, pReplaceColors, nColorCount, pTols ) && - Bitmap::Convert( BMP_CONVERSION_8BIT_GREYS ); - - delete[] pSearchColors; - delete[] pReplaceColors; - - return bRet; -} - -// ----------------------------------------------------------------------------- - void AlphaMask::ReleaseAccess( BitmapReadAccess* pAccess ) { if( pAccess ) |