diff options
author | Fumitoshi UKAI <ukai@debian.or.jp> | 2003-06-13 15:03:02 +0000 |
---|---|---|
committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2003-06-13 15:03:02 +0000 |
commit | 2de1e038964bc40db61064d8f0bf1af9699bbadb (patch) | |
tree | 84fed4412e5702ff941a4a6455150297f8d2b49b | |
parent | fix indent (diff) | |
download | w3m-2de1e038964bc40db61064d8f0bf1af9699bbadb.tar.gz w3m-2de1e038964bc40db61064d8f0bf1af9699bbadb.zip |
[w3m-dev 03913] fix gif animation support
* w3mimg/fb/fb_gdkpixbuf.c (fb_image_load): fix gif animation
* w3mimg/x11/x11_w3mimg.c (x11_load_image): ditto
From: Hiroyuki Ito <hito@crl.go.jp>
Diffstat (limited to '')
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | w3mimg/fb/fb_gdkpixbuf.c | 61 | ||||
-rw-r--r-- | w3mimg/x11/x11_w3mimg.c | 54 |
3 files changed, 73 insertions, 50 deletions
@@ -1,3 +1,9 @@ +2003-06-13 Hiroyuki Ito <hito@crl.go.jp> + + * [w3m-dev 03913] fix gif animation support + * w3mimg/fb/fb_gdkpixbuf.c (fb_image_load): fix gif animation + * w3mimg/x11/x11_w3mimg.c (x11_load_image): ditto + 2003-05-15 Akinori Ito <aito@fw.ipsj.or.jp> * [w3m-dev 03902] Re: table rendering @@ -7844,4 +7850,4 @@ a * [w3m-dev 03276] compile error on EWS4800 * release-0-2-1 * import w3m-0.2.1 -$Id: ChangeLog,v 1.840 2003/05/14 16:01:32 ukai Exp $ +$Id: ChangeLog,v 1.841 2003/06/13 15:03:02 ukai Exp $ diff --git a/w3mimg/fb/fb_gdkpixbuf.c b/w3mimg/fb/fb_gdkpixbuf.c index c7ee624..cc986d1 100644 --- a/w3mimg/fb/fb_gdkpixbuf.c +++ b/w3mimg/fb/fb_gdkpixbuf.c @@ -1,4 +1,4 @@ -/* $Id: fb_gdkpixbuf.c,v 1.14 2003/04/03 16:36:33 ukai Exp $ */ +/* $Id: fb_gdkpixbuf.c,v 1.15 2003/06/13 15:03:05 ukai Exp $ */ /************************************************************************** fb_gdkpixbuf.c 0.3 Copyright (C) 2002, hito **************************************************************************/ @@ -65,8 +65,8 @@ fb_image_load(char *filename, int w, int h, int max_anim) GList *frames; double ratio_w, ratio_h; int n, i, j, fw, fh, frame_num, delay; - FB_IMAGE **fb_frame; - GdkPixbufFrameAction action = GDK_PIXBUF_FRAME_REVERT; + FB_IMAGE **fb_frame = NULL, *tmp_image = NULL; + if (filename == NULL) return NULL; animation = gdk_pixbuf_animation_new_from_file(filename); @@ -92,12 +92,22 @@ 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, 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; + + tmp_image = fb_image_new(w, h); + if (tmp_image == NULL) { + fb_frame_free(fb_frame); + fb_frame = NULL; + goto END; + } + + if (bg_r != 0 || bg_g != 0 || bg_b != 0) { + fb_image_fill(tmp_image, bg_r, bg_g, bg_b); + } + for (j = 0; j < n; j++) { GdkPixbufFrame *frame; GdkPixbuf *org_pixbuf, *pixbuf; @@ -126,33 +136,30 @@ fb_image_load(char *filename, int w, int h, int max_anim) } width = gdk_pixbuf_get_width(pixbuf); height = gdk_pixbuf_get_height(pixbuf); - if (j > 0) { - switch (action) { - case GDK_PIXBUF_FRAME_RETAIN: - 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) { - fb_image_fill(fb_frame[i], bg_r, bg_g, bg_b); - } - break; - case GDK_PIXBUF_FRAME_REVERT: - if (i > 0) - fb_image_copy(fb_frame[i], fb_frame[0]); - break; - default: - 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); + fb_image_copy(fb_frame[i], tmp_image); draw(fb_frame[i], !i, ofstx, ofsty, width, height, pixbuf); + + switch (gdk_pixbuf_frame_get_action(frame)) { + case GDK_PIXBUF_FRAME_RETAIN: + fb_image_copy(tmp_image, fb_frame[i]); + break; + case GDK_PIXBUF_FRAME_DISPOSE: + break; + case GDK_PIXBUF_FRAME_REVERT: + fb_image_copy(tmp_image, fb_frame[0]); + break; + default: + fb_image_copy(tmp_image, fb_frame[0]); + } + if (org_pixbuf != pixbuf) gdk_pixbuf_finalize(pixbuf); } END: + if (tmp_image) + fb_image_free(tmp_image); gdk_pixbuf_animation_unref(animation); return fb_frame; } diff --git a/w3mimg/x11/x11_w3mimg.c b/w3mimg/x11/x11_w3mimg.c index 62e4ad1..3f932b6 100644 --- a/w3mimg/x11/x11_w3mimg.c +++ b/w3mimg/x11/x11_w3mimg.c @@ -1,4 +1,4 @@ -/* $Id: x11_w3mimg.c,v 1.20 2003/04/03 16:36:54 ukai Exp $ */ +/* $Id: x11_w3mimg.c,v 1.21 2003/06/13 15:03:05 ukai Exp $ */ #include <stdio.h> #include <stdlib.h> #include <ctype.h> @@ -275,7 +275,7 @@ x11_load_image(w3mimg_op * self, W3MImage * img, char *fname, int w, int h) 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; + Pixmap tmp_pixmap; #endif if (self == NULL) @@ -349,8 +349,16 @@ 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; } + tmp_pixmap = XCreatePixmap(xi->display, xi->parent, w, h, + DefaultDepth(xi->display, 0)); + XFillRectangle(xi->display, (Pixmap) tmp_pixmap, xi->imageGC, 0, 0, w, h); + if (!tmp_pixmap) { + gdk_pixbuf_animation_unref(animation); + return 0; + } ximg = x11_img_new(xi, w, h, frame_num); if (!ximg) { + XFreePixmap(xi->display, tmp_pixmap); gdk_pixbuf_animation_unref(animation); return 0; } @@ -388,36 +396,38 @@ x11_load_image(w3mimg_op * self, W3MImage * img, char *fname, int w, int h) if (delay > ximg->delay) ximg->delay = delay; - if (i > 0) { - switch (action) { - case GDK_PIXBUF_FRAME_RETAIN: - XCopyArea(xi->display, ximg->pixmap[i - 1], ximg->pixmap[i], - xi->imageGC, 0, 0, w, h, 0, 0); - break; - case GDK_PIXBUF_FRAME_DISPOSE: - break; - case GDK_PIXBUF_FRAME_REVERT: - XCopyArea(xi->display, ximg->pixmap[0], ximg->pixmap[i], - xi->imageGC, 0, 0, w, h, 0, 0); - break; - default: - XCopyArea(xi->display, ximg->pixmap[0], ximg->pixmap[i], - xi->imageGC, 0, 0, w, h, 0, 0); - break; - } - } - + 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, GDK_PIXBUF_ALPHA_BILEVEL, 1, XLIB_RGB_DITHER_NORMAL, 0, 0); - action = gdk_pixbuf_frame_get_action(frame); + + switch (gdk_pixbuf_frame_get_action(frame)) { + case GDK_PIXBUF_FRAME_RETAIN: + XCopyArea(xi->display, ximg->pixmap[i], tmp_pixmap, + xi->imageGC, 0, 0, w, h, 0, 0); + break; + case GDK_PIXBUF_FRAME_DISPOSE: + break; + case GDK_PIXBUF_FRAME_REVERT: + XCopyArea(xi->display, ximg->pixmap[0], tmp_pixmap, + xi->imageGC, 0, 0, w, h, 0, 0); + break; + default: + XCopyArea(xi->display, ximg->pixmap[0], tmp_pixmap, + xi->imageGC, 0, 0, w, h, 0, 0); + break; + } + + if (org_pixbuf != pixbuf) gdk_pixbuf_finalize(pixbuf); } + XFreePixmap(xi->display, tmp_pixmap); gdk_pixbuf_animation_unref(animation); img->pixmap = ximg; #endif |