1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
type
TForm1 = class(TForm)
Sauver: TButton;
Image2: TImage;
Label2: TLabel;
Effacer: TButton;
Signature: TImage;
procedure ppPaintBox1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
procedure FormCreate(Sender: TObject);
procedure SignatureMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
procedure SignatureMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Single);
procedure SignatureMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
procedure EffacerClick(Sender: TObject);
procedure SauverClick(Sender: TObject);
private
{ Déclarations privées }
painting : boolean;
OldX, OldY : Single;
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.EffacerClick(Sender: TObject);
begin
With Signature.Bitmap.Canvas do
begin
BeginScene;
Clear(TAlphacolors.white);
EndScene;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Painting:=False;
GlobalUseGPUCanvas:=true;
Signature.Bitmap.SetSize(trunc(Signature.Width),trunc(Signature.Height));
With Signature.Bitmap.Canvas do
begin
BeginScene;
Stroke.Thickness:=2;
Stroke.Color:=TAlphaColorRec.Black;
Stroke.Kind:=TBrushKind.bkSolid;
EndScene;
end;
end;
procedure TForm1.SauverClick(Sender: TObject);
begin
Signature.Bitmap.SaveToFile('Signature.jpg');
Image2.Bitmap.LoadFromFile('Signature.jpg');
end;
procedure TForm1.SignatureMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
begin
Painting:=true;
OldX:=X;
OldY:=Y;
end;
procedure TForm1.SignatureMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Single);
var Point1,Point2 : TPointF;
begin
if Painting then
begin
Point1:=TPointF.Create(OldX,OldY);
Point2:=TPointF.Create(X,Y);
with Signature.Bitmap.Canvas do
begin
BeginScene;
DrawLine(Point1,Point2,1);
EndScene;
end;
oldx:=X;
oldy:=Y;
end;
end;
procedure TForm1.SignatureMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
begin
Painting:=False;
end;
procedure TForm1.ppPaintBox1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
begin
painting:=false;
end; |
Partager