title: change a bitmap's pixel colour
body: <p>I am trying to change a bit-map's pixel color if it's white. I wrote following code. But it's awfully slow!. i want to check if a pixel's color is white or not, and if it is white, change the color to black.</p>
  
  <p>Can anybody suggest a better approach?</p>
  
  <pre><code>procedure TForm1.Button1Click(Sender: TObject);
  var
    BitMap1 : TBitmap;
    X, Y, Size : Integer;
  
    P: Cardinal;
  begin
    BitMap1 := TBitmap.Create;
    bitMap1.LoadFromFile('image1.bmp');
  
    for Y := 0 to Bitmap1.Height - 1 do
    begin
      for X := 0 to Bitmap1.width  * size - 1 do
      begin
      p := BitMap1.Canvas.Pixels[X,Y];
      if p = 255 then
        BitMap1.Canvas.Pixels[X,Y] := 0;
  
      end;
    end;
  
    Image1.Picture.Assign(BitMap1);
  end;
  </code></pre>