Delphi实现图像反色实例4种方法


Delphi实现图像反色实例4种方法
procedure TForm1.Button1Click(Sender: TObject);
var
MyDC: HDC;
begin
MyDC := GetDC(Form1.Handle);
if not PatBlt(MyDC,
Image1.Left,
Image1.Top,
Image1.Left + Image1.Width,
Image1.Top + Image1.Height,
DSTINVERT) then
ShowMessage('ERROR :~(');
end;


procedure TForm1.Button2Click(Sender: TObject);
var
BMP: TBitmap;
begin
Bmp := TBitmap.Create;
try
Bmp.Width := Image1.Picture.Bitmap.Width;
Bmp.Height := Image1.Picture.Bitmap.Height;
Bitblt(Bmp.Canvas.Handle, 0, 0, Bmp.Width, Bmp.Height, Image1.Picture.Bitmap.Canvas.Handle, 0, 0, NOTSRCCOPY);
Image2.Picture.Bitmap.Assign(Bmp);
finally
Bmp.Free;
end;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
invertrect(image2.Canvas.Handle, image1.ClientRect);
image2.Repaint;

end;

procedure TForm1.Button5Click(Sender: TObject);
var
p: PByteArray;
x, y: Integer;
Bmp: TBitmap;
begin
Bmp := TBitmap.Create;
Bmp.Assign(Image1.Picture.Bitmap);
Bmp.PixelFormat := pf24Bit;
for y := 0 to Bmp.Height - 1 do
begin
p := Bmp.scanline[y];
for x := 0 to Bmp.Width - 1 do
begin
begin
p[x * 3] := not p[x * 3];
p[x * 3 + 1] := not p[x * 3 + 1];
p[x * 3 + 2] := not p[x * 3 + 2];
end
end;
end;
Image2.Picture.Bitmap.Assign(Bmp);
Bmp.Free;
end;
联系电话:
020-00000000
联系电话:
020-00000000
联系电话:
020-12345678