1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <gtk/gtk.h>
#include <time.h>
#include <conio.h>
int main(int argc, char **argv)
{
// Variables
GtkWidget * MainWindow;//fenêtre principale
GtkWidget *pVBox; //container
GtkWidget *pImage; //image
char montage[10], ci[5];//création du nom de l'image
int i = 0,nbImages = 47;//création du nom de l'image
// Initialisation de GTK+
gtk_init(&argc, &argv);
// Création de la fenêtre
MainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(MainWindow), "delete-event", G_CALLBACK(gtk_main_quit), NULL);
while(i<nbImages)
{
if(i != 0) gtk_container_remove(GTK_CONTAINER(MainWindow), pVBox);
//création du nom de l'image
strcpy(montage,"montage");
sprintf(ci,"%d",i);
strcat(montage,ci);
strcat(montage,".bmp");
//incrémentation des images (1 sur 4 pour une plus grande fluidité)
i+=4;
//création du container
pVBox = gtk_hbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(MainWindow), pVBox);
// Chargement d'une image à partir d'un fichier
pImage = gtk_image_new_from_file(montage);
//place les images de haut en bas
gtk_box_pack_start(GTK_BOX(pVBox), pImage, FALSE, FALSE, 5);
// Affichage
gtk_widget_show_all(MainWindow);
//attente
_sleep(1);
}
gtk_main();
// Fermeture de GTK+
gtk_exit(EXIT_SUCCESS);
return EXIT_SUCCESS;
} |
Partager