w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

commit 74616eb070a7856b373bb47a5f782d845ebb41e6
parent 720c2e24078c64450a1b98d59903ed4253672fa9
Author: ukai <ukai>
Date:   Fri, 13 Jun 2003 15:03:02 +0000

[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:
MChangeLog | 6++++++
Mw3mimg/fb/fb_gdkpixbuf.c | 59+++++++++++++++++++++++++++++++++--------------------------
Mw3mimg/x11/x11_w3mimg.c | 52+++++++++++++++++++++++++++++++---------------------
3 files changed, 70 insertions(+), 47 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -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 diff --git a/w3mimg/fb/fb_gdkpixbuf.c b/w3mimg/fb/fb_gdkpixbuf.c @@ -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 @@ -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