Page 1 of 1

include an animated gif in an exe?

Posted: Thu Aug 17, 2006 8:28 am
by nessie
Does anyine know how to include an animated gif into the exe?. At the moment i'm using a web gadget and loading the gif from disk, but it would make it easier to be able to distribute a single exe.

Posted: Thu Aug 17, 2006 9:18 am
by mskuma
You could do an includebinary in a DataSection, something like:

Code: Select all

DataSection 
  TheGif: 
    IncludeBinary "file.gif" 
EndDataSection
The would bind the GIF (or any other binary) to the EXE. However I think GIF is not natively supported in PB for patent reasons. Does it have to be a GIF. How about a PNG - then you can do the above and a catchimage to use the image in your code. [edit: whoops - I see you want animated.. sorry - oh well maybe you can use AnimSprite in a 3rd party lib -do a search to find which one - I think Droopy's or PBOSL].

Posted: Thu Aug 17, 2006 9:38 am
by netmaestro
The .gif format has no more licensing problems since quite a while. What I would do is download El_Choni's ImageOleDecoder from PureArea.net and install it. This will be easy if you're using 3.94 and a bit more difficult if you're using 4.0, the reason being you'll have to compile it. It's not that hard, it's just that you'll have a few hoops to jump through, including downloading lccwin32 from the publisher site. Full instructions are supplied. I have done this a couple times now, and it's quite doable, although a bit daunting. I'd be happy to post a link to the compiled lib and you could put it in your \userlibraries folder and use the other parts of the download for your licensing info, help .chm, etc. but I don't know if that would be alright with El_Choni or not. Anyway, that lib will decode .gifs and you can just IncludeBinary and carry on.

Posted: Thu Aug 17, 2006 9:52 am
by netmaestro
Ack I'm a retard. I didn't see the animated part either! Ok, here's a way you can do it:

You need this to test: http://www.networkmaestro.com/fish.gif

Then try this code out:

Code: Select all

If CreateFile(0,"fish.gif")
  WriteData(0, ?gif, ?endgif-?gif)
  CloseFile(0)
Else
  MessageRequester("OOPS!","Could not create .gif file")
EndIf

OpenWindow(0,0,0,320,240,"Animated .gif Test",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
gif$=GetCurrentDirectory()+"\fish.gif" ; full path is necessary
url$="about:<html><body scroll='no' leftmargin='0' topmargin='0'><img src='"+gif$+"'></img></body></html>"
WebGadget(0,50,50,90,120,url$)
Repeat
ev=WaitWindowEvent()
Until ev=#PB_Event_CloseWindow

DataSection
  gif: IncludeBinary "d:\network maestro\fish.gif" ; <----change this to your location
  endgif:
EndDataSection
Based (a bit loosely) on forum code posted by Sparkie here:

http://www.purebasic.fr/english/viewtopic.php?t=13855

and PB here:

http://www.purebasic.fr/english/viewtopic.php?t=3817

Posted: Thu Aug 17, 2006 10:46 am
by nessie
netmaestro, as always, you are a star. I couldn't figure out how to do this. Thanks very much !! :D

Posted: Sun Aug 20, 2006 1:49 pm
by bingo