ReplaceExactColor

procedure ReplaceExactColor(img: TImage32; 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 Img32, Img32.Extra, Img32.Fmt.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

RemoveColor