diff options
Diffstat (limited to 'vcl/source/gdi/bitmap.cxx')
-rw-r--r-- | vcl/source/gdi/bitmap.cxx | 242 |
1 files changed, 123 insertions, 119 deletions
diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx index 8d13cdb41a0f..a0b48f4ee124 100644 --- a/vcl/source/gdi/bitmap.cxx +++ b/vcl/source/gdi/bitmap.cxx @@ -86,7 +86,7 @@ Bitmap::Bitmap( SalBitmap* pSalBitmap ) // ------------------------------------------------------------------ -Bitmap::Bitmap( const Size& rSizePixel, USHORT nBitCount, const BitmapPalette* pPal ) +Bitmap::Bitmap( const Size& rSizePixel, sal_uInt16 nBitCount, const BitmapPalette* pPal ) { if( rSizePixel.Width() && rSizePixel.Height() ) { @@ -126,12 +126,12 @@ Bitmap::Bitmap( const Size& rSizePixel, USHORT nBitCount, const BitmapPalette* p // Dither-Palette erzeugen if( 8 == nBitCount ) { - USHORT nActCol = 16; + sal_uInt16 nActCol = 16; - for( USHORT nB = 0; nB < 256; nB += 51 ) - for( USHORT nG = 0; nG < 256; nG += 51 ) - for( USHORT nR = 0; nR < 256; nR += 51 ) - aPal[ nActCol++ ] = BitmapColor( (BYTE) nR, (BYTE) nG, (BYTE) nB ); + for( sal_uInt16 nB = 0; nB < 256; nB += 51 ) + for( sal_uInt16 nG = 0; nG < 256; nG += 51 ) + for( sal_uInt16 nR = 0; nR < 256; nR += 51 ) + aPal[ nActCol++ ] = BitmapColor( (sal_uInt8) nR, (sal_uInt8) nG, (sal_uInt8) nB ); // Standard-Office-Farbe setzen aPal[ nActCol++ ] = BitmapColor( 0, 184, 255 ); @@ -196,11 +196,11 @@ const BitmapPalette& Bitmap::GetGreyPalette( int nEntries ) { if( !aGreyPalette16.GetEntryCount() ) { - BYTE cGrey = 0, cGreyInc = 17; + sal_uInt8 cGrey = 0, cGreyInc = 17; aGreyPalette16.SetEntryCount( 16 ); - for( USHORT i = 0; i < 16; i++, cGrey = sal::static_int_cast<BYTE>(cGrey + cGreyInc) ) + for( sal_uInt16 i = 0; i < 16; i++, cGrey = sal::static_int_cast<sal_uInt8>(cGrey + cGreyInc) ) aGreyPalette16[ i ] = BitmapColor( cGrey, cGrey, cGrey ); } @@ -212,8 +212,8 @@ const BitmapPalette& Bitmap::GetGreyPalette( int nEntries ) { aGreyPalette256.SetEntryCount( 256 ); - for( USHORT i = 0; i < 256; i++ ) - aGreyPalette256[ i ] = BitmapColor( (BYTE) i, (BYTE) i, (BYTE) i ); + for( sal_uInt16 i = 0; i < 256; i++ ) + aGreyPalette256[ i ] = BitmapColor( (sal_uInt8) i, (sal_uInt8) i, (sal_uInt8) i ); } return aGreyPalette256; @@ -235,9 +235,13 @@ bool BitmapPalette::IsGreyPalette() const const int nEntryCount = GetEntryCount(); if( !nEntryCount ) // NOTE: an empty palette means 1:1 mapping return true; - const BitmapPalette& rGreyPalette = Bitmap::GetGreyPalette( nEntryCount ); - if( rGreyPalette == *this ) - return true; + // see above: only certain entry values will result in a valid call to GetGreyPalette + if( nEntryCount == 2 || nEntryCount == 4 || nEntryCount == 16 || nEntryCount == 256 ) + { + const BitmapPalette& rGreyPalette = Bitmap::GetGreyPalette( nEntryCount ); + if( rGreyPalette == *this ) + return true; + } // TODO: is it worth to compare the entries? return false; } @@ -260,7 +264,7 @@ Bitmap& Bitmap::operator=( const Bitmap& rBitmap ) // ------------------------------------------------------------------ -BOOL Bitmap::IsEqual( const Bitmap& rBmp ) const +sal_Bool Bitmap::IsEqual( const Bitmap& rBmp ) const { return( IsSameInstance( rBmp ) || ( rBmp.GetSizePixel() == GetSizePixel() && @@ -309,17 +313,17 @@ void Bitmap::SetSourceSizePixel( const Size& rSize) // ------------------------------------------------------------------ -USHORT Bitmap::GetBitCount() const +sal_uInt16 Bitmap::GetBitCount() const { return( mpImpBmp ? mpImpBmp->ImplGetBitCount() : 0 ); } // ------------------------------------------------------------------ -BOOL Bitmap::HasGreyPalette() const +sal_Bool Bitmap::HasGreyPalette() const { - const USHORT nBitCount = GetBitCount(); - BOOL bRet = FALSE; + const sal_uInt16 nBitCount = GetBitCount(); + sal_Bool bRet = sal_False; if( 1 == nBitCount ) { @@ -332,12 +336,12 @@ BOOL Bitmap::HasGreyPalette() const if( rCol0.GetRed() == rCol0.GetGreen() && rCol0.GetRed() == rCol0.GetBlue() && rCol1.GetRed() == rCol1.GetGreen() && rCol1.GetRed() == rCol1.GetBlue() ) { - bRet = TRUE; + bRet = sal_True; } ( (Bitmap*) this )->ReleaseAccess( pRAcc ); } else - bRet = TRUE; + bRet = sal_True; } else if( 4 == nBitCount || 8 == nBitCount ) { @@ -346,7 +350,7 @@ BOOL Bitmap::HasGreyPalette() const if( pRAcc ) { if( pRAcc->HasPalette() && ( (BitmapPalette&) pRAcc->GetPalette() == GetGreyPalette( 1 << nBitCount ) ) ) - bRet = TRUE; + bRet = sal_True; ( (Bitmap*) this )->ReleaseAccess( pRAcc ); } @@ -357,9 +361,9 @@ BOOL Bitmap::HasGreyPalette() const // ------------------------------------------------------------------ -ULONG Bitmap::GetChecksum() const +sal_uLong Bitmap::GetChecksum() const { - ULONG nRet = 0UL; + sal_uLong nRet = 0UL; if( mpImpBmp ) { @@ -523,44 +527,44 @@ void Bitmap::ReleaseAccess( BitmapReadAccess* pBitmapAccess ) // ------------------------------------------------------------------ -BOOL Bitmap::Erase( const Color& rFillColor ) +sal_Bool Bitmap::Erase( const Color& rFillColor ) { if( !(*this) ) - return TRUE; + return sal_True; BitmapWriteAccess* pWriteAcc = AcquireWriteAccess(); - BOOL bRet = FALSE; + sal_Bool bRet = sal_False; if( pWriteAcc ) { - const ULONG nFormat = pWriteAcc->GetScanlineFormat(); - BYTE cIndex = 0; - BOOL bFast = FALSE; + const sal_uLong nFormat = pWriteAcc->GetScanlineFormat(); + sal_uInt8 cIndex = 0; + sal_Bool bFast = sal_False; switch( nFormat ) { case( BMP_FORMAT_1BIT_MSB_PAL ): case( BMP_FORMAT_1BIT_LSB_PAL ): { - cIndex = (BYTE) pWriteAcc->GetBestPaletteIndex( rFillColor ); + cIndex = (sal_uInt8) pWriteAcc->GetBestPaletteIndex( rFillColor ); cIndex = ( cIndex ? 255 : 0 ); - bFast = TRUE; + bFast = sal_True; } break; case( BMP_FORMAT_4BIT_MSN_PAL ): case( BMP_FORMAT_4BIT_LSN_PAL ): { - cIndex = (BYTE) pWriteAcc->GetBestPaletteIndex( rFillColor ); + cIndex = (sal_uInt8) pWriteAcc->GetBestPaletteIndex( rFillColor ); cIndex = cIndex | ( cIndex << 4 ); - bFast = TRUE; + bFast = sal_True; } break; case( BMP_FORMAT_8BIT_PAL ): { - cIndex = (BYTE) pWriteAcc->GetBestPaletteIndex( rFillColor ); - bFast = TRUE; + cIndex = (sal_uInt8) pWriteAcc->GetBestPaletteIndex( rFillColor ); + bFast = sal_True; } break; @@ -571,21 +575,21 @@ BOOL Bitmap::Erase( const Color& rFillColor ) ( rFillColor.GetRed() == rFillColor.GetBlue() ) ) { cIndex = rFillColor.GetRed(); - bFast = TRUE; + bFast = sal_True; } else - bFast = FALSE; + bFast = sal_False; } break; default: - bFast = FALSE; + bFast = sal_False; break; } if( bFast ) { - const ULONG nBufSize = pWriteAcc->GetScanlineSize() * pWriteAcc->Height(); + const sal_uLong nBufSize = pWriteAcc->GetScanlineSize() * pWriteAcc->Height(); memset( pWriteAcc->GetBuffer(), cIndex, nBufSize ); } else @@ -597,7 +601,7 @@ BOOL Bitmap::Erase( const Color& rFillColor ) } ReleaseAccess( pWriteAcc ); - bRet = TRUE; + bRet = sal_True; } return bRet; @@ -605,19 +609,19 @@ BOOL Bitmap::Erase( const Color& rFillColor ) // ------------------------------------------------------------------ -BOOL Bitmap::Invert() +sal_Bool Bitmap::Invert() { BitmapWriteAccess* pAcc = AcquireWriteAccess(); - BOOL bRet = FALSE; + sal_Bool bRet = sal_False; if( pAcc ) { if( pAcc->HasPalette() ) { BitmapPalette aBmpPal( pAcc->GetPalette() ); - const USHORT nCount = aBmpPal.GetEntryCount(); + const sal_uInt16 nCount = aBmpPal.GetEntryCount(); - for( USHORT i = 0; i < nCount; i++ ) + for( sal_uInt16 i = 0; i < nCount; i++ ) aBmpPal[ i ].Invert(); pAcc->SetPalette( aBmpPal ); @@ -633,7 +637,7 @@ BOOL Bitmap::Invert() } ReleaseAccess( pAcc ); - bRet = TRUE; + bRet = sal_True; } return bRet; @@ -641,11 +645,11 @@ BOOL Bitmap::Invert() // ------------------------------------------------------------------ -BOOL Bitmap::Mirror( ULONG nMirrorFlags ) +sal_Bool Bitmap::Mirror( sal_uLong nMirrorFlags ) { - BOOL bHorz = ( ( nMirrorFlags & BMP_MIRROR_HORZ ) == BMP_MIRROR_HORZ ); - BOOL bVert = ( ( nMirrorFlags & BMP_MIRROR_VERT ) == BMP_MIRROR_VERT ); - BOOL bRet = FALSE; + sal_Bool bHorz = ( ( nMirrorFlags & BMP_MIRROR_HORZ ) == BMP_MIRROR_HORZ ); + sal_Bool bVert = ( ( nMirrorFlags & BMP_MIRROR_VERT ) == BMP_MIRROR_VERT ); + sal_Bool bRet = sal_False; if( bHorz && !bVert ) { @@ -670,7 +674,7 @@ BOOL Bitmap::Mirror( ULONG nMirrorFlags ) } ReleaseAccess( pAcc ); - bRet = TRUE; + bRet = sal_True; } } else if( bVert && !bHorz ) @@ -680,7 +684,7 @@ BOOL Bitmap::Mirror( ULONG nMirrorFlags ) if( pAcc ) { const long nScanSize = pAcc->GetScanlineSize(); - BYTE* pBuffer = new BYTE[ nScanSize ]; + sal_uInt8* pBuffer = new sal_uInt8[ nScanSize ]; const long nHeight = pAcc->Height(); const long nHeight1 = nHeight - 1L; const long nHeight_2 = nHeight >> 1L; @@ -694,7 +698,7 @@ BOOL Bitmap::Mirror( ULONG nMirrorFlags ) delete[] pBuffer; ReleaseAccess( pAcc ); - bRet = TRUE; + bRet = sal_True; } } else if( bHorz && bVert ) @@ -731,26 +735,26 @@ BOOL Bitmap::Mirror( ULONG nMirrorFlags ) } ReleaseAccess( pAcc ); - bRet = TRUE; + bRet = sal_True; } } else - bRet = TRUE; + bRet = sal_True; return bRet; } // ------------------------------------------------------------------ -BOOL Bitmap::Rotate( long nAngle10, const Color& rFillColor ) +sal_Bool Bitmap::Rotate( long nAngle10, const Color& rFillColor ) { - BOOL bRet = FALSE; + sal_Bool bRet = sal_False; nAngle10 %= 3600L; nAngle10 = ( nAngle10 < 0L ) ? ( 3599L + nAngle10 ) : nAngle10; if( !nAngle10 ) - bRet = TRUE; + bRet = sal_True; else if( 1800L == nAngle10 ) bRet = Mirror( BMP_MIRROR_HORZ | BMP_MIRROR_VERT ); else @@ -800,7 +804,7 @@ BOOL Bitmap::Rotate( long nAngle10, const Color& rFillColor ) Point aTmpPoint; Rectangle aTmpRectangle( aTmpPoint, aSizePix ); Polygon aPoly( aTmpRectangle ); - aPoly.Rotate( aTmpPoint, (USHORT) nAngle10 ); + aPoly.Rotate( aTmpPoint, (sal_uInt16) nAngle10 ); Rectangle aNewBound( aPoly.GetBoundRect() ); const Size aNewSizePix( aNewBound.GetSize() ); @@ -876,7 +880,7 @@ BOOL Bitmap::Rotate( long nAngle10, const Color& rFillColor ) ReleaseAccess( pReadAcc ); } - if( ( bRet = !!aRotatedBmp ) == TRUE ) + if( ( bRet = !!aRotatedBmp ) == sal_True ) ImplAssignWithSize( aRotatedBmp ); } @@ -885,11 +889,11 @@ BOOL Bitmap::Rotate( long nAngle10, const Color& rFillColor ) // ------------------------------------------------------------------ -BOOL Bitmap::Crop( const Rectangle& rRectPixel ) +sal_Bool Bitmap::Crop( const Rectangle& rRectPixel ) { const Size aSizePix( GetSizePixel() ); Rectangle aRect( rRectPixel ); - BOOL bRet = FALSE; + sal_Bool bRet = sal_False; aRect.Intersection( Rectangle( Point(), aSizePix ) ); @@ -916,7 +920,7 @@ BOOL Bitmap::Crop( const Rectangle& rRectPixel ) pWriteAcc->SetPixel( nY, nX, pReadAcc->GetPixel( nY2, nX2 ) ); aNewBmp.ReleaseAccess( pWriteAcc ); - bRet = TRUE; + bRet = sal_True; } ReleaseAccess( pReadAcc ); @@ -931,12 +935,12 @@ BOOL Bitmap::Crop( const Rectangle& rRectPixel ) // ------------------------------------------------------------------ -BOOL Bitmap::CopyPixel( const Rectangle& rRectDst, +sal_Bool Bitmap::CopyPixel( const Rectangle& rRectDst, const Rectangle& rRectSrc, const Bitmap* pBmpSrc ) { const Size aSizePix( GetSizePixel() ); Rectangle aRectDst( rRectDst ); - BOOL bRet = FALSE; + sal_Bool bRet = sal_False; aRectDst.Intersection( Rectangle( Point(), aSizePix ) ); @@ -947,8 +951,8 @@ BOOL Bitmap::CopyPixel( const Rectangle& rRectDst, Bitmap* pSrc = (Bitmap*) pBmpSrc; const Size aCopySizePix( pSrc->GetSizePixel() ); Rectangle aRectSrc( rRectSrc ); - const USHORT nSrcBitCount = pBmpSrc->GetBitCount(); - const USHORT nDstBitCount = GetBitCount(); + const sal_uInt16 nSrcBitCount = pBmpSrc->GetBitCount(); + const sal_uInt16 nDstBitCount = GetBitCount(); if( nSrcBitCount > nDstBitCount ) { @@ -976,25 +980,25 @@ BOOL Bitmap::CopyPixel( const Rectangle& rRectDst, { const long nSrcCount = pDstAcc->GetPaletteEntryCount(); const long nDstCount = 1 << nDstBitCount; - BOOL bFound; + sal_Bool bFound; for( long i = 0L; ( i < nSrcCount ) && ( nNextIndex < nSrcCount ); i++ ) { - const BitmapColor& rSrcCol = pSrcAcc->GetPaletteColor( (USHORT) i ); + const BitmapColor& rSrcCol = pSrcAcc->GetPaletteColor( (sal_uInt16) i ); - bFound = FALSE; + bFound = sal_False; for( long j = 0L; j < nDstCount; j++ ) { - if( rSrcCol == pDstAcc->GetPaletteColor( (USHORT) j ) ) + if( rSrcCol == pDstAcc->GetPaletteColor( (sal_uInt16) j ) ) { - bFound = TRUE; + bFound = sal_True; break; } } if( !bFound ) - pDstAcc->SetPaletteColor( (USHORT) nNextIndex++, rSrcCol ); + pDstAcc->SetPaletteColor( (sal_uInt16) nNextIndex++, rSrcCol ); } } @@ -1026,14 +1030,14 @@ BOOL Bitmap::CopyPixel( const Rectangle& rRectDst, if( pReadAcc->HasPalette() && pWriteAcc->HasPalette() ) { - const USHORT nCount = pReadAcc->GetPaletteEntryCount(); - BYTE* pMap = new BYTE[ nCount ]; + const sal_uInt16 nCount = pReadAcc->GetPaletteEntryCount(); + sal_uInt8* pMap = new sal_uInt8[ nCount ]; // Index-Map fuer Farbtabelle // aufbauen, da das Bild ja (relativ) farbgenau // kopiert werden soll - for( USHORT i = 0; i < nCount; i++ ) - pMap[ i ] = (BYTE) pWriteAcc->GetBestPaletteIndex( pReadAcc->GetPaletteColor( i ) ); + for( sal_uInt16 i = 0; i < nCount; i++ ) + pMap[ i ] = (sal_uInt8) pWriteAcc->GetBestPaletteIndex( pReadAcc->GetPaletteColor( i ) ); for( long nSrcY = aRectSrc.Top(); nSrcY < nSrcEndY; nSrcY++, nDstY++ ) for( long nSrcX = aRectSrc.Left(), nDstX = aRectDst.Left(); nSrcX < nSrcEndX; nSrcX++, nDstX++ ) @@ -1109,7 +1113,7 @@ BOOL Bitmap::CopyPixel( const Rectangle& rRectDst, } ReleaseAccess( pWriteAcc ); - bRet = TRUE; + bRet = sal_True; } } } @@ -1120,9 +1124,9 @@ BOOL Bitmap::CopyPixel( const Rectangle& rRectDst, // ------------------------------------------------------------------ -BOOL Bitmap::Expand( ULONG nDX, ULONG nDY, const Color* pInitColor ) +sal_Bool Bitmap::Expand( sal_uLong nDX, sal_uLong nDY, const Color* pInitColor ) { - BOOL bRet = FALSE; + sal_Bool bRet = sal_False; if( nDX || nDY ) { @@ -1166,7 +1170,7 @@ BOOL Bitmap::Expand( ULONG nDX, ULONG nDY, const Color* pInitColor ) pWriteAcc->SetPixel( nY, nX, aColor ); aNewBmp.ReleaseAccess( pWriteAcc ); - bRet = TRUE; + bRet = sal_True; } ReleaseAccess( pReadAcc ); @@ -1181,11 +1185,11 @@ BOOL Bitmap::Expand( ULONG nDX, ULONG nDY, const Color* pInitColor ) // ------------------------------------------------------------------ -Bitmap Bitmap::CreateMask( const Color& rTransColor, ULONG nTol ) const +Bitmap Bitmap::CreateMask( const Color& rTransColor, sal_uLong nTol ) const { Bitmap aNewBmp( GetSizePixel(), 1 ); BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess(); - BOOL bRet = FALSE; + sal_Bool bRet = sal_False; if( pWriteAcc ) { @@ -1207,7 +1211,7 @@ Bitmap Bitmap::CreateMask( const Color& rTransColor, ULONG nTol ) const pReadAcc->GetScanlineFormat() == BMP_FORMAT_4BIT_LSN_PAL ) { // optimized for 4Bit-MSN/LSN source palette - const BYTE cTest = aTest.GetIndex(); + const sal_uInt8 cTest = aTest.GetIndex(); const long nShiftInit = ( ( pReadAcc->GetScanlineFormat() == BMP_FORMAT_4BIT_MSN_PAL ) ? 4 : 0 ); if( pWriteAcc->GetScanlineFormat() == BMP_FORMAT_1BIT_MSB_PAL && @@ -1245,7 +1249,7 @@ Bitmap Bitmap::CreateMask( const Color& rTransColor, ULONG nTol ) const else if( pReadAcc->GetScanlineFormat() == BMP_FORMAT_8BIT_PAL ) { // optimized for 8Bit source palette - const BYTE cTest = aTest.GetIndex(); + const sal_uInt8 cTest = aTest.GetIndex(); if( pWriteAcc->GetScanlineFormat() == BMP_FORMAT_1BIT_MSB_PAL && aWhite.GetIndex() == 1 ) @@ -1352,7 +1356,7 @@ Bitmap Bitmap::CreateMask( const Color& rTransColor, ULONG nTol ) const } ( (Bitmap*) this )->ReleaseAccess( pReadAcc ); - bRet = TRUE; + bRet = sal_True; } aNewBmp.ReleaseAccess( pWriteAcc ); @@ -1424,11 +1428,11 @@ Region Bitmap::CreateRegion( const Color& rColor, const Rectangle& rRect ) const // ------------------------------------------------------------------ -BOOL Bitmap::Replace( const Bitmap& rMask, const Color& rReplaceColor ) +sal_Bool Bitmap::Replace( const Bitmap& rMask, const Color& rReplaceColor ) { BitmapReadAccess* pMaskAcc = ( (Bitmap&) rMask ).AcquireReadAccess(); BitmapWriteAccess* pAcc = AcquireWriteAccess(); - BOOL bRet = FALSE; + sal_Bool bRet = sal_False; if( pMaskAcc && pAcc ) { @@ -1439,15 +1443,15 @@ BOOL Bitmap::Replace( const Bitmap& rMask, const Color& rReplaceColor ) if( pAcc->HasPalette() ) { - const USHORT nActColors = pAcc->GetPaletteEntryCount(); - const USHORT nMaxColors = 1 << pAcc->GetBitCount(); + const sal_uInt16 nActColors = pAcc->GetPaletteEntryCount(); + const sal_uInt16 nMaxColors = 1 << pAcc->GetBitCount(); // erst einmal naechste Farbe nehmen aReplace = pAcc->GetBestMatchingColor( rReplaceColor ); // falls Palettenbild, und die zu setzende Farbe ist nicht // in der Palette, suchen wir nach freien Eintraegen (teuer) - if( pAcc->GetPaletteColor( (BYTE) aReplace ) != BitmapColor( rReplaceColor ) ) + if( pAcc->GetPaletteColor( (sal_uInt8) aReplace ) != BitmapColor( rReplaceColor ) ) { // erst einmal nachsehen, ob wir unsere ReplaceColor // nicht auf einen freien Platz am Ende der Palette @@ -1456,26 +1460,26 @@ BOOL Bitmap::Replace( const Bitmap& rMask, const Color& rReplaceColor ) { pAcc->SetPaletteEntryCount( nActColors + 1 ); pAcc->SetPaletteColor( nActColors, rReplaceColor ); - aReplace = BitmapColor( (BYTE) nActColors ); + aReplace = BitmapColor( (sal_uInt8) nActColors ); } else { - BOOL* pFlags = new BOOL[ nMaxColors ]; + sal_Bool* pFlags = new sal_Bool[ nMaxColors ]; // alle Eintraege auf 0 setzen memset( pFlags, 0, nMaxColors ); for( long nY = 0L; nY < nHeight; nY++ ) for( long nX = 0L; nX < nWidth; nX++ ) - pFlags[ (BYTE) pAcc->GetPixel( nY, nX ) ] = TRUE; + pFlags[ (sal_uInt8) pAcc->GetPixel( nY, nX ) ] = sal_True; - for( USHORT i = 0UL; i < nMaxColors; i++ ) + for( sal_uInt16 i = 0UL; i < nMaxColors; i++ ) { // Hurra, wir haben einen unbenutzten Eintrag if( !pFlags[ i ] ) { - pAcc->SetPaletteColor( (USHORT) i, rReplaceColor ); - aReplace = BitmapColor( (BYTE) i ); + pAcc->SetPaletteColor( (sal_uInt16) i, rReplaceColor ); + aReplace = BitmapColor( (sal_uInt8) i ); } } @@ -1491,7 +1495,7 @@ BOOL Bitmap::Replace( const Bitmap& rMask, const Color& rReplaceColor ) if( pMaskAcc->GetPixel( nY, nX ) == aMaskWhite ) pAcc->SetPixel( nY, nX, aReplace ); - bRet = TRUE; + bRet = sal_True; } ( (Bitmap&) rMask ).ReleaseAccess( pMaskAcc ); @@ -1502,13 +1506,13 @@ BOOL Bitmap::Replace( const Bitmap& rMask, const Color& rReplaceColor ) // ------------------------------------------------------------------ -BOOL Bitmap::Replace( const AlphaMask& rAlpha, const Color& rMergeColor ) +sal_Bool Bitmap::Replace( const AlphaMask& rAlpha, const Color& rMergeColor ) { Bitmap aNewBmp( GetSizePixel(), 24 ); BitmapReadAccess* pAcc = AcquireReadAccess(); BitmapReadAccess* pAlphaAcc = ( (AlphaMask&) rAlpha ).AcquireReadAccess(); BitmapWriteAccess* pNewAcc = aNewBmp.AcquireWriteAccess(); - BOOL bRet = FALSE; + sal_Bool bRet = sal_False; if( pAcc && pAlphaAcc && pNewAcc ) { @@ -1521,11 +1525,11 @@ BOOL Bitmap::Replace( const AlphaMask& rAlpha, const Color& rMergeColor ) for( long nX = 0L; nX < nWidth; nX++ ) { aCol = pAcc->GetColor( nY, nX ); - pNewAcc->SetPixel( nY, nX, aCol.Merge( rMergeColor, 255 - (BYTE) pAlphaAcc->GetPixel( nY, nX ) ) ); + pNewAcc->SetPixel( nY, nX, aCol.Merge( rMergeColor, 255 - (sal_uInt8) pAlphaAcc->GetPixel( nY, nX ) ) ); } } - bRet = TRUE; + bRet = sal_True; } ReleaseAccess( pAcc ); @@ -1548,7 +1552,7 @@ BOOL Bitmap::Replace( const AlphaMask& rAlpha, const Color& rMergeColor ) // ------------------------------------------------------------------ -BOOL Bitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, ULONG nTol ) +sal_Bool Bitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) { // Bitmaps with 1 bit color depth can cause problems // if they have other entries than black/white in their palette @@ -1556,7 +1560,7 @@ BOOL Bitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, ULO Convert( BMP_CONVERSION_4BIT_COLORS ); BitmapWriteAccess* pAcc = AcquireWriteAccess(); - BOOL bRet = FALSE; + sal_Bool bRet = sal_False; if( pAcc ) { @@ -1569,7 +1573,7 @@ BOOL Bitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, ULO if( pAcc->HasPalette() ) { - for( USHORT i = 0, nPalCount = pAcc->GetPaletteEntryCount(); i < nPalCount; i++ ) + for( sal_uInt16 i = 0, nPalCount = pAcc->GetPaletteEntryCount(); i < nPalCount; i++ ) { const BitmapColor& rCol = pAcc->GetPaletteColor( i ); @@ -1603,7 +1607,7 @@ BOOL Bitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, ULO } ReleaseAccess( pAcc ); - bRet = TRUE; + bRet = sal_True; } return bRet; @@ -1611,8 +1615,8 @@ BOOL Bitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, ULO // ------------------------------------------------------------------ -BOOL Bitmap::Replace( const Color* pSearchColors, const Color* pReplaceColors, - ULONG nColorCount, ULONG* _pTols ) +sal_Bool Bitmap::Replace( const Color* pSearchColors, const Color* pReplaceColors, + sal_uLong nColorCount, sal_uLong* _pTols ) { // Bitmaps with 1 bit color depth can cause problems // if they have other entries than black/white in their palette @@ -1620,7 +1624,7 @@ BOOL Bitmap::Replace( const Color* pSearchColors, const Color* pReplaceColors, Convert( BMP_CONVERSION_4BIT_COLORS ); BitmapWriteAccess* pAcc = AcquireWriteAccess(); - BOOL bRet = FALSE; + sal_Bool bRet = sal_False; if( pAcc ) { @@ -1631,7 +1635,7 @@ BOOL Bitmap::Replace( const Color* pSearchColors, const Color* pReplaceColors, long* pMinB = new long[ nColorCount ]; long* pMaxB = new long[ nColorCount ]; long* pTols; - ULONG i; + sal_uLong i; if( !_pTols ) { @@ -1656,7 +1660,7 @@ BOOL Bitmap::Replace( const Color* pSearchColors, const Color* pReplaceColors, if( pAcc->HasPalette() ) { - for( USHORT nEntry = 0, nPalCount = pAcc->GetPaletteEntryCount(); nEntry < nPalCount; nEntry++ ) + for( sal_uInt16 nEntry = 0, nPalCount = pAcc->GetPaletteEntryCount(); nEntry < nPalCount; nEntry++ ) { const BitmapColor& rCol = pAcc->GetPaletteColor( nEntry ); @@ -1666,7 +1670,7 @@ BOOL Bitmap::Replace( const Color* pSearchColors, const Color* pReplaceColors, pMinG[ i ] <= rCol.GetGreen() && pMaxG[ i ] >= rCol.GetGreen() && pMinB[ i ] <= rCol.GetBlue() && pMaxB[ i ] >= rCol.GetBlue() ) { - pAcc->SetPaletteColor( (USHORT)nEntry, pReplaceColors[ i ] ); + pAcc->SetPaletteColor( (sal_uInt16)nEntry, pReplaceColors[ i ] ); break; } } @@ -1712,7 +1716,7 @@ BOOL Bitmap::Replace( const Color* pSearchColors, const Color* pReplaceColors, delete[] pMinB; delete[] pMaxB; ReleaseAccess( pAcc ); - bRet = TRUE; + bRet = sal_True; } return bRet; @@ -1739,11 +1743,11 @@ Bitmap Bitmap::CreateDisplayBitmap( OutputDevice* pDisplay ) // ------------------------------------------------------------------ -BOOL Bitmap::CombineSimple( const Bitmap& rMask, BmpCombine eCombine ) +sal_Bool Bitmap::CombineSimple( const Bitmap& rMask, BmpCombine eCombine ) { BitmapReadAccess* pMaskAcc = ( (Bitmap&) rMask ).AcquireReadAccess(); BitmapWriteAccess* pAcc = AcquireWriteAccess(); - BOOL bRet = FALSE; + sal_Bool bRet = sal_False; if( pMaskAcc && pAcc ) { @@ -1867,7 +1871,7 @@ BOOL Bitmap::CombineSimple( const Bitmap& rMask, BmpCombine eCombine ) break; } - bRet = TRUE; + bRet = sal_True; } ( (Bitmap&) rMask ).ReleaseAccess( pMaskAcc ); @@ -1878,7 +1882,7 @@ BOOL Bitmap::CombineSimple( const Bitmap& rMask, BmpCombine eCombine ) // ------------------------------------------------------------------ -BOOL Bitmap::Blend( const AlphaMask& rAlpha, const Color& rBackgroundColor ) +sal_Bool Bitmap::Blend( const AlphaMask& rAlpha, const Color& rBackgroundColor ) { // TODO: Have a look at OutputDevice::ImplDrawAlpha() for some // optimizations. Might even consolidate the code here and there. @@ -1890,7 +1894,7 @@ BOOL Bitmap::Blend( const AlphaMask& rAlpha, const Color& rBackgroundColor ) BitmapReadAccess* pAlphaAcc = const_cast<AlphaMask&>(rAlpha).AcquireReadAccess(); BitmapWriteAccess* pAcc = AcquireWriteAccess(); - BOOL bRet = FALSE; + sal_Bool bRet = sal_False; if( pAlphaAcc && pAcc ) { @@ -1903,7 +1907,7 @@ BOOL Bitmap::Blend( const AlphaMask& rAlpha, const Color& rBackgroundColor ) pAcc->GetPixel( nY, nX ).Merge( rBackgroundColor, 255 - pAlphaAcc->GetPixel( nY, nX ) ) ); - bRet = TRUE; + bRet = sal_True; } const_cast<AlphaMask&>(rAlpha).ReleaseAccess( pAlphaAcc ); @@ -1914,7 +1918,7 @@ BOOL Bitmap::Blend( const AlphaMask& rAlpha, const Color& rBackgroundColor ) // ------------------------------------------------------------------ -BOOL Bitmap::MakeMono( BYTE cThreshold ) +sal_Bool Bitmap::MakeMono( sal_uInt8 cThreshold ) { return ImplMakeMono( cThreshold ); } |