diff options
| author | James Henstridge <james@daa.com.au> | 2003-01-30 14:12:17 +0000 |
|---|---|---|
| committer | James Henstridge <jamesh@src.gnome.org> | 2003-01-30 14:12:17 +0000 |
| commit | 336836ca8d356856f0db8ca222e6e20b6c1dc481 (patch) | |
| tree | 3074d79e05abc6773105529762aeaf3cba3611f4 | |
| parent | 164198942cd85241bb0ad91625cfa9e243934f8e (diff) | |
| download | pygtk-336836ca8d356856f0db8ca222e6e20b6c1dc481.tar.gz | |
add wrapper that returns a NumPy array.
2003-01-30 James Henstridge <james@daa.com.au>
* gtk/gdk.override (_wrap_gdk_pixbuf__get_pixel_array): add
wrapper that returns a NumPy array.
* gtk/gdk-types.defs (Pixbuf): add a "pixel_array" member to
pixbuf object.
* configure.in (enable_numpy): get rid of code detecting which
directory Numeric's arrayobject.h header is in. No point in
supporting ancient versions ...
| -rw-r--r-- | ChangeLog | 12 | ||||
| -rw-r--r-- | configure.in | 31 | ||||
| -rw-r--r-- | gtk/gdk-types.defs | 4 | ||||
| -rw-r--r-- | gtk/gdk.override | 36 |
4 files changed, 69 insertions, 14 deletions
@@ -1,3 +1,15 @@ +2003-01-30 James Henstridge <james@daa.com.au> + + * gtk/gdk.override (_wrap_gdk_pixbuf__get_pixel_array): add + wrapper that returns a NumPy array. + + * gtk/gdk-types.defs (Pixbuf): add a "pixel_array" member to + pixbuf object. + + * configure.in (enable_numpy): get rid of code detecting which + directory Numeric's arrayobject.h header is in. No point in + supporting ancient versions ... + 2003-01-30 Gustavo J. A. M. Carneiro <gustavo@users.sourceforge.net> * gtk/gtk-types.defs (Layout): Wrap bin_window. diff --git a/configure.in b/configure.in index bd14ba94..66522011 100644 --- a/configure.in +++ b/configure.in @@ -86,19 +86,25 @@ export_dynamic=`(./libtool --config; echo eval echo \\$export_dynamic_flag_spec) dnl glib AM_PATH_GLIB_2_0(glib_required_version,,[AC_MSG_ERROR(maybe you want the gtk-gnome-1-2 branch?)],gobject $extra_mods) -GLIB_LIBS=`echo $GLIB_LIBS | sed -e "s/$export_dynamic//"` +if test -n "$export_dynamic"; then + GLIB_LIBS=`echo $GLIB_LIBS | sed -e "s/$export_dynamic//"` +fi dnl atk PKG_CHECK_MODULES(ATK, atk >= atk_required_version,,[AC_MSG_ERROR(maybe you want the gtk-gnome-1-2 branch?)]) AC_SUBST(ATK_CFLAGS) AC_SUBST(ATK_LIBS) -ATK_LIBS=`echo $ATK_LIBS | sed -e "s/$export_dynamic//"` +if test -n "$export_dynamic"; then + ATK_LIBS=`echo $ATK_LIBS | sed -e "s/$export_dynamic//"` +fi dnl pango PKG_CHECK_MODULES(PANGO, pango >= pango_required_version,,[AC_MSG_ERROR(maybe you want the gtk-gnome-1-2 branch?)]) AC_SUBST(PANGO_CFLAGS) AC_SUBST(PANGO_LIBS) -PANGO_LIBS=`echo $PANGO_LIBS | sed -e "s/$export_dynamic//"` +if test -n "$export_dynamic"; then + PANGO_LIBS=`echo $PANGO_LIBS | sed -e "s/$export_dynamic//"` +fi dnl gtk+ AM_PATH_GTK_2_0(gtk_required_version,,[AC_MSG_ERROR(maybe you want the gtk-gnome-1-2 branch?)],$extra_mods) @@ -112,7 +118,9 @@ PKG_CHECK_MODULES(LIBGLADE, libglade-2.0 >= libglade_required_version, AC_SUBST(LIBGLADE_CFLAGS) AC_SUBST(LIBGLADE_LIBS) AM_CONDITIONAL(BUILD_LIBGLADE, $build_libglade) -LIBGLADE_LIBS=`echo $LIBGLADE_LIBS | sed -e "s/$export_dynamic//"` +if test -n "$export_dynamic"; then + LIBGLADE_LIBS=`echo $LIBGLADE_LIBS | sed -e "s/$export_dynamic//"` +fi dnl gtkgl build_gtkgl=false @@ -122,7 +130,9 @@ PKG_CHECK_MODULES(GTKGL, gtkgl-2.0 >= gtkgl_required_version, AC_SUBST(GTKGL_CFLAGS) AC_SUBST(GTKGL_LIBS) AM_CONDITIONAL(BUILD_GTKGL, $build_gtkgl) -GTKGL_LIBS=`echo $GTKGL_LIBS | sed -e "s/$export_dynamic//"` +if test -n "$export_dynamic"; then + GTKGL_LIBS=`echo $GTKGL_LIBS | sed -e "s/$export_dynamic//"` +fi AC_ARG_ENABLE(numpy, @@ -133,15 +143,8 @@ dnl checks to see if Numeric Python is installed. if test "x$enable_numpy" != xno; then save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES" - AC_CHECK_HEADER(arrayobject.h, - [AC_DEFINE(HAVE_NUMPY) - AC_DEFINE(HAVE_ARRAYOBJECT_H)], - [AC_CHECK_HEADER(Extensions/arrayobject.h, - [AC_DEFINE(HAVE_NUMPY) - AC_DEFINE(HAVE_EXTENSIONS_ARRAYOBJECT_H)], - [AC_CHECK_HEADER(Numeric/arrayobject.h, - [AC_DEFINE(HAVE_NUMPY) - AC_DEFINE(HAVE_NUMERIC_ARRAYOBJECT_H)])])]) + AC_CHECK_HEADER(Numeric/arrayobject.h, + [AC_DEFINE(HAVE_NUMPY,,[whether to include numeric python support])]) CPPFLAGS="$save_CPPFLAGS" fi diff --git a/gtk/gdk-types.defs b/gtk/gdk-types.defs index fd087091..61591563 100644 --- a/gtk/gdk-types.defs +++ b/gtk/gdk-types.defs @@ -89,6 +89,10 @@ (parent "GObject") (c-name "GdkPixbuf") (gtype-id "GDK_TYPE_PIXBUF") + (fields +; XXXX this next one isn't a real field. added for Python bindings + '("guchar*" "pixel_array") + ) ) (define-object PixbufAnimation diff --git a/gtk/gdk.override b/gtk/gdk.override index 1a8d2db3..c17891a7 100644 --- a/gtk/gdk.override +++ b/gtk/gdk.override @@ -11,6 +11,10 @@ headers #include <gdk-pixbuf/gdk-pixbuf.h> #include "pygtk-private.h" +#ifdef HAVE_NUMPY +# include <Numeric/arrayobject.h> +#endif + extern PyTypeObject PyGtkWidget_Type; %% @@ -21,6 +25,9 @@ import pango.Context as PyPangoContext_Type import pango.Font as PyPangoFont_Type import pango.Layout as PyPangoLayout_Type %% +init + import_array(); +%% ignore-glob *_get_type _* @@ -1854,6 +1861,35 @@ _wrap_gdk_pixbuf_render_pixmap_and_mask(PyGObject *self, PyObject *args, return ret; } %% +override-attr GdkPixbuf.pixel_array +static PyObject * +_wrap_gdk_pixbuf__get_pixel_array(PyGObject *self, void *closure) +{ +#ifdef HAVE_NUMPY + GdkPixbuf *pixbuf = GDK_PIXBUF(self->obj); + PyArrayObject *array; + int dims[3] = { 0, 0, 3 }; + + dims[0] = gdk_pixbuf_get_width(pixbuf); + dims[1] = gdk_pixbuf_get_height(pixbuf); + if (gdk_pixbuf_get_has_alpha(pixbuf)) + dims[2] = 4; + array = (PyArrayObject *)PyArray_FromDimsAndData(3, dims, PyArray_UBYTE, + (char *)gdk_pixbuf_get_pixels(pixbuf)); + if (array == NULL) + return NULL; + + array->strides[0] = gdk_pixbuf_get_rowstride(pixbuf); + /* the array holds a ref to the pixbuf pixels through this wrapper*/ + Py_INCREF(self); + array->base = (PyObject *)self; + return PyArray_Return(array); +#else + PyErr_SetString(PyExc_RuntimeError, "pygtk was not compiled with Numeric Python support"); + return NULL; +#endif +} +%% override gdk_pixbuf_get_pixels noargs static PyObject * _wrap_gdk_pixbuf_get_pixels(PyGObject *self) |
