[cairo-commit] pycairo/cairo cairomodule.c, 1.12,
1.13 caironumpymodule.c, 1.4, 1.5 cairosvgmodule.c, 1.1, 1.2
Steve Chaplin
commit at pdx.freedesktop.org
Fri Mar 11 09:03:08 PST 2005
Committed by: stevech1097
Update of /cvs/cairo/pycairo/cairo
In directory gabe:/tmp/cvs-serv8030/cairo
Modified Files:
cairomodule.c caironumpymodule.c cairosvgmodule.c
Log Message:
SC 2005/03/11
Index: cairomodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairomodule.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- cairomodule.c 10 Mar 2005 08:29:52 -0000 1.12
+++ cairomodule.c 11 Mar 2005 17:03:05 -0000 1.13
@@ -236,8 +236,6 @@
#ifdef CAIRO_HAS_PS_SURFACE
{ "ps_surface_create", (PyCFunction)pycairo_ps_surface_create, METH_VARARGS, "" },
#endif
- /* this is the old function name, should use image_surface_create_for_data */
- { "surface_create_for_image", (PyCFunction)pycairo_image_surface_create_for_data, METH_VARARGS, "this is the old function name, should use image_surface_create_for_data" },
{ NULL, NULL, 0 }
};
Index: caironumpymodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/caironumpymodule.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- caironumpymodule.c 10 Dec 2004 13:03:35 -0000 1.4
+++ caironumpymodule.c 11 Mar 2005 17:03:05 -0000 1.5
@@ -42,8 +42,7 @@
{
PyArrayObject *array;
cairo_format_t format;
- int width, height, stride;
- char *data;
+ int nd;
cairo_surface_t *surface;
if (!PyArg_ParseTuple(args, "O!:surface_create_for_array",
@@ -54,29 +53,26 @@
PyErr_SetString(PyExc_TypeError, "array data must be unsigned bytes");
return NULL;
}
- if (array->nd < 2) {
+
+ nd = array->nd;
+ if (nd < 2) {
PyErr_SetString(PyExc_TypeError,
"array must have at least two dimensions");
return NULL;
}
- width = array->dimensions[1];
- height = array->dimensions[0];
- stride = array->strides[0];
- data = (char *)array->data;
-
- if (array->nd == 2 || (array->nd == 3 && array->dimensions[2] == 1)) {
+ 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 (array->nd == 3 && array->dimensions[2] == 3) {
+ } 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 (array->nd == 3 && array->dimensions[2] == 4) {
+ } else if (nd == 3 && array->dimensions[2] == 4) {
if (array->strides[1] != 4) {
PyErr_SetString(PyExc_TypeError, "second axis must be contiguous");
return NULL;
@@ -87,13 +83,19 @@
"array must be MxN or MxNxP where P is 1, 3 or 4");
return NULL;
}
-
- surface = cairo_surface_create_for_image(data, format,
- width, height, stride);
+ surface = cairo_image_surface_create_for_data(array->data,
+ format,
+ array->dimensions[1],
+ array->dimensions[0],
+ array->strides[0]);
if (!surface)
return PyErr_NoMemory();
- /* should get surface to hold reference to array ... */
+ /* The output buffer (data) must be kept around until the cairo_surface_t is
+ destroyed or cairo_surface_finish() is called on the surface.
+ TODO: surface should reference the array to keep it alive.
+ and unref when surface destroyed/finished
+ */
return pycairo_surface_wrap(surface);
}
Index: cairosvgmodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairosvgmodule.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cairosvgmodule.c 10 Dec 2004 15:15:46 -0000 1.1
+++ cairosvgmodule.c 11 Mar 2005 17:03:05 -0000 1.2
@@ -47,7 +47,7 @@
*/
-static PyMethodDef svg_methods[] = {
+static PyMethodDef svg_functions[] = {
{NULL},
};
@@ -67,7 +67,7 @@
if (PyType_Ready(&PyCairoSVGContext_Type) < 0)
return;
- mod = Py_InitModule3 ("cairo.svg", svg_methods, svg_doc);
+ mod = Py_InitModule3 ("cairo.svg", svg_functions, svg_doc);
if (mod == NULL)
return;
More information about the cairo-commit
mailing list