[w3m-dev 04097] Re: w3m-img gtk2
* w3mimg/fb/fb_gdkpixbuf.c (draw): no need bg (get_animation_size): use GTimeVal (fb_image_load): use GTimeVal fix for animation * w3mimg/x11/x11_w3mimg.c (get_animation_size): use GTimeVal (x11_load_image): use GTimeVal fix for animation From: Hiroyuki Ito <ZXB01226@nifty.com>
This commit is contained in:
13
ChangeLog
13
ChangeLog
@@ -1,3 +1,14 @@
|
|||||||
|
2004-08-06 Hiroyuki Ito <ZXB01226@nifty.com>
|
||||||
|
|
||||||
|
* [w3m-dev 04097] Re: w3m-img gtk2
|
||||||
|
* w3mimg/fb/fb_gdkpixbuf.c (draw): no need bg
|
||||||
|
(get_animation_size): use GTimeVal
|
||||||
|
(fb_image_load): use GTimeVal
|
||||||
|
fix for animation
|
||||||
|
* w3mimg/x11/x11_w3mimg.c (get_animation_size): use GTimeVal
|
||||||
|
(x11_load_image): use GTimeVal
|
||||||
|
fix for animation
|
||||||
|
|
||||||
2004-08-05 Fumitoshi UKAI <ukai@debian.or.jp>
|
2004-08-05 Fumitoshi UKAI <ukai@debian.or.jp>
|
||||||
|
|
||||||
* [w3m-dev 04096] w3m-img gtk2
|
* [w3m-dev 04096] w3m-img gtk2
|
||||||
@@ -8553,4 +8564,4 @@ a * [w3m-dev 03276] compile error on EWS4800
|
|||||||
* release-0-2-1
|
* release-0-2-1
|
||||||
* import w3m-0.2.1
|
* import w3m-0.2.1
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.934 2004/08/04 17:32:27 ukai Exp $
|
$Id: ChangeLog,v 1.935 2004/08/05 18:22:15 ukai Exp $
|
||||||
|
|||||||
@@ -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
|
fb_gdkpixbuf.c 0.3 Copyright (C) 2002, hito
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
#include "fb.h"
|
#include "fb.h"
|
||||||
#include "fb_img.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);
|
GdkPixbuf * pixbuf);
|
||||||
static GdkPixbuf *resize_image(GdkPixbuf * pixbuf, int width, int height);
|
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)
|
get_animation_size(GdkPixbufAnimation * animation, int *w, int *h, int *delay)
|
||||||
{
|
{
|
||||||
GdkPixbufAnimationIter *iter;
|
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);
|
*w = gdk_pixbuf_animation_get_width(animation);
|
||||||
*h = gdk_pixbuf_animation_get_height(animation);
|
*h = gdk_pixbuf_animation_get_height(animation);
|
||||||
for (i = 1;
|
for (i = 1;
|
||||||
@@ -31,9 +33,10 @@ get_animation_size(GdkPixbufAnimation * animation, int *w, int *h, int *delay)
|
|||||||
i++) {
|
i++) {
|
||||||
int tmp;
|
int tmp;
|
||||||
tmp = gdk_pixbuf_animation_iter_get_delay_time(iter);
|
tmp = gdk_pixbuf_animation_iter_get_delay_time(iter);
|
||||||
|
g_time_val_add(&time, tmp * 1000);
|
||||||
if (tmp > d)
|
if (tmp > d)
|
||||||
d = tmp;
|
d = tmp;
|
||||||
gdk_pixbuf_animation_iter_advance(iter, NULL);
|
gdk_pixbuf_animation_iter_advance(iter, &time);
|
||||||
}
|
}
|
||||||
if (delay)
|
if (delay)
|
||||||
*delay = d;
|
*delay = d;
|
||||||
@@ -113,6 +116,7 @@ fb_image_load(char *filename, int w, int h, int max_anim)
|
|||||||
GdkPixbufAnimation *animation;
|
GdkPixbufAnimation *animation;
|
||||||
#if defined(USE_GTK2)
|
#if defined(USE_GTK2)
|
||||||
GdkPixbufAnimationIter *iter;
|
GdkPixbufAnimationIter *iter;
|
||||||
|
GTimeVal time;
|
||||||
#else
|
#else
|
||||||
GList *frames;
|
GList *frames;
|
||||||
#endif
|
#endif
|
||||||
@@ -164,41 +168,29 @@ fb_image_load(char *filename, int w, int h, int max_anim)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(USE_GTK2)
|
#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++) {
|
for (j = 0; j < n; j++) {
|
||||||
GdkPixbuf *org_pixbuf, *pixbuf;
|
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);
|
org_pixbuf = gdk_pixbuf_animation_iter_get_pixbuf(iter);
|
||||||
width = gdk_pixbuf_get_width(org_pixbuf);
|
pixbuf = resize_image(org_pixbuf, fw, fh);
|
||||||
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);
|
|
||||||
|
|
||||||
fb_frame[i]->delay = gdk_pixbuf_animation_iter_get_delay_time(iter);
|
fb_frame[j]->delay = gdk_pixbuf_animation_iter_get_delay_time(iter);
|
||||||
fb_image_copy(fb_frame[i], tmp_image);
|
g_time_val_add(&time, fb_frame[j]->delay * 1000);
|
||||||
draw(fb_frame[i], !i, 0, 0, width, height, pixbuf);
|
draw(fb_frame[j], 0, 0, fw, fh, pixbuf);
|
||||||
fb_image_copy(tmp_image, fb_frame[0]); /* ??? default */
|
|
||||||
if (org_pixbuf != pixbuf)
|
if (org_pixbuf != pixbuf)
|
||||||
g_object_unref(G_OBJECT(pixbuf));
|
g_object_unref(G_OBJECT(pixbuf));
|
||||||
gdk_pixbuf_animation_iter_advance(iter, NULL);
|
gdk_pixbuf_animation_iter_advance(iter, &time);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
frames = gdk_pixbuf_animation_get_frames(animation);
|
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_frame[i]->delay = gdk_pixbuf_frame_get_delay_time(frame);
|
||||||
fb_image_copy(fb_frame[i], tmp_image);
|
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)) {
|
switch (gdk_pixbuf_frame_get_action(frame)) {
|
||||||
case GDK_PIXBUF_FRAME_RETAIN:
|
case GDK_PIXBUF_FRAME_RETAIN:
|
||||||
@@ -264,7 +256,7 @@ fb_image_load(char *filename, int w, int h, int max_anim)
|
|||||||
return fb_frame;
|
return fb_frame;
|
||||||
}
|
}
|
||||||
static void
|
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;
|
int i, j, r, g, b, offset, bpp, rowstride;
|
||||||
guchar *pixels;
|
guchar *pixels;
|
||||||
|
|||||||
@@ -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 <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -55,8 +55,10 @@ get_animation_size(GdkPixbufAnimation * animation, int *w, int *h, int *delay)
|
|||||||
{
|
{
|
||||||
GdkPixbufAnimationIter *iter;
|
GdkPixbufAnimationIter *iter;
|
||||||
int 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);
|
*w = gdk_pixbuf_animation_get_width(animation);
|
||||||
*h = gdk_pixbuf_animation_get_height(animation);
|
*h = gdk_pixbuf_animation_get_height(animation);
|
||||||
for (i = 1;
|
for (i = 1;
|
||||||
@@ -64,9 +66,10 @@ get_animation_size(GdkPixbufAnimation * animation, int *w, int *h, int *delay)
|
|||||||
i++) {
|
i++) {
|
||||||
int tmp;
|
int tmp;
|
||||||
tmp = gdk_pixbuf_animation_iter_get_delay_time(iter);
|
tmp = gdk_pixbuf_animation_iter_get_delay_time(iter);
|
||||||
|
g_time_val_add(&time, tmp * 1000);
|
||||||
if (tmp > d)
|
if (tmp > d)
|
||||||
d = tmp;
|
d = tmp;
|
||||||
gdk_pixbuf_animation_iter_advance(iter, NULL);
|
gdk_pixbuf_animation_iter_advance(iter, &time);
|
||||||
}
|
}
|
||||||
if (delay)
|
if (delay)
|
||||||
*delay = d;
|
*delay = d;
|
||||||
@@ -332,6 +335,7 @@ x11_load_image(w3mimg_op * self, W3MImage * img, char *fname, int w, int h)
|
|||||||
Pixmap tmp_pixmap;
|
Pixmap tmp_pixmap;
|
||||||
#if defined(USE_GTK2)
|
#if defined(USE_GTK2)
|
||||||
GdkPixbufAnimationIter *iter;
|
GdkPixbufAnimationIter *iter;
|
||||||
|
GTimeVal time;
|
||||||
#else
|
#else
|
||||||
GList *frames;
|
GList *frames;
|
||||||
#endif
|
#endif
|
||||||
@@ -432,55 +436,36 @@ x11_load_image(w3mimg_op * self, W3MImage * img, char *fname, int w, int h)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#if defined(USE_GTK2)
|
#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++) {
|
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;
|
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 (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);
|
org_pixbuf = gdk_pixbuf_animation_iter_get_pixbuf(iter);
|
||||||
delay = gdk_pixbuf_animation_iter_get_delay_time(iter);
|
delay = gdk_pixbuf_animation_iter_get_delay_time(iter);
|
||||||
width = gdk_pixbuf_get_width(org_pixbuf);
|
pixbuf = resize_image(org_pixbuf, w, h);
|
||||||
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);
|
|
||||||
|
|
||||||
if (delay > ximg->delay)
|
if (delay > ximg->delay)
|
||||||
ximg->delay = 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,
|
gdk_pixbuf_xlib_render_to_drawable_alpha(pixbuf,
|
||||||
(Drawable) ximg->pixmap[i], 0,
|
(Drawable) ximg->pixmap[j], 0,
|
||||||
0, ofstx, ofsty, width,
|
0, 0, 0, w, h,
|
||||||
height,
|
|
||||||
GDK_PIXBUF_ALPHA_BILEVEL, 1,
|
GDK_PIXBUF_ALPHA_BILEVEL, 1,
|
||||||
XLIB_RGB_DITHER_NORMAL, 0, 0);
|
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)
|
if (org_pixbuf != pixbuf)
|
||||||
g_object_unref(G_OBJECT(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);
|
XFreePixmap(xi->display, tmp_pixmap);
|
||||||
g_object_unref(G_OBJECT(animation));
|
g_object_unref(G_OBJECT(animation));
|
||||||
|
|||||||
Reference in New Issue
Block a user