ctypes and unsigned char*
oliver.andrich at gmail.com
oliver.andrich at gmail.com
Mon Aug 20 07:30:50 EDT 2007
On 19 Aug., 20:40, Gabriel Genellina <gagsl-... at yahoo.com.ar> wrote:
> In the first case, use a plain c_char_p - the individual "chars" are
> already unsigned in Python (that is, ord(xxx[i]) is always positive)
> In the second case, first define the pointer type:
>
> c_ubyte_p = POINTER(c_ubyte)
> your_function.restype = c_ubyte_p
I will have to look into that. My function I want to wrap has the
following signature
unsigned char *MagickGetImageProfile(MagickWand *wand,const char
*name,
size_t *length)
Well, the first argument and the second are straight forward, and work
as expected. The last argument also works and it should take up the
length of the string (unsigned char *). If I now do
dll.MagickGetImageProfile.restype = c_char_p
result = dll.MagickGetImageProfile(wand, "8bim", byref(length))
result is either an empty string or a 3 bytes long string, while
length containes the correct length of 1086 bytes for example. I also
tried
dll.MagickGetImageProfile.restype = POINTER(c_ubyte)
with the same result. But maybe I should do some further debugging....
Best regards,
Oliver
More information about the Python-list
mailing list