summaryrefslogtreecommitdiff
path: root/vcl/source/gdi
diff options
context:
space:
mode:
authorHerbert Dürr <hdu@apache.org>2012-10-19 15:12:40 +0000
committerHerbert Dürr <hdu@apache.org>2012-10-19 15:12:40 +0000
commit2d9d5c8d6beb7fb0a7dafa0c1c4d10a25d7200fd (patch)
tree15a68700c164567baace3aa5dc175aa588ed9134 /vcl/source/gdi
parentb0a48fbbaa2d3d530743672186618a468cce694a (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 'vcl/source/gdi')
-rw-r--r--vcl/source/gdi/bitmap.cxx24
-rw-r--r--vcl/source/gdi/bitmap2.cxx46
-rw-r--r--vcl/source/gdi/bitmap3.cxx64
-rw-r--r--vcl/source/gdi/bitmap4.cxx2
-rw-r--r--vcl/source/gdi/bmpacc2.cxx10
-rw-r--r--vcl/source/gdi/octree.cxx2
-rw-r--r--vcl/source/gdi/outdev2.cxx10
-rw-r--r--vcl/source/gdi/pngread.cxx8
-rw-r--r--vcl/source/gdi/pngwrite.cxx16
9 files changed, 92 insertions, 90 deletions
diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx
index d7ae4f09aca3..409cf5cf2828 100644
--- a/vcl/source/gdi/bitmap.cxx
+++ b/vcl/source/gdi/bitmap.cxx
@@ -1039,7 +1039,7 @@ sal_Bool Bitmap::CopyPixel( const Rectangle& rRectDst,
for( long nSrcY = aRectSrc.Top(); nSrcY < nSrcEndY; nSrcY++, nDstY++ )
for( long nSrcX = aRectSrc.Left(), nDstX = aRectDst.Left(); nSrcX < nSrcEndX; nSrcX++, nDstX++ )
- pWriteAcc->SetPixel( nDstY, nDstX, pMap[ pReadAcc->GetPixel( nSrcY, nSrcX ).GetIndex() ] );
+ pWriteAcc->SetPixelIndex( nDstY, nDstX, pMap[ pReadAcc->GetPixelIndex( nSrcY, nSrcX ) ] );
delete[] pMap;
}
@@ -1047,7 +1047,7 @@ sal_Bool Bitmap::CopyPixel( const Rectangle& rRectDst,
{
for( long nSrcY = aRectSrc.Top(); nSrcY < nSrcEndY; nSrcY++, nDstY++ )
for( long nSrcX = aRectSrc.Left(), nDstX = aRectDst.Left(); nSrcX < nSrcEndX; nSrcX++, nDstX++ )
- pWriteAcc->SetPixel( nDstY, nDstX, pReadAcc->GetPaletteColor( pReadAcc->GetPixel( nSrcY, nSrcX ) ) );
+ pWriteAcc->SetPixel( nDstY, nDstX, pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nSrcY, nSrcX ) ) );
}
else
for( long nSrcY = aRectSrc.Top(); nSrcY < nSrcEndY; nSrcY++, nDstY++ )
@@ -1313,7 +1313,7 @@ Bitmap Bitmap::CreateMask( const Color& rTransColor, sal_uLong nTol ) const
{
for( long nX = 0L; nX < nWidth; nX++ )
{
- aCol = pReadAcc->GetPaletteColor( pReadAcc->GetPixel( nY, nX ) );
+ aCol = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, nX ) );
nR = aCol.GetRed();
nG = aCol.GetGreen();
nB = aCol.GetBlue();
@@ -1444,16 +1444,14 @@ sal_Bool Bitmap::Replace( const Bitmap& rMask, const Color& rReplaceColor )
const sal_uInt16 nActColors = pAcc->GetPaletteEntryCount();
const sal_uInt16 nMaxColors = 1 << pAcc->GetBitCount();
- // erst einmal naechste Farbe nehmen
+ // default to the nearest color
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( (sal_uInt8) aReplace ) != BitmapColor( rReplaceColor ) )
+ // for paletted images without a matching palette entry
+ // look for an unused palette entry (NOTE: expensive!)
+ if( pAcc->GetPaletteColor( aReplace.GetIndex() ) != BitmapColor( rReplaceColor ) )
{
- // erst einmal nachsehen, ob wir unsere ReplaceColor
- // nicht auf einen freien Platz am Ende der Palette
- // setzen koennen
+ // if the palette has empty entries use the last one
if( nActColors < nMaxColors )
{
pAcc->SetPaletteEntryCount( nActColors + 1 );
@@ -1469,7 +1467,7 @@ sal_Bool Bitmap::Replace( const Bitmap& rMask, const Color& rReplaceColor )
for( long nY = 0L; nY < nHeight; nY++ )
for( long nX = 0L; nX < nWidth; nX++ )
- pFlags[ (sal_uInt8) pAcc->GetPixel( nY, nX ) ] = sal_True;
+ pFlags[ pAcc->GetPixelIndex( nY, nX ) ] = sal_True;
for( sal_uInt16 i = 0UL; i < nMaxColors; i++ )
{
@@ -1523,7 +1521,7 @@ sal_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 - (sal_uInt8) pAlphaAcc->GetPixel( nY, nX ) ) );
+ pNewAcc->SetPixel( nY, nX, aCol.Merge( rMergeColor, 255 - pAlphaAcc->GetPixelIndex( nY, nX ) ) );
}
}
@@ -1935,7 +1933,7 @@ sal_Bool Bitmap::Blend( const AlphaMask& rAlpha, const Color& rBackgroundColor )
for( long nX = 0L; nX < nWidth; ++nX )
pAcc->SetPixel( nY, nX,
pAcc->GetPixel( nY, nX ).Merge( rBackgroundColor,
- 255 - pAlphaAcc->GetPixel( nY, nX ) ) );
+ 255 - pAlphaAcc->GetPixelIndex( nY, nX ) ) );
bRet = sal_True;
}
diff --git a/vcl/source/gdi/bitmap2.cxx b/vcl/source/gdi/bitmap2.cxx
index 680d8a888eda..5992dd62cf0b 100644
--- a/vcl/source/gdi/bitmap2.cxx
+++ b/vcl/source/gdi/bitmap2.cxx
@@ -531,7 +531,7 @@ sal_Bool Bitmap::ImplReadDIBBits( SvStream& rIStm, DIBInfoHeader& rHeader, Bitma
cTmp = *pTmp++;
}
- rAcc.SetPixel( nY, nX, sal::static_int_cast<sal_uInt8>(( cTmp >> --nShift ) & 1) );
+ rAcc.SetPixelIndex( nY, nX, (cTmp >> --nShift) & 1);
}
}
}
@@ -555,7 +555,7 @@ sal_Bool Bitmap::ImplReadDIBBits( SvStream& rIStm, DIBInfoHeader& rHeader, Bitma
cTmp = *pTmp++;
}
- rAcc.SetPixel( nY, nX, sal::static_int_cast<sal_uInt8>(( cTmp >> ( --nShift << 2UL ) ) & 0x0f) );
+ rAcc.SetPixelIndex( nY, nX, (cTmp >> ( --nShift << 2UL ) ) & 0x0f);
}
}
}
@@ -570,7 +570,7 @@ sal_Bool Bitmap::ImplReadDIBBits( SvStream& rIStm, DIBInfoHeader& rHeader, Bitma
rIStm.Read( pTmp = pBuf, nAlignedWidth );
for( long nX = 0L; nX < nWidth; nX++ )
- rAcc.SetPixel( nY, nX, *pTmp++ );
+ rAcc.SetPixelIndex( nY, nX, *pTmp++ );
}
}
break;
@@ -970,7 +970,7 @@ sal_Bool Bitmap::ImplWriteDIBBits( SvStream& rOStm, BitmapReadAccess& rAcc,
cTmp = 0;
}
- cTmp |= ( (sal_uInt8) rAcc.GetPixel( nY, nX ) << --nShift );
+ cTmp |= rAcc.GetPixelIndex( nY, nX ) << --nShift;
}
*pTmp = cTmp;
@@ -995,7 +995,7 @@ sal_Bool Bitmap::ImplWriteDIBBits( SvStream& rOStm, BitmapReadAccess& rAcc,
cTmp = 0;
}
- cTmp |= ( (sal_uInt8) rAcc.GetPixel( nY, nX ) << ( --nShift << 2L ) );
+ cTmp |= rAcc.GetPixelIndex( nY, nX ) << ( --nShift << 2L );
}
*pTmp = cTmp;
rOStm.Write( pBuf, nAlignedWidth );
@@ -1010,7 +1010,7 @@ sal_Bool Bitmap::ImplWriteDIBBits( SvStream& rOStm, BitmapReadAccess& rAcc,
pTmp = pBuf;
for( long nX = 0L; nX < nWidth; nX++ )
- *pTmp++ = rAcc.GetPixel( nY, nX );
+ *pTmp++ = rAcc.GetPixelIndex( nY, nX );
rOStm.Write( pBuf, nAlignedWidth );
}
@@ -1082,16 +1082,16 @@ void Bitmap::ImplDecodeRLE( sal_uInt8* pBuffer, DIBInfoHeader& rHeader,
cTmp = *pRLE++;
if( nX < nWidth )
- rAcc.SetPixel( nY, nX++, cTmp >> 4 );
+ rAcc.SetPixelIndex( nY, nX++, cTmp >> 4 );
if( nX < nWidth )
- rAcc.SetPixel( nY, nX++, cTmp & 0x0f );
+ rAcc.SetPixelIndex( nY, nX++, cTmp & 0x0f );
}
if( nRunByte & 1 )
{
if( nX < nWidth )
- rAcc.SetPixel( nY, nX++, *pRLE >> 4 );
+ rAcc.SetPixelIndex( nY, nX++, *pRLE >> 4 );
pRLE++;
}
@@ -1104,7 +1104,7 @@ void Bitmap::ImplDecodeRLE( sal_uInt8* pBuffer, DIBInfoHeader& rHeader,
for( sal_uLong i = 0UL; i < nRunByte; i++ )
{
if( nX < nWidth )
- rAcc.SetPixel( nY, nX++, *pRLE );
+ rAcc.SetPixelIndex( nY, nX++, *pRLE );
pRLE++;
}
@@ -1137,19 +1137,19 @@ void Bitmap::ImplDecodeRLE( sal_uInt8* pBuffer, DIBInfoHeader& rHeader,
for( sal_uLong i = 0UL; i < nRunByte; i++ )
{
if( nX < nWidth )
- rAcc.SetPixel( nY, nX++, cTmp >> 4 );
+ rAcc.SetPixelIndex( nY, nX++, cTmp >> 4 );
if( nX < nWidth )
- rAcc.SetPixel( nY, nX++, cTmp & 0x0f );
+ rAcc.SetPixelIndex( nY, nX++, cTmp & 0x0f );
}
if( ( nCountByte & 1 ) && ( nX < nWidth ) )
- rAcc.SetPixel( nY, nX++, cTmp >> 4 );
+ rAcc.SetPixelIndex( nY, nX++, cTmp >> 4 );
}
else
{
for( sal_uLong i = 0UL; ( i < nCountByte ) && ( nX < nWidth ); i++ )
- rAcc.SetPixel( nY, nX++, cTmp );
+ rAcc.SetPixelIndex( nY, nX++, cTmp );
}
}
}
@@ -1180,9 +1180,10 @@ sal_Bool Bitmap::ImplWriteRLE( SvStream& rOStm, BitmapReadAccess& rAcc, sal_Bool
while( nX < nWidth )
{
nCount = 1L;
- cPix = rAcc.GetPixel( nY, nX++ );
+ cPix = rAcc.GetPixelIndex( nY, nX++ );
- while( ( nX < nWidth ) && ( nCount < 255L ) && ( cPix == rAcc.GetPixel( nY, nX ) ) )
+ while( ( nX < nWidth ) && ( nCount < 255L )
+ && ( cPix == rAcc.GetPixelIndex( nY, nX ) ) )
{
nX++;
nCount++;
@@ -1200,7 +1201,8 @@ sal_Bool Bitmap::ImplWriteRLE( SvStream& rOStm, BitmapReadAccess& rAcc, sal_Bool
nSaveIndex = nX - 1UL;
bFound = sal_False;
- while( ( nX < nWidth ) && ( nCount < 256L ) && ( cPix = rAcc.GetPixel( nY, nX ) ) != cLast )
+ while( ( nX < nWidth ) && ( nCount < 256L )
+ && ( cPix = rAcc.GetPixelIndex( nY, nX ) ) != cLast )
{
nX++; nCount++;
cLast = cPix;
@@ -1219,10 +1221,10 @@ sal_Bool Bitmap::ImplWriteRLE( SvStream& rOStm, BitmapReadAccess& rAcc, sal_Bool
{
for ( sal_uLong i = 0; i < nCount; i++, pTmp++ )
{
- *pTmp = (sal_uInt8) rAcc.GetPixel( nY, nSaveIndex++ ) << 4;
+ *pTmp = rAcc.GetPixelIndex( nY, nSaveIndex++ ) << 4;
if ( ++i < nCount )
- *pTmp |= rAcc.GetPixel( nY, nSaveIndex++ );
+ *pTmp |= rAcc.GetPixelIndex( nY, nSaveIndex++ );
}
nCount = ( nCount + 1 ) >> 1;
@@ -1230,7 +1232,7 @@ sal_Bool Bitmap::ImplWriteRLE( SvStream& rOStm, BitmapReadAccess& rAcc, sal_Bool
else
{
for( sal_uLong i = 0UL; i < nCount; i++ )
- *pTmp++ = rAcc.GetPixel( nY, nSaveIndex++ );
+ *pTmp++ = rAcc.GetPixelIndex( nY, nSaveIndex++ );
}
if ( nCount & 1 )
@@ -1244,12 +1246,12 @@ sal_Bool Bitmap::ImplWriteRLE( SvStream& rOStm, BitmapReadAccess& rAcc, sal_Bool
else
{
*pTmp++ = 1;
- *pTmp++ = (sal_uInt8) rAcc.GetPixel( nY, nSaveIndex ) << ( bRLE4 ? 4 : 0 );
+ *pTmp++ = rAcc.GetPixelIndex( nY, nSaveIndex ) << (bRLE4 ? 4 : 0);
if ( nCount == 3 )
{
*pTmp++ = 1;
- *pTmp++ = (sal_uInt8) rAcc.GetPixel( nY, ++nSaveIndex ) << ( bRLE4 ? 4 : 0 );
+ *pTmp++ = rAcc.GetPixelIndex( nY, ++nSaveIndex ) << ( bRLE4 ? 4 : 0 );
nBufCount += 4;
}
else
diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx
index 34dc80ac18cd..2f91cb5e073f 100644
--- a/vcl/source/gdi/bitmap3.cxx
+++ b/vcl/source/gdi/bitmap3.cxx
@@ -383,7 +383,8 @@ sal_Bool Bitmap::ImplMakeMono( sal_uInt8 cThreshold )
{
for( long nX = 0L; nX < nWidth; nX++ )
{
- if( pReadAcc->GetPaletteColor( pReadAcc->GetPixel( nY, nX ) ).GetLuminance() >=
+ const sal_uInt8 cIndex = pReadAcc->GetPixelIndex( nY, nX );
+ if( pReadAcc->GetPaletteColor( cIndex ).GetLuminance() >=
cThreshold )
{
pWriteAcc->SetPixel( nY, nX, aWhite );
@@ -459,7 +460,8 @@ sal_Bool Bitmap::ImplMakeMonoDither()
{
for( long nX = 0L, nModY = nY % 16; nX < nWidth; nX++ )
{
- if( pReadAcc->GetPaletteColor( pReadAcc->GetPixel( nY, nX ) ).GetLuminance() >
+ const sal_uInt8 cIndex = pReadAcc->GetPixelIndex( nY, nX );
+ if( pReadAcc->GetPaletteColor( cIndex ).GetLuminance() >
pDitherMatrix[ nModY ][ nX % 16 ] )
{
pWriteAcc->SetPixel( nY, nX, aWhite );
@@ -541,9 +543,9 @@ sal_Bool Bitmap::ImplMakeGreyscales( sal_uInt16 nGreys )
{
for( long nX = 0L; nX < nWidth; nX++ )
{
- pWriteAcc->SetPixel( nY, nX,
- (sal_uInt8) ( pReadAcc->GetPaletteColor(
- pReadAcc->GetPixel( nY, nX ) ).GetLuminance() >> nShift ) );
+ const sal_uInt8 cIndex = pReadAcc->GetPixelIndex( nY, nX );
+ pWriteAcc->SetPixelIndex( nY, nX,
+ (pReadAcc->GetPaletteColor( cIndex ).GetLuminance() >> nShift) );
}
}
}
@@ -591,7 +593,7 @@ sal_Bool Bitmap::ImplMakeGreyscales( sal_uInt16 nGreys )
{
for( long nY = 0L; nY < nHeight; nY++ )
for( long nX = 0L; nX < nWidth; nX++ )
- pWriteAcc->SetPixel( nY, nX, sal::static_int_cast<sal_uInt8>(( pReadAcc->GetPixel( nY, nX ) ).GetLuminance() >> nShift) );
+ pWriteAcc->SetPixelIndex( nY, nX, (pReadAcc->GetPixel( nY, nX ) ).GetLuminance() >> nShift );
}
aNewBmp.ReleaseAccess( pWriteAcc );
@@ -666,7 +668,7 @@ sal_Bool Bitmap::ImplConvertUp( sal_uInt16 nBitCount, Color* pExtColor )
{
for( long nY = 0L; nY < nHeight; nY++ )
for( long nX = 0L; nX < nWidth; nX++ )
- pWriteAcc->SetPixel( nY, nX, pReadAcc->GetPaletteColor( pReadAcc->GetPixel( nY, nX ) ) );
+ pWriteAcc->SetPixel( nY, nX, pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, nX ) ) );
}
else
{
@@ -752,7 +754,7 @@ sal_Bool Bitmap::ImplConvertDown( sal_uInt16 nBitCount, Color* pExtColor )
for( nX = 0L, pQLine2 = !nY ? pErrQuad1 : pErrQuad2; nX < nWidth; nX++ )
{
if( pReadAcc->HasPalette() )
- pQLine2[ nX ] = pReadAcc->GetPaletteColor( pReadAcc->GetPixel( nYTmp, nX ) );
+ pQLine2[ nX ] = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nYTmp, nX ) );
else
pQLine2[ nX ] = pReadAcc->GetPixel( nYTmp, nX );
}
@@ -760,9 +762,9 @@ sal_Bool Bitmap::ImplConvertDown( sal_uInt16 nBitCount, Color* pExtColor )
for( nY = 0L; nY < nHeight; nY++, nYTmp++ )
{
- // erstes ZeilenPixel
+ // first pixel in the line
cIndex = (sal_uInt8) aColorMap.GetBestPaletteIndex( pQLine1[ 0 ].ImplGetColor() );
- pWriteAcc->SetPixel( nY, 0, cIndex );
+ pWriteAcc->SetPixelIndex( nY, 0, cIndex );
for( nX = 1L; nX < nWidth1; nX++ )
{
@@ -772,14 +774,14 @@ sal_Bool Bitmap::ImplConvertDown( sal_uInt16 nBitCount, Color* pExtColor )
pQLine2[ nX-- ].ImplAddColorError1( aErrQuad );
pQLine2[ nX-- ].ImplAddColorError5( aErrQuad );
pQLine2[ nX++ ].ImplAddColorError3( aErrQuad );
- pWriteAcc->SetPixel( nY, nX, cIndex );
+ pWriteAcc->SetPixelIndex( nY, nX, cIndex );
}
// letztes ZeilenPixel
if( nX < nWidth )
{
cIndex = (sal_uInt8) aColorMap.GetBestPaletteIndex( pQLine1[ nWidth1 ].ImplGetColor() );
- pWriteAcc->SetPixel( nY, nX, cIndex );
+ pWriteAcc->SetPixelIndex( nY, nX, cIndex );
}
// Zeilenpuffer neu fuellen/kopieren
@@ -791,7 +793,7 @@ sal_Bool Bitmap::ImplConvertDown( sal_uInt16 nBitCount, Color* pExtColor )
for( nX = 0L; nX < nWidth; nX++ )
{
if( pReadAcc->HasPalette() )
- pQLine2[ nX ] = pReadAcc->GetPaletteColor( pReadAcc->GetPixel( nYTmp, nX ) );
+ pQLine2[ nX ] = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nYTmp, nX ) );
else
pQLine2[ nX ] = pReadAcc->GetPixel( nYTmp, nX );
}
@@ -1058,7 +1060,7 @@ sal_Bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rSca
{
if( 1 == nWidth )
{
- aCol0 = pReadAcc->GetPaletteColor( pReadAcc->GetPixel( nY, 0 ) );
+ aCol0 = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, 0 ) );
for( nX = 0L; nX < nNewWidth; nX++ )
pWriteAcc->SetPixel( nY, nX, aCol0 );
@@ -1069,8 +1071,8 @@ sal_Bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rSca
{
nTemp = pLutInt[ nX ];
- aCol0 = pReadAcc->GetPaletteColor( pReadAcc->GetPixel( nY, nTemp++ ) );
- aCol1 = pReadAcc->GetPaletteColor( pReadAcc->GetPixel( nY, nTemp ) );
+ aCol0 = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, nTemp++ ) );
+ aCol1 = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, nTemp ) );
nTemp = pLutFrac[ nX ];
@@ -1162,7 +1164,7 @@ sal_Bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rSca
{
if( 1 == nHeight )
{
- aCol0 = pReadAcc->GetPaletteColor( pReadAcc->GetPixel( 0, nX ) );
+ aCol0 = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( 0, nX ) );
for( nY = 0L; nY < nNewHeight; nY++ )
pWriteAcc->SetPixel( nY, nX, aCol0 );
@@ -1173,8 +1175,8 @@ sal_Bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rSca
{
nTemp = pLutInt[ nY ];
- aCol0 = pReadAcc->GetPaletteColor( pReadAcc->GetPixel( nTemp++, nX ) );
- aCol1 = pReadAcc->GetPaletteColor( pReadAcc->GetPixel( nTemp, nX ) );
+ aCol0 = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nTemp++, nX ) );
+ aCol1 = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nTemp, nX ) );
nTemp = pLutFrac[ nY ];
@@ -1287,7 +1289,7 @@ sal_Bool Bitmap::ImplDitherMatrix()
{
for( sal_uLong nX = 0UL, nModY = ( nY & 0x0FUL ) << 4UL; nX < nWidth; nX++ )
{
- const BitmapColor aCol( pReadAcc->GetPaletteColor( pReadAcc->GetPixel( nY, nX ) ) );
+ const BitmapColor aCol( pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, nX ) ) );
const sal_uLong nD = nVCLDitherLut[ nModY + ( nX & 0x0FUL ) ];
const sal_uLong nR = ( nVCLLut[ aCol.GetRed() ] + nD ) >> 16UL;
const sal_uLong nG = ( nVCLLut[ aCol.GetGreen() ] + nD ) >> 16UL;
@@ -1375,7 +1377,7 @@ sal_Bool Bitmap::ImplDitherFloyd()
{
for( nZ = 0; nZ < nWidth; nZ++ )
{
- aColor = pReadAcc->GetPaletteColor( pReadAcc->GetPixel( 0, nZ ) );
+ aColor = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( 0, nZ ) );
*pTmp++ = (long) aColor.GetBlue() << 12;
*pTmp++ = (long) aColor.GetGreen() << 12;
@@ -1406,7 +1408,7 @@ sal_Bool Bitmap::ImplDitherFloyd()
{
for( nZ = 0; nZ < nWidth; nZ++ )
{
- aColor = pReadAcc->GetPaletteColor( pReadAcc->GetPixel( nY, nZ ) );
+ aColor = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, nZ ) );
*pTmp++ = (long) aColor.GetBlue() << 12;
*pTmp++ = (long) aColor.GetGreen() << 12;
@@ -1432,7 +1434,7 @@ sal_Bool Bitmap::ImplDitherFloyd()
CALC_TABLES7;
nX -= 5;
CALC_TABLES5;
- pWriteAcc->SetPixel( nYAcc, 0, BitmapColor( (sal_uInt8) ( nVCLBLut[ nBC ] + nVCLGLut[nGC ] + nVCLRLut[nRC ] ) ) );
+ pWriteAcc->SetPixelIndex( nYAcc, 0, static_cast<sal_uInt8>(nVCLBLut[ nBC ] + nVCLGLut[nGC ] + nVCLRLut[nRC ]) );
// mittlere Pixel ueber Schleife
long nXAcc;
@@ -1443,7 +1445,7 @@ sal_Bool Bitmap::ImplDitherFloyd()
nX -= 8;
CALC_TABLES3;
CALC_TABLES5;
- pWriteAcc->SetPixel( nYAcc, nXAcc, BitmapColor( (sal_uInt8) ( nVCLBLut[ nBC ] + nVCLGLut[nGC ] + nVCLRLut[nRC ] ) ) );
+ pWriteAcc->SetPixelIndex( nYAcc, nXAcc, static_cast<sal_uInt8>(nVCLBLut[ nBC ] + nVCLGLut[nGC ] + nVCLRLut[nRC ]) );
}
// letztes Pixel gesondert betrachten
@@ -1451,7 +1453,7 @@ sal_Bool Bitmap::ImplDitherFloyd()
nX -= 5;
CALC_TABLES3;
CALC_TABLES5;
- pWriteAcc->SetPixel( nYAcc, nWidth1, BitmapColor( (sal_uInt8) ( nVCLBLut[ nBC ] + nVCLGLut[nGC ] + nVCLRLut[nRC ] ) ) );
+ pWriteAcc->SetPixelIndex( nYAcc, nWidth1, static_cast<sal_uInt8>(nVCLBLut[ nBC ] + nVCLGLut[nGC ] + nVCLRLut[nRC ]) );
}
delete[] p1;
@@ -1626,13 +1628,13 @@ sal_Bool Bitmap::ImplReduceSimple( sal_uInt16 nColorCount )
{
for( long nY = 0L; nY < nHeight; nY++ )
for( long nX =0L; nX < nWidth; nX++ )
- pWAcc->SetPixel( nY, nX, (sal_uInt8) aOct.GetBestPaletteIndex( pRAcc->GetPaletteColor( pRAcc->GetPixel( nY, nX ) ) ) );
+ pWAcc->SetPixelIndex( nY, nX, static_cast<sal_uInt8>(aOct.GetBestPaletteIndex( pRAcc->GetPaletteColor( pRAcc->GetPixelIndex( nY, nX ) ))) );
}
else
{
for( long nY = 0L; nY < nHeight; nY++ )
for( long nX =0L; nX < nWidth; nX++ )
- pWAcc->SetPixel( nY, nX, (sal_uInt8) aOct.GetBestPaletteIndex( pRAcc->GetPixel( nY, nX ) ) );
+ pWAcc->SetPixelIndex( nY, nX, static_cast<sal_uInt8>(aOct.GetBestPaletteIndex( pRAcc->GetPixel( nY, nX ) )) );
}
aNewBmp.ReleaseAccess( pWAcc );
@@ -1729,7 +1731,7 @@ sal_Bool Bitmap::ImplReducePopular( sal_uInt16 nColCount )
{
for( nX = 0L; nX < nWidth; nX++ )
{
- const BitmapColor& rCol = pRAcc->GetPaletteColor( pRAcc->GetPixel( nY, nX ) );
+ const BitmapColor& rCol = pRAcc->GetPaletteColor( pRAcc->GetPixelIndex( nY, nX ) );
pCountTable[ ( ( ( (sal_uInt32) rCol.GetRed() ) >> nRightShiftBits ) << nLeftShiftBits2 ) |
( ( ( (sal_uInt32) rCol.GetGreen() ) >> nRightShiftBits ) << nLeftShiftBits1 ) |
( ( (sal_uInt32) rCol.GetBlue() ) >> nRightShiftBits ) ].mnCount++;
@@ -1781,7 +1783,7 @@ sal_Bool Bitmap::ImplReducePopular( sal_uInt16 nColCount )
{
for( nX = 0L; nX < nWidth; nX++ )
{
- const BitmapColor& rCol = pRAcc->GetPaletteColor( pRAcc->GetPixel( nY, nX ) );
+ const BitmapColor& rCol = pRAcc->GetPaletteColor( pRAcc->GetPixelIndex( nY, nX ) );
aDstCol.SetIndex( pIndexMap[ ( ( ( (sal_uInt32) rCol.GetRed() ) >> nRightShiftBits ) << nLeftShiftBits2 ) |
( ( ( (sal_uInt32) rCol.GetGreen() ) >> nRightShiftBits ) << nLeftShiftBits1 ) |
( ( (sal_uInt32) rCol.GetBlue() ) >> nRightShiftBits ) ] );
@@ -1867,7 +1869,7 @@ sal_Bool Bitmap::ImplReduceMedian( sal_uInt16 nColCount )
{
for( long nX = 0L; nX < nWidth; nX++ )
{
- const BitmapColor& rCol = pRAcc->GetPaletteColor( pRAcc->GetPixel( nY, nX ) );
+ const BitmapColor& rCol = pRAcc->GetPaletteColor( pRAcc->GetPixelIndex( nY, nX ) );
pColBuf[ RGB15( rCol.GetRed() >> 3, rCol.GetGreen() >> 3, rCol.GetBlue() >> 3 ) ]++;
}
}
@@ -1894,7 +1896,7 @@ sal_Bool Bitmap::ImplReduceMedian( sal_uInt16 nColCount )
pWAcc->SetPalette( aPal );
for( long nY = 0L; nY < nHeight; nY++ )
for( long nX = 0L; nX < nWidth; nX++ )
- pWAcc->SetPixel( nY, nX, (sal_uInt8) aMap.GetBestPaletteIndex( pRAcc->GetColor( nY, nX ) ) );
+ pWAcc->SetPixelIndex( nY, nX, static_cast<sal_uInt8>( aMap.GetBestPaletteIndex( pRAcc->GetColor( nY, nX ) )) );
rtl_freeMemory( pColBuf );
aNewBmp.ReleaseAccess( pWAcc );
diff --git a/vcl/source/gdi/bitmap4.cxx b/vcl/source/gdi/bitmap4.cxx
index cc922149d109..da2f23d1aa4b 100644
--- a/vcl/source/gdi/bitmap4.cxx
+++ b/vcl/source/gdi/bitmap4.cxx
@@ -856,7 +856,7 @@ sal_Bool Bitmap::ImplMosaic( const BmpFilterParam* pFilterParam, const Link* /*p
{
for( nX = nX1; nX <= nX2; nX++ )
{
- const BitmapColor& rCol = pReadAcc->GetPaletteColor( (sal_uInt8) pReadAcc->GetPixel( nY, nX ) );
+ const BitmapColor& rCol = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, nX ) );
nSumR += rCol.GetRed();
nSumG += rCol.GetGreen();
nSumB += rCol.GetBlue();
diff --git a/vcl/source/gdi/bmpacc2.cxx b/vcl/source/gdi/bmpacc2.cxx
index dc5410bbadf9..45b5063eb25a 100644
--- a/vcl/source/gdi/bmpacc2.cxx
+++ b/vcl/source/gdi/bmpacc2.cxx
@@ -32,7 +32,7 @@
IMPL_FORMAT_GETPIXEL_NOMASK( _1BIT_MSB_PAL )
{
- return( pScanline[ nX >> 3 ] & ( 1 << ( 7 - ( nX & 7 ) ) ) ? 1 : 0 );
+ return BitmapColor( pScanline[ nX >> 3 ] & ( 1 << ( 7 - ( nX & 7 ) ) ) ? 1 : 0 );
}
// ------------------------------------------------------------------
@@ -49,7 +49,7 @@ IMPL_FORMAT_SETPIXEL_NOMASK( _1BIT_MSB_PAL )
IMPL_FORMAT_GETPIXEL_NOMASK( _1BIT_LSB_PAL )
{
- return( pScanline[ nX >> 3 ] & ( 1 << ( nX & 7 ) ) ? 1 : 0 );
+ return BitmapColor( pScanline[ nX >> 3 ] & ( 1 << ( nX & 7 ) ) ? 1 : 0 );
}
// ------------------------------------------------------------------
@@ -66,7 +66,7 @@ IMPL_FORMAT_SETPIXEL_NOMASK( _1BIT_LSB_PAL )
IMPL_FORMAT_GETPIXEL_NOMASK( _4BIT_MSN_PAL )
{
- return( ( pScanline[ nX >> 1 ] >> ( nX & 1 ? 0 : 4 ) ) & 0x0f );
+ return BitmapColor( ( pScanline[ nX >> 1 ] >> ( nX & 1 ? 0 : 4 ) ) & 0x0f );
}
// ------------------------------------------------------------------
@@ -83,7 +83,7 @@ IMPL_FORMAT_SETPIXEL_NOMASK( _4BIT_MSN_PAL )
IMPL_FORMAT_GETPIXEL_NOMASK( _4BIT_LSN_PAL )
{
- return( ( pScanline[ nX >> 1 ] >> ( nX & 1 ? 4 : 0 ) ) & 0x0f );
+ return BitmapColor( ( pScanline[ nX >> 1 ] >> ( nX & 1 ? 4 : 0 ) ) & 0x0f );
}
// ------------------------------------------------------------------
@@ -100,7 +100,7 @@ IMPL_FORMAT_SETPIXEL_NOMASK( _4BIT_LSN_PAL )
IMPL_FORMAT_GETPIXEL_NOMASK( _8BIT_PAL )
{
- return pScanline[ nX ];
+ return BitmapColor( pScanline[ nX ] );
}
// ------------------------------------------------------------------
diff --git a/vcl/source/gdi/octree.cxx b/vcl/source/gdi/octree.cxx
index 6ce2f7fc0ca3..ef164a2d3503 100644
--- a/vcl/source/gdi/octree.cxx
+++ b/vcl/source/gdi/octree.cxx
@@ -130,7 +130,7 @@ void Octree::ImplCreateOctree()
{
for( long nX = 0; nX < nWidth; nX++ )
{
- pColor = &(BitmapColor&) pAcc->GetPaletteColor( pAcc->GetPixel( nY, nX ) );
+ pColor = &(BitmapColor&) pAcc->GetPaletteColor( pAcc->GetPixelIndex( nY, nX ) );
nLevel = 0L;
ImplAdd( &pTree );
diff --git a/vcl/source/gdi/outdev2.cxx b/vcl/source/gdi/outdev2.cxx
index d1b25b871f8e..9a90ae414fe6 100644
--- a/vcl/source/gdi/outdev2.cxx
+++ b/vcl/source/gdi/outdev2.cxx
@@ -1666,8 +1666,8 @@ Bitmap OutputDevice::ImplBlendWithAlpha( Bitmap aBmp,
aSrcCol = pP->GetColor( nMapY, nMapX );
aDstCol = pB->GetColor( nY, nX );
- const sal_uInt8 nSrcOpaq = 255 - pA->GetPixel( nMapY, nMapX ).GetBlueOrIndex();
- const sal_uInt8 nDstOpaq = 255 - pAlphaW->GetPixel( nY, nX ).GetBlueOrIndex();
+ const sal_uInt8 nSrcOpaq = 255 - pA->GetPixelIndex( nMapY, nMapX );
+ const sal_uInt8 nDstOpaq = 255 - pAlphaW->GetPixelIndex( nY, nX );
aDstCol.SetRed( lcl_calcColor( aSrcCol.GetRed(), nSrcOpaq, aDstCol.GetRed() ) );
aDstCol.SetBlue( lcl_calcColor( aSrcCol.GetBlue(), nSrcOpaq, aDstCol.GetBlue() ) );
@@ -1711,8 +1711,8 @@ Bitmap OutputDevice::ImplBlendWithAlpha( Bitmap aBmp,
aSrcCol = pP->GetColor( nMapY, nMapX );
aDstCol = pB->GetColor( nY, nX );
- const sal_uInt8 nSrcOpaq = 255 - pA->GetPixel( nMapY, nMapX ).GetBlueOrIndex();
- const sal_uInt8 nDstOpaq = 255 - pAlphaW->GetPixel( nY, nX ).GetBlueOrIndex();
+ const sal_uInt8 nSrcOpaq = 255 - pA->GetPixelIndex( nMapY, nMapX );
+ const sal_uInt8 nDstOpaq = 255 - pAlphaW->GetPixelIndex( nY, nX );
aDstCol.SetRed( lcl_calcColor( aSrcCol.GetRed(), nSrcOpaq, aDstCol.GetRed() ) );
aDstCol.SetBlue( lcl_calcColor( aSrcCol.GetBlue(), nSrcOpaq, aDstCol.GetBlue() ) );
@@ -1782,7 +1782,7 @@ Bitmap OutputDevice::ImplBlend( Bitmap aBmp,
const sal_uLong nD = nVCLDitherLut[ nModY | ( nOutX & 0x0FL ) ];
aDstCol = pB->GetColor( nY, nX );
- aDstCol.Merge( pP->GetColor( nMapY, nMapX ), (sal_uInt8) pA->GetPixel( nMapY, nMapX ) );
+ aDstCol.Merge( pP->GetColor( nMapY, nMapX ), pA->GetPixelIndex( nMapY, nMapX ) );
aIndex.SetIndex( (sal_uInt8) ( nVCLRLut[ ( nVCLLut[ aDstCol.GetRed() ] + nD ) >> 16UL ] +
nVCLGLut[ ( nVCLLut[ aDstCol.GetGreen() ] + nD ) >> 16UL ] +
nVCLBLut[ ( nVCLLut[ aDstCol.GetBlue() ] + nD ) >> 16UL ] ) );
diff --git a/vcl/source/gdi/pngread.cxx b/vcl/source/gdi/pngread.cxx
index 89e96799919f..3e798b5ea601 100644
--- a/vcl/source/gdi/pngread.cxx
+++ b/vcl/source/gdi/pngread.cxx
@@ -1485,7 +1485,7 @@ void PNGReaderImpl::ImplSetPixel( sal_uInt32 nY, sal_uInt32 nX, sal_uInt8 nPalIn
return;
nX >>= mnPreviewShift;
- mpAcc->SetPixel( nY, nX, nPalIndex );
+ mpAcc->SetPixelIndex( nY, nX, nPalIndex );
}
// ------------------------------------------------------------------------
@@ -1515,8 +1515,8 @@ void PNGReaderImpl::ImplSetAlphaPixel( sal_uInt32 nY, sal_uInt32 nX,
return;
nX >>= mnPreviewShift;
- mpAcc->SetPixel( nY, nX, nPalIndex );
- mpMaskAcc->SetPixel( nY, nX, ~nAlpha );
+ mpAcc->SetPixelIndex( nY, nX, nPalIndex );
+ mpMaskAcc->SetPixelIndex( nY, nX, ~nAlpha );
}
// ------------------------------------------------------------------------
@@ -1530,7 +1530,7 @@ void PNGReaderImpl::ImplSetAlphaPixel( sal_uInt32 nY, sal_uInt32 nX,
nX >>= mnPreviewShift;
mpAcc->SetPixel( nY, nX, rBitmapColor );
- mpMaskAcc->SetPixel( nY, nX, ~nAlpha );
+ mpMaskAcc->SetPixelIndex( nY, nX, ~nAlpha );
}
// ------------------------------------------------------------------------
diff --git a/vcl/source/gdi/pngwrite.cxx b/vcl/source/gdi/pngwrite.cxx
index fe10e4d4be01..459fcc2a2863 100644
--- a/vcl/source/gdi/pngwrite.cxx
+++ b/vcl/source/gdi/pngwrite.cxx
@@ -366,7 +366,7 @@ void PNGWriterImpl::ImplWritePalette()
void PNGWriterImpl::ImplWriteTransparent ()
{
- const sal_uLong nTransIndex = mpAccess->GetBestMatchingColor( BMP_COL_TRANS );
+ const sal_uLong nTransIndex = mpAccess->GetBestPaletteIndex( BMP_COL_TRANS );
ImplOpenChunk( PNGCHUNK_tRNS );
@@ -517,11 +517,11 @@ sal_uLong PNGWriterImpl::ImplGetFilter ( sal_uLong nY, sal_uLong nXStart, sal_uL
{
sal_uLong nShift = ( nXIndex & 7 ) ^ 7;
if ( nShift == 7)
- *pDest = (sal_uInt8)(mpAccess->GetPixel( nY, nX ) << nShift);
+ *pDest = mpAccess->GetPixelIndex( nY, nX ) << nShift;
else if ( nShift == 0 )
- *pDest++ |= (sal_uInt8) mpAccess->GetPixel( nY, nX ) << nShift;
+ *pDest++ |= mpAccess->GetPixelIndex( nY, nX ) << nShift;
else
- *pDest |= (sal_uInt8) mpAccess->GetPixel( nY, nX ) << nShift;
+ *pDest |= mpAccess->GetPixelIndex( nY, nX ) << nShift;
}
if ( ( nXIndex & 7 ) != 0 ) pDest++; // byte is not completely used, so the
} // bufferpointer is to correct
@@ -533,9 +533,9 @@ sal_uLong PNGWriterImpl::ImplGetFilter ( sal_uLong nY, sal_uLong nXStart, sal_uL
for ( nX = nXStart, nXIndex = 0; nX < mnWidth; nX+= nXAdd, nXIndex++ )
{
if( nXIndex & 1 )
- *pDest++ |= (sal_uInt8) mpAccess->GetPixel( nY, nX );
+ *pDest++ |= mpAccess->GetPixelIndex( nY, nX );
else
- *pDest = (sal_uInt8) mpAccess->GetPixel( nY, nX ) << 4;
+ *pDest = mpAccess->GetPixelIndex( nY, nX ) << 4;
}
if ( nXIndex & 1 ) pDest++;
}
@@ -544,7 +544,7 @@ sal_uLong PNGWriterImpl::ImplGetFilter ( sal_uLong nY, sal_uLong nXStart, sal_uL
case( 8 ):
{
for ( sal_uLong nX = nXStart; nX < mnWidth; nX+=nXAdd )
- *pDest++ = mpAccess->GetPixel( nY, nX );
+ *pDest++ = mpAccess->GetPixelIndex( nY, nX );
}
break;
@@ -565,7 +565,7 @@ sal_uLong PNGWriterImpl::ImplGetFilter ( sal_uLong nY, sal_uLong nXStart, sal_uL
*pDest++ = rColor.GetRed();
*pDest++ = rColor.GetGreen();
*pDest++ = rColor.GetBlue();
- *pDest++ = 255 - mpMaskAccess->GetPixel( nY, nX );
+ *pDest++ = 255 - mpMaskAccess->GetPixelIndex( nY, nX );
}
}
else