Re: how to make an animation ;)

2007-02-08 Thread Olivier Ramare
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){;};
}
void set_image(char *nom_image)
{
my_gtk_image_set_from_file(GTK_IMAGE(SG_Icone), nom_image);
GTK_FLUSH; wait_fine(delai_d_installation_image);
}

void set_images(char *im1, char *im2, char *im3, char *im4, char *im5,
char *im6, char *im7, char *im8, char *im9, char *im10)
{
set_image(im1); set_image(im2); set_image(im3); set_image(im4);
set_image(im5); set_image(im6); set_image(im7); set_image(im8);
set_image(im9); set_image(im10);
}
--
That's simpleminded --
HTH still :-)
Olivier
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: how to make an animation ;)

2007-02-09 Thread tomas
-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ás
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFFzDy9Bcgs9XrR2kYRAvvaAJ0RUkyetf/UJV0A0fI6pwddCq9xdQCfaPg3
rzNrjOoa0qgtF4N+0DWx4pw=
=wasb
-END PGP SIGNATURE-

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: how to make an animation ;)

2007-02-09 Thread Enrico Sardi
[EMAIL PROTECTED] pronuncio' le seguenti parole il 09/02/2007 10:19:

Hi Tomas!
> 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 saw  gdk_pixbuf_animation_new_from_file but it  only works with  an 
animated file as input while I need to build the animation from a series 
of indipendent files...thanks for the help!

Enrico
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: how to make an animation ;)

2007-02-09 Thread Olivier Ramare
Hi,

  I would ask gimp to create the animated part.
Open gimp with your first image.
Create as many layers as you have images.
Open each of the images and copy them
  in the successive layers
Use menu item Filter->Animation->play or replay I'm not sure
 to check the partial result.
Use Filter->Animation->optimise (GIF) to reduce the size.
Use File->Save as
  A dialog wil open and ask you if you want the image
flattened (all layers on one image) or if you want to register
that as an animation. You want the latter and the job if done.

  I don't know how to automate this algorithm since
I'm not script-fu writer ---
  FWIW :-)
  Olivier

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: how to make an animation ;)

2007-02-10 Thread tomas
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Fri, Feb 09, 2007 at 01:39:17PM +0100, Enrico Sardi wrote:
> [EMAIL PROTECTED] pronuncio' le seguenti parole il 09/02/2007 10:19:
> 
> Hi Tomas!
[...]
> > Even better: pixbufs know about animations and do it for you! [...]

> I saw  gdk_pixbuf_animation_new_from_file but it  only works with  an 
> animated file as input while I need to build the animation from a series 
> of indipendent files...thanks for the help!

Yes. Well, either you go Olivier's path (concoct an animated GIF with
all your images -- you can even embed timing info in that), or you start
with

  gdk_pixbuf_simple_anim_new()
  -- Creates a new, empty animation.

and add frame by frame with:

  gdk_pixbuf_simple_anim_add_frame()
  -- Adds a new frame to animation. 

In a timeout function (or possibly in an idle handler) you might have to
call gdk_pixbuf_animation_iter_advance() (I don't know if that's done
for you). The whole page

  

is worth a read.

Regards
- -- tomás
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFFzq6hBcgs9XrR2kYRAmE1AJ97E0EFY5IhTWerRPFCiCjJm/GmgQCfSDY6
fYb3nfhBh0DKznBgv2lazu0=
=FGBc
-END PGP SIGNATURE-

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list