diff options
author | Fumitoshi UKAI <ukai@debian.or.jp> | 2003-04-03 16:35:42 +0000 |
---|---|---|
committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2003-04-03 16:35:42 +0000 |
commit | fdb83cd002398c14b270fa15be279e39fa6ac2f4 (patch) | |
tree | 40eacda023682b54e8551d1b9e2ebd811d5fbe55 | |
parent | ';' is quoted in keymap.default (diff) | |
download | w3m-fdb83cd002398c14b270fa15be279e39fa6ac2f4.tar.gz w3m-fdb83cd002398c14b270fa15be279e39fa6ac2f4.zip |
[w3m-dev 03837] Re: gif animation with no delay_time
* w3mimg/fb/fb_gdkpixbuf.c (get_animation_size): add delay
check delay_time
(get_image_size): no need delay time
(fb_image_load): check delay
(draw): no bg
* w3mimg/fb/fb_w3mimg.c (w3mfb_show_image): delete delay skip loop
* w3mimg/x11/x11_w3mimg.c (get_animation_size): add delay
check delay_time
(x11_load_image): check delay
(x11_get_image_size): no need delay time
From: Hiroyuki Ito <hito@crl.go.jp>
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | w3mimg/fb/fb_gdkpixbuf.c | 62 | ||||
-rw-r--r-- | w3mimg/fb/fb_w3mimg.c | 6 | ||||
-rw-r--r-- | w3mimg/x11/x11_w3mimg.c | 43 |
4 files changed, 86 insertions, 41 deletions
@@ -1,3 +1,17 @@ +2003-04-04 Hiroyuki Ito <hito@crl.go.jp> + + * [w3m-dev 03837] Re: gif animation with no delay_time + * w3mimg/fb/fb_gdkpixbuf.c (get_animation_size): add delay + check delay_time + (get_image_size): no need delay time + (fb_image_load): check delay + (draw): no bg + * w3mimg/fb/fb_w3mimg.c (w3mfb_show_image): delete delay skip loop + * w3mimg/x11/x11_w3mimg.c (get_animation_size): add delay + check delay_time + (x11_load_image): check delay + (x11_get_image_size): no need delay time + 2003-03-28 Dai Sato <satodai@dog.intcul.tohoku.ac.jp> * doc(-jp)/keymap.default: ';' is quoted @@ -7623,4 +7637,4 @@ a * [w3m-dev 03276] compile error on EWS4800 * release-0-2-1 * import w3m-0.2.1 -$Id: ChangeLog,v 1.808 2003/03/28 10:26:40 inu Exp $ +$Id: ChangeLog,v 1.809 2003/04/03 16:35:42 ukai Exp $ diff --git a/w3mimg/fb/fb_gdkpixbuf.c b/w3mimg/fb/fb_gdkpixbuf.c index ca20b5c..ebaef01 100644 --- a/w3mimg/fb/fb_gdkpixbuf.c +++ b/w3mimg/fb/fb_gdkpixbuf.c @@ -1,4 +1,4 @@ -/* $Id: fb_gdkpixbuf.c,v 1.12 2003/03/26 15:34:55 ukai Exp $ */ +/* $Id: fb_gdkpixbuf.c,v 1.13 2003/04/03 16:35:45 ukai Exp $ */ /************************************************************************** fb_gdkpixbuf.c 0.3 Copyright (C) 2002, hito **************************************************************************/ @@ -12,10 +12,10 @@ static void draw(FB_IMAGE * img, int bg, int x, int y, int w, int h, static GdkPixbuf *resize_image(GdkPixbuf * pixbuf, int width, int height); static void -get_animation_size(GdkPixbufAnimation * animation, int *w, int *h) +get_animation_size(GdkPixbufAnimation * animation, int *w, int *h, int *delay) { GList *frames; - int iw, ih, n, i; + int iw, ih, n, i, d = -1; frames = gdk_pixbuf_animation_get_frames(animation); n = gdk_pixbuf_animation_get_num_frames(animation); @@ -24,8 +24,12 @@ get_animation_size(GdkPixbufAnimation * animation, int *w, int *h) for (i = 0; i < n; i++) { GdkPixbufFrame *frame; GdkPixbuf *pixbuf; + int tmp; frame = (GdkPixbufFrame *) g_list_nth_data(frames, i); + tmp = gdk_pixbuf_frame_get_delay_time(frame); + if (tmp > d) + d = tmp; pixbuf = gdk_pixbuf_frame_get_pixbuf(frame); iw = gdk_pixbuf_frame_get_x_offset(frame) + gdk_pixbuf_get_width(pixbuf); @@ -36,6 +40,8 @@ get_animation_size(GdkPixbufAnimation * animation, int *w, int *h) if (ih > *h) *h = ih; } + if (delay) + *delay = d; } int @@ -47,7 +53,7 @@ get_image_size(char *filename, int *w, int *h) animation = gdk_pixbuf_animation_new_from_file(filename); if (animation == NULL) return 1; - get_animation_size(animation, w, h); + get_animation_size(animation, w, h, NULL); gdk_pixbuf_animation_unref(animation); return 0; } @@ -58,7 +64,7 @@ fb_image_load(char *filename, int w, int h, int max_anim) GdkPixbufAnimation *animation; GList *frames; double ratio_w, ratio_h; - int n, i, fw, fh; + int n, i, j, fw, fh, frame_num, delay; FB_IMAGE **fb_frame; GdkPixbufFrameAction action = GDK_PIXBUF_FRAME_REVERT; if (filename == NULL) @@ -67,10 +73,14 @@ fb_image_load(char *filename, int w, int h, int max_anim) if (animation == NULL) return NULL; frames = gdk_pixbuf_animation_get_frames(animation); - get_animation_size(animation, &fw, &fh); - n = gdk_pixbuf_animation_get_num_frames(animation); - if (max_anim > 0) { - n = (max_anim > n) ? n : max_anim; + get_animation_size(animation, &fw, &fh, &delay); + frame_num = n = gdk_pixbuf_animation_get_num_frames(animation); + if (delay <= 0) + max_anim = -1; + if (max_anim < 0) { + frame_num = (-max_anim > n) ? n : -max_anim; + } else if (max_anim > 0) { + frame_num = n = (max_anim > n) ? n : max_anim; } if (w < 1 || h < 1) { w = fw; @@ -81,14 +91,23 @@ fb_image_load(char *filename, int w, int h, int max_anim) ratio_w = 1.0 * w / fw; ratio_h = 1.0 * h / fh; } - fb_frame = fb_frame_new(w, h, n); + fb_frame = fb_frame_new(w, h, frame_num); + if (bg_r != 0 || bg_g != 0 || bg_b != 0) { + fb_image_fill(fb_frame[0], bg_r, bg_g, bg_b); + } if (fb_frame == NULL) goto END; - for (i = 0; i < n; i++) { + for (j = 0; j < n; j++) { GdkPixbufFrame *frame; GdkPixbuf *org_pixbuf, *pixbuf; int width, height, ofstx, ofsty; - frame = (GdkPixbufFrame *) g_list_nth_data(frames, i); + + if (max_anim < 0) { + i = (j - n + frame_num > 0)? (j - n + frame_num): 0; + } else { + i = j; + } + frame = (GdkPixbufFrame *) g_list_nth_data(frames, j); org_pixbuf = gdk_pixbuf_frame_get_pixbuf(frame); ofstx = gdk_pixbuf_frame_get_x_offset(frame); ofsty = gdk_pixbuf_frame_get_y_offset(frame); @@ -105,11 +124,11 @@ fb_image_load(char *filename, int w, int h, int max_anim) } width = gdk_pixbuf_get_width(pixbuf); height = gdk_pixbuf_get_height(pixbuf); - fb_frame[i]->delay = gdk_pixbuf_frame_get_delay_time(frame); - if (i > 0) { + if (j > 0) { switch (action) { case GDK_PIXBUF_FRAME_RETAIN: - fb_image_copy(fb_frame[i], fb_frame[i - 1]); + if (i > 0) + fb_image_copy(fb_frame[i], fb_frame[i - 1]); break; case GDK_PIXBUF_FRAME_DISPOSE: if (bg_r != 0 || bg_g != 0 || bg_b != 0) { @@ -117,13 +136,16 @@ fb_image_load(char *filename, int w, int h, int max_anim) } break; case GDK_PIXBUF_FRAME_REVERT: - fb_image_copy(fb_frame[i], fb_frame[0]); + if (i > 0) + fb_image_copy(fb_frame[i], fb_frame[0]); break; default: - fb_image_copy(fb_frame[i], fb_frame[0]); + if (i > 0) + fb_image_copy(fb_frame[i], fb_frame[0]); } } action = gdk_pixbuf_frame_get_action(frame); + fb_frame[i]->delay = gdk_pixbuf_frame_get_delay_time(frame); draw(fb_frame[i], !i, ofstx, ofsty, width, height, pixbuf); if (org_pixbuf != pixbuf) gdk_pixbuf_finalize(pixbuf); @@ -150,11 +172,7 @@ draw(FB_IMAGE * img, int bg, int x, int y, int w, int h, GdkPixbuf * pixbuf) r = pixels[offset]; g = pixels[offset + 1]; b = pixels[offset + 2]; - if (alpha && pixels[offset + 3] == 0) { - if (bg) - fb_image_pset(img, i + x, j + y, bg_r, bg_g, bg_b); - } - else { + if (!alpha || pixels[offset + 3] != 0) { fb_image_pset(img, i + x, j + y, r, g, b); } } diff --git a/w3mimg/fb/fb_w3mimg.c b/w3mimg/fb/fb_w3mimg.c index d6c4cfa..5c8fe4c 100644 --- a/w3mimg/fb/fb_w3mimg.c +++ b/w3mimg/fb/fb_w3mimg.c @@ -1,4 +1,4 @@ -/* $Id: fb_w3mimg.c,v 1.10 2003/03/26 15:34:19 ukai Exp $ */ +/* $Id: fb_w3mimg.c,v 1.11 2003/04/03 16:35:48 ukai Exp $ */ #include <stdio.h> #include <stdlib.h> #include <ctype.h> @@ -92,10 +92,6 @@ w3mfb_show_image(w3mimg_op * self, W3MImage * img, int sx, int sy, frame = (FB_IMAGE **) img->pixmap; i = frame[0]->id; - while (i < frame[0]->num - 1 && frame[i]->delay <= 0) { - frame[0]->id += 1; - i = frame[0]->id; - } fb_image_draw(frame[i], x + self->offset_x, y + self->offset_y, sx, sy, (sw ? sw : img->width), (sh ? sh : img->height)); diff --git a/w3mimg/x11/x11_w3mimg.c b/w3mimg/x11/x11_w3mimg.c index 8f98f7b..2a6c251 100644 --- a/w3mimg/x11/x11_w3mimg.c +++ b/w3mimg/x11/x11_w3mimg.c @@ -1,4 +1,4 @@ -/* $Id: x11_w3mimg.c,v 1.18 2003/03/27 17:12:10 ukai Exp $ */ +/* $Id: x11_w3mimg.c,v 1.19 2003/04/03 16:35:49 ukai Exp $ */ #include <stdio.h> #include <stdlib.h> #include <ctype.h> @@ -43,10 +43,10 @@ struct x11_image { }; static void -get_animation_size(GdkPixbufAnimation * animation, int *w, int *h) +get_animation_size(GdkPixbufAnimation * animation, int *w, int *h, int *delay) { GList *frames; - int iw, ih, n, i; + int iw, ih, n, i, d = -1; frames = gdk_pixbuf_animation_get_frames(animation); n = gdk_pixbuf_animation_get_num_frames(animation); @@ -55,8 +55,12 @@ get_animation_size(GdkPixbufAnimation * animation, int *w, int *h) for (i = 0; i < n; i++) { GdkPixbufFrame *frame; GdkPixbuf *pixbuf; + int tmp; frame = (GdkPixbufFrame *) g_list_nth_data(frames, i); + tmp = gdk_pixbuf_frame_get_delay_time(frame); + if (tmp > d) + d = tmp; pixbuf = gdk_pixbuf_frame_get_pixbuf(frame); iw = gdk_pixbuf_frame_get_x_offset(frame) + gdk_pixbuf_get_width(pixbuf); @@ -67,6 +71,8 @@ get_animation_size(GdkPixbufAnimation * animation, int *w, int *h) if (ih > *h) *h = ih; } + if (delay) + *delay = d; } #endif @@ -266,7 +272,7 @@ x11_load_image(w3mimg_op * self, W3MImage * img, char *fname, int w, int h) #elif defined(USE_GDKPIXBUF) GdkPixbufAnimation *animation; GList *frames; - int i, iw, ih, n; + int i, j, iw, ih, n, frame_num, delay, max_anim; double ratio_w, ratio_h; struct x11_image *ximg; GdkPixbufFrameAction action = GDK_PIXBUF_FRAME_REVERT; @@ -316,15 +322,21 @@ x11_load_image(w3mimg_op * self, W3MImage * img, char *fname, int w, int h) imlib_render_image_on_drawable_at_size(0, 0, w, h); imlib_free_image(); #elif defined(USE_GDKPIXBUF) + max_anim = self->max_anim; animation = gdk_pixbuf_animation_new_from_file(fname); if (!animation) return 0; frames = gdk_pixbuf_animation_get_frames(animation); - n = gdk_pixbuf_animation_get_num_frames(animation); - get_animation_size(animation, &iw, &ih); + frame_num = n = gdk_pixbuf_animation_get_num_frames(animation); + + get_animation_size(animation, &iw, &ih, &delay); + if (delay <= 0) + max_anim = -1; - if (self->max_anim > 0) { - n = (self->max_anim > n) ? n : self->max_anim; + if (max_anim < 0) { + frame_num = (-max_anim > n) ? n : -max_anim; + } else if (max_anim > 0) { + frame_num = n = (max_anim > n) ? n : max_anim; } if (w < 1 || h < 1) { @@ -336,17 +348,22 @@ x11_load_image(w3mimg_op * self, W3MImage * img, char *fname, int w, int h) ratio_w = 1.0 * w / iw; ratio_h = 1.0 * h / ih; } - ximg = x11_img_new(xi, w, h, n); + ximg = x11_img_new(xi, w, h, frame_num); if (!ximg) { gdk_pixbuf_animation_unref(animation); return 0; } - for (i = 0; i < n; i++) { + for (j = 0; j < n; j++) { GdkPixbufFrame *frame; GdkPixbuf *org_pixbuf, *pixbuf; - int width, height, ofstx, ofsty, delay; + int width, height, ofstx, ofsty; - frame = (GdkPixbufFrame *) g_list_nth_data(frames, i); + if (max_anim < 0) { + i = (j - n + frame_num > 0)? (j - n + frame_num): 0; + } else { + i = j; + } + frame = (GdkPixbufFrame *) g_list_nth_data(frames, j); org_pixbuf = gdk_pixbuf_frame_get_pixbuf(frame); ofstx = gdk_pixbuf_frame_get_x_offset(frame); ofsty = gdk_pixbuf_frame_get_y_offset(frame); @@ -533,7 +550,7 @@ x11_get_image_size(w3mimg_op * self, W3MImage * img, char *fname, int *w, if (!animation) return 0; - get_animation_size(animation, w, h); + get_animation_size(animation, w, h, NULL); gdk_pixbuf_animation_unref(animation); #endif return 1; |