unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,GDIPAPI,GDIPOBJ, StdCtrls, ExtCtrls;
type
TForm2 =
class(TForm)
Image1: TImage;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
Function ColorToTGPColor (c : Tcolor; trans : Byte = 255):TGPColor;
Type
TBarry=Array[0..3]
of Byte;
Var
Barry:TBarry;
R:Byte;
begin
move(C,Barry,4);
R:=Barry[2];
Barry[2]:=Barry[0];
Barry[0]:=R;
Barry[3]:=trans;
move(Barry,Result,4);
end;
Procedure GDILineTo( C:TCanvas; x,y:Integer);
var
G:TGPGraphics;
P:TGPPen;
begin
G:=TGPGraphics.Create(C.Handle);
G.SetSmoothingMode(SmoothingModeHighQuality);
P:=TGPPen.Create(ColorToTGPColor(C.Pen.Color),C.Pen.Width);
G.DrawLine(p,C.PenPos.X,C.PenPos.Y,x,y);
P.Free;
G.Free;
C.MoveTo(X,Y);
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
Image1.Canvas.MoveTo(10,10);
Image1.Canvas.Pen.Color := clBlue;
Image1.Canvas.Pen.Width := 3;
GDILineTo(Image1.Canvas, 100,100);
Image1.Canvas.Pen.Color := clRed;
GDILineTo(Image1.Canvas, 400,10);
end;
end.