[cairo-commit]
pycairo/cairo pycairo.h, 1.22, 1.23 pycairo-surface.c, 1.26, 1.27
Steve Chaplin
commit at pdx.freedesktop.org
Sun Apr 24 21:12:33 PDT 2005
Committed by: stevech1097
Update of /cvs/cairo/pycairo/cairo
In directory gabe:/tmp/cvs-serv750/cairo
Modified Files:
pycairo.h pycairo-surface.c
Log Message:
SC
Index: pycairo.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- pycairo.h 14 Apr 2005 12:05:26 -0000 1.22
+++ pycairo.h 25 Apr 2005 04:12:31 -0000 1.23
@@ -35,10 +35,15 @@
#define _PYCAIRO_H_
#include <Python.h>
+
#include <cairo.h>
-#include <cairo-pdf.h>
-#include <cairo-png.h>
-#include <cairo-ps.h>
+
+#ifdef CAIRO_HAS_PDF_SURFACE
+# include <cairo-pdf.h>
+#endif
+#ifdef CAIRO_HAS_PS_SURFACE
+# include <cairo-ps.h>
+#endif
typedef struct {
PyObject_HEAD
Index: pycairo-surface.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-surface.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- pycairo-surface.c 16 Apr 2005 05:02:19 -0000 1.26
+++ pycairo-surface.c 25 Apr 2005 04:12:31 -0000 1.27
@@ -210,14 +210,18 @@
static PyObject *
surface_write_png(PyCairoSurface *s, PyObject *args)
{
- PyObject *file_object;
+ /*PyObject *file_object;*/
+ char *filename;
cairo_status_t status;
- if (!PyArg_ParseTuple(args, "O!:Surface.write_png",
- &PyFile_Type, &file_object))
+ /*if (!PyArg_ParseTuple(args, "O!:Surface.write_png",
+ &PyFile_Type, &file_object)) */
+ if (!PyArg_ParseTuple(args, "S:Surface.write_png",
+ filename))
return NULL;
- status = cairo_surface_write_png(s->surface, PyFile_AsFile(file_object));
+ /*status = cairo_surface_write_png(s->surface, PyFile_AsFile(file_object));*/
+ status = cairo_surface_write_png(s->surface, filename);
if (pycairo_check_status(status))
return NULL;
Py_RETURN_NONE;
@@ -451,19 +455,22 @@
#ifdef CAIRO_HAS_PNG_FUNCTIONS
/* alternative constructor */
static PyObject *
-image_surface_create_for_png(PyTypeObject *type, PyObject *args)
+image_surface_create_from_png(PyTypeObject *type, PyObject *args)
{
PyObject *s;
- PyObject *file_object;
+ /*PyObject *file_object;*/
+ char *filename;
cairo_surface_t *surface;
- int width=0, height=0;
+ /*int width=0, height=0;*/
- if (!PyArg_ParseTuple(args, "O!:Surface.create_for_png",
- &PyFile_Type, &file_object))
+ /*if (!PyArg_ParseTuple(args, "O!:Surface.create_from_png",
+ &PyFile_Type, &file_object))*/
+ if (!PyArg_ParseTuple(args, "S:Surface.create_from_png",
+ filename))
return NULL;
- surface = cairo_image_surface_create_for_png
- (PyFile_AsFile(file_object), &width, &height);
+ surface = cairo_image_surface_create_from_png(filename);
+ /*(PyFile_AsFile(file_object), &width, &height);*/
if (!surface) {
PyErr_SetString(PyExc_ValueError, "invalid PNG file or memory could "
"not be allocated for operation");
@@ -473,15 +480,14 @@
if (!s)
cairo_surface_destroy(surface);
- return Py_BuildValue("O(ii)", s, width, height);
- /*return (PyObject *)s;*/
-
- /* Py_BuildValue increments object ref count, which we don't want
+ /*return Py_BuildValue("O(ii)", s, width, height);
+ * Py_BuildValue increments object ref count, which we don't want
* proposed solution of returning object only (with getter for width,height) is better
*
- * wrapping cairo_image_surface_create_for_png() gives a seg fault
- * since cairo_image_surface_create_for_png() calls fclose(file)
+ * wrapping cairo_image_surface_create_from_png() gives a seg fault
+ * since cairo_image_surface_create_from_png() calls fclose(file)
*/
+ return (PyObject *)s;
}
#endif /* CAIRO_HAS_PNG_FUNCTIONS */
@@ -496,7 +502,7 @@
METH_VARARGS | METH_CLASS },
#endif
#ifdef CAIRO_HAS_PNG_FUNCTIONS
- { "create_for_png", (PyCFunction)image_surface_create_for_png,
+ { "create_from_png", (PyCFunction)image_surface_create_from_png,
METH_VARARGS | METH_CLASS },
#endif
{ NULL, NULL, 0 }
More information about the cairo-commit
mailing list