[Image-SIG] (patch) move definition of ImagingObject to Imaging.h

Matthias Kramm kramm at quiss.org
Tue Jun 1 12:07:50 EDT 2004


Hi All,

I'm currently in the process of writing a C Python extension
which is (among others) able to generate SWF h.263 movies from pictures
supplied by Imaging.
(Some first crude examples (together with source) are at the bottom of 
 http://www.quiss.org/swftools/examples.html
) 

The problem I was having was that I need to know the definition
of ImagingObject in my extension C code- otherwise I can't process the
Imaging pictures my functions are called with- the relevant
ImagingObject isn't yet defined in the Imaging.h include file.
It seems Scencil (former Sketch) has the same problem.

What I now did (patch is attached) is to move ImagingObject to Imaging.h,
together with Imaging_Type to also allow for type checks in my
extension code.
The relevant piece of code is surrounded with an #ifdef Py_PYTHON_H,
because it's the only Python-specific code, so the defines should
only be executed if the Python headers are included, too.

It would be great if this patch could make it into the official
Imaging distribution.

Greetings

Matthias

-------------- next part --------------
--- _imaging.c.bak	2003-04-26 13:50:24.000000000 +0200
+++ _imaging.c	2004-06-01 17:45:27.000000000 +0200
@@ -99,13 +99,6 @@
 /* OBJECT ADMINISTRATION						*/
 /* -------------------------------------------------------------------- */
 
-typedef struct {
-    PyObject_HEAD
-    Imaging image;
-} ImagingObject;
-
-staticforward PyTypeObject Imaging_Type;
-
 #ifdef WITH_IMAGEDRAW
 
 typedef struct
@@ -2599,7 +2592,7 @@
 
 /* type description */
 
-statichere PyTypeObject Imaging_Type = {
+PyTypeObject Imaging_Type = {
     PyObject_HEAD_INIT(NULL)
     0,				/*ob_size*/
     "ImagingCore",		/*tp_name*/
--- libImaging/Imaging.h.bak	2004-06-01 17:42:16.000000000 +0200
+++ libImaging/Imaging.h	2004-06-01 17:47:47.000000000 +0200
@@ -62,6 +62,17 @@
 typedef struct ImagingOutlineInstance* ImagingOutline;
 typedef struct ImagingPaletteInstance* ImagingPalette;
 
+/* Python Object Definition */
+
+#ifdef Py_PYTHON_H
+typedef struct {
+    PyObject_HEAD
+    Imaging image;
+} ImagingObject;
+
+extern PyTypeObject Imaging_Type;
+#endif
+
 /* pixel types */
 #define IMAGING_TYPE_UINT8 0
 #define IMAGING_TYPE_INT32 1


More information about the Image-SIG mailing list