aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFumitoshi UKAI <ukai@debian.or.jp>2002-09-29 15:29:12 +0000
committerFumitoshi UKAI <ukai@debian.or.jp>2002-09-29 15:29:12 +0000
commit6b3f98f6c74e04c2381b00d11913bc31175ec3f7 (patch)
tree34535c0621f07aa17a850b84d5d74158168dcfda
parent[w3m-dev 03325] Re: hang up when seeing web page that contains xbm file (diff)
downloadw3m-6b3f98f6c74e04c2381b00d11913bc31175ec3f7.tar.gz
w3m-6b3f98f6c74e04c2381b00d11913bc31175ec3f7.zip
[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>
-rw-r--r--ChangeLog12
-rwxr-xr-xconfigure12
-rw-r--r--w3mimg/x11/x11_w3mimg.c56
3 files changed, 75 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 1a49bb9..93ffc97 100644
--- 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
@@ -3851,4 +3861,4 @@
* release-0-2-1
* import w3m-0.2.1
-$Id: ChangeLog,v 1.433 2002/09/29 15:14:32 ukai Exp $
+$Id: ChangeLog,v 1.434 2002/09/29 15:29:12 ukai Exp $
diff --git a/configure b/configure
index a821cbe..46d42d7 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
#!/bin/sh
-# $Id: configure,v 1.76 2002/09/11 14:54:33 ukai Exp $
+# $Id: configure,v 1.77 2002/09/29 15:29:12 ukai Exp $
# Configuration.
#
@@ -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
index d36de0d..843a2d1 100644
--- a/w3mimg/x11/x11_w3mimg.c
+++ b/w3mimg/x11/x11_w3mimg.c
@@ -1,9 +1,16 @@
-/* $Id: x11_w3mimg.c,v 1.6 2002/09/09 13:59:09 ukai Exp $ */
+/* $Id: x11_w3mimg.c,v 1.7 2002/09/29 15:29:12 ukai Exp $ */
#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;
}