Loading TGAImage from http.Get

After some attempts, tricks, and changes. I was successfully able to create a PHP script that can generate tga images, and then use http.Get to download the image, place it in data folder as a .txt file and load the image into a TGAImage vgui element.

I made a more detailed description on my blog, if anyone is interested in reading: http://blog.nican.net/2010/07/dynamic-tgas-into-garrys-mod/

Otherwise you can just download the source, and modify it with your needs:
http://blog.nican.net/wp-content/uploads/2010/07/tgaimages.zip

Nice job Nican, is it fast enough to do a download-less GUI system somehow?

It takes about half a second from when I execute the script, and image appears on the screen.

Also, I noticed I uploaded a wrong version, I just uploaded the right one.

That’s a cool find.

Why do this when you can load an image from a html vgui panel?

I like it!

Because that gives you a I-don’t-know-how-many% chance of crashing.

Or is this only when doing flash stuff? I know playx can crash clients a few times.

Sadly becuse file.Write dosent write in binary mode, windows turns into an asshole and replace all
with
this will corrupt most images

It’s mostly Flash stuff from my experience.

Some people will always crash, but this seems to have to do something with FLVs and YouTube primarily.

The TGA uncompressed format is really simple, it is bassicly all the RGBA pixels written over and over again to complete the whole image.

Since the new line is 0x0A, I simple changed all 0A color pixels to 0B. For exemple, if one pixel has the color #0A0AFF, that will be changed to #0B0BFF. Of course, there will be a bit of a color change, but I do not think enough for any capable human to notice. At least that bypasses the newline problem.

How about base64 encoding it? That way you can basically use any format you want.