"john taylor" wrote:

> I've produced a DLL from my C++ program, which gets an
> image from external hardware and saves to a buffer.
> How can I get the image data from the DLL in Python?
>
> The C functions are somehow implemented as follows:
>
> static char *ImageBuffer = NULL;
>
> int WriteImageBuffer(void)
> {
>    // acquire an image and write to the buffer
>    AcquireImg(ImageBuffer, params);
> }
>
> PyObject* GetImage(void)
> {
>    return Py_BuildValue("s#", &ImageBuffer, 640*480);
> }

you're passing in the address of the pointer, not the address of the
buffer.  try changing this to:

    return Py_BuildValue("s#", ImageBuffer, 640*480);

or, better:

    return PyString_FromStringAndSize(ImageBuffer, 640*480);

(your malloc/pystring/fromstring approach does a of extra copying, but
I suppose you can start worrying about that only if you find that it's not
fast enough...)

</F> 



_______________________________________________
Image-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/image-sig

Reply via email to