w3m

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

commit 333014a26aa71096cb8c10c0158d20da4c44b603
parent 859e09ed0d3e9c9fa1a4ed224d73a537ca6f78ad
Author: ukai <ukai>
Date:   Sun, 29 Sep 2002 15:29:12 +0000

[w3m-dev 03327] gdk-pixbuf support for w3m-img/x11
* configure (use_w3mimg_x11) Imlib1 or GdkPixbuf
	check gdkpixbuf
* w3mimg/x11/x11_w3mimg.c (USE_GDKPIXBUF): added
	(x11_init): USE_GDKPIXBUF
	(x11_load_image): USE_GDKPIXBUF
	(x11_get_image_size): USE_GDKPIXBUF
From: Yuji Abe <cbo46560@pop12.odn.ne.jp>

Diffstat:
MChangeLog | 10++++++++++
Mconfigure | 10++++++++--
Mw3mimg/x11/x11_w3mimg.c | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 72 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,13 @@ +2002-09-30 Yuji Abe <cbo46560@pop12.odn.ne.jp> + + * [w3m-dev 03327] gdk-pixbuf support for w3m-img/x11 + * configure (use_w3mimg_x11) Imlib1 or GdkPixbuf + check gdkpixbuf + * w3mimg/x11/x11_w3mimg.c (USE_GDKPIXBUF): added + (x11_init): USE_GDKPIXBUF + (x11_load_image): USE_GDKPIXBUF + (x11_get_image_size): USE_GDKPIXBUF + 2002-09-30 qhwt@myrealbox.com * [w3m-dev 03325] Re: hang up when seeing web page that contains xbm file diff --git a/configure b/configure @@ -791,7 +791,7 @@ ask_param "Inline image support" use_image n if [ "$use_image" = y ]; then def_use_image="#define USE_IMAGE" imgtarget='$(IMGDISPLAY) $(IMGSIZE)' - ask_param "X11 inline image support (you need Imlib1 library)" use_w3mimg_x11 y + ask_param "X11 inline image support (you need Imlib1 or GdkPixbuf library)" use_w3mimg_x11 y d_w3mimg_fb=n case $sysname in Linux|linux|LINUX) @@ -2132,7 +2132,13 @@ imgobjs='w3mimg/w3mimg.o' if [ "$use_image" = y ]; then if [ "$use_w3mimg_x11" = y ]; then - if find_imlib; then + if find_gdkpixbuf; then + def_use_w3mimg_x11="#define USE_W3MIMG_X11" + def_use_gdkpixbuf='#define USE_GDKPIXBUF' + imgobjs="$imgobjs w3mimg/x11/x11_w3mimg.o" + imgx11cflags='`gdk-pixbuf-config --cflags`' + imgx11ldflags='`gdk-pixbuf-config --libs` -lgdk_pixbuf_xlib' + elif find_imlib; then def_use_w3mimg_x11="#define USE_W3MIMG_X11" def_use_imlib='#define USE_IMLIB' imgobjs="$imgobjs w3mimg/x11/x11_w3mimg.o" diff --git a/w3mimg/x11/x11_w3mimg.c b/w3mimg/x11/x11_w3mimg.c @@ -2,8 +2,15 @@ #include <stdio.h> #include <stdlib.h> #include <ctype.h> +#include "config.h" +#if defined(USE_IMLIB) #include <Imlib.h> +#elif defined(USE_GDKPIXBUF) +#include <gdk-pixbuf/gdk-pixbuf-xlib.h> +#else +#error no Imlib and GdkPixbuf support +#endif #include "w3mimg/w3mimg.h" @@ -15,7 +22,11 @@ struct x11_info { Window window, parent; unsigned long background_pixel; GC imageGC; +#if defined(USE_IMLIB) ImlibData *id; +#elif defined(USE_GDKPIXBUF) + int init_flag; +#endif }; static int @@ -27,11 +38,18 @@ x11_init(w3mimg_op * self) xi = (struct x11_info *)self->priv; if (xi == NULL) return 0; +#if defined(USE_IMLIB) if (!xi->id) { xi->id = Imlib_init(xi->display); if (!xi->id) return 0; } +#elif defined(USE_GDKPIXBUF) + if (!xi->init_flag) { + gdk_pixbuf_xlib_init(xi->display, 0); + xi->init_flag = TRUE; + } +#endif if (!xi->imageGC) { xi->imageGC = XCreateGC(xi->display, xi->parent, 0, NULL); if (!xi->imageGC) @@ -131,7 +149,11 @@ static int x11_load_image(w3mimg_op * self, W3MImage * img, char *fname, int w, int h) { struct x11_info *xi; +#if defined(USE_IMLIB) ImlibImage *im; +#elif defined(USE_GDKPIXBUF) + GdkPixbuf *pixbuf; +#endif if (self == NULL) return 0; @@ -139,6 +161,7 @@ x11_load_image(w3mimg_op * self, W3MImage * img, char *fname, int w, int h) if (xi == NULL) return 0; +#if defined(USE_IMLIB) im = Imlib_load_image(xi->id, fname); if (!im) return 0; @@ -146,14 +169,30 @@ x11_load_image(w3mimg_op * self, W3MImage * img, char *fname, int w, int h) w = im->rgb_width; if (h <= 0) h = im->rgb_height; +#elif defined(USE_GDKPIXBUF) + pixbuf = gdk_pixbuf_new_from_file(fname); + if (!pixbuf) + return 0; + if (w <= 0) + w = gdk_pixbuf_get_width(pixbuf); + if (h <= 0) + h = gdk_pixbuf_get_height(pixbuf); +#endif img->pixmap = (void *)XCreatePixmap(xi->display, xi->parent, w, h, DefaultDepth(xi->display, 0)); if (!img->pixmap) return 0; XSetForeground(xi->display, xi->imageGC, xi->background_pixel); XFillRectangle(xi->display, (Pixmap) img->pixmap, xi->imageGC, 0, 0, w, h); +#if defined(USE_IMLIB) Imlib_paste_image(xi->id, im, (Pixmap) img->pixmap, 0, 0, w, h); Imlib_kill_image(xi->id, im); +#elif defined(USE_GDKPIXBUF) + gdk_pixbuf_xlib_render_to_drawable(pixbuf, (Drawable) img->pixmap, + xi->imageGC, 0, 0, 0, 0, w, h, + XLIB_RGB_DITHER_NORMAL, 0, 0); + gdk_pixbuf_unref(pixbuf); +#endif img->width = w; img->height = h; return 1; @@ -199,7 +238,11 @@ x11_get_image_size(w3mimg_op * self, W3MImage * img, char *fname, int *w, int *h) { struct x11_info *xi; +#if defined(USE_IMLIB) ImlibImage *im; +#elif defined(USE_GDKPIXBUF) + GdkPixbuf *pixbuf; +#endif if (self == NULL) return 0; @@ -207,6 +250,7 @@ x11_get_image_size(w3mimg_op * self, W3MImage * img, char *fname, int *w, if (xi == NULL) return 0; +#if defined(USE_IMLIB) im = Imlib_load_image(xi->id, fname); if (!im) return 0; @@ -214,6 +258,16 @@ x11_get_image_size(w3mimg_op * self, W3MImage * img, char *fname, int *w, *w = im->rgb_width; *h = im->rgb_height; Imlib_kill_image(xi->id, im); +#elif defined(USE_GDKPIXBUF) + pixbuf = gdk_pixbuf_new_from_file(fname); + if (!pixbuf) + return 0; + + *w = gdk_pixbuf_get_width(pixbuf); + *h = gdk_pixbuf_get_height(pixbuf); + + gdk_pixbuf_unref(pixbuf); +#endif return 1; }