[w3m-dev 04097] Re: w3m-img gtk2

Hiroyuki Ito <[email protected]>
Newsgroups gmane.comp.web.w3m.devel
Message-ID <[email protected]>

> w3m-img  gtk2
> ?





diff -ru w3m/w3mimg/fb/fb_gdkpixbuf.c w3m-gtk2/w3mimg/fb/fb_gdkpixbuf.c
--- w3m/w3mimg/fb/fb_gdkpixbuf.c	2004-08-05 17:53:24.000000000 +0900
+++ w3m-gtk2/w3mimg/fb/fb_gdkpixbuf.c	2004-08-05 18:19:17.000000000 +0900
@@ -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 @@
 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 @@
 	 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 @@
     GdkPixbufAnimation *animation;
 #if defined(USE_GTK2)
     GdkPixbufAnimationIter *iter;
+    GTimeVal time;
 #else
     GList *frames;
 #endif
@@ -164,41 +168,29 @@
     }
 
 #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_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 @@
     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 -ru w3m/w3mimg/x11/x11_w3mimg.c w3m-gtk2/w3mimg/x11/x11_w3mimg.c
--- w3m/w3mimg/x11/x11_w3mimg.c	2004-08-05 17:54:19.000000000 +0900
+++ w3m-gtk2/w3mimg/x11/x11_w3mimg.c	2004-08-05 18:18:50.000000000 +0900
@@ -55,8 +55,10 @@
 {
     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 @@
 	 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 @@
     Pixmap tmp_pixmap;
 #if defined(USE_GTK2)
     GdkPixbufAnimationIter *iter;
+    GTimeVal time;
 #else
     GList *frames;
 #endif
@@ -432,55 +436,36 @@
 	return 0;
     }
 #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);
 
-    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;
+   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));
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.