title: Show Error in Scanline When PixelFormat is pf8bit
body: <p>I use <a href="http://community.embarcadero.com/blogs?view=entry&amp;id=3342" rel="nofollow">this code</a> to scan very fast Bitmap.</p>
  
  <p>Everything is Ok When PixelFormat = pf24bit but my program only work with 256 image color and for this reason PixelFormat = pf8bit.</p>
  
  <p>When PixelFormat = pf8bit this code show error.</p>
  
  <pre><code>  var
      w, h: Integer;
      CurrRow, OffSet: Integer;
      x: byte;
      pRed, pGreen, pBlue: PByte;
    begin
      CurrRow := Integer(aBitmap.Scanline[0]);
      OffSet := Integer(aBitmap.Scanline[1]) - CurrRow;
      Result:= False;
      for h := 0 to aBitmap.Height - 1 do
      begin
        for w := 0 to aBitmap.Width - 1 do
        begin
          pBlue := PByte(CurrRow + w * 3);
          pGreen := PByte(CurrRow + w * 3 + 1);
          pRed := PByte(CurrRow + w * 3 + 2);
        end;
        inc(CurrRow, OffSet);
      end;
  </code></pre>
  
  <p>now I use this code to swap color but dont work because scanline dont check color</p>
  
  <pre><code>  procedure ReplaceColor(aBitmap: TBitmap; swap1, swap2: TRGBQuad);
    var
    w, h, k: Integer;
    pScanline: pByte;
    Red, Green, Blue, palindex: Byte;
    PalEntries: array[0..255] of TRGBQuad;
  begin
    if aBitmap.Palette &lt;&gt; 0 then
      GetPaletteEntries(aBitmap.Palette, 0, 255, PalEntries);
  
    for h := 0 to aBitmap.Height - 1 do
    begin
      pScanline := pByte(aBitmap.Scanline[h]);
  
      for w := 0 to aBitmap.Width - 1 do
      begin
  
             Blue:=  PalEntries[pScanline^].rgbBlue ;
             Red:=  PalEntries[pScanline^].rgbRed ;
             Green:=  PalEntries[pScanline^].rgbGreen ;
  
            if (Blue = swap1.rgbBlue) and (Red = swap1.rgbRed) and
              (Green = swap1.rgbGreen) then
            begin
              Blue := swap2.rgbBlue;
  
              Green := swap2.rgbGreen;
  
              Red := swap2.rgbRed;
  
            end
            else if (Blue = swap2.rgbBlue) and (Red = swap2.rgbRed) and
              (Green = swap2.rgbGreen) then
            begin
              Blue := swap1.rgbBlue;
  
              Green := swap1.rgbGreen;
  
              Red := swap1.rgbRed;
  
            end;
  
           Inc(pScanline);
      end;
    end;
  end;
  </code></pre>