Hi I have been trying to wrap a c library called FreeImage for python and am having trouble with a couple of functions.

One function is

FreeImage_Load which takes parameters (enum, const char*, int)

I have wrapped the function with the following code
static PyObject *
freeimage_load(PyObject *self, PyObject *args)
{
       int format, flags;
       char* filename = "None";
       FIBITMAP *dib = NULL;

       if (!PyArg_ParseTuple(args, "isi", &format, filename, &flags))
           return NULL;

       dib = FreeImage_Load(format, filename, flags);

       return Py_BuildValue("o", dib);
}

However I am getting a segmentation fault at PyArg_ParseTuple.
Also I have little Idea what to return from the function. FIBITMAP * is an opaque pointer
that I pass to other FreeImage functions, I pretty certain
Py_BuildValue("o", dib) is wrong.


There is also the function
unsigned char  *FreeImage_GetBits(FIBITMAP *dib);

I and not sure how to return the bits to python.

I would probably like to display an image with the gtk function

drawable.draw_rgb_image(*gc*, *x*, *y*, *width*, *height*, *dith*, *rgb_buf*, 
*rowstride*)

here the RGB Image data is packed in a string as a
sequence of 8-bit RGB pixel triplets


but I have no idea how to get from unsigned char * to that.

Any advice would be greatly appreciated.

Thanks
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to