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
|
Unit Unit1;
{$mode objfpc}{$H+}
Interface
Uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
BZGraphic, BZBitmap, BZBitmapIO;
Type
{ TForm1 }
TForm1 = Class(TForm)
Button1: TButton;
OPD: TOpenDialog;
pnlView: TPanel;
Procedure Button1Click(Sender: TObject);
Procedure FormCreate(Sender: TObject);
Procedure FormDestroy(Sender: TObject);
Procedure FormPaint(Sender: TObject);
private
public
Bmp : TBZBitmap;
isLoaded : Boolean;
End;
Var
Form1: TForm1;
Implementation
{$R *.lfm}
{ TForm1 }
Procedure TForm1.FormCreate(Sender: TObject);
Begin
isLoaded := False;
Bmp := TBZBitmap.Create;
end;
Procedure TForm1.Button1Click(Sender: TObject);
Var
w,h : integer;
Begin
if OPD.Execute then
begin
w := pnlView.ClientRect.Right;
h := pnlView.ClientRect.Bottom;
Screen.Cursor := crHourGlass;
Bmp.LoadFromFile(OPD.FileName);
Bmp.Transformation.Stretch(w,h,true);
isLoaded := True;
Screen.Cursor := crDefault;
Invalidate;
End;
end;
Procedure TForm1.FormDestroy(Sender: TObject);
Begin
FreeAndNil(Bmp)
end;
Procedure TForm1.FormPaint(Sender: TObject);
Begin
if IsLoaded then Bmp.DrawToCanvas(pnlView.Canvas, pnlView.ClientRect,True,False); // Satané TRect.i Il est ou ClientBounds ???? mdr Microsoft ou pas Microsoft ?
end;
End. |
Partager