AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Multimedia Delphi Bitmap.LoadFromFile (internetfile)
Thema durchsuchen
Ansicht
Themen-Optionen

Bitmap.LoadFromFile (internetfile)

Ein Thema von mr_fahrrad · begonnen am 9. Jan 2007 · letzter Beitrag vom 9. Jan 2007
Antwort Antwort
Seite 1 von 2  1 2      
mr_fahrrad

Registriert seit: 28. Dez 2006
46 Beiträge
 
#1

Bitmap.LoadFromFile (internetfile)

  Alt 9. Jan 2007, 11:18
How I make to load an Image to bitmap from Url(internet) file

example
bitmap.loadFromFile('http://www.cis.udel.edu/~mills/pic/hornrab.bmp'); the code above dont work, the error is:
Cannot open file 'c:\PathOfApplication\http://www.cis.udel.edu/~mills/pic/hornrab.bmp'

so, how I make to url?

Thanks a lot
  Mit Zitat antworten Zitat
Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#2

Re: Bitmap.LoadFromFile (internetfile)

  Alt 9. Jan 2007, 11:22
The method LoadFromFile cannot load a file from the internet. You have to download the file first onto your local hard drive.
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
mr_fahrrad

Registriert seit: 28. Dez 2006
46 Beiträge
 
#3

Re: Bitmap.LoadFromFile (internetfile)

  Alt 9. Jan 2007, 11:24
Hi,

Thanks for reply

I need another solution, I cant save files at my local drive (but stream I can)
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#4

Re: Bitmap.LoadFromFile (internetfile)

  Alt 9. Jan 2007, 11:32
No Problem use .LoadFromStream() instead
Markus Kinzler
  Mit Zitat antworten Zitat
marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#5

Re: Bitmap.LoadFromFile (internetfile)

  Alt 9. Jan 2007, 11:35
Hi,

you can use the following code, which is a variation from over there: klick

Delphi-Quellcode:
function DownloadBitmap(uri: String; bm: TBitmap): Boolean;
var
  s: TStream;
begin
  Result := False;
  s := TMemoryStream.Create;
  with TIdHTTP.Create(nil) do
  try
    Get(uri, s);
    bm.LoadFromStream(s);
    Result := True;
  finally
    Free;
    s.Free;
  end;
end;
Kind Regards
  Mit Zitat antworten Zitat
Muetze1
(Gast)

n/a Beiträge
 
#6

Re: Bitmap.LoadFromFile (internetfile)

  Alt 9. Jan 2007, 12:08
I am wondering about the position property of the memory stream: LoadFromStream() will load from the actual position of the stream, but Get() will append the data or not? Is there really no need to seek to the beginning of the stream?
  Mit Zitat antworten Zitat
mr_fahrrad

Registriert seit: 28. Dez 2006
46 Beiträge
 
#7

Re: Bitmap.LoadFromFile (internetfile)

  Alt 9. Jan 2007, 12:19
Hi,

I wrote this code basead in your code:

Delphi-Quellcode:
procedure TForm1.BitBtn2Click(Sender: TObject);
var
  s: TStream;
  uri:String;
begin
     uri:='http://www.rotary.org/newsroom/downloadcenter/graphics/logos/programs/fellowships/fellowships_bmp.bmp';
  s := TMemoryStream.Create;

  with TIdHTTP.Create(nil) do
  try
    Get(uri, s);
    Image1.picture.bitmap.loadFromStream(s);
  finally
    Free;
    s.Free;
  end;
  showMessage('.');
end;
but dont work, dont appear image in the Image1 component...

I try to save the stream 's' to file and was generated a file with 0bytes...

so, Whats the problem if code above?


Zitat von marabu:
Hi,

you can use the following code, which is a variation from over there: klick

Delphi-Quellcode:
function DownloadBitmap(uri: String; bm: TBitmap): Boolean;
var
  s: TStream;
begin
  Result := False;
  s := TMemoryStream.Create;
  with TIdHTTP.Create(nil) do
  try
    Get(uri, s);
    bm.LoadFromStream(s);
    Result := True;
  finally
    Free;
    s.Free;
  end;
end;
Kind Regards
  Mit Zitat antworten Zitat
Benutzerbild von Sko
Sko

Registriert seit: 11. Sep 2005
327 Beiträge
 
Turbo Delphi für Win32
 
#8

Re: Bitmap.LoadFromFile (internetfile)

  Alt 9. Jan 2007, 12:24
Hi,

you can try this in marabu´s code:
Delphi-Quellcode:
...
  Get(uri, s);
  s.Position := 0;
  Image1.picture.bitmap.loadFromStream(s);
...
MfG Sko
Zitat von Phoenix:
[OT]Phoenix guckt in die Glaskugel, zuckt mit den Flügelspitzen, krächzt etwas von wegen 'Boden' und 'Scherben' und schubbst die Kugel in Richtung Tischkante.[/OT]
Rockbox
  Mit Zitat antworten Zitat
mr_fahrrad

Registriert seit: 28. Dez 2006
46 Beiträge
 
#9

Re: Bitmap.LoadFromFile (internetfile)

  Alt 9. Jan 2007, 12:28
Thanks! this solve my ploblem

Thanks for all that help me

Zitat von Sko:
Hi,

you can try this in marabu´s code:
Delphi-Quellcode:
...
  Get(uri, s);
  s.Position := 0;
  Image1.picture.bitmap.loadFromStream(s);
...
  Mit Zitat antworten Zitat
marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#10

Re: Bitmap.LoadFromFile (internetfile)

  Alt 9. Jan 2007, 12:35
Hi Thomas,

that's the point: LoadFromStream() does not reposition the stream - we have to do it explicitly.

Thanks to Sko for lending a hand, too.

So long.
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:19 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz