Loading image from website
BlitzMax Forums/BlitzMax Programming/Loading image from website
| ||
Hi, i want to be able to load an image from a website or ftp direct into a tImage or pixmap? is this possible? |
| ||
you should just be able to specify http:: as the protocal in the image url (AFAIK). |
| ||
:| so local x:tImage = loadimage ("http://xxx.jpg") |
| ||
Here's a snippet that Skidracer posted a while back:Graphics 400, 300, 0 DrawText "Getting Image...", 140, 144 Flip img:TImage = LoadImage(LoadBank("http::www.domain.com/images/image.jpg")) If Not img Then RuntimeError "Unable to download image" 'Graphics img.width, img.height, 0 Graphics 1024,768 DrawImage img, 0, 0 Flip WaitKey() End |
| ||
:| so local x:tImage = loadimage ("http://xxx.jpg") No -- you don't use http:// as a prefix, but http:: when using streams. Just like you would use IncBin::filename.jpg when addressing an image file that has been included into your .exe with with the incbin command. But trying to load the image directly over HTTP without storing it in a bank first doesn't seem to work. |
| ||
Because the pixmap loaders expect a seekable stream, you need to load the image into a bank first...Strict Graphics 640, 480, 0 Local image:Timage = LoadImage(LoadBank("http::blitzbasic.com/img/brllogo-thin.png")) Cls DrawImage image, 100, 100 Flip WaitKey() [edit] Bah...You fellas are too fast for me. ;o) @xlsior - I think you'll find that's my code. ;o) http://www.blitzbasic.com/Community/posts.php?topic=50729#565158 [/edit] |
| ||
I dont knew this stuff ! :) cool :) |
| ||
hey thanks everyone, u r all so great ;) |
| ||
I never knew that, thanks all. |
| ||
Thanks for that tip! To get a web image and save it to a file, I have been using this code; Function GetHTTPpic(PicAddr:String,NewPicFile:String) If NewPicFile Then Local wwwAddr = ReadStream(PicAddr) Local stream = WriteStream(NewPicFile) CopyStream(wwwAddr,stream) CloseStream wwwAddr CloseStream stream EndIf End Function |
| ||
@xlsior - I think you'll find that's my code. ;o) Oops, sorry... I had the snippet saved to my HD, but had somehow attributed it to Skidracer. Sorry about that. :-? |