GIF handling in Blitzmax?

BlitzMax Forums/BlitzMax Beginners Area/GIF handling in Blitzmax?

mikelandzelo(Posted 2006) [#1]
Hey,
I'm new to BlitzMax and tried a few things out today. I'm really keen on getting more knowledge because BlitzMax is a wonderful language. But now there's a problem: I can't load GIF graphics / display them.

----------------------------------------
Here's the code:
----------------------------------------
SuperStrict
Graphics 320, 240, 0

IncBin "images/sample.gif"
Local myGif:TImage = LoadImage("incbin::images/sample.gif")

While not KeyHit(KEY_ESCAPE)
Cls
DrawImage myGif, 10, 10
Flip
Wend
----------------------------------------


So what's wrong?

Thanks in advance


tonyg(Posted 2006) [#2]
There's no GIF support in Bmax


Jesse(Posted 2006) [#3]
it support png and bmp.
in case you don't know, you can save your image into a png or a bmp image with microsoft paint program. Just load it in to the paint program and use "save as" and choose the format in the save as type.


Mordax_Praetorian(Posted 2006) [#4]
Gif is an aweful image format anyway, unless its a photograph, png is your friend


Yan(Posted 2006) [#5]
Import - BMP, JPG, PNG and TGA
Export - PNG and JPG


ImaginaryHuman(Posted 2006) [#6]
PNG was designed to succeed GIF and does pretty much everything better, except animation frames.


mikelandzelo(Posted 2006) [#7]
I think this answeres my question...

So in order to get a full animation I'll need an animation-sprite-strip and load it with LoadAnimImage() ?


tonyg(Posted 2006) [#8]
yep


skidracer(Posted 2006) [#9]
I'm not quite ready but there should be gif support added to the axe modules shortly. Here is the reader in it's current state, use LoadImage(pixmap) with the pixmap result in my test code if you want to play with it:



or try the following untested wrapper:
Function LoadGif:TImage(url:Object)
	Local stream:TStream
	Local pixmaps:TList
	Local pix:TPixmap
	stream=ReadFile(url)
	If stream
		pixmaps=ReadGifPixmaps(stream)
		CloseFile stream
		If pixmaps
			pix=TPixmap(pixmaps.valueatindex(0))
			Return LoadImage(pix)
		EndIf
	EndIf
End Function



ImaginaryHuman(Posted 2006) [#10]
saving too?


xlsior(Posted 2006) [#11]
Interesting enough:

The last patents on the GIF file format expire on october 1st, 2006, making GIF truly 'free' to use again just 2 days from now.

http://www.freesoftwaremagazine.com/node/1772


mikelandzelo(Posted 2006) [#12]
@skidracer:
Thanks for the code. I haven't tried it out yet, but I will do today. I'll post my success here in this topic.

@xlsior:
Interesting. Could this mean that Mark will include a GIF support within the next Updates of BlitzMax?


tonyg(Posted 2006) [#13]
I'm not quite ready but there should be gif support added to the axe modules shortly



mikelandzelo(Posted 2006) [#14]
@skidracer:
Your code works fine. The gif images are displayed correctly but there is just on problem: There is no transparency, instead of this a magenta color is shown.

I guess I can remove the magenta color by setting the mask color, correct? Anyone got a little piece of code for me?


skidracer(Posted 2006) [#15]
It should already support alpha, if you can, please email me your gif so I can test.

The loader still needs per frame palette support which I can put in soon and there may be a bug with the background color support, will test.


mikelandzelo(Posted 2006) [#16]
This is the gif picture:



skidracer(Posted 2006) [#17]
oops change ReadGifPixmaps at ~ line 84 to:

			parsegif(pixmaps,stream,pal,_flags)



mikelandzelo(Posted 2006) [#18]
yep, that works!
Thank you very much


Teddyfles(Posted 2007) [#19]
I'm not quite ready but there should be gif support added to the axe modules shortly.


Hi, sorry for bumping an old thread like this, but might this still happen? I just synched with axe enabled but all I see is a module to load jpg2000.

(Don't worry, I'm not planning on using gif files as game graphics, it's for a program that can load image files from the user, so the more supported formats the better.)


ImaginaryHuman(Posted 2007) [#20]
Yeah gif would be nince since it is still in use quite a bit on the web, even though png is in most cases much nicer (then then png is nicer than bmp but we have that too). Anyone want to do an IFF/ILBM loader? I did one in basic a while ago, wasn't too hard.


Chroma(Posted 2007) [#21]
Hmm...I can't get simon's code to work at all. Anyone have a clear example?


Brucey(Posted 2007) [#22]
Another option, if you need GIF support... there is always my freeimage module - which supports GIF load and save, as well as conversion to lots of other file formats.

See link for more details...

http://brucey.net/programming/blitz/index.php#bahfreeimage

Even supports loading IFF/ILBM (whatever those are)... ;-)


ImaginaryHuman(Posted 2007) [#23]
Brucey, was your smiley there to indicate that you know what ILBM is from (Amiga), or a serious question?

Of note, IFF is the Interchangeable File Format developed by Electronic Arts for Deluxe Paint, but which is meant to be able to store several types of data including audio. It's kind of a flexible file format able to store multiple items - images, sounds, palettes, etc. ILBM is the InterLeaved BitMap which is the format for images that IFF uses.


Brucey(Posted 2007) [#24]
IFF was probably a bit ahead of its time, as far as having the capability to store information other than images in it.
Clever idea, but sadly under-exploited.