ReplaceColor

procedure ReplaceColor(oldColor, newColor: TColor32);


Replaces a color with another, but only where pixels exactly match oldColor.

Note: Be careful when using this procedure in antialiased drawings as oldColor will mostly remain where antialiasing has blended this with adjacent colors.

Example

  uses Image32, Image32_Extra, Image32_PNG;
  ...
  img := TImage32.Create;
  img.LoadFromFile('beetle_aq.png');
  //make aqua colored pixels transparent, but unlike EraseColor, 
  //here there's no accommodation for blended colors
  ReplaceColor(img, clAqua32, clNone32); 
  img.SaveToFile('beetle3.png');
  img.Free;
      
Before:
After:

See Also

EraseColor