Autor Beitrag
stratege15
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 58



BeitragVerfasst: Di 11.11.03 17:31 
hi,
wie kann man mit idtcpclient eine datei downloaden?
hab mal was gemacht um ein bild aus dem internet anzeigen zu lassen .. aber irgendwie funktioniert es nicht:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.IdTCPClient1Connected(Sender: TObject);
var s: tstream; bit: tbitmap;
begin
s:=tstream.Create;
idtcpclient1.ReadStream(s);
bit:=tbitmap.Create;
bit.LoadFromStream(s);
image1.Picture.Graphic.LoadFromStream(s);
bit.free;
end;


kann mir da jemand weiterhelfen?
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Di 11.11.03 19:44 
also so kannst du ein bild gelich ausm netz in eine image kompo laden ohne den umweg über ne datei:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
var MS : TMemoryStream;
    JPeg: TJPegImage;

MS := TMemoryStream.Create;
JPeg := TJPegImage.Create;
try
  IdHTTP1.Get('http://pic.jpg', MS);
  MS.Position := 0;
  JPeg.LoadFromStream(MS);
  image1.Picture.Bitmap.Assign(JPeg);
finally
  MS.Free;
  JPeg.Free;
end;

_________________
In the beginning was the word.
And the word was content-type: text/plain.
stratege15 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 58



BeitragVerfasst: Mi 12.11.03 15:31 
thx .. aber geht das auch irgendwie über die indy kompo idtcpclient?
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Mi 12.11.03 16:18 
dann müsstest du halt die ganze arbiet mit dem http headern un dem http protocoll selber machen !!! würde ich dir nicht empfehlen !

_________________
In the beginning was the word.
And the word was content-type: text/plain.
stratege15 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 58



BeitragVerfasst: Mi 12.11.03 17:29 
ne aber ich meinte jetzt von einem pc zum anderen .. und nicht von nem webserver.
und wie könnte ich den memorystream zum speichern von z.b. exe-dateien einsetzen?