Is there a way to load a .GIF image ?

Monkey Forums/Monkey Programming/Is there a way to load a .GIF image ?

semar(Posted 2015) [#1]
What the title says..

Alternatively, is there a way to convert a .GIF file to a .PNG or JPG on the fly, and use it in code ?


ImmutableOctet(SKNG)(Posted 2015) [#2]
Image formats are target specific, as seen here. If you want raw image-data from a file, you could use 'LoadImageData' from 'opengl.gles11', but that'll only work if GIF is supported by the target.

Your best bet is PNG to begin with. GIF files are basically just bitmaps stitched together, so you're looking at an uncompressed image format. PNG files are basically nicely dressed bitmaps thrown into zlib (Zipped). The answer seems pretty clear to me, convert the file to PNG with another tool. Even MS Paint can convert GIFs to PNG files. And if you're looking to GIF for animation, you're definitely doing things backwards. Use a program like GIMP, MS Paint, Photoshop, or Paint.NET.


semar(Posted 2015) [#3]
Thanks SKNG.

Problem is, I call from monkey a weahter service that returns me a json string, which I extract some informations from, for example temperature, relative humidity, and the like.

To visualize the weahter as a static image, a link to a .gif is also provided inside the json.

I just would like to visualize that icon from within Monkey (html5 target), but the .gif format is not supported by LoadImage(URL).

May be I should download all the ..gifs, convert it to .png, pack in the data directory, and use them instead..

I just found nice to load the image from an URL, that'is :-)


semar(Posted 2015) [#4]
I could eventually convert the .gif to a .png with java code and include it in the monkey application. But this leads to another question:
how to embed java code in a monkey program ? I guess using the keyword "Extern".
Is there a working example ?


CopperCircle(Posted 2015) [#5]
Hi, I put up my gif loader in the Monkey Code section, it may help...


semar(Posted 2015) [#6]
Thanks a load CopperCircle, I'll give it a try :-)


bitJericho(Posted 2015) [#7]
For html5 you don't need to do anything besides allow gif extensions to be loaded. However, it seems to not animate the gif (that may be why it's not supported, and there may be other reasons too). I tested DrawImage() and it works, anyway. Add the following at the top of your code:

#IMAGE_FILES+="*.gif|"

Hmm it looks like this doesn't work with loading a file from a URL, but you can load gifs from the data folder this way...


semar(Posted 2015) [#8]
Add the following at the top of your code:
#IMAGE_FILES+="*.gif|"

Hi bitJericho,
thanks for the information, I didn' know that was possible, for html5, to allow other graphic extensions !

It's a pity it does not work with loading a file from an URL, that was exactly what I needed.

Regards,
Sergio.