[Libreoffice-commits] core.git: canvas/source filter/source include/vcl svtools/source svx/source vcl/source

Herbert Dürr hdu at apache.org
Thu May 9 03:18:45 PDT 2013


 canvas/source/vcl/impltools.cxx             |   28 +++--------
 filter/source/graphicfilter/egif/egif.cxx   |    2 
 filter/source/graphicfilter/epbm/epbm.cxx   |    4 -
 filter/source/graphicfilter/epgm/epgm.cxx   |    4 -
 filter/source/graphicfilter/epict/epict.cxx |    6 +-
 filter/source/graphicfilter/eps/eps.cxx     |   10 ++--
 filter/source/graphicfilter/eras/eras.cxx   |    4 -
 filter/source/graphicfilter/etiff/etiff.cxx |    8 +--
 filter/source/graphicfilter/expm/expm.cxx   |    4 -
 filter/source/graphicfilter/icgm/bitmap.cxx |   10 ++--
 filter/source/graphicfilter/ieps/ieps.cxx   |    4 -
 filter/source/graphicfilter/ipbm/ipbm.cxx   |    8 +--
 filter/source/graphicfilter/ipcx/ipcx.cxx   |   19 +++----
 filter/source/graphicfilter/ipict/ipict.cxx |   30 ++++++------
 filter/source/graphicfilter/ipsd/ipsd.cxx   |   12 ++--
 filter/source/graphicfilter/iras/iras.cxx   |    5 --
 filter/source/graphicfilter/itga/itga.cxx   |    6 +-
 filter/source/graphicfilter/itiff/itiff.cxx |   52 ++++++++++-----------
 filter/source/msfilter/svdfppt.cxx          |    2 
 include/vcl/bmpacc.hxx                      |   23 +++++++--
 include/vcl/salbtype.hxx                    |   12 ----
 svtools/source/graphic/grfmgr2.cxx          |   14 ++---
 svtools/source/graphic/transformer.cxx      |   18 +++----
 svx/source/gallery2/galobj.cxx              |    2 
 svx/source/svdraw/svdetc.cxx                |    4 -
 svx/source/xoutdev/_xoutbmp.cxx             |   26 +++++-----
 svx/source/xoutdev/xattrbmp.cxx             |    4 -
 vcl/source/filter/igif/gifread.cxx          |    8 +--
 vcl/source/filter/jpeg/JpegWriter.cxx       |    4 -
 vcl/source/filter/wmf/winwmf.cxx            |    2 
 vcl/source/gdi/bitmap.cxx                   |   22 ++++-----
 vcl/source/gdi/bitmap2.cxx                  |   46 +++++++++---------
 vcl/source/gdi/bitmap3.cxx                  |   68 ++++++++++++++--------------
 vcl/source/gdi/bitmap4.cxx                  |   15 +-----
 vcl/source/gdi/bmpacc2.cxx                  |   10 ++--
 vcl/source/gdi/octree.cxx                   |    2 
 vcl/source/gdi/outdev2.cxx                  |    6 +-
 vcl/source/gdi/pngread.cxx                  |    8 +--
 vcl/source/gdi/pngwrite.cxx                 |   16 +++---
 vcl/source/helper/canvasbitmap.cxx          |   27 +++--------
 vcl/source/helper/canvastools.cxx           |    8 +--
 41 files changed, 265 insertions(+), 298 deletions(-)

New commits:
commit 78eca44c4db67848a85b600cc40e25d41bb647df
Author: Herbert Dürr <hdu at apache.org>
Date:   Fri Oct 19 15:12:40 2012 +0000

    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)

diff --git a/canvas/source/vcl/impltools.cxx b/canvas/source/vcl/impltools.cxx
index 2988508..797fca9 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 ) );
                                     }
                                 }
                             }
diff --git a/filter/source/graphicfilter/egif/egif.cxx b/filter/source/graphicfilter/egif/egif.cxx
index 0f701f9..708e7b5 100644
--- a/filter/source/graphicfilter/egif/egif.cxx
+++ b/filter/source/graphicfilter/egif/egif.cxx
@@ -520,7 +520,7 @@ void GIFWriter::WriteAccess()
             else
             {
                 for( long nX = 0L; nX < nWidth; nX++ )
-                    pBuffer[ nX ] = (sal_uInt8) m_pAcc->GetPixel( nY, nX );
+                    pBuffer[ nX ] = m_pAcc->GetPixelIndex( nY, nX );
 
                 aCompressor.Compress( pBuffer, nWidth );
             }
diff --git a/filter/source/graphicfilter/epbm/epbm.cxx b/filter/source/graphicfilter/epbm/epbm.cxx
index 4080d70..a32fd8a 100644
--- a/filter/source/graphicfilter/epbm/epbm.cxx
+++ b/filter/source/graphicfilter/epbm/epbm.cxx
@@ -145,7 +145,7 @@ void PBMWriter::ImplWriteBody()
             for ( x = 0; x < mnWidth; x++ )
             {
                 nBYTE <<= 1;
-                if (!(mpAcc->GetPixel( y, x ) & 1 ) )
+                if (!(mpAcc->GetPixelIndex( y, x ) & 1 ) )
                     nBYTE++;
                 if ( ( x & 7 ) == 7 )
                     m_rOStm << nBYTE;
@@ -167,7 +167,7 @@ void PBMWriter::ImplWriteBody()
                     nxCount = 69;
                     m_rOStm << (sal_uInt8)10;
                 }
-                m_rOStm << (sal_uInt8)( ( mpAcc->GetPixel( y, x ) ^ 1 ) + '0' ) ;
+                m_rOStm << (sal_uInt8)( ( mpAcc->GetPixelIndex( y, x ) ^ 1 ) + '0' ) ;
             }
             m_rOStm << (sal_uInt8)10;
         }
diff --git a/filter/source/graphicfilter/epgm/epgm.cxx b/filter/source/graphicfilter/epgm/epgm.cxx
index 47c0860..ee91eb8 100644
--- a/filter/source/graphicfilter/epgm/epgm.cxx
+++ b/filter/source/graphicfilter/epgm/epgm.cxx
@@ -147,7 +147,7 @@ void PGMWriter::ImplWriteBody()
         {
             for ( sal_uLong x = 0; x < mnWidth; x++ )
             {
-                m_rOStm << (sal_uInt8)( mpAcc->GetPixel( y, x ) );
+                m_rOStm << mpAcc->GetPixelIndex( y, x );
             }
         }
     }
@@ -164,7 +164,7 @@ void PGMWriter::ImplWriteBody()
                     nCount = 69;
                     m_rOStm << (sal_uInt8)10;
                 }
-                nDat = (sal_uInt8)mpAcc->GetPixel( y, x );
+                nDat = mpAcc->GetPixelIndex( y, x );
                 nNumb = nDat / 100;
                 if ( nNumb )
                 {
diff --git a/filter/source/graphicfilter/epict/epict.cxx b/filter/source/graphicfilter/epict/epict.cxx
index 3512384..8af1c52 100644
--- a/filter/source/graphicfilter/epict/epict.cxx
+++ b/filter/source/graphicfilter/epict/epict.cxx
@@ -1164,17 +1164,17 @@ void PictWriter::WriteOpcode_BitsRect(const Point & rPoint, const Size & rSize,
                     for ( pTemp = pPix, i = 0; i < nSrcRowBytes; i++ )
                         *pTemp++ = (sal_uInt8)0;
                     for ( i = 0; i < nWidth; i++ )
-                        pPix[ ( i >> 3 ) ] |= (sal_uInt8)( pAcc->GetPixel( ny, i ) & 1 ) << ( ( i & 7 ) ^ 7 );
+                        pPix[ ( i >> 3 ) ] |= (pAcc->GetPixelIndex( ny, i ) & 1) << ((i & 7) ^ 7);
                     break;
                 case 4 :
                     for ( pTemp = pPix, i = 0; i < nSrcRowBytes; i++ )
                         *pTemp++ = (sal_uInt8)0;
                     for ( i = 0; i < nWidth; i++ )
-                        pPix[ ( i >> 1 ) ] |= (sal_uInt8)( pAcc->GetPixel( ny, i ) & 15 ) << ( ( i & 1 ) << 2 ) ;
+                        pPix[ ( i >> 1 ) ] |= (pAcc->GetPixelIndex( ny, i ) & 15) << ((i & 1) << 2);
                     break;
                 case 8 :
                     for ( i = 0; i < nWidth; i++ )
-                        pPix[ i ] = (sal_uInt8)pAcc->GetPixel( ny, i );
+                        pPix[ i ] = pAcc->GetPixelIndex( ny, i );
                     break;
             }
 
diff --git a/filter/source/graphicfilter/eps/eps.cxx b/filter/source/graphicfilter/eps/eps.cxx
index b48fba7..3d721d9 100644
--- a/filter/source/graphicfilter/eps/eps.cxx
+++ b/filter/source/graphicfilter/eps/eps.cxx
@@ -1792,7 +1792,7 @@ void PSWriter::ImplBmp( Bitmap* pBitmap, Bitmap* pMaskBitmap, const Point & rPoi
             {
                 for ( long x = 0; x < nWidth; x++ )
                 {
-                    ImplWriteHexByte( (sal_uInt8)pAcc->GetPixel( y, x ) );
+                    ImplWriteHexByte( pAcc->GetPixelIndex( y, x ) );
                 }
             }
             *mpPS << (sal_uInt8)10;
@@ -1830,7 +1830,7 @@ void PSWriter::ImplBmp( Bitmap* pBitmap, Bitmap* pMaskBitmap, const Point & rPoi
                     {
                         for ( long x = 0; x < nWidth; x++ )
                         {
-                            Compress( (sal_uInt8)pAcc->GetPixel( y, x ) );
+                            Compress( pAcc->GetPixelIndex( y, x ) );
                         }
                     }
                     EndCompression();
@@ -1841,7 +1841,7 @@ void PSWriter::ImplBmp( Bitmap* pBitmap, Bitmap* pMaskBitmap, const Point & rPoi
                     {
                         for ( long x = 0; x < nWidth; x++ )
                         {
-                            ImplWriteHexByte( (sal_uInt8)pAcc->GetPixel( y, x ) );
+                            ImplWriteHexByte( pAcc->GetPixelIndex( y, x ) );
                         }
                     }
                 }
@@ -1893,7 +1893,7 @@ void PSWriter::ImplBmp( Bitmap* pBitmap, Bitmap* pMaskBitmap, const Point & rPoi
                         {
                             for ( long x = 0; x < nWidth; x++ )
                             {
-                                Compress( (sal_uInt8)pAcc->GetPixel( y, x ) );
+                                Compress( pAcc->GetPixelIndex( y, x ) );
                             }
                         }
                         EndCompression();
@@ -1904,7 +1904,7 @@ void PSWriter::ImplBmp( Bitmap* pBitmap, Bitmap* pMaskBitmap, const Point & rPoi
                         {
                             for ( long x = 0; x < nWidth; x++ )
                             {
-                                ImplWriteHexByte( (sal_uInt8)pAcc->GetPixel( y, x ) );
+                                ImplWriteHexByte( pAcc->GetPixelIndex( y, x ) );
                             }
                         }
                     }
diff --git a/filter/source/graphicfilter/eras/eras.cxx b/filter/source/graphicfilter/eras/eras.cxx
index 77d6009..d0f3eff 100644
--- a/filter/source/graphicfilter/eras/eras.cxx
+++ b/filter/source/graphicfilter/eras/eras.cxx
@@ -203,7 +203,7 @@ void RASWriter::ImplWriteBody()
             ImplCallback( y );                              // processing output
             for ( x = 0; x < mnWidth; x++ )
             {
-                ImplPutByte ( mpAcc->GetPixel( y, x ) );
+                ImplPutByte ( mpAcc->GetPixelIndex( y, x ) );
             }
             if ( x & 1 ) ImplPutByte( 0 );      // WORD ALIGNMENT ???
         }
@@ -217,7 +217,7 @@ void RASWriter::ImplWriteBody()
             ImplCallback( y );                              // processing output
             for ( x = 0; x < mnWidth; x++ )
             {
-                nDat = ( ( nDat << 1 ) | ( mpAcc->GetPixel ( y, x ) & 1 ) );
+                nDat = ( ( nDat << 1 ) | ( mpAcc->GetPixelIndex( y, x ) & 1 ) );
                 if ( ( x & 7 ) == 7 )
                     ImplPutByte( nDat );
             }
diff --git a/filter/source/graphicfilter/etiff/etiff.cxx b/filter/source/graphicfilter/etiff/etiff.cxx
index 6475c90..b7ae837 100644
--- a/filter/source/graphicfilter/etiff/etiff.cxx
+++ b/filter/source/graphicfilter/etiff/etiff.cxx
@@ -386,7 +386,7 @@ sal_Bool TIFFWriter::ImplWriteBody()
                 ImplCallback( 100 * mnCurAllPictHeight / mnSumOfAllPictHeight );
                 for ( x = 0; x < mnWidth; x++ )
                 {
-                    Compress( mpAcc->GetPixel( y, x ) );
+                    Compress( mpAcc->GetPixelIndex( y, x ) );
                 }
             }
         }
@@ -400,9 +400,9 @@ sal_Bool TIFFWriter::ImplWriteBody()
                 for ( x = 0; x < mnWidth; x++, nShift++ )
                 {
                     if (!( nShift & 1 ))
-                        nTemp = ( (sal_uInt8)mpAcc->GetPixel( y, x ) << 4 );
+                        nTemp = ( mpAcc->GetPixelIndex( y, x ) << 4 );
                     else
-                        Compress( (sal_uInt8)( nTemp | ( mpAcc->GetPixel( y, x ) & 0xf ) ) );
+                        Compress( (sal_uInt8)( nTemp | ( mpAcc->GetPixelIndex( y, x ) & 0xf ) ) );
                 }
                 if ( nShift & 1 )
                     Compress( nTemp );
@@ -419,7 +419,7 @@ sal_Bool TIFFWriter::ImplWriteBody()
                 for ( x = 0; x < mnWidth; x++)
                 {
                     j <<= 1;
-                    j |= ( ( ~mpAcc->GetPixel( y, x ) ) & 1 );
+                    j |= ( ( ~mpAcc->GetPixelIndex( y, x ) ) & 1 );
                     if ( j & 0x100 )
                     {
                         Compress( (sal_uInt8)j );
diff --git a/filter/source/graphicfilter/expm/expm.cxx b/filter/source/graphicfilter/expm/expm.cxx
index 7af3eca..451ad2e 100644
--- a/filter/source/graphicfilter/expm/expm.cxx
+++ b/filter/source/graphicfilter/expm/expm.cxx
@@ -170,7 +170,7 @@ void XPMWriter::ImplWritePalette()
     sal_uInt16 nTransIndex = 0xffff;
 
     if ( mbTrans )
-        nTransIndex = mpAcc->GetBestMatchingColor( BMP_COL_TRANS );
+        nTransIndex = mpAcc->GetBestPaletteIndex( BMP_COL_TRANS );
     for ( sal_uInt16 i = 0; i < mnColors; i++ )
     {
         m_rOStm << "\x22";
@@ -196,7 +196,7 @@ void XPMWriter::ImplWriteBody()
         m_rOStm << (sal_uInt8)0x22;
         for ( sal_uLong x = 0; x < mnWidth; x++ )
         {
-            ImplWritePixel( (sal_uInt8)(mpAcc->GetPixel( y, x ) ) );
+            ImplWritePixel( mpAcc->GetPixelIndex( y, x ) );
         }
         m_rOStm << "\x22,\x0a";
     }
diff --git a/filter/source/graphicfilter/icgm/bitmap.cxx b/filter/source/graphicfilter/icgm/bitmap.cxx
index eb636eb..995bbe2 100644
--- a/filter/source/graphicfilter/icgm/bitmap.cxx
+++ b/filter/source/graphicfilter/icgm/bitmap.cxx
@@ -75,7 +75,7 @@ void CGMBitmap::ImplGetBitmap( CGMBitmapDescriptor& rDesc )
                             nxC = nxCount;
                             for ( nx = 0; --nxC; nx++ )
                             {   // this is not fast, but a one bit/pixel format is rarely used
-                                rDesc.mpAcc->SetPixel( ny, nx, (sal_Int8)( (*( rDesc.mpBuf + ( nx >> 3 ) ) >> ( ( nx & 7 ) ^ 7 ) ) ) & 1 );
+                                rDesc.mpAcc->SetPixelIndex( ny, nx, static_cast<sal_uInt8>( (*( rDesc.mpBuf + (nx >> 3)) >> ((nx & 7)^7))) & 1 );
                             }
                         }
                     }
@@ -89,7 +89,7 @@ void CGMBitmap::ImplGetBitmap( CGMBitmapDescriptor& rDesc )
                             nxC = nxCount;
                             for ( nx = 0; --nxC; nx++ )
                             {   // this is not fast, but a two bits/pixel format is rarely used
-                                rDesc.mpAcc->SetPixel( ny, nx, (sal_Int8)( (*( rDesc.mpBuf + ( nx >> 2 ) ) >> ( ( ( nx & 3 ) ^ 3 ) << 1 ) ) ) & 3 );
+                                rDesc.mpAcc->SetPixelIndex( ny, nx, static_cast<sal_uInt8>( (*(rDesc.mpBuf + (nx >> 2)) >> (((nx & 3)^3) << 1))) & 3 );
                             }
                         }
                     }
@@ -106,11 +106,11 @@ void CGMBitmap::ImplGetBitmap( CGMBitmapDescriptor& rDesc )
                             for ( nx = 0; --nxC; nx++ )
                             {
                                 nDat = *pTemp++;
-                                rDesc.mpAcc->SetPixel( ny, nx, (sal_Int8)( nDat >> 4 ) );
+                                rDesc.mpAcc->SetPixelIndex( ny, nx, static_cast<sal_uInt8>(nDat >> 4) );
                                 if ( --nxC )
                                 {
                                     nx ++;
-                                    rDesc.mpAcc->SetPixel( ny, nx, (sal_Int8)( nDat & 15 ) );
+                                    rDesc.mpAcc->SetPixelIndex( ny, nx, static_cast<sal_uInt8>(nDat & 15) );
                                 }
                                 else
                                     break;
@@ -128,7 +128,7 @@ void CGMBitmap::ImplGetBitmap( CGMBitmapDescriptor& rDesc )
                             nxC = nxCount;
                             for ( nx = 0; --nxC; nx++ )
                             {
-                                rDesc.mpAcc->SetPixel( ny, nx, (sal_Int8)( *pTemp++ ) );
+                                rDesc.mpAcc->SetPixelIndex( ny, nx, *(pTemp++) );
                             }
                         }
                     }
diff --git a/filter/source/graphicfilter/ieps/ieps.cxx b/filter/source/graphicfilter/ieps/ieps.cxx
index e45b1dd..31ad870 100644
--- a/filter/source/graphicfilter/ieps/ieps.cxx
+++ b/filter/source/graphicfilter/ieps/ieps.cxx
@@ -619,10 +619,10 @@ GraphicImport(SvStream & rStream, Graphic & rGraphic, FilterConfigItem*, sal_Boo
                                             }
                                         }
                                         if ( nBitDepth == 1 )
-                                            pAcc->SetPixel( y, x, sal::static_int_cast< sal_uInt8 >(( nDat >> nBitsLeft ) & 1) );
+                                            pAcc->SetPixelIndex( y, x, static_cast<sal_uInt8>(nDat >> nBitsLeft) & 1 );
                                         else
                                         {
-                                            pAcc->SetPixel( y, x, ( nDat ) ? 1 : 0 );   // nBitDepth == 8
+                                            pAcc->SetPixelIndex( y, x, nDat ? 1 : 0 );  // nBitDepth == 8
                                             nBitsLeft = 0;
                                         }
                                     }
diff --git a/filter/source/graphicfilter/ipbm/ipbm.cxx b/filter/source/graphicfilter/ipbm/ipbm.cxx
index f9b7f93..5ca1c7b 100644
--- a/filter/source/graphicfilter/ipbm/ipbm.cxx
+++ b/filter/source/graphicfilter/ipbm/ipbm.cxx
@@ -271,7 +271,7 @@ sal_Bool PBMReader::ImplReadBody()
                         mrPBM >> nDat;
                         nShift = 7;
                     }
-                    mpAcc->SetPixel( nHeight, nWidth, nDat >> nShift );
+                    mpAcc->SetPixelIndex( nHeight, nWidth, nDat >> nShift );
                     if ( ++nWidth == mnWidth )
                     {
                         nShift = 0;
@@ -290,7 +290,7 @@ sal_Bool PBMReader::ImplReadBody()
                         return sal_False;
 
                     mrPBM >> nDat;
-                    mpAcc->SetPixel( nHeight, nWidth++, nDat);
+                    mpAcc->SetPixelIndex( nHeight, nWidth++, nDat);
 
                     if ( nWidth == mnWidth )
                     {
@@ -351,7 +351,7 @@ sal_Bool PBMReader::ImplReadBody()
 
                 if ( nDat == '0' || nDat == '1' )
                 {
-                    mpAcc->SetPixel( nHeight, nWidth, (sal_uInt8)nDat-'0' );
+                    mpAcc->SetPixelIndex( nHeight, nWidth, static_cast<sal_uInt8>(nDat - '0') );
                     nWidth++;
                     if ( nWidth == mnWidth )
                     {
@@ -380,7 +380,7 @@ sal_Bool PBMReader::ImplReadBody()
                     nCount--;
                     if ( nGrey <= mnMaxVal )
                         nGrey = 255 * nGrey / mnMaxVal;
-                    mpAcc->SetPixel( nHeight, nWidth++, (sal_uInt8)nGrey );
+                    mpAcc->SetPixelIndex( nHeight, nWidth++, static_cast<sal_uInt8>(nGrey) );
                     nGrey = 0;
                     if ( nWidth == mnWidth )
                     {
diff --git a/filter/source/graphicfilter/ipcx/ipcx.cxx b/filter/source/graphicfilter/ipcx/ipcx.cxx
index a73c64b..c45f98c 100644
--- a/filter/source/graphicfilter/ipcx/ipcx.cxx
+++ b/filter/source/graphicfilter/ipcx/ipcx.cxx
@@ -291,12 +291,9 @@ void PCXReader::ImplReadBody()
                 {
                     sal_uLong nShift = ( i & 7 ) ^ 7;
                     if ( nShift == 0 )
-                        pAcc->SetPixel( ny, i, ( *pSource1++ & 1 ) );
+                        pAcc->SetPixelIndex( ny, i, *(pSource1++) & 1 );
                     else
-                        pAcc->SetPixel(
-                            ny, i,
-                            sal::static_int_cast< sal_uInt8 >(
-                                ( *pSource1 >> nShift ) & 1) );
+                        pAcc->SetPixelIndex( ny, i, (*pSource1 >> nShift ) & 1 );
                 }
                 break;
             // 4 colors
@@ -318,14 +315,14 @@ void PCXReader::ImplReadBody()
                             nCol = ( *pSource1++ ) & 0x03;
                             break;
                     }
-                    pAcc->SetPixel( ny, i, nCol );
+                    pAcc->SetPixelIndex( ny, i, nCol );
                 }
                 break;
             // 256 colors
             case 0x108 :
                 for ( i = 0; i < nWidth; i++ )
                 {
-                    pAcc->SetPixel( ny, i, *pSource1++ );
+                    pAcc->SetPixelIndex( ny, i, *pSource1++ );
                 }
                 break;
             // 8 colors
@@ -336,14 +333,14 @@ void PCXReader::ImplReadBody()
                     if ( nShift == 0 )
                     {
                         nCol = ( *pSource1++ & 1) + ( ( *pSource2++ << 1 ) & 2 ) + ( ( *pSource3++ << 2 ) & 4 );
-                        pAcc->SetPixel( ny, i, nCol );
+                        pAcc->SetPixelIndex( ny, i, nCol );
                     }
                     else
                     {
                         nCol = sal::static_int_cast< sal_uInt8 >(
                             ( ( *pSource1 >> nShift ) & 1)  + ( ( ( *pSource2 >> nShift ) << 1 ) & 2 ) +
                             ( ( ( *pSource3 >> nShift ) << 2 ) & 4 ));
-                        pAcc->SetPixel( ny, i, nCol );
+                        pAcc->SetPixelIndex( ny, i, nCol );
                     }
                 }
                 break;
@@ -356,14 +353,14 @@ void PCXReader::ImplReadBody()
                     {
                         nCol = ( *pSource1++ & 1) + ( ( *pSource2++ << 1 ) & 2 ) + ( ( *pSource3++ << 2 ) & 4 ) +
                             ( ( *pSource4++ << 3 ) & 8 );
-                        pAcc->SetPixel( ny, i, nCol );
+                        pAcc->SetPixelIndex( ny, i, nCol );
                     }
                     else
                     {
                         nCol = sal::static_int_cast< sal_uInt8 >(
                             ( ( *pSource1 >> nShift ) & 1)  + ( ( ( *pSource2 >> nShift ) << 1 ) & 2 ) +
                             ( ( ( *pSource3 >> nShift ) << 2 ) & 4 ) + ( ( ( *pSource4 >> nShift ) << 3 ) & 8 ));
-                        pAcc->SetPixel( ny, i, nCol );
+                        pAcc->SetPixelIndex( ny, i, nCol );
                     }
                 }
                 break;
diff --git a/filter/source/graphicfilter/ipict/ipict.cxx b/filter/source/graphicfilter/ipict/ipict.cxx
index 5832509..49d9f92 100644
--- a/filter/source/graphicfilter/ipict/ipict.cxx
+++ b/filter/source/graphicfilter/ipict/ipict.cxx
@@ -255,38 +255,38 @@ public:
     switch ( nPixelSize )                               \
     {                                                   \
         case 1 :                                        \
-            pAcc->SetPixel( ny, nx++, nDat >> 7 );      \
+            pAcc->SetPixelIndex( ny, nx++, nDat >> 7 ); \
             if ( nx == nWidth ) break;                  \
-            pAcc->SetPixel( ny, nx++, nDat >> 6 );      \
+            pAcc->SetPixelIndex( ny, nx++, nDat >> 6 ); \
             if ( nx == nWidth ) break;                  \
-            pAcc->SetPixel( ny, nx++, nDat >> 5 );      \
+            pAcc->SetPixelIndex( ny, nx++, nDat >> 5 ); \
             if ( nx == nWidth ) break;                  \
-            pAcc->SetPixel( ny, nx++, nDat >> 4 );      \
+            pAcc->SetPixelIndex( ny, nx++, nDat >> 4 ); \
             if ( nx == nWidth ) break;                  \
-            pAcc->SetPixel( ny, nx++, nDat >> 3 );      \
+            pAcc->SetPixelIndex( ny, nx++, nDat >> 3 ); \
             if ( nx == nWidth ) break;                  \
-            pAcc->SetPixel( ny, nx++, nDat >> 2 );      \
+            pAcc->SetPixelIndex( ny, nx++, nDat >> 2 ); \
             if ( nx == nWidth ) break;                  \
-            pAcc->SetPixel( ny, nx++, nDat >> 1 );      \
+            pAcc->SetPixelIndex( ny, nx++, nDat >> 1 ); \
             if ( nx == nWidth ) break;                  \
-            pAcc->SetPixel( ny, nx++, nDat );           \
+            pAcc->SetPixelIndex( ny, nx++, nDat );      \
             break;                                      \
         case 2 :                                        \
-            pAcc->SetPixel( ny, nx++, nDat >> 6 );      \
+            pAcc->SetPixelIndex( ny, nx++, nDat >> 6 ); \
             if ( nx == nWidth ) break;                  \
-            pAcc->SetPixel( ny, nx++, nDat >> 4 & 3);   \
+            pAcc->SetPixelIndex( ny, nx++, (nDat>>4)&3);\
             if ( nx == nWidth ) break;                  \
-            pAcc->SetPixel( ny, nx++, nDat >> 2 & 3 );  \
+            pAcc->SetPixelIndex( ny, nx++, (nDat>>2)&3 );\
             if ( nx == nWidth ) break;                  \
-            pAcc->SetPixel( ny, nx++, nDat & 3);        \
+            pAcc->SetPixelIndex( ny, nx++, nDat & 3);       \
             break;                                      \
         case 4 :                                        \
-            pAcc->SetPixel( ny, nx++, nDat >> 4 );      \
+            pAcc->SetPixelIndex( ny, nx++, nDat >> 4 ); \
             if ( nx == nWidth ) break;                  \
-            pAcc->SetPixel( ny, nx++, nDat );           \
+            pAcc->SetPixelIndex( ny, nx++, nDat );      \
             break;                                      \
         case 8 :                                        \
-            pAcc->SetPixel( ny, nx++, nDat );           \
+            pAcc->SetPixelIndex( ny, nx++, nDat );      \
             break;                                      \
     }
 
diff --git a/filter/source/graphicfilter/ipsd/ipsd.cxx b/filter/source/graphicfilter/ipsd/ipsd.cxx
index 50c2f8e..b693c13 100644
--- a/filter/source/graphicfilter/ipsd/ipsd.cxx
+++ b/filter/source/graphicfilter/ipsd/ipsd.cxx
@@ -364,7 +364,7 @@ sal_Bool PSDReader::ImplReadBody()
                     }
                     for ( sal_uInt16 i = 0; i < ( -nRunCount + 1 ); i++ )
                     {
-                        mpWriteAcc->SetPixel( nY, nX, (sal_uInt8)nDat >> nBitCount-- );
+                        mpWriteAcc->SetPixelIndex( nY, nX, nDat >> nBitCount-- );
                         if ( ++nX == mpFileHeader->nColumns )
                         {
                             nX = 0;
@@ -385,7 +385,7 @@ sal_Bool PSDReader::ImplReadBody()
                             nDat ^= 0xff;
                             nBitCount = 7;
                         }
-                        mpWriteAcc->SetPixel( nY, nX, (sal_uInt8)nDat >> nBitCount-- );
+                        mpWriteAcc->SetPixelIndex( nY, nX, nDat >> nBitCount-- );
                         if ( ++nX == mpFileHeader->nColumns )
                         {
                             nX = 0;
@@ -414,7 +414,7 @@ sal_Bool PSDReader::ImplReadBody()
                         m_rPSD >> nDummy;
                     for ( sal_uInt16 i = 0; i < ( -nRunCount + 1 ); i++ )
                     {
-                        mpWriteAcc->SetPixel( nY, nX, (sal_uInt8)nDat );
+                        mpWriteAcc->SetPixelIndex( nY, nX, nDat );
                         if ( ++nX == mpFileHeader->nColumns )
                         {
                             nX = 0;
@@ -431,7 +431,7 @@ sal_Bool PSDReader::ImplReadBody()
                         m_rPSD >> nDat;
                         if ( mpFileHeader->nDepth == 16 )   // 16 bit depth is to be skipped
                             m_rPSD >> nDummy;
-                        mpWriteAcc->SetPixel( nY, nX, (sal_uInt8)nDat );
+                        mpWriteAcc->SetPixelIndex( nY, nX, nDat );
                         if ( ++nX == mpFileHeader->nColumns )
                         {
                             nX = 0;
@@ -682,7 +682,7 @@ sal_Bool PSDReader::ImplReadBody()
                     m_rPSD >> nDummy;
                 for ( sal_uInt16 i = 0; i < ( -nRunCount + 1 ); i++ )
                 {
-                    mpMaskWriteAcc->SetPixel( nY, nX, (sal_uInt8)nDat );
+                    mpMaskWriteAcc->SetPixelIndex( nY, nX, nDat );
                     if ( ++nX == mpFileHeader->nColumns )
                     {
                         nX = 0;
@@ -703,7 +703,7 @@ sal_Bool PSDReader::ImplReadBody()
                         nDat = 1;
                     if ( mpFileHeader->nDepth == 16 )   // 16 bit depth is to be skipped
                         m_rPSD >> nDummy;
-                    mpMaskWriteAcc->SetPixel( nY, nX, (sal_uInt8)nDat );
+                    mpMaskWriteAcc->SetPixelIndex( nY, nX, nDat );
                     if ( ++nX == mpFileHeader->nColumns )
                     {
                         nX = 0;
diff --git a/filter/source/graphicfilter/iras/iras.cxx b/filter/source/graphicfilter/iras/iras.cxx
index c5f9462..36241e5 100644
--- a/filter/source/graphicfilter/iras/iras.cxx
+++ b/filter/source/graphicfilter/iras/iras.cxx
@@ -224,8 +224,7 @@ sal_Bool RASReader::ImplReadBody()
                 {
                     if (!(x & 7))
                         nDat = ImplGetByte();
-                    mpAcc->SetPixel (
-                        y, x,
+                    mpAcc->SetPixelIndex( y, x,
                         sal::static_int_cast< sal_uInt8 >(
                             nDat >> ( ( x & 7 ) ^ 7 )) );
                 }
@@ -239,7 +238,7 @@ sal_Bool RASReader::ImplReadBody()
                 for ( x = 0; x < mnWidth; x++ )
                 {
                     nDat = ImplGetByte();
-                    mpAcc->SetPixel ( y, x, nDat );
+                    mpAcc->SetPixelIndex( y, x, nDat );
                 }
                 if ( x & 1 ) ImplGetByte();                     // WORD ALIGNMENT ???
             }
diff --git a/filter/source/graphicfilter/itga/itga.cxx b/filter/source/graphicfilter/itga/itga.cxx
index b17c70a..e3967e9 100644
--- a/filter/source/graphicfilter/itga/itga.cxx
+++ b/filter/source/graphicfilter/itga/itga.cxx
@@ -397,7 +397,7 @@ sal_Bool TGAReader::ImplReadBody()
                                 return sal_False;
                             for ( sal_uInt16 i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ )
                             {
-                                mpAcc->SetPixel( nY, nX, (sal_uInt8)nDummy );
+                                mpAcc->SetPixelIndex( nY, nX, nDummy );
                                 nX += nXAdd;
                                 nXCount++;
                                 if ( nXCount == mpFileHeader->nImageWidth )
@@ -422,7 +422,7 @@ sal_Bool TGAReader::ImplReadBody()
                                     return sal_False;
                                 if ( nDummy >= mpFileHeader->nColorMapLength )
                                     return sal_False;
-                                mpAcc->SetPixel( nY, nX, (sal_uInt8)nDummy );
+                                mpAcc->SetPixelIndex( nY, nX, nDummy );
                                 nX += nXAdd;
                                 nXCount++;
                                 if ( nXCount == mpFileHeader->nImageWidth )
@@ -658,7 +658,7 @@ sal_Bool TGAReader::ImplReadBody()
                                 return sal_False;
                             if ( nDummy >= mpFileHeader->nColorMapLength )
                                 return sal_False;
-                            mpAcc->SetPixel( nY, nX, (sal_uInt8)nDummy );
+                            mpAcc->SetPixelIndex( nY, nX, nDummy );
                         }
                         break;
                     default:
diff --git a/filter/source/graphicfilter/itiff/itiff.cxx b/filter/source/graphicfilter/itiff/itiff.cxx
index 0698a14..e2ebadb 100644
--- a/filter/source/graphicfilter/itiff/itiff.cxx
+++ b/filter/source/graphicfilter/itiff/itiff.cxx
@@ -755,7 +755,7 @@ sal_Bool TIFFReader::ConvertScanline( sal_uLong nY )
                     if (nSamplesPerPixel >= 4 && pMaskAcc)
                     {
                         nLAlpha = nLAlpha + pt[ 3 ];
-                        pMaskAcc->SetPixel( nY, nx, ~nLAlpha );
+                        pMaskAcc->SetPixel( nY, nx, BitmapColor(~nLAlpha) );
                     }
                 }
             }
@@ -767,7 +767,7 @@ sal_Bool TIFFReader::ConvertScanline( sal_uLong nY )
                     if (nSamplesPerPixel >= 4 && pMaskAcc)
                     {
                         sal_uInt8 nAlpha = pt[3];
-                        pMaskAcc->SetPixel( nY, nx, ~nAlpha );
+                        pMaskAcc->SetPixel( nY, nx, BitmapColor(~nAlpha) );
                     }
                 }
             }
@@ -885,7 +885,7 @@ sal_Bool TIFFReader::ConvertScanline( sal_uLong nY )
                             nLast = BYTESWAP( (sal_uInt8)*pt++ );
                             for ( nx = 0; nx < nImageWidth; nx++ )
                             {
-                                pAcc->SetPixel( nY, nx, nLast );
+                                pAcc->SetPixelIndex( nY, nx, nLast );
                                 nLast = nLast + *pt++;
                             }
                         }
@@ -894,7 +894,7 @@ sal_Bool TIFFReader::ConvertScanline( sal_uLong nY )
                             for ( nx = 0; nx < nImageWidth; nx++ )
                             {
                                 nLast = *pt++;
-                                pAcc->SetPixel( nY, nx, (sal_uInt8)( ( (BYTESWAP((sal_uLong)nLast ) - nMinSampleValue ) * nMinMax ) ) );
+                                pAcc->SetPixelIndex( nY, nx, static_cast<sal_uInt8>( (BYTESWAP((sal_uLong)nLast) - nMinSampleValue) * nMinMax ) );
                             }
                         }
                     }
@@ -905,7 +905,7 @@ sal_Bool TIFFReader::ConvertScanline( sal_uLong nY )
                             nLast = *pt++;
                             for ( nx = 0; nx < nImageWidth; nx++ )
                             {
-                                pAcc->SetPixel( nY, nx, nLast );
+                                pAcc->SetPixelIndex( nY, nx, nLast );
                                 nLast = nLast + *pt++;
                             }
                         }
@@ -913,7 +913,7 @@ sal_Bool TIFFReader::ConvertScanline( sal_uLong nY )
                         {
                             for ( nx = 0; nx < nImageWidth; nx++ )
                             {
-                                pAcc->SetPixel( nY, nx, (sal_uInt8)( ( (sal_uLong)*pt++ - nMinSampleValue ) * nMinMax ) );
+                                pAcc->SetPixelIndex( nY, nx, static_cast<sal_uInt8>( ((sal_uLong)*pt++ - nMinSampleValue) * nMinMax ) );
 
                             }
                         }
@@ -931,7 +931,7 @@ sal_Bool TIFFReader::ConvertScanline( sal_uLong nY )
                     for ( nx = 0; nx < nImageWidth; nx++ )
                     {
                         nVal = ( GetBits( pt, nx * nBitsPerSample, nBitsPerSample ) - nMinSampleValue ) * nMinMax;
-                        pAcc->SetPixel( nY, nx, (sal_uInt8)nVal );
+                        pAcc->SetPixelIndex( nY, nx, static_cast<sal_uInt8>(nVal));
                     }
                 }
                 break;
@@ -945,28 +945,28 @@ sal_Bool TIFFReader::ConvertScanline( sal_uLong nY )
                         while ( --nByteCount )
                         {
                             nByteVal = *pt++;
-                            pAcc->SetPixel( nY, nx++, nByteVal & 1 );
+                            pAcc->SetPixelIndex( nY, nx++, nByteVal & 1 );
                             nByteVal >>= 1;
-                            pAcc->SetPixel( nY, nx++, nByteVal & 1 );
+                            pAcc->SetPixelIndex( nY, nx++, nByteVal & 1 );
                             nByteVal >>= 1;
-                            pAcc->SetPixel( nY, nx++, nByteVal & 1 );
+                            pAcc->SetPixelIndex( nY, nx++, nByteVal & 1 );
                             nByteVal >>= 1;
-                            pAcc->SetPixel( nY, nx++, nByteVal & 1 );
+                            pAcc->SetPixelIndex( nY, nx++, nByteVal & 1 );
                             nByteVal >>= 1;
-                            pAcc->SetPixel( nY, nx++, nByteVal & 1 );
+                            pAcc->SetPixelIndex( nY, nx++, nByteVal & 1 );
                             nByteVal >>= 1;
-                            pAcc->SetPixel( nY, nx++, nByteVal & 1 );
+                            pAcc->SetPixelIndex( nY, nx++, nByteVal & 1 );
                             nByteVal >>= 1;
-                            pAcc->SetPixel( nY, nx++, nByteVal & 1 );
+                            pAcc->SetPixelIndex( nY, nx++, nByteVal & 1 );
                             nByteVal >>= 1;
-                            pAcc->SetPixel( nY, nx++, nByteVal );
+                            pAcc->SetPixelIndex( nY, nx++, nByteVal );
                         }
                         if ( nImageWidth & 7 )
                         {
                             nByteVal = *pt++;
                             while ( nx < nImageWidth )
                             {
-                                pAcc->SetPixel( nY, nx++, nByteVal & 1 );
+                                pAcc->SetPixelIndex( nY, nx++, nByteVal & 1 );
                                 nByteVal >>= 1;
                             }
                         }
@@ -978,21 +978,21 @@ sal_Bool TIFFReader::ConvertScanline( sal_uLong nY )
                         while ( --nByteCount )
                         {
                             nByteVal = *pt++;
-                            pAcc->SetPixel( nY, nx, nByteVal & 1 );
+                            pAcc->SetPixelIndex( nY, nx, nByteVal & 1 );
                             nByteVal >>= 1;
-                            pAcc->SetPixel( nY, --nx, nByteVal & 1 );
+                            pAcc->SetPixelIndex( nY, --nx, nByteVal & 1 );
                             nByteVal >>= 1;
-                            pAcc->SetPixel( nY, --nx, nByteVal & 1 );
+                            pAcc->SetPixelIndex( nY, --nx, nByteVal & 1 );
                             nByteVal >>= 1;
-                            pAcc->SetPixel( nY, --nx, nByteVal & 1 );
+                            pAcc->SetPixelIndex( nY, --nx, nByteVal & 1 );
                             nByteVal >>= 1;
-                            pAcc->SetPixel( nY, --nx, nByteVal & 1 );
+                            pAcc->SetPixelIndex( nY, --nx, nByteVal & 1 );
                             nByteVal >>= 1;
-                            pAcc->SetPixel( nY, --nx, nByteVal & 1 );
+                            pAcc->SetPixelIndex( nY, --nx, nByteVal & 1 );
                             nByteVal >>= 1;
-                            pAcc->SetPixel( nY, --nx, nByteVal & 1 );
+                            pAcc->SetPixelIndex( nY, --nx, nByteVal & 1 );
                             nByteVal >>= 1;
-                            pAcc->SetPixel( nY, --nx, nByteVal );
+                            pAcc->SetPixelIndex( nY, --nx, nByteVal );
                             nx += 15;
                         }
                         if ( nImageWidth & 7 )
@@ -1002,7 +1002,7 @@ sal_Bool TIFFReader::ConvertScanline( sal_uLong nY )
                             nShift = 7;
                             while ( nx < nImageWidth )
                             {
-                                pAcc->SetPixel( nY, nx++, ( nByteVal >> nShift ) & 1);
+                                pAcc->SetPixelIndex( nY, nx++, ( nByteVal >> nShift ) & 1);
                             }
                         }
                     }
@@ -1025,7 +1025,7 @@ sal_Bool TIFFReader::ConvertScanline( sal_uLong nY )
                 pt++;
             for ( nx = 0; nx < nImageWidth; nx++, pt += 2 )
             {
-                pAcc->SetPixel( nY, nx, (sal_uInt8)( ( (sal_uLong)*pt - nMinSampleValue ) * nMinMax ) );
+                pAcc->SetPixelIndex( nY, nx, static_cast<sal_uInt8>( ((sal_uLong)*pt - nMinSampleValue) * nMinMax) );
             }
         }
     }
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index ae2f36f..1914c55 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -5602,7 +5602,7 @@ void PPTPortionObj::ApplyTo(  SfxItemSet& rSet, SdrPowerPointImport& rManager, s
                                 {
                                     for( long nX = 0L; nX < nWidth; nX++ )
                                     {
-                                        const BitmapColor& rCol = pAcc->GetPaletteColor( (sal_uInt8) pAcc->GetPixel( nY, nX ) );
+                                        const BitmapColor& rCol = pAcc->GetPaletteColor( pAcc->GetPixelIndex( nY, nX ) );
                                         nRt+=rCol.GetRed(); nGn+=rCol.GetGreen(); nBl+=rCol.GetBlue();
                                     }
                                 }
diff --git a/include/vcl/bmpacc.hxx b/include/vcl/bmpacc.hxx
index 097fd7c..306f28a 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: */
diff --git a/include/vcl/salbtype.hxx b/include/vcl/salbtype.hxx
index 85a00a1..3fc153d 100644
--- a/include/vcl/salbtype.hxx
+++ b/include/vcl/salbtype.hxx
@@ -117,7 +117,8 @@ public:
     inline              BitmapColor( const BitmapColor& rBitmapColor );
     inline              BitmapColor( sal_uInt8 cRed, sal_uInt8 cGreen, sal_uInt8 cBlue );
     inline              BitmapColor( const Color& rColor );
-    inline              BitmapColor( sal_uInt8 cIndex );
+    explicit inline     BitmapColor( sal_uInt8 cIndex );
+
     inline              ~BitmapColor() {};
 
     inline sal_Bool         operator==( const BitmapColor& rBitmapColor ) const;
@@ -139,7 +140,6 @@ public:
     inline void         SetIndex( sal_uInt8 cIndex );
 
     operator            Color() const;
-    inline operator     sal_uInt8() const;
 
     inline sal_uInt8         GetBlueOrIndex() const;
 
@@ -428,14 +428,6 @@ inline BitmapColor::operator Color() const
 
 // ------------------------------------------------------------------
 
-inline BitmapColor::operator sal_uInt8() const
-{
-    DBG_ASSERT( mbIndex, "Pixel represents color values!" );
-    return mcBlueOrIndex;
-}
-
-// ------------------------------------------------------------------
-
 inline sal_uInt8 BitmapColor::GetBlueOrIndex() const
 {
     // #i47518# Yield a value regardless of mbIndex
diff --git a/svtools/source/graphic/grfmgr2.cxx b/svtools/source/graphic/grfmgr2.cxx
index 7eb8233..45c3686 100644
--- a/svtools/source/graphic/grfmgr2.cxx
+++ b/svtools/source/graphic/grfmgr2.cxx
@@ -423,14 +423,14 @@ sal_Bool ImplCreateRotatedScaled( const BitmapEx& rBmpEx, const GraphicAttr& rAt
                                 nTmpX = pMapIX[ nUnRotX ]; nTmpFX = pMapFX[ nUnRotX ];
                                 nTmpY = pMapIY[ nUnRotY ], nTmpFY = pMapFY[ nUnRotY ];
 
-                                const BitmapColor& rCol0 = pReadAccess->GetPaletteColor( pReadAccess->GetPixel( nTmpY, nTmpX ) );
-                                const BitmapColor& rCol1 = pReadAccess->GetPaletteColor( pReadAccess->GetPixel( nTmpY, ++nTmpX ) );
+                                const BitmapColor& rCol0 = pReadAccess->GetPaletteColor( pReadAccess->GetPixelIndex( nTmpY, nTmpX ) );
+                                const BitmapColor& rCol1 = pReadAccess->GetPaletteColor( pReadAccess->GetPixelIndex( nTmpY, ++nTmpX ) );
                                 cR0 = MAP( rCol0.GetRed(), rCol1.GetRed(), nTmpFX );
                                 cG0 = MAP( rCol0.GetGreen(), rCol1.GetGreen(), nTmpFX );
                                 cB0 = MAP( rCol0.GetBlue(), rCol1.GetBlue(), nTmpFX );
 
-                                const BitmapColor& rCol3 = pReadAccess->GetPaletteColor( pReadAccess->GetPixel( ++nTmpY, nTmpX ) );
-                                const BitmapColor& rCol2 = pReadAccess->GetPaletteColor( pReadAccess->GetPixel( nTmpY, --nTmpX ) );
+                                const BitmapColor& rCol3 = pReadAccess->GetPaletteColor( pReadAccess->GetPixelIndex( ++nTmpY, nTmpX ) );
+                                const BitmapColor& rCol2 = pReadAccess->GetPaletteColor( pReadAccess->GetPixelIndex( nTmpY, --nTmpX ) );
                                 cR1 = MAP( rCol2.GetRed(), rCol3.GetRed(), nTmpFX );
                                 cG1 = MAP( rCol2.GetGreen(), rCol3.GetGreen(), nTmpFX );
                                 cB1 = MAP( rCol2.GetBlue(), rCol3.GetBlue(), nTmpFX );
@@ -527,10 +527,10 @@ sal_Bool ImplCreateRotatedScaled( const BitmapEx& rBmpEx, const GraphicAttr& rAt
                             {
                                 for (int xIn = xStart; xIn <= xEnd; xIn++)
                                 {
-                                    aColor = pReadAccess->GetPixel( yIn, xIn );
-
                                     if( pReadAccess->HasPalette() )
-                                        aColor = pReadAccess->GetPaletteColor( aColor );
+                                        aColor = pReadAccess->GetPaletteColor( pReadAccess->GetPixelIndex( yIn, xIn ) );
+                                    else
+                                        aColor = pReadAccess->GetPixel( yIn, xIn );
 
                                     aSumRed   += aColor.GetRed();
                                     aSumGreen += aColor.GetGreen();
diff --git a/svtools/source/graphic/transformer.cxx b/svtools/source/graphic/transformer.cxx
index 874bb34..1b8e3c2 100644
--- a/svtools/source/graphic/transformer.cxx
+++ b/svtools/source/graphic/transformer.cxx
@@ -54,22 +54,19 @@ GraphicTransformer::~GraphicTransformer()
 
 // ------------------------------------------------------------------------------
 
-void setAlpha( Bitmap& rBitmap, AlphaMask& rAlpha, sal_Int32 nColorFrom, sal_Int8 nAlphaTo )
+void setAlpha( Bitmap& rBitmap, AlphaMask& rAlpha, sal_uInt8 cIndexFrom, sal_Int8 nAlphaTo )
 {
     BitmapWriteAccess* pWriteAccess = rAlpha.AcquireWriteAccess();
     BitmapReadAccess* pReadAccess = rBitmap.AcquireReadAccess();
-    BitmapColor aColorFrom( static_cast< sal_uInt8 >( nColorFrom >> 16 ),
-        static_cast< sal_uInt8 >( nColorFrom >> 8 ),
-        static_cast< sal_uInt8 >( nColorFrom ) );
     if ( pReadAccess && pWriteAccess )
     {
         for ( sal_Int32 nY = 0; nY < pReadAccess->Height(); nY++ )
         {
             for ( sal_Int32 nX = 0; nX < pReadAccess->Width(); nX++ )
             {
-                BitmapColor aColor( pReadAccess->GetPixel( nY, nX ) );
-                if ( aColor == aColorFrom )
-                    pWriteAccess->SetPixel( nY, nX, nAlphaTo );
+                const sal_uInt8 cIndex = pReadAccess->GetPixelIndex( nY, nX );
+                if ( cIndex == cIndexFrom )
+                    pWriteAccess->SetPixelIndex( nY, nX, nAlphaTo );
             }
         }
     }
@@ -87,6 +84,7 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange(
 
     BitmapColor aColorFrom( static_cast< sal_uInt8 >( nColorFrom ), static_cast< sal_uInt8 >( nColorFrom >> 8 ), static_cast< sal_uInt8 >( nColorFrom >> 16 ) );
     BitmapColor aColorTo( static_cast< sal_uInt8 >( nColorTo ), static_cast< sal_uInt8 >( nColorTo >> 8 ), static_cast< sal_uInt8 >( nColorTo  >> 16 ) );
+    const sal_uInt8 cIndexFrom = aColorFrom.GetBlueOrIndex();
 
     if ( aGraphic.GetType() == GRAPHIC_BITMAP )
     {
@@ -96,7 +94,7 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange(
         if ( aBitmapEx.IsAlpha() )
         {
             AlphaMask aAlphaMask( aBitmapEx.GetAlpha() );
-            setAlpha( aBitmap, aAlphaMask, aColorFrom, nAlphaTo );
+            setAlpha( aBitmap, aAlphaMask, cIndexFrom, nAlphaTo );
             aBitmap.Replace( aColorFrom, aColorTo, nTolerance );
             aGraphic = ::Graphic( BitmapEx( aBitmap, aAlphaMask ) );
         }
@@ -113,7 +111,7 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange(
             else
             {
                 AlphaMask aAlphaMask( aBitmapEx.GetMask() );
-                setAlpha( aBitmap, aAlphaMask, aColorFrom, nAlphaTo );
+                setAlpha( aBitmap, aAlphaMask, cIndexFrom, nAlphaTo );
                 aBitmap.Replace( aColorFrom, aColorTo, nTolerance );
                 aGraphic = ::Graphic( BitmapEx( aBitmap, aAlphaMask ) );
             }
@@ -129,7 +127,7 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange(
             else
             {
                 AlphaMask aAlphaMask( aBitmapEx.GetSizePixel() );
-                setAlpha( aBitmap, aAlphaMask, aColorFrom, nAlphaTo );
+                setAlpha( aBitmap, aAlphaMask, cIndexFrom, nAlphaTo );
                 aBitmap.Replace( aColorFrom, aColorTo, nTolerance );
                 aGraphic = ::Graphic( BitmapEx( aBitmap, aAlphaMask ) );
             }
diff --git a/svx/source/gallery2/galobj.cxx b/svx/source/gallery2/galobj.cxx
index 763790a..290eaec 100644
--- a/svx/source/gallery2/galobj.cxx
+++ b/svx/source/gallery2/galobj.cxx
@@ -102,7 +102,7 @@ sal_Bool SgaObject::CreateThumb( const Graphic& rGraphic )
                                       std::max( (long) (fFactor < 1. ? S_THUMB : S_THUMB / fFactor), 8L ) );
 
                 if( aThumbBmp.Scale( (double) aNewSize.Width() / aBmpSize.Width(),
-                                     (double) aNewSize.Height() / aBmpSize.Height(), BMP_SCALE_BEST ) )
+                                     (double) aNewSize.Height() / aBmpSize.Height(), BMP_SCALE_BESTQUALITY ) )
                 {
                     aThumbBmp.Convert( BMP_CONVERSION_8BIT_COLORS );
                     bRet = sal_True;
diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx
index 58b6349..f133ca8 100644
--- a/svx/source/svdraw/svdetc.cxx
+++ b/svx/source/svdraw/svdetc.cxx
@@ -341,9 +341,7 @@ bool GetDraftFillColor(const SfxItemSet& rSet, Color& rCol)
                 {
                     for(sal_uInt32 nX(0L); nX < nWidth; nX += nXStep)
                     {
-                        const BitmapColor& rCol2 = (pAccess->HasPalette())
-                            ? pAccess->GetPaletteColor((sal_uInt8)pAccess->GetPixel(nY, nX))
-                            : pAccess->GetPixel(nY, nX);
+                        const BitmapColor& rCol2 = pAccess->GetColor(nY, nX);
 
                         nRt += rCol2.GetRed();
                         nGn += rCol2.GetGreen();
diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx
index f088526..62a6137 100644
--- a/svx/source/xoutdev/_xoutbmp.cxx
+++ b/svx/source/xoutdev/_xoutbmp.cxx
@@ -332,13 +332,13 @@ Bitmap XOutBitmap::DetectEdges( const Bitmap& rBmp, const sal_uInt8 cThreshold )
                 const long          nHeight = aSize.Height();
                 const long          nHeight2 = nHeight - 2L;
                 const long          lThres2 = (long) cThreshold * cThreshold;
-                const BitmapColor   aWhite = (sal_uInt8) pWriteAcc->GetBestMatchingColor( Color( COL_WHITE ) );
-                const BitmapColor   aBlack = (sal_uInt8) pWriteAcc->GetBestMatchingColor( Color( COL_BLACK ) );
+                const sal_uInt8 nWhitePalIdx = pWriteAcc->GetBestPaletteIndex( Color( COL_WHITE ) );
+                const sal_uInt8 nBlackPalIdx = pWriteAcc->GetBestPaletteIndex( Color( COL_BLACK ) );
                 long                nSum1;
                 long                nSum2;
                 long                lGray;
 
-                // Rand mit Weiss init.
+                // initialize border with white pixels
                 pWriteAcc->SetLineColor( Color( COL_WHITE) );
                 pWriteAcc->DrawLine( Point(), Point( nWidth - 1L, 0L ) );
                 pWriteAcc->DrawLine( Point( nWidth - 1L, 0L ), Point( nWidth - 1L, nHeight - 1L ) );
@@ -351,24 +351,24 @@ Bitmap XOutBitmap::DetectEdges( const Bitmap& rBmp, const sal_uInt8 cThreshold )
                     {
                         nXTmp = nX;
 
-                        nSum1 = -( nSum2 = lGray = (sal_uInt8) pReadAcc->GetPixel( nY, nXTmp++ ) );
-                        nSum2 += ( (long) (sal_uInt8) pReadAcc->GetPixel( nY, nXTmp++ ) ) << 1;
-                        nSum1 += ( lGray = pReadAcc->GetPixel( nY, nXTmp ) );
+                        nSum1 = -( nSum2 = lGray = pReadAcc->GetPixelIndex( nY, nXTmp++ ) );
+                        nSum2 += ( (long) pReadAcc->GetPixelIndex( nY, nXTmp++ ) ) << 1;
+                        nSum1 += ( lGray = pReadAcc->GetPixelIndex( nY, nXTmp ) );
                         nSum2 += lGray;
 
-                        nSum1 += ( (long) (sal_uInt8) pReadAcc->GetPixel( nY1, nXTmp ) ) << 1;
-                        nSum1 -= ( (long) (sal_uInt8) pReadAcc->GetPixel( nY1, nXTmp -= 2 ) ) << 1;
+                        nSum1 += ( (long) pReadAcc->GetPixelIndex( nY1, nXTmp ) ) << 1;
+                        nSum1 -= ( (long) pReadAcc->GetPixelIndex( nY1, nXTmp -= 2 ) ) << 1;
 
-                        nSum1 += ( lGray = -(long) (sal_uInt8) pReadAcc->GetPixel( nY2, nXTmp++ ) );
+                        nSum1 += ( lGray = -(long) pReadAcc->GetPixelIndex( nY2, nXTmp++ ) );
                         nSum2 += lGray;
-                        nSum2 -= ( (long) (sal_uInt8) pReadAcc->GetPixel( nY2, nXTmp++ ) ) << 1;
-                        nSum1 += ( lGray = (long) (sal_uInt8) pReadAcc->GetPixel( nY2, nXTmp ) );
+                        nSum2 -= ( (long) pReadAcc->GetPixelIndex( nY2, nXTmp++ ) ) << 1;
+                        nSum1 += ( lGray = (long) pReadAcc->GetPixelIndex( nY2, nXTmp ) );
                         nSum2 -= lGray;
 
                         if( ( nSum1 * nSum1 + nSum2 * nSum2 ) < lThres2 )
-                            pWriteAcc->SetPixel( nY1, nXDst, aWhite );
+                            pWriteAcc->SetPixelIndex( nY1, nXDst, nWhitePalIdx );
                         else
-                            pWriteAcc->SetPixel( nY1, nXDst, aBlack );
+                            pWriteAcc->SetPixelIndex( nY1, nXDst, nBlackPalIdx );
                     }
                 }
 
diff --git a/svx/source/xoutdev/xattrbmp.cxx b/svx/source/xoutdev/xattrbmp.cxx
index 8a6be6b..d2a5566 100644
--- a/svx/source/xoutdev/xattrbmp.cxx
+++ b/svx/source/xoutdev/xattrbmp.cxx
@@ -297,11 +297,11 @@ Bitmap createHistorical8x8FromArray(const sal_uInt16* pArray, Color aColorPix, C
             {
                 if(pArray[(a * 8) + b])
                 {
-                    pContent->SetPixel(b, a, sal_uInt8(1));
+                    pContent->SetPixelIndex(b, a, 1);
                 }
                 else
                 {
-                    pContent->SetPixel(b, a, sal_uInt8(0));
+                    pContent->SetPixelIndex(b, a, 0);
                 }
             }
         }
diff --git a/vcl/source/filter/igif/gifread.cxx b/vcl/source/filter/igif/gifread.cxx
index fa165d6..f4f5294 100644
--- a/vcl/source/filter/igif/gifread.cxx
+++ b/vcl/source/filter/igif/gifread.cxx
@@ -509,15 +509,15 @@ void GIFReader::FillImages( HPBYTE pBytes, sal_uLong nCount )
             if( bGCTransparent )
             {
                 if( cTmp == nGCTransparentIndex )
-                    pAcc1->SetPixel( nYAcc, nImageX++, cTransIndex1 );
+                    pAcc1->SetPixelIndex( nYAcc, nImageX++, cTransIndex1 );
                 else
                 {
-                    pAcc8->SetPixel( nYAcc, nImageX, cTmp );
-                    pAcc1->SetPixel( nYAcc, nImageX++, cNonTransIndex1 );
+                    pAcc8->SetPixelIndex( nYAcc, nImageX, cTmp );
+                    pAcc1->SetPixelIndex( nYAcc, nImageX++, cNonTransIndex1 );
                 }
             }
             else
-                pAcc8->SetPixel( nYAcc, nImageX++, cTmp );
+                pAcc8->SetPixelIndex( nYAcc, nImageX++, cTmp );
         }
         else
         {
diff --git a/vcl/source/filter/jpeg/JpegWriter.cxx b/vcl/source/filter/jpeg/JpegWriter.cxx
index 44d77ea..0b87ad6 100644
--- a/vcl/source/filter/jpeg/JpegWriter.cxx
+++ b/vcl/source/filter/jpeg/JpegWriter.cxx
@@ -174,7 +174,7 @@ void* JPEGWriter::GetScanline( long nY )
             {
                 for( long nX = 0L; nX < nWidth; nX++ )
                 {
-                    aColor = mpReadAccess->GetPaletteColor( (sal_uInt8) mpReadAccess->GetPixel( nY, nX ) );
+                    aColor = mpReadAccess->GetPaletteColor( mpReadAccess->GetPixelIndex( nY, nX ) );
                     *pTmp++ = aColor.GetRed();
                     if ( !mbGreys )
                     {
@@ -235,7 +235,7 @@ sal_Bool JPEGWriter::Write( const Graphic& rGraphic )
             BitmapColor aColor;
             for( long nX = 0L; bIsGrey && ( nX < nWidth ); nX++ )
             {
-                aColor = mpReadAccess->HasPalette() ? mpReadAccess->GetPaletteColor( (sal_uInt8) mpReadAccess->GetPixel( nY, nX ) )
+                aColor = mpReadAccess->HasPalette() ? mpReadAccess->GetPaletteColor( mpReadAccess->GetPixelIndex( nY, nX ) )
                                             : mpReadAccess->GetPixel( nY, nX );
                 bIsGrey = ( aColor.GetRed() == aColor.GetGreen() ) && ( aColor.GetRed() == aColor.GetBlue() );
             }
diff --git a/vcl/source/filter/wmf/winwmf.cxx b/vcl/source/filter/wmf/winwmf.cxx
index e1dfed1..f16f1d8 100644
--- a/vcl/source/filter/wmf/winwmf.cxx
+++ b/vcl/source/filter/wmf/winwmf.cxx
@@ -596,7 +596,7 @@ void WMFReader::ReadRecordParams( sal_uInt16 nFunc )
                             {
                                 if ( x < nWidth )
                                 {
-                                    pAcc->SetPixel( y, x, (nEightPixels>>i)&1 );
+                                    pAcc->SetPixelIndex( y, x, (nEightPixels>>i)&1 );
                                 }
                                 x++;
                             }
diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx
index c78131b..223dc64 100644
--- a/vcl/source/gdi/bitmap.cxx
+++ b/vcl/source/gdi/bitmap.cxx
@@ -940,7 +940,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;
                         }
@@ -948,7 +948,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++ )
@@ -1212,7 +1212,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();
@@ -1339,14 +1339,14 @@ sal_Bool Bitmap::Replace( const Bitmap& rMask, const Color& rReplaceColor )
             const sal_uInt16 nActColors = pAcc->GetPaletteEntryCount();
             const sal_uInt16 nMaxColors = 1 << pAcc->GetBitCount();
 
-            // For a start, choose the next color
+            // default to the nearest color
             aReplace = pAcc->GetBestMatchingColor( rReplaceColor );
 
-            // If it's a pallette picture and the color that should be set
-            // is not in the pallette, we try finding a free entry (expensive)
-            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 ) )
             {
-                // See first if we can put the ReplaceColor at a free entry at the end of the pallette
+                // if the palette has empty entries use the last one
                 if( nActColors < nMaxColors )
                 {
                     pAcc->SetPaletteEntryCount( nActColors + 1 );
@@ -1362,7 +1362,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++ )
                     {
@@ -1414,7 +1414,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 ) ) );
             }
         }
 
@@ -1783,7 +1783,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 f71e757..92078d2 100644
--- a/vcl/source/gdi/bitmap2.cxx
+++ b/vcl/source/gdi/bitmap2.cxx
@@ -520,7 +520,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);
                         }
                     }
                 }
@@ -544,7 +544,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);
                         }
                     }
                 }
@@ -559,7 +559,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;
@@ -965,7 +965,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;
@@ -990,7 +990,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 );
@@ -1005,7 +1005,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 );
                     }
@@ -1075,16 +1075,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++;
                     }
@@ -1097,7 +1097,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++;
                     }
@@ -1130,19 +1130,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 );
             }
         }
     }
@@ -1171,9 +1171,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++;
@@ -1191,7 +1192,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;
@@ -1210,10 +1212,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;
@@ -1221,7 +1223,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 )
@@ -1235,12 +1237,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 b92d9fe..2b9ed69 100644
--- a/vcl/source/gdi/bitmap3.cxx
+++ b/vcl/source/gdi/bitmap3.cxx
@@ -344,7 +344,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 );
@@ -418,7 +419,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 );
@@ -498,9 +500,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) );
                         }
                     }
                 }
@@ -548,7 +550,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 );
@@ -621,7 +623,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
                 {
@@ -705,7 +707,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 );
                 }
@@ -713,9 +715,9 @@ sal_Bool Bitmap::ImplConvertDown( sal_uInt16 nBitCount, Color* pExtColor )
 
             for( nY = 0L; nY < nHeight; nY++, nYTmp++ )
             {
-                // First RowPixel
+                // 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++ )
                 {
@@ -725,14 +727,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 );
                 }
 
                 // Last RowPixel
                 if( nX < nWidth )
                 {
                     cIndex = (sal_uInt8) aColorMap.GetBestPaletteIndex( pQLine1[ nWidth1 ].ImplGetColor() );
-                    pWriteAcc->SetPixel( nY, nX, cIndex );
+                    pWriteAcc->SetPixelIndex( nY, nX, cIndex );
                 }
 
                 // Refill/copy row buffer
@@ -744,7 +746,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 );
                     }
@@ -1027,7 +1029,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 );
@@ -1038,8 +1040,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 ];
 
@@ -1131,7 +1133,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 );
@@ -1142,8 +1144,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 ];
 
@@ -1252,7 +1254,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;
@@ -1338,7 +1340,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;
@@ -1369,7 +1371,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;
@@ -1395,7 +1397,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 ]) );
 
                 // Get middle Pixels using a loop
                 long nXAcc;
@@ -1406,7 +1408,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 ]) );
                 }
 
                 // Treat last Pixel separately
@@ -1414,7 +1416,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;
@@ -1583,13 +1585,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 );
@@ -1680,7 +1682,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++;
@@ -1732,7 +1734,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 ) ] );
@@ -1816,7 +1818,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 ) ]++;
                     }
                 }
@@ -1843,7 +1845,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 );
@@ -2272,9 +2274,7 @@ bool Bitmap::ImplConvolutionPass(Bitmap& aNewBitmap, const int nNewSize, BitmapR
                 aIndex = aBaseIndex + j;
                 aSum += aWeight = pWeights[ aIndex ];
 
-                aColor = pReadAcc->GetPixel( y, pPixels[ aIndex ] );
-                if( pReadAcc->HasPalette() )
-                    aColor = pReadAcc->GetPaletteColor( aColor );
+                aColor = pReadAcc->GetColor( y, pPixels[ aIndex ] );
 
                 aValueRed   += aWeight * aColor.GetRed();
                 aValueGreen += aWeight * aColor.GetGreen();
diff --git a/vcl/source/gdi/bitmap4.cxx b/vcl/source/gdi/bitmap4.cxx
index 45c99c8..b0afd67 100644
--- a/vcl/source/gdi/bitmap4.cxx
+++ b/vcl/source/gdi/bitmap4.cxx
@@ -839,7 +839,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();
@@ -1145,17 +1145,8 @@ bool Bitmap::ImplSeparableUnsharpenFilter(const double radius) {
     {
         for( int y = 0; y < nHeight; y++ )
         {
-            aColorBlur = pReadAccBlur->GetPixel( y , x );
-            if( pReadAccBlur->HasPalette() )
-            {
-                 pReadAccBlur->GetPaletteColor( aColorBlur );
-            }
-
-            aColor = pReadAcc->GetPixel( y , x );
-            if( pReadAcc->HasPalette() )
-            {
-                aColor = pReadAcc->GetPaletteColor( aColor );
-            }
+            aColorBlur = pReadAccBlur->GetColor( y , x );
+            aColor = pReadAcc->GetColor( y , x );
 
             BitmapColor aResultColor(
                 (sal_uInt8) MinMax( aColor.GetRed()   + (aColor.GetRed()   - aColorBlur.GetRed())   * aAmount, 0, 255 ),
diff --git a/vcl/source/gdi/bmpacc2.cxx b/vcl/source/gdi/bmpacc2.cxx
index 22a6ce2..bf1d540 100644
--- a/vcl/source/gdi/bmpacc2.cxx
+++ b/vcl/source/gdi/bmpacc2.cxx
@@ -22,7 +22,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 );
 }
 
 IMPL_FORMAT_SETPIXEL_NOMASK( _1BIT_MSB_PAL )
@@ -35,7 +35,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 );
 }
 
 IMPL_FORMAT_SETPIXEL_NOMASK( _1BIT_LSB_PAL )
@@ -48,7 +48,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 );
 }
 
 IMPL_FORMAT_SETPIXEL_NOMASK( _4BIT_MSN_PAL )
@@ -61,7 +61,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 );
 }
 
 IMPL_FORMAT_SETPIXEL_NOMASK( _4BIT_LSN_PAL )
@@ -74,7 +74,7 @@ IMPL_FORMAT_SETPIXEL_NOMASK( _4BIT_LSN_PAL )
 
 IMPL_FORMAT_GETPIXEL_NOMASK( _8BIT_PAL )
 {
-    return pScanline[ nX ];
+    return BitmapColor( pScanline[ nX ] );
 }
 
 IMPL_FORMAT_SETPIXEL_NOMASK( _8BIT_PAL )
diff --git a/vcl/source/gdi/octree.cxx b/vcl/source/gdi/octree.cxx
index 0774003..93fb8c5 100644
--- a/vcl/source/gdi/octree.cxx
+++ b/vcl/source/gdi/octree.cxx
@@ -100,7 +100,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 11bdd11..e178426 100644
--- a/vcl/source/gdi/outdev2.cxx
+++ b/vcl/source/gdi/outdev2.cxx
@@ -1437,8 +1437,8 @@ inline BitmapColor lcl_AlphaBlend( int nX,               int nY,
     aDstCol = pB->GetColor( nY, nX );
 
     // vcl stores transparency, not alpha - invert it
-    const sal_uInt8 nSrcAlpha = 255 - pA->GetPixel( nMapY, nMapX ).GetBlueOrIndex();
-    const sal_uInt8 nDstAlpha = 255 - pAlphaW->GetPixel( nY, nX ).GetBlueOrIndex();
+    const sal_uInt8 nSrcAlpha = 255 - pA->GetPixelIndex( nMapY, nMapX );
+    const sal_uInt8 nDstAlpha = 255 - pAlphaW->GetPixelIndex( nY, nX );
 
     // Perform porter-duff compositing 'over' operation
     //
@@ -1592,7 +1592,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 f1ae865..4eeb6f5 100644
--- a/vcl/source/gdi/pngread.cxx
+++ b/vcl/source/gdi/pngread.cxx
@@ -1409,7 +1409,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 );
 }
 
 void PNGReaderImpl::ImplSetTranspPixel( sal_uInt32 nY, sal_uInt32 nX, const BitmapColor& rBitmapColor, sal_Bool bTrans )
@@ -1435,8 +1435,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 );
 }
 
 void PNGReaderImpl::ImplSetAlphaPixel( sal_uInt32 nY, sal_uInt32 nX,
@@ -1448,7 +1448,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 );
 }
 
 sal_uInt32 PNGReaderImpl::ImplReadsal_uInt32()
diff --git a/vcl/source/gdi/pngwrite.cxx b/vcl/source/gdi/pngwrite.cxx
index fcd4211..f7c6086 100644
--- a/vcl/source/gdi/pngwrite.cxx
+++ b/vcl/source/gdi/pngwrite.cxx
@@ -327,7 +327,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 );
 
@@ -473,11 +473,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
@@ -489,9 +489,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++;
                 }
@@ -500,7 +500,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;
 
@@ -521,7 +521,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

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list