Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Draw / Play Animated Gif (C++)

Recommended Posts

  • 1 month later...


i like your idea. The way is maybe create your own loader/class. For every frame of GIF create texture using function Texture:Create and fill data with Texture:SetPixel (look for it in API) Description of GIF format will be on internet or look for some GIF loader for pure opengl, it will be similar i guess :)

Link to post
Share on other sites
  • 2 weeks later...
  • 2 months later...

I thought I'd update this thread, seeing as I said I would!


During my research I came across issues with GIF licensing, and why the GNU - and others - pretty much refuse to even deal with GIF now.


However, I came across Animated-PNG which is an extension to the PNG format developed by Mozilla! I think APNG is a viable substitute if we want to integrate animated images in Leadwerks.


I have the APNG add-on for GIMP, and now I'm researching how to read the file's frames in C++ and draw them to the screen using OpenGL. I haven't come across much information yet, but I think it's worth the effort.



  • Upvote 1
Link to post
Share on other sites

[i know this post could have been much better in explanation, but I'm tired and need sleep tongue.png ]


Okay guys, another update on implementing an animated image file (now A-PNG) in Leadwerks.


It's pretty simple: implement the TinyImageLoader ohmy.png!


Use that library to read the APNG into a TIL::Image - by default it will give you image frame count - then, just use a Leadwerks::Texture to draw to the context, setting the texture's pixels to the appropriate TIL::Image frame's pixels based on a simple interval timer - using TIL to get the pixel data (and manually converting it to a char* before passing to the Leadwerks::Texture).


There are a couple of good examples included with TinyImageLoader SDK. I just referenced the first example, and thought how I could create an actual Leadwerks::Texture from the information supplied to me by TinyImageLoader. happy.png


I now have an Animated-PNG image that renders to the screen and auto-updates the frame based on a set interval. I was going to have the APNG class implement Leadwerks::Texture, but I don't feel like implementing the extra 30+ virtual methods right now! *sad face*


That's all for now, as I feel it could be simple enough for others to implement - if not a good test of some basic C++ to C/C++1 implementation abilities. However, if anyone would like me to post a code example I will! smile.png


Many thanks!


1 The original code was written in C and then rewritten in C++ for TinymageLoader, though some C-style syntax does still appear.

  • Upvote 3
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...