From: Tomas Musil Date: Fri, 19 Oct 2012 16:43:08 +0000 (+0200) Subject: pcf.test, makefile X-Git-Url: http://git.tomasm.cz/imago.git/commitdiff_plain/6e16bbc7797b679d6681eee08d9103984728b98f pcf.test, makefile --- diff --git a/makefile b/makefile new file mode 100644 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 index 0000000..eccb991 --- /dev/null +++ b/pcf.c @@ -0,0 +1,27 @@ +#include + +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); +}