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
|
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, IdBaseComponent, IdComponent, jpeg, IdTCPConnection,
IdTCPClient, IdHTTP;
type
TMyThread = class(TThread)
procedure Execute; override;
end;
type
TFMonitor1 = class(TForm)
Image1: TImage;
IdHTTP1: TIdHTTP;
procedure LoadImage;
procedure ShowImage;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Déclarations privées }
url: string;
MyStreamt:TMemoryStream;
Jpg:TJpegImage;
thread: TThread;
public
{ Déclarations publiques }
end;
var
FMonitor1: TFMonitor1;
// IdHTTP1:Tidhttp;
// MyStreamt:TMemoryStream;
// Jpg:TJpegImage;
// BMP : TBitmap;
implementation
{$R *.dfm}
procedure TMyThread.Execute;
begin
repeat
Fmonitor1.LoadImage;
Synchronize(FMonitor1.ShowImage);
Sleep(0);
until Terminated;
end;
procedure TFmonitor1.LoadImage;
begin
Mystreamt.clear ;
Try
IdHTTP1.Request.UserAgent := 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1';
IdHTTP1.Get(url,Mystreamt);
except
End;
end;
procedure TFMonitor1.ShowImage;
begin
Mystreamt.Seek(0, soFromBeginning); { on rembobine le stream }
jpg.LoadFromStream(MyStreamt);
Image1.Picture.Assign(jpg);
end;
procedure TFMonitor1.FormCreate(Sender: TObject);
begin
url := 'http://192.168.1.83:88/snapshot.cgi?user=&pwd=';
Mystreamt := TMemoryStream.Create;
jpg := TJPEGImage.Create;
thread := TMyThread.Create;
// IdHTTP1.Get('http://192.168.1.83:88/snapshot.cgi?user=&pwd=',Mystreamt);
end;
procedure TFMonitor1.FormDestroy(Sender: TObject);
begin
thread.Free
mystreamt.Free;
jpg.Free;
end;
end. |
Partager