pcf.test, makefile
authorTomas Musil <tomik.musil@gmail.com>
Fri, 19 Oct 2012 16:43:08 +0000 (18:43 +0200)
committerTomas Musil <tomik.musil@gmail.com>
Fri, 19 Oct 2012 19:06:09 +0000 (21:06 +0200)
makefile [new file with mode: 0644]
pcf.c [new file with mode: 0644]

diff --git a/makefile b/makefile
new file mode 100644 (file)
index 0000000..11daba2
--- /dev/null
+++ b/makefile
@@ -0,0 +1,4 @@
+imago: pcf.c
+       gcc -shared -I/usr/include/python2.7/ -lpython2.7 -o pcf.so pcf.c
+clean:
+       rm -f pcf.so
diff --git a/pcf.c b/pcf.c
new file mode 100644 (file)
index 0000000..eccb991
--- /dev/null
+++ b/pcf.c
@@ -0,0 +1,27 @@
+#include <Python.h>
+
+static PyObject* py_test(PyObject* self, PyObject* args)
+{
+       unsigned char *image;
+       int x;
+       int y;
+       int size;
+
+       if (!PyArg_ParseTuple(args, "(ii)s#", &x, &y, &image, &size)) return NULL;
+       
+       int i;
+       for (i=0; i < size; i++) {
+               image[i] = i % 256;
+       }
+
+       return Py_BuildValue("s#", image, size);
+}
+static PyMethodDef myModule_methods[] = {
+       {"test", py_test, METH_VARARGS},
+       {NULL, NULL}
+};
+
+void initpcf()
+{
+               (void) Py_InitModule("pcf", myModule_methods);
+}