Author Topic: Downloading an image from image.blockland.us for server previews  (Read 4194 times)

I am remaking the GUI+, and I wanted to do this, since the person who created the mod has stopped working on it, and the website is also down.

How can I download an image and set it to a bitmap?

I believe Greek2Me's networking library can download preview images properly.

The maker of GUI+ used his eternal site due to torquescript not being able to download images from image.blockland.us properly.

Be sure to request the data as http/1.0 so that you don't get sent chunked data. Outside of that, use the search function to figure out how to download images. I know I myself have done at least three different full writeups.

Support_TCPClient can do this properly.

Here's some documentation: http://greek2me.us/code/Support_TCPClient.html

As a basic example, this single line of code will download the following preview image:
Code: [Select]
connectToURL("http://image.blockland.us/detail/69-64-40-157_31400.jpg", "GET", "base/preview.png");

If you want something to happen when the download finishes, such as displaying the image, you can do this:
Code: [Select]
function MyImageDownloader::onDone(%this, %error)
{
if(%error == 0)
{
//do stuff!
}
}
connectToURL("http://image.blockland.us/detail/69-64-40-157_31400.jpg", "GET", "base/preview.png", "MyImageDownloader");

That should be all you need.
« Last Edit: December 10, 2014, 07:06:01 PM by Greek2me »

Does that actually suffice though? Last time I tried (a while ago) it would still give me chunked images, even with HTTP/1.0 and Accept-Encoding: identity. Only with the more complex and colorful images though, low-detail ones like the example here would not get chunked.

This request is enough for it to work for all server preview images for me:

GET /detail/... HTTP/1.0
Host: image.blockland.us


Does that actually suffice though? Last time I tried (a while ago) it would still give me chunked images, even with HTTP/1.0 and Accept-Encoding: identity. Only with the more complex and colorful images though, low-detail ones like the example here would not get chunked.

It can download any image from there. The problem most people have is that even though they use HTTP/1.0 , they're looking for the Content-Length header, but that's not used on image.blockland.us. This causes their onBinChunk methods to end the download too early (after just the first chunk), because they're checking the downloaded size against a blank content-length variable. TCPClient handles that properly.
« Last Edit: December 11, 2014, 09:25:35 AM by Greek2me »