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 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Unit3, Math;
type
TForm2 = class(TForm)
PaintBox1: TPaintBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Button1: TButton;
Button2: TButton;
PaintBox2: TPaintBox;
Panel1: TPanel;
Image2: TImage;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure PaintBox1Paint(Sender: TObject);
procedure PaintBox2Paint(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Déclarations privées }
Bitmap: TBitmap;
RotatedBitmap: TBitmap;
procedure Rotate(angle: integer);
public
{ Déclarations publiques }
end;
var
Form2: TForm2;
implementation
uses Unit1;
procedure chgt_rep_lati_longi ();
var
epsilon : real;
begin
epsilon := alpha - beta;
Yr := distance * cos(epsilon*Pi/180);
Xr := distance * sin(epsilon*Pi/180);
Form2.PaintBox2.Left := 272{Form3.PaintBox2.Left} - round(Xr)+ round(h);
Form2.PaintBox2.Top := 40{Form3.PaintBox2.Top} + round(Yr)+ round(v);
end;
.
.
.
procedure TForm2.Rotate(angle: integer);
var
RadAngle: extended;
SinAngle, CosAngle: extended;
CenterX, CenterY: extended;
X, Y: extended;
Xi, Yi: integer;
i, j: integer;
c: TColor;
begin
RadAngle := angle * pi / 180;
SinAngle := sin(RadAngle);
CosAngle := cos(RadAngle);
CenterX := Bitmap.Width div 2;
CenterY := Bitmap.Height div 2;
for i := 0 to Pred(RotatedBitmap.Width) do
for j := 0 to Pred(RotatedBitmap.Height) do
begin
X := (j - CenterY) * SinAngle + (i - CenterX) * CosAngle + CenterX;
Y := (j - CenterY) * CosAngle - (i - CenterX) * SinAngle + CenterY;
Xi := Round(X);
Yi := Round(Y);
c := Bitmap.Canvas.Pixels[Xi, Yi];
if (c = -1) then c := clWhite;
RotatedBitmap.Canvas.Pixels[i, j] := c;
end;
end;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
Application.Terminate ;
end;
procedure TForm2.PaintBox1Paint(Sender: TObject);
begin
PaintBox1.Canvas.Draw(0, 0, Bitmap);
end;
procedure TForm2.PaintBox2Paint(Sender: TObject);
begin
PaintBox1.Canvas.Draw(0, 0, RotatedBitmap);
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
Bitmap := TBitmap.Create;
RotatedBitmap := TBitmap.Create;
Bitmap.LoadFromFile('ETface.bmp');
RotatedBitmap.LoadFromFile('EtFace.bmp');
end;
procedure TForm2.FormActivate(Sender: TObject);
begin
DoubleBuffered :=True;
while (QFU_new_repere<340) do
begin
fct_diff;
fct_angle;
fct_c;
fct_repere_avion;
deplacement_piste;
chgt_rep_lati_longi;
latitude_avion := latitude_avion + 0.02;
longitude_avion := longitude_avion + 0.02;
//Screen.Cursor := crHourGlass;
//Form2.Image2.Visible := False;
Rotate(Round(QFU_new_repere));
Form2.Refresh;
//Form2.Image1.Visible := True;
Paintbox2.Canvas.Draw(0, 0, RotatedBitmap);
Form2.PaintBox2.SendToBack;
Form2.Image2.Visible := True;
Form2.Image2.BringToFront;
RotatedBitmap.SaveToFile('C:\tmpBmp.bmp');
//Screen.Cursor := crDefault;
Form2.Label1.Caption := FloatToStr (Xr) ;
Form2.Label2.Caption := FloatToStr (Yr) ;
Form2.Label3.Caption := FloatToStr (QFU_new_repere);
route := route + 2;
end;
end;
end. |
Partager