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
|
unit UPrinc;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, UDll, UCamera,
StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Image1: TImage;
Timer1: TTimer;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Déclarations privées}
nbCamera : integer;
fCamera : TCamera;
fImage: pointer;
fBitmapInfo: PBitmapInfo;
public
{ Déclarations publiques}
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
if fCamera.PrendrePhoto(1,1,time,true) then showMessage('photo prise !!!');
end;
procedure TForm1.Button2Click(Sender: TObject);
var num : integer;
begin
fImage := nil;
num:=AttentePhoto(300);
if num<>-1 then
begin
fImage := fCamera.RecupererPhoto;
if fImage<>nil then showMessage('photo récupérée');
end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FreeMem(fBitmapInfo, sizeof(TBitmapInfo)+256*sizeof(RGBQUAD));
end;
procedure TForm1.FormShow(Sender: TObject);
var index: integer;
begin
if InitialisationDll then showMessage('chargement dll réussi');
nbCamera:=InitialisationBus(0,0);
showMessage('fait');
fCamera := TCamera.Create(0);
GetMem(fBitmapInfo, sizeof(TBitmapInfo)+256*sizeof(RGBQUAD)); // Allocation d'une zone mémoire (affecté à fBitmapInfo)
// la taille est : la taille de l'en-tête d'un TBitmapInfo + la palette de couleur
// (pour nous les 256 niveaux de gris).
fBitmapInfo^.bmiHeader.biSize := sizeof(TBitmapInfoHeader);
fBitmapInfo^.bmiHeader.biPlanes := 1;
fBitmapInfo^.bmiHeader.biBitCount := 8;
fBitmapInfo^.bmiHeader.biCompression := BI_RGB;
fBitmapInfo^.bmiHeader.biXPelsPerMeter := 1;
fBitmapInfo^.bmiHeader.biYPelsPerMeter := 1;
fBitmapInfo^.bmiHeader.biClrUsed := 256;
fBitmapInfo^.bmiHeader.biClrImportant := 0;
fBitmapInfo^.bmiHeader.biWidth := 100;
fBitmapInfo^.bmiHeader.biHeight := 100;
fBitmapInfo^.bmiHeader.biSizeImage := 100*100;
for index:=0 to 255 do
begin
FillChar(fBitmapInfo^.bmiColors[index],sizeof(RGBQUAD),index);
end;
if fCamera.Initialise then showMessage('initialisation réussie');
end;
procedure TForm1.Button3Click(Sender: TObject);
var nb : integer;
begin
image1.Picture.Bitmap.Canvas.Lock;
nb := StretchDIBits(image1.Picture.Bitmap.Canvas.Handle, 0, 0, 100, 100, 0, 0, 100, 100, fImage, fBitmapInfo^, DIB_RGB_COLORS, SRCCOPY);
showMessage(IntToStr(nb));
image1.Picture.Bitmap.Canvas.Unlock;
Image1.Repaint;
end;
end. |
Partager