diff options
Diffstat (limited to 'w3mimg')
-rw-r--r-- | w3mimg/fb/fb_gdkpixbuf.c | 60 | ||||
-rw-r--r-- | w3mimg/x11/x11_w3mimg.c | 63 |
2 files changed, 50 insertions, 73 deletions
diff --git a/w3mimg/fb/fb_gdkpixbuf.c b/w3mimg/fb/fb_gdkpixbuf.c index 3f75eb0..3995e61 100644 --- a/w3mimg/fb/fb_gdkpixbuf.c +++ b/w3mimg/fb/fb_gdkpixbuf.c @@ -1,4 +1,4 @@ -/* $Id: fb_gdkpixbuf.c,v 1.17 2004/08/04 17:32:28 ukai Exp $ */ +/* $Id: fb_gdkpixbuf.c,v 1.18 2004/08/05 18:22:15 ukai Exp $ */ /************************************************************************** fb_gdkpixbuf.c 0.3 Copyright (C) 2002, hito **************************************************************************/ @@ -12,7 +12,7 @@ #include "fb.h" #include "fb_img.h" -static void draw(FB_IMAGE * img, int bg, int x, int y, int w, int h, +static void draw(FB_IMAGE * img, int x, int y, int w, int h, GdkPixbuf * pixbuf); static GdkPixbuf *resize_image(GdkPixbuf * pixbuf, int width, int height); @@ -21,9 +21,11 @@ static int get_animation_size(GdkPixbufAnimation * animation, int *w, int *h, int *delay) { GdkPixbufAnimationIter *iter; - int iw, ih, n, i, d = -1; + int n, i, d = -1; + GTimeVal time; - iter = gdk_pixbuf_animation_get_iter(animation, NULL); + g_get_current_time(&time); + iter = gdk_pixbuf_animation_get_iter(animation, &time); *w = gdk_pixbuf_animation_get_width(animation); *h = gdk_pixbuf_animation_get_height(animation); for (i = 1; @@ -31,9 +33,10 @@ get_animation_size(GdkPixbufAnimation * animation, int *w, int *h, int *delay) i++) { int tmp; tmp = gdk_pixbuf_animation_iter_get_delay_time(iter); + g_time_val_add(&time, tmp * 1000); if (tmp > d) d = tmp; - gdk_pixbuf_animation_iter_advance(iter, NULL); + gdk_pixbuf_animation_iter_advance(iter, &time); } if (delay) *delay = d; @@ -113,6 +116,7 @@ fb_image_load(char *filename, int w, int h, int max_anim) GdkPixbufAnimation *animation; #if defined(USE_GTK2) GdkPixbufAnimationIter *iter; + GTimeVal time; #else GList *frames; #endif @@ -164,41 +168,29 @@ fb_image_load(char *filename, int w, int h, int max_anim) } #if defined(USE_GTK2) - iter = gdk_pixbuf_animation_get_iter(animation, NULL); + g_get_current_time(&time); + iter = gdk_pixbuf_animation_get_iter(animation, &time); + if (max_anim < 0 && n > -max_anim) { + max_anim = n + max_anim; + for (j = 0; j < max_anim; j++) { + g_time_val_add(&time, + gdk_pixbuf_animation_iter_get_delay_time(iter) * 1000); + gdk_pixbuf_animation_iter_advance(iter, &time); + } + } for (j = 0; j < n; j++) { GdkPixbuf *org_pixbuf, *pixbuf; - int width, height; - - if (max_anim < 0) { - i = (j - n + frame_num > 0) ? (j - n + frame_num) : 0; - } - else { - i = j; - } - if (gdk_pixbuf_animation_iter_on_currently_loading_frame(iter)) { - g_object_unref(G_OBJECT(iter)); - iter = gdk_pixbuf_animation_get_iter(animation, NULL); - } org_pixbuf = gdk_pixbuf_animation_iter_get_pixbuf(iter); - width = gdk_pixbuf_get_width(org_pixbuf); - height = gdk_pixbuf_get_height(org_pixbuf); - if (width == fw && height == fh) { - pixbuf = resize_image(org_pixbuf, w, h); - } else { - pixbuf = resize_image(org_pixbuf, width * ratio_w, height * ratio_h); - } - width = gdk_pixbuf_get_width(pixbuf); - height = gdk_pixbuf_get_height(pixbuf); + pixbuf = resize_image(org_pixbuf, fw, fh); - fb_frame[i]->delay = gdk_pixbuf_animation_iter_get_delay_time(iter); - fb_image_copy(fb_frame[i], tmp_image); - draw(fb_frame[i], !i, 0, 0, width, height, pixbuf); - fb_image_copy(tmp_image, fb_frame[0]); /* ??? default */ + fb_frame[j]->delay = gdk_pixbuf_animation_iter_get_delay_time(iter); + g_time_val_add(&time, fb_frame[j]->delay * 1000); + draw(fb_frame[j], 0, 0, fw, fh, pixbuf); if (org_pixbuf != pixbuf) g_object_unref(G_OBJECT(pixbuf)); - gdk_pixbuf_animation_iter_advance(iter, NULL); + gdk_pixbuf_animation_iter_advance(iter, &time); } #else frames = gdk_pixbuf_animation_get_frames(animation); @@ -234,7 +226,7 @@ fb_image_load(char *filename, int w, int h, int max_anim) fb_frame[i]->delay = gdk_pixbuf_frame_get_delay_time(frame); fb_image_copy(fb_frame[i], tmp_image); - draw(fb_frame[i], !i, ofstx, ofsty, width, height, pixbuf); + draw(fb_frame[i], ofstx, ofsty, width, height, pixbuf); switch (gdk_pixbuf_frame_get_action(frame)) { case GDK_PIXBUF_FRAME_RETAIN: @@ -264,7 +256,7 @@ fb_image_load(char *filename, int w, int h, int max_anim) return fb_frame; } static void -draw(FB_IMAGE * img, int bg, int x, int y, int w, int h, GdkPixbuf * pixbuf) +draw(FB_IMAGE * img, int x, int y, int w, int h, GdkPixbuf * pixbuf) { int i, j, r, g, b, offset, bpp, rowstride; guchar *pixels; diff --git a/w3mimg/x11/x11_w3mimg.c b/w3mimg/x11/x11_w3mimg.c index 74b326b..ef9dcf1 100644 --- a/w3mimg/x11/x11_w3mimg.c +++ b/w3mimg/x11/x11_w3mimg.c @@ -1,4 +1,4 @@ -/* $Id: x11_w3mimg.c,v 1.26 2004/08/04 17:32:28 ukai Exp $ */ +/* $Id: x11_w3mimg.c,v 1.27 2004/08/05 18:22:16 ukai Exp $ */ #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -55,8 +55,10 @@ get_animation_size(GdkPixbufAnimation * animation, int *w, int *h, int *delay) { GdkPixbufAnimationIter *iter; int n, i, d = -1; + GTimeVal time; - iter = gdk_pixbuf_animation_get_iter(animation, NULL); + g_get_current_time(&time); + iter = gdk_pixbuf_animation_get_iter(animation, &time); *w = gdk_pixbuf_animation_get_width(animation); *h = gdk_pixbuf_animation_get_height(animation); for (i = 1; @@ -64,9 +66,10 @@ get_animation_size(GdkPixbufAnimation * animation, int *w, int *h, int *delay) i++) { int tmp; tmp = gdk_pixbuf_animation_iter_get_delay_time(iter); + g_time_val_add(&time, tmp * 1000); if (tmp > d) d = tmp; - gdk_pixbuf_animation_iter_advance(iter, NULL); + gdk_pixbuf_animation_iter_advance(iter, &time); } if (delay) *delay = d; @@ -332,6 +335,7 @@ x11_load_image(w3mimg_op * self, W3MImage * img, char *fname, int w, int h) Pixmap tmp_pixmap; #if defined(USE_GTK2) GdkPixbufAnimationIter *iter; + GTimeVal time; #else GList *frames; #endif @@ -432,55 +436,36 @@ x11_load_image(w3mimg_op * self, W3MImage * img, char *fname, int w, int h) return 0; } #if defined(USE_GTK2) - iter = gdk_pixbuf_animation_get_iter(animation, NULL); - - for (j = 0; j < n; j++) { - GdkPixbuf *org_pixbuf, *pixbuf; - int width, height, ofstx = 0, ofsty = 0; - - if (max_anim < 0) { - i = (j - n + frame_num > 0) ? (j - n + frame_num) : 0; - } - else { - i = j; + g_get_current_time(&time); + iter = gdk_pixbuf_animation_get_iter(animation, &time); + + if (max_anim < 0 && n > -max_anim) { + max_anim = n + max_anim; + for (j = 0; j < max_anim; j++) { + delay = gdk_pixbuf_animation_iter_get_delay_time(iter); + g_time_val_add(&time, delay * 1000); + gdk_pixbuf_animation_iter_advance(iter, &time); } + } + for (j = 0; j < frame_num; j++) { + GdkPixbuf *org_pixbuf, *pixbuf; - if (gdk_pixbuf_animation_iter_on_currently_loading_frame(iter)) { - g_object_unref(G_OBJECT(iter)); - iter = gdk_pixbuf_animation_get_iter(animation, NULL); - } org_pixbuf = gdk_pixbuf_animation_iter_get_pixbuf(iter); delay = gdk_pixbuf_animation_iter_get_delay_time(iter); - width = gdk_pixbuf_get_width(org_pixbuf); - height = gdk_pixbuf_get_height(org_pixbuf); - - if (width == w && height == h) { - pixbuf = resize_image(org_pixbuf, w, h); - } - else { - pixbuf = - resize_image(org_pixbuf, width * ratio_w, height * ratio_h); - } - width = gdk_pixbuf_get_width(pixbuf); - height = gdk_pixbuf_get_height(pixbuf); + pixbuf = resize_image(org_pixbuf, w, h); if (delay > ximg->delay) ximg->delay = delay; - XCopyArea(xi->display, tmp_pixmap, ximg->pixmap[i], - xi->imageGC, 0, 0, w, h, 0, 0); gdk_pixbuf_xlib_render_to_drawable_alpha(pixbuf, - (Drawable) ximg->pixmap[i], 0, - 0, ofstx, ofsty, width, - height, + (Drawable) ximg->pixmap[j], 0, + 0, 0, 0, w, h, GDK_PIXBUF_ALPHA_BILEVEL, 1, XLIB_RGB_DITHER_NORMAL, 0, 0); - /* XXX */ - XCopyArea(xi->display, ximg->pixmap[0], tmp_pixmap, - xi->imageGC, 0, 0, w, h, 0, 0); if (org_pixbuf != pixbuf) g_object_unref(G_OBJECT(pixbuf)); - gdk_pixbuf_animation_iter_advance(iter, NULL); + g_time_val_add(&time, delay * 1000); + gdk_pixbuf_animation_iter_advance(iter, &time); } XFreePixmap(xi->display, tmp_pixmap); g_object_unref(G_OBJECT(animation)); |