[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>
This commit is contained in:
16
ChangeLog
16
ChangeLog
@@ -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>
|
2003-03-28 Dai Sato <satodai@dog.intcul.tohoku.ac.jp>
|
||||||
|
|
||||||
* doc(-jp)/keymap.default: ';' is quoted
|
* doc(-jp)/keymap.default: ';' is quoted
|
||||||
@@ -7623,4 +7637,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.808 2003/03/28 10:26:40 inu Exp $
|
$Id: ChangeLog,v 1.809 2003/04/03 16:35:42 ukai Exp $
|
||||||
|
@@ -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
|
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 GdkPixbuf *resize_image(GdkPixbuf * pixbuf, int width, int height);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
get_animation_size(GdkPixbufAnimation * animation, int *w, int *h)
|
get_animation_size(GdkPixbufAnimation * animation, int *w, int *h, int *delay)
|
||||||
{
|
{
|
||||||
GList *frames;
|
GList *frames;
|
||||||
int iw, ih, n, i;
|
int iw, ih, n, i, d = -1;
|
||||||
|
|
||||||
frames = gdk_pixbuf_animation_get_frames(animation);
|
frames = gdk_pixbuf_animation_get_frames(animation);
|
||||||
n = gdk_pixbuf_animation_get_num_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++) {
|
for (i = 0; i < n; i++) {
|
||||||
GdkPixbufFrame *frame;
|
GdkPixbufFrame *frame;
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
|
int tmp;
|
||||||
|
|
||||||
frame = (GdkPixbufFrame *) g_list_nth_data(frames, i);
|
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);
|
pixbuf = gdk_pixbuf_frame_get_pixbuf(frame);
|
||||||
iw = gdk_pixbuf_frame_get_x_offset(frame)
|
iw = gdk_pixbuf_frame_get_x_offset(frame)
|
||||||
+ gdk_pixbuf_get_width(pixbuf);
|
+ gdk_pixbuf_get_width(pixbuf);
|
||||||
@@ -36,6 +40,8 @@ get_animation_size(GdkPixbufAnimation * animation, int *w, int *h)
|
|||||||
if (ih > *h)
|
if (ih > *h)
|
||||||
*h = ih;
|
*h = ih;
|
||||||
}
|
}
|
||||||
|
if (delay)
|
||||||
|
*delay = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -47,7 +53,7 @@ get_image_size(char *filename, int *w, int *h)
|
|||||||
animation = gdk_pixbuf_animation_new_from_file(filename);
|
animation = gdk_pixbuf_animation_new_from_file(filename);
|
||||||
if (animation == NULL)
|
if (animation == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
get_animation_size(animation, w, h);
|
get_animation_size(animation, w, h, NULL);
|
||||||
gdk_pixbuf_animation_unref(animation);
|
gdk_pixbuf_animation_unref(animation);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -58,7 +64,7 @@ fb_image_load(char *filename, int w, int h, int max_anim)
|
|||||||
GdkPixbufAnimation *animation;
|
GdkPixbufAnimation *animation;
|
||||||
GList *frames;
|
GList *frames;
|
||||||
double ratio_w, ratio_h;
|
double ratio_w, ratio_h;
|
||||||
int n, i, fw, fh;
|
int n, i, j, fw, fh, frame_num, delay;
|
||||||
FB_IMAGE **fb_frame;
|
FB_IMAGE **fb_frame;
|
||||||
GdkPixbufFrameAction action = GDK_PIXBUF_FRAME_REVERT;
|
GdkPixbufFrameAction action = GDK_PIXBUF_FRAME_REVERT;
|
||||||
if (filename == NULL)
|
if (filename == NULL)
|
||||||
@@ -67,10 +73,14 @@ fb_image_load(char *filename, int w, int h, int max_anim)
|
|||||||
if (animation == NULL)
|
if (animation == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
frames = gdk_pixbuf_animation_get_frames(animation);
|
frames = gdk_pixbuf_animation_get_frames(animation);
|
||||||
get_animation_size(animation, &fw, &fh);
|
get_animation_size(animation, &fw, &fh, &delay);
|
||||||
n = gdk_pixbuf_animation_get_num_frames(animation);
|
frame_num = n = gdk_pixbuf_animation_get_num_frames(animation);
|
||||||
if (max_anim > 0) {
|
if (delay <= 0)
|
||||||
n = (max_anim > n) ? n : max_anim;
|
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) {
|
if (w < 1 || h < 1) {
|
||||||
w = fw;
|
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_w = 1.0 * w / fw;
|
||||||
ratio_h = 1.0 * h / fh;
|
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)
|
if (fb_frame == NULL)
|
||||||
goto END;
|
goto END;
|
||||||
for (i = 0; i < n; i++) {
|
for (j = 0; j < n; j++) {
|
||||||
GdkPixbufFrame *frame;
|
GdkPixbufFrame *frame;
|
||||||
GdkPixbuf *org_pixbuf, *pixbuf;
|
GdkPixbuf *org_pixbuf, *pixbuf;
|
||||||
int width, height, ofstx, ofsty;
|
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);
|
org_pixbuf = gdk_pixbuf_frame_get_pixbuf(frame);
|
||||||
ofstx = gdk_pixbuf_frame_get_x_offset(frame);
|
ofstx = gdk_pixbuf_frame_get_x_offset(frame);
|
||||||
ofsty = gdk_pixbuf_frame_get_y_offset(frame);
|
ofsty = gdk_pixbuf_frame_get_y_offset(frame);
|
||||||
@@ -105,10 +124,10 @@ fb_image_load(char *filename, int w, int h, int max_anim)
|
|||||||
}
|
}
|
||||||
width = gdk_pixbuf_get_width(pixbuf);
|
width = gdk_pixbuf_get_width(pixbuf);
|
||||||
height = gdk_pixbuf_get_height(pixbuf);
|
height = gdk_pixbuf_get_height(pixbuf);
|
||||||
fb_frame[i]->delay = gdk_pixbuf_frame_get_delay_time(frame);
|
if (j > 0) {
|
||||||
if (i > 0) {
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case GDK_PIXBUF_FRAME_RETAIN:
|
case GDK_PIXBUF_FRAME_RETAIN:
|
||||||
|
if (i > 0)
|
||||||
fb_image_copy(fb_frame[i], fb_frame[i - 1]);
|
fb_image_copy(fb_frame[i], fb_frame[i - 1]);
|
||||||
break;
|
break;
|
||||||
case GDK_PIXBUF_FRAME_DISPOSE:
|
case GDK_PIXBUF_FRAME_DISPOSE:
|
||||||
@@ -117,13 +136,16 @@ fb_image_load(char *filename, int w, int h, int max_anim)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GDK_PIXBUF_FRAME_REVERT:
|
case GDK_PIXBUF_FRAME_REVERT:
|
||||||
|
if (i > 0)
|
||||||
fb_image_copy(fb_frame[i], fb_frame[0]);
|
fb_image_copy(fb_frame[i], fb_frame[0]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
if (i > 0)
|
||||||
fb_image_copy(fb_frame[i], fb_frame[0]);
|
fb_image_copy(fb_frame[i], fb_frame[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
action = gdk_pixbuf_frame_get_action(frame);
|
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);
|
draw(fb_frame[i], !i, ofstx, ofsty, width, height, pixbuf);
|
||||||
if (org_pixbuf != pixbuf)
|
if (org_pixbuf != pixbuf)
|
||||||
gdk_pixbuf_finalize(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];
|
r = pixels[offset];
|
||||||
g = pixels[offset + 1];
|
g = pixels[offset + 1];
|
||||||
b = pixels[offset + 2];
|
b = pixels[offset + 2];
|
||||||
if (alpha && pixels[offset + 3] == 0) {
|
if (!alpha || pixels[offset + 3] != 0) {
|
||||||
if (bg)
|
|
||||||
fb_image_pset(img, i + x, j + y, bg_r, bg_g, bg_b);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fb_image_pset(img, i + x, j + y, r, g, b);
|
fb_image_pset(img, i + x, j + y, r, g, b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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 <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.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;
|
frame = (FB_IMAGE **) img->pixmap;
|
||||||
i = frame[0]->id;
|
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],
|
fb_image_draw(frame[i],
|
||||||
x + self->offset_x, y + self->offset_y,
|
x + self->offset_x, y + self->offset_y,
|
||||||
sx, sy, (sw ? sw : img->width), (sh ? sh : img->height));
|
sx, sy, (sw ? sw : img->width), (sh ? sh : img->height));
|
||||||
|
@@ -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 <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@@ -43,10 +43,10 @@ struct x11_image {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
get_animation_size(GdkPixbufAnimation * animation, int *w, int *h)
|
get_animation_size(GdkPixbufAnimation * animation, int *w, int *h, int *delay)
|
||||||
{
|
{
|
||||||
GList *frames;
|
GList *frames;
|
||||||
int iw, ih, n, i;
|
int iw, ih, n, i, d = -1;
|
||||||
|
|
||||||
frames = gdk_pixbuf_animation_get_frames(animation);
|
frames = gdk_pixbuf_animation_get_frames(animation);
|
||||||
n = gdk_pixbuf_animation_get_num_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++) {
|
for (i = 0; i < n; i++) {
|
||||||
GdkPixbufFrame *frame;
|
GdkPixbufFrame *frame;
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
|
int tmp;
|
||||||
|
|
||||||
frame = (GdkPixbufFrame *) g_list_nth_data(frames, i);
|
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);
|
pixbuf = gdk_pixbuf_frame_get_pixbuf(frame);
|
||||||
iw = gdk_pixbuf_frame_get_x_offset(frame)
|
iw = gdk_pixbuf_frame_get_x_offset(frame)
|
||||||
+ gdk_pixbuf_get_width(pixbuf);
|
+ gdk_pixbuf_get_width(pixbuf);
|
||||||
@@ -67,6 +71,8 @@ get_animation_size(GdkPixbufAnimation * animation, int *w, int *h)
|
|||||||
if (ih > *h)
|
if (ih > *h)
|
||||||
*h = ih;
|
*h = ih;
|
||||||
}
|
}
|
||||||
|
if (delay)
|
||||||
|
*delay = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -266,7 +272,7 @@ x11_load_image(w3mimg_op * self, W3MImage * img, char *fname, int w, int h)
|
|||||||
#elif defined(USE_GDKPIXBUF)
|
#elif defined(USE_GDKPIXBUF)
|
||||||
GdkPixbufAnimation *animation;
|
GdkPixbufAnimation *animation;
|
||||||
GList *frames;
|
GList *frames;
|
||||||
int i, iw, ih, n;
|
int i, j, iw, ih, n, frame_num, delay, max_anim;
|
||||||
double ratio_w, ratio_h;
|
double ratio_w, ratio_h;
|
||||||
struct x11_image *ximg;
|
struct x11_image *ximg;
|
||||||
GdkPixbufFrameAction action = GDK_PIXBUF_FRAME_REVERT;
|
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_render_image_on_drawable_at_size(0, 0, w, h);
|
||||||
imlib_free_image();
|
imlib_free_image();
|
||||||
#elif defined(USE_GDKPIXBUF)
|
#elif defined(USE_GDKPIXBUF)
|
||||||
|
max_anim = self->max_anim;
|
||||||
animation = gdk_pixbuf_animation_new_from_file(fname);
|
animation = gdk_pixbuf_animation_new_from_file(fname);
|
||||||
if (!animation)
|
if (!animation)
|
||||||
return 0;
|
return 0;
|
||||||
frames = gdk_pixbuf_animation_get_frames(animation);
|
frames = gdk_pixbuf_animation_get_frames(animation);
|
||||||
n = gdk_pixbuf_animation_get_num_frames(animation);
|
frame_num = n = gdk_pixbuf_animation_get_num_frames(animation);
|
||||||
get_animation_size(animation, &iw, &ih);
|
|
||||||
|
|
||||||
if (self->max_anim > 0) {
|
get_animation_size(animation, &iw, &ih, &delay);
|
||||||
n = (self->max_anim > n) ? n : self->max_anim;
|
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) {
|
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_w = 1.0 * w / iw;
|
||||||
ratio_h = 1.0 * h / ih;
|
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) {
|
if (!ximg) {
|
||||||
gdk_pixbuf_animation_unref(animation);
|
gdk_pixbuf_animation_unref(animation);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
for (i = 0; i < n; i++) {
|
for (j = 0; j < n; j++) {
|
||||||
GdkPixbufFrame *frame;
|
GdkPixbufFrame *frame;
|
||||||
GdkPixbuf *org_pixbuf, *pixbuf;
|
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);
|
org_pixbuf = gdk_pixbuf_frame_get_pixbuf(frame);
|
||||||
ofstx = gdk_pixbuf_frame_get_x_offset(frame);
|
ofstx = gdk_pixbuf_frame_get_x_offset(frame);
|
||||||
ofsty = gdk_pixbuf_frame_get_y_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)
|
if (!animation)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
get_animation_size(animation, w, h);
|
get_animation_size(animation, w, h, NULL);
|
||||||
gdk_pixbuf_animation_unref(animation);
|
gdk_pixbuf_animation_unref(animation);
|
||||||
#endif
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
|
Reference in New Issue
Block a user