type
PRGBArray = ^TRGBArray;
TRGBArray = array [0..MaxPixelCount - 1] of TRGBTriple;
procedure Convert2TargetColor(bmp: TBitmap; targetColor: TColor);
var
i, j: Integer;
Row: PRGBArray;
R,G,B: Byte;
begin
R := GetRValue(ColorToRGB(targetColor));
G := GetGValue(ColorToRGB(targetColor));
B := GetBValue(ColorToRGB(targetColor));
for i := 0 to Bmp.Height - 1 do
begin
Row := Bmp.Scanline[i];
for j := 0 to Bmp.Width - 1 do
begin
Row[j].rgbtRed := 255 - (255 - Row[j].rgbtRed) * (255 - R) div 255;
Row[j].rgbtGreen := 255 - (255 - Row[j].rgbtGreen) * (255 - G) div 255;
Row[j].rgbtBlue := 255 - (255 - Row[j].rgbtBlue) * (255 - B) div 255;
end;
end;
Bmp.Canvas.Refresh;
end;