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
|
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TForm1 = class(TForm)
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormPaint(Sender: TObject);
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure FormCreate(Sender: TObject);
private
{ Déclarations privées }
largeur,hauteur:integer;
bmp,buff,diaphragme:Tbitmap;
procedure creebmp(w,h:integer;out bitmap:Tbitmap);
procedure deplace(x,y:integer);
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
width:=screen.Width;
height:=screen.Height;
position:=poscreencenter;
largeur:=form1.ClientWidth;
hauteur:=form1.ClientHeight;
bmp:=Tbitmap.Create;
with bmp do begin
width:=largeur;
height:=hauteur;
end;
buff:=Tbitmap.create;
buff.Assign(bmp);
bmp.LoadFromFile('Chemin carte.bmp');
diaphragme:=Tbitmap.create;
with diaphragme do begin
width:=100;
height:=100;
end;
end;
procedure Tform1.deplace(x,y:integer);
begin
diaphragme.Canvas.CopyRect(rect(0,0,100,100),bmp.Canvas,rect(x-50,y-50,50+x,50+y));
end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
deplace(x,y);
with buff.Canvas do begin
brush.Color:=clblack;
fillrect(form1.clientrect);
Draw(x-50,y-50,diaphragme);
end;
canvas.draw(0,0,buff);
end;
procedure Tform1.creebmp(w,h:integer;out bitmap:Tbitmap); //ne sert à rien; j'ai essayé mais ça ne marche pas à voir...
begin
bitmap:=Tbitmap.Create;
width:=w;
height:=h;
end;
procedure TForm1.FormPaint(Sender: TObject);
begin
canvas.draw(0,0,buff);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
bmp.Free;
buff.Free;
diaphragme.Free;
end;
end. |
Partager