Online image grabbing
Blitz3D Forums/Blitz3D Programming/Online image grabbing
| ||
Pardon me if I don't know the technical term for what I'm about to ask. Is it possible to download an image from the internet to use in a program, within the program itself? I want to be able to download specific images depending on what weapon the player in-game is using (Its a multiplayer game) I suppose a relevant example would also be, if I wanted to make my program look for a patch or something similar. Thank you for your time! Kii |
| ||
Take à look in code archive look for ftp or www transfer.. Usama usling tcpip streams. |
| ||
If your doing this at load time with straight up TCP its relatively trivial - you can use a pre-baked HTTP GET request and dump the image data straight unless its in chunked format. If you want to do this in realtime i.e. as a background grabber during gameplay you'll either need a remote host thats serving the images over UDP or use fastpointer to thread the TCP function thats grabbing the file and then load it once the thread has completed sucessfully - do not try to access the image while the thread is active and you'd need some type of marker if the thread was sucessful or not - you can use a global variable but don't try to check the variable until the thread has exited. TCP commands can take awhile to respond sometimes which can hitch your whole game 100s of ms at a time if they are on the main thread. |
| ||
Thanks, you two! Sorry for the late response. I appreciate the info! :) |
| ||
Here's a function I wrote a while back to do what you want and apparently forgot to add to the code archives. Make sure you read the comments in the function. Note that the 'SaveString' function can be used to save the downloaded file (which is downloaded as a string). GetInternetFile - downloads a file as a string http://www.blitzbasic.com/codearcs/codearcs.php?code=3069 SaveString - saves a string value as a file http://www.blitzbasic.com/codearcs/codearcs.php?code=3070 |
| ||
Awesome, this helps me a lot, Zethrax! Time to break this down and learn... Everyone here is so helpful! |