bsp; begin
for by := 0 to bm.Height-1 do
begin
//clBlue = TColor($FF0000); clBlack = TColor($000000);
//clRed = TColor($0000FF);clWhite = TColor($FFFFFF);
//clLime = TColor($00FF00);
aColor:=bm.Canvas.Pixels[bx,by];
aChageColorEn:=False;
aClb:=Abs( Byte(aColor shr 16)- Byte(aMainColor shr 16));
if aClb<=aMainTorl then
begin
// Blue ok
aClg:=Abs( Byte(aColor shr 8)-Byte(aMainColor shr 8));
if aClg <= aMainTorl then
begin
//Green OK
aClr:=Abs( Byte(aColor)-Byte(aMainColor));
if aClr <= aMainTorl then
begin
//Red ok
aChageColorEn:=True;
end;
end;
end;
if aChageColorEn then
bm.Canvas.Pixels[bx,by]:=TColor($FFFFFF); //White
else
bm.Canvas.Pixels[bx,by]:=TColor($000000); //Black
end;
end;
Result:=bm;
end;
//图片反色
procedure TFrmMain.Negative(var Bmp:TBitmap);
var
i, j: Integer;
PRGB: pRGBTriple;
begin
Bmp.PixelFormat:=pf24Bit;
for i := 0 to Bmp.Height - 1 do
begin
PRGB := Bmp.ScanLine[i];
for j := 0 to Bmp.Width - 1 do
begin
PRGB^.rgbtRed :=not PRGB^.rgbtRed ;
PRGB^.rgbtGreen :=not PRGB^.rgbtGreen;
PRGB^.rgbtBlue :=not PRGB^.rgbtBlue;
Inc(PRGB);
end;
end;
end;
以上只做大家的参考
写的不好 别喷我啊