[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: how to make an animation ;)
- From: tomas tuxteam de
- To: Olivier Ramare <Olivier Ramare univ-lille1 fr>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: how to make an animation ;)
- Date: Fri, 9 Feb 2007 09:19:57 +0000
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Fri, Feb 09, 2007 at 01:02:20AM +0100, Olivier Ramare wrote:
> Enrico Sardi wrote:
> > Hi all!
> >
> > I want to make a simple animation in gtk with a pixbuf that rotates, how
> > can I make it?
> >
> For every change of state of my application, the image changes.
> I have 10 files with the rotated images (I've created them with
> a repeated use of gimp) and I use the following code:
> ----------------------------------------------------------------------------------------------------------------------
> #define GTK_FLUSH while (gtk_events_pending()) gtk_main_iteration();
> void wait_fine(float intervalle)
> {
> float lheure = (clock()/CLOCKS_PER_SEC);
> while(((clock()/CLOCKS_PER_SEC) - lheure) < intervalle){;};
> }
The problem with this is that it'll keep your program (and most of your
computer ;) busy with the job. Better use a timer (or an idle) callback.
Even better: pixbufs know about animations and do it for you! With
gdk_pixbuf_animation_new_from_file()[1] you can load an animation from a
file (there are other functions aroud there if you want to build-up the
anim frame-by-frame). You can put this animated pixbuf in a GtkImage the
usual way with gtk_image_set_from_pixbuf()[2]
I'm too bogged down to cook up an example right now, but this might
help.
- ------------------------------------
[1] http://developer.gnome.org/doc/API/2.0/gdk-pixbuf/gdk-pixbuf-animation.html#gdk-pixbuf-animation-new-from-file
[2] http://developer.gnome.org/doc/API/2.0/gtk/GtkImage.html#gtk-image-set-from-pixbuf
Regards
- -- tom�-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFFzDy9Bcgs9XrR2kYRAvvaAJ0RUkyetf/UJV0A0fI6pwddCq9xdQCfaPg3
rzNrjOoa0qgtF4N+0DWx4pw=
=wasb
-----END PGP SIGNATURE-----
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]