[cairo-commit] pycairo/cairo pycairo-surface.c,1.85,1.86
Steve Chaplin
commit at pdx.freedesktop.org
Tue Jan 16 21:40:06 PST 2007
- Previous message: [cairo-commit] pycairo ChangeLog, 1.257, 1.258 README, 1.30,
1.31 NOTES, 1.24, 1.25 configure.ac, 1.61, 1.62
- Next message: [cairo-commit] pycairo/test isurface_create_for_array.py, 1.2,
NONE Makefile.am, 1.9, 1.10
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: stevech1097
Update of /cvs/cairo/pycairo/cairo
In directory kemper:/tmp/cvs-serv20698/cairo
Modified Files:
pycairo-surface.c
Log Message:
'SC'
Index: pycairo-surface.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-surface.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -d -r1.85 -r1.86
--- pycairo-surface.c 16 Jan 2007 14:59:34 -0000 1.85
+++ pycairo-surface.c 17 Jan 2007 05:40:01 -0000 1.86
@@ -38,11 +38,6 @@
#include "pycairo-private.h"
-#ifdef HAVE_NUMPY
-# include <Numeric/arrayobject.h>
- static int load_numpy (void);
-#endif
-
/* Class Surface ---------------------------------------------------------- */
/* PycairoSurface_FromSurface
@@ -380,66 +375,6 @@
NULL);
}
-#ifdef HAVE_NUMPY
-static PyObject *
-image_surface_create_for_array (PyTypeObject *type, PyObject *args)
-{
- PyArrayObject *array;
- cairo_format_t format;
- cairo_surface_t *surface;
- int nd;
-
- if (!load_numpy())
- return NULL;
-
- if (!PyArg_ParseTuple(args, "O!:surface_create_for_array",
- &PyArray_Type, &array))
- return NULL;
-
- if (array->descr->type_num != PyArray_UBYTE) {
- PyErr_SetString(PyExc_TypeError, "array data must be unsigned bytes");
- return NULL;
- }
-
- nd = array->nd;
- if (nd < 2) {
- PyErr_SetString(PyExc_TypeError,
- "array must have at least two dimensions");
- return NULL;
- }
- if (nd == 2 || (nd == 3 && array->dimensions[2] == 1)) {
- if (array->strides[1] != 1) {
- PyErr_SetString(PyExc_TypeError, "second axis must be contiguous");
- return NULL;
- }
- format = CAIRO_FORMAT_A8;
- } else if (nd == 3 && array->dimensions[2] == 3) {
- if (array->strides[1] != 3) {
- PyErr_SetString(PyExc_TypeError, "second axis must be contiguous");
- return NULL;
- }
- format = CAIRO_FORMAT_RGB24;
- } else if (nd == 3 && array->dimensions[2] == 4) {
- if (array->strides[1] != 4) {
- PyErr_SetString(PyExc_TypeError, "second axis must be contiguous");
- return NULL;
- }
- format = CAIRO_FORMAT_ARGB32;
- } else {
- PyErr_SetString(PyExc_TypeError,
- "array must be MxN or MxNxP where P is 1, 3 or 4");
- return NULL;
- }
- surface = cairo_image_surface_create_for_data(
- (unsigned char *) array->data,
- format,
- array->dimensions[1],
- array->dimensions[0],
- array->strides[0]);
- return PycairoSurface_FromSurface(surface, (PyObject *)array);
-}
-#endif /* HAVE_NUMPY */
-
static PyObject *
image_surface_create_for_data (PyTypeObject *type, PyObject *args)
{
@@ -633,10 +568,6 @@
};
static PyMethodDef image_surface_methods[] = {
-#ifdef HAVE_NUMPY
- {"create_for_array",(PyCFunction)image_surface_create_for_array,
- METH_VARARGS | METH_CLASS },
-#endif
{"create_for_data",(PyCFunction)image_surface_create_for_data,
METH_VARARGS | METH_CLASS },
#ifdef CAIRO_HAS_PNG_FUNCTIONS
@@ -1177,39 +1108,3 @@
0, /* tp_bases */
};
#endif /* CAIRO_HAS_XLIB_SURFACE */
-
-
-/* Numeric routines ------------------------------------------------------- */
-
-#ifdef HAVE_NUMPY
-/* load the Numeric Python module
- * Return 1 if Numeric is available,
- * 0 and set exception if it is not.
- *
- * copied from pygtk
- */
-static int
-load_numpy(void)
-{
- static int import_done = 0;
- static PyObject *exc_type=NULL, *exc_value=NULL;
- PyObject *exc_tb=NULL;
-
- if (exc_type != NULL) {
- PyErr_Restore(exc_type, exc_value, NULL);
- return 0;
- }
- if (!import_done) {
- import_done = 1;
- import_array();
- if (PyErr_Occurred()) {
- PyErr_Fetch(&exc_type, &exc_value, &exc_tb);
- Py_INCREF(exc_type);
- Py_XINCREF(exc_value);
- PyErr_Restore(exc_type, exc_value, exc_tb);
- return 0;
- }
- }
- return 1;
-}
-#endif /* HAVE_NUMPY */
- Previous message: [cairo-commit] pycairo ChangeLog, 1.257, 1.258 README, 1.30,
1.31 NOTES, 1.24, 1.25 configure.ac, 1.61, 1.62
- Next message: [cairo-commit] pycairo/test isurface_create_for_array.py, 1.2,
NONE Makefile.am, 1.9, 1.10
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the cairo-commit
mailing list