Thread View: borland.public.cppbuilder.internet.web
3 messages
3 total messages
Started by Asger Jorgensen
Fri, 27 Jul 2007 22:12
How to download an imagefile to my pc from the web
Author: Asger Jorgensen
Date: Fri, 27 Jul 2007 22:12
Date: Fri, 27 Jul 2007 22:12
20 lines
1477 bytes
1477 bytes
Hi there I need to download an image from the net and then show it in my app in a TImage. The testfile is: http://asger-p.dk/stark.bmp I have Indy 9 installed, but I don't have a clue as to how I do this. Could somebody be so kind as to show a little piece of code. Then I will be very very greatfull. By the way is there a place where I can get c++ examples on how to use the different Indy components. I have a very good one for the TidFTP I got that a couple of years ago but I can't remember from where. Thanks in advance Asger
Re: How to download an imagefile to my pc from the web
Author: Remy Lebeau (TeamB)
Date: Fri, 27 Jul 2007 22:42
Date: Fri, 27 Jul 2007 22:42
57 lines
2573 bytes
2573 bytes
"Asger Jorgensen" <Junk@Asger-P.dk> wrote in message
news:MPG.21148c4b892d11cd9897b9@newsgroups.borland.com...
> I have Indy 9 installed, but I don't have a clue
> as to how I do this.
Use the TIdHTTP component, passing the URL to its Get() method, to download
the image to a temporary file, and then you can load that into the TImage
afterwards, ie:
AnsiString FileName = "c:\\folder\\stark.bmp";
TFileStream *Strm = new TFileStream(FileName, fmCreate);
try
{
try
{
IdHTTP->Get("http://asger-p.dk/stark.bmp", Strm);
}
__finally {
delete Strm;
}
Image1->Picture->LoadFromFile(FileName);
}
__finally {
DeleteFile(FileName);
}
If you know that the image will always be a bitmap, then you can bypass the
temporary file altogether and download the image into a TMemoryStream
instead, and then load it into TBitmap for the Timage to display, ie:
TMemoryStream *Strm = new TMemoryStream;
try
{
IdHTTP->Get("http://asger-p.dk/stark.bmp", Strm);
Strm->Position = 0;
Image1->Picture->Bitmap->LoadFromStream(Strm);
}
__finally {
delete Strm;
}
> By the way is there a place where I can get c++ examples
> on how to use the different Indy components.
There aren't very many demos available for C++, sorry.
> I have a very good one for the TidFTP I got that a couple
> of years ago but I can't remember from where.
There are demos on both Indy's and AToZed's websites.
Gambit
Re: How to download an imagefile to my pc from the web
Author: Asger Jorgensen
Date: Fri, 27 Jul 2007 23:34
Date: Fri, 27 Jul 2007 23:34
6 lines
1078 bytes
1078 bytes
Hi Remy Thank You very much!! Best regards Asger
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads