Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/fill/fillmodule.c
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2012-10-26 19:33:44 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2012-10-30 13:14:49 (GMT)
commit929a4f333b4a41dd96598afc8bae3effd0cc9de9 (patch)
tree4d7c9fff3206e2d4033c3db5214af867540eda59 /fill/fillmodule.c
parent8d5543a256a30df6eccefd1d3cf823b26b281600 (diff)
Fix c bucket implementation - SL #4073
The c implementation is reworked to process a array with the surface data instead of the GdkImage. It returns a list instead of a array The c do not depends on gtk anymore. Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
Diffstat (limited to 'fill/fillmodule.c')
-rw-r--r--fill/fillmodule.c59
1 files changed, 43 insertions, 16 deletions
diff --git a/fill/fillmodule.c b/fill/fillmodule.c
index b23bfd7..9a1c0e1 100644
--- a/fill/fillmodule.c
+++ b/fill/fillmodule.c
@@ -46,26 +46,53 @@ Cientific Coordinator:
Roseli de Deus Lopes (roseli@lsi.usp.br)
*/
-#include <pygobject.h>
+#include <Python.h>
+#include "eggfill.h"
-void fill_register_classes (PyObject *d);
-
-extern PyMethodDef fill_functions[];
-
-DL_EXPORT(void)
-init_fill(void)
+static PyObject* fill(PyObject* self, PyObject* args)
{
- PyObject *m, *d;
-
- init_pygobject ();
+ PyObject *mylist;
+ unsigned int x, y, width, height, color;
+
+ if (!PyArg_ParseTuple(args, "OIIIII", &mylist, &x, &y, &width, &height, &color))
+ return NULL;
+
+ /* from http://mail.python.org/pipermail/tutor/1999-November/000758.html */
+ unsigned int *intarr, arrsize, index;
+ PyObject *item;
+ PyObject *pylist;
+
+ /* how many elements are in the Python object */
+ arrsize = PyObject_Length(mylist);
+ /* create a dynamic C array of integers */
+ intarr = (int *)malloc(sizeof(int)*arrsize);
+ for (index = 0; index < arrsize; index++) {
+ /* get the element from the list/tuple */
+ item = PySequence_GetItem(mylist, index);
+ /* assign to the C array */
+ intarr[index] = PyInt_AsUnsignedLongMask(item);
+ }
- m = Py_InitModule ("_fill", fill_functions);
- d = PyModule_GetDict (m);
-
- fill_register_classes (d);
+ /* now use intarr and arrsize in you extension */
+ //printf("x %u y %u width %u height %u color %u", x, y, width, height, color);
+ floodfill(intarr, x, y, width, height, color);
- if (PyErr_Occurred ()) {
- Py_FatalError ("can't initialise module fill");
+ pylist = PyTuple_New(arrsize);
+ for (index = 0; index < arrsize; index++) {
+ PyTuple_SetItem(pylist, index, PyInt_FromLong(intarr[index]));
}
+ return Py_BuildValue("O", pylist);
+}
+
+
+static PyMethodDef FillMethods[] = {
+ {"fill", fill, METH_VARARGS, "do fill flood in a array with the image data"},
+ {NULL, NULL, 0, NULL}
+};
+
+PyMODINIT_FUNC
+init_fill(void)
+{
+ (void) Py_InitModule("_fill", FillMethods);
}