4 #include <gdk-pixbuf/gdk-pixbuf.h>
7 extern int fullscreen, window_id;
9 /* Declare it here to avoid warnings */
10 GdkPixbuf *gai_load_image(const char *);
12 void load_image(char *fname, SA_Image *image, int frames)
15 image->pixbuf = gai_load_image(fname);
16 image->frames = frames;
18 image->width = gdk_pixbuf_get_width(image->pixbuf);
19 image->full_height = gdk_pixbuf_get_height(image->pixbuf);
21 image->rowstride = gdk_pixbuf_get_rowstride(image->pixbuf);
22 image->height = (int)((float)image->full_height / (float)frames+0.5);
23 image->image = gdk_pixbuf_get_pixels(image->pixbuf);
28 void load_image_n_scale(char *fname, SA_Image *image,
29 int frames, int scale)
32 int w, h, newh, neww,i;
33 GdkPixbuf *tmpbuff, *workbuff1, *workbuff2;
36 load_image(fname,image,frames);
41 tmpbuff = gai_load_image(fname);
42 image->frames = frames;
45 w = gdk_pixbuf_get_width(tmpbuff);
46 h = gdk_pixbuf_get_height(tmpbuff);
48 image->width = neww =(int)((((float)w * (float)scale) / 100.0)+0.5);
49 image->height = newh = (int)((((float)h / (float)frames) * (float)scale) / 100.0 + 0.5);
50 image->full_height = newh * frames;
52 image->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE,8,
56 for(i=0;i<frames;i++){
57 workbuff1 = gdk_pixbuf_new_subpixbuf(tmpbuff,0,i*h/frames,w,h/frames);
58 workbuff2 = gdk_pixbuf_scale_simple(workbuff1, neww, newh, GDK_INTERP_BILINEAR);
59 g_object_unref(workbuff1);
60 gdk_pixbuf_copy_area(workbuff2,0,0,neww,newh,image->pixbuf,0,newh*i);
61 g_object_unref(workbuff2);
68 image->image = gdk_pixbuf_get_pixels(image->pixbuf);
69 image->rowstride = gdk_pixbuf_get_rowstride(image->pixbuf);
71 g_object_unref(tmpbuff);