ctypes

jay thompson jayryan.thompson at gmail.com
Thu Sep 23 15:16:12 EDT 2010


My apologies! I worte the email while doing 3 other things.

I haven't really tried anything to access this struct other than trying to
find different elements with ctypes.c_int.in_dll(dll, 'symbol') and access
the elements in the same way I do in C. I didn't think either of these would
work but hoped I would get some type of return that would give me a little
more info.

I have been using a cli to access the library from python and would just
send the image data via stdin and the parameters of the struct as command
line args. From C the struct is easily accessible through the class instance
(libraw::imgdata) and I tried similar variations with ctypes but just get
'function not found'. Makes sense though.

this works:

lr = ctypes.cdll.LoadLibrary(libraw)

handle = lr.libraw_init(0)

lr.libraw_open_buffer(handle, buf, len(buf)) # buf is an image read by
python
lr.libraw_unpack(handle, buf, len(buf))

# imgdata attampt. returns  "function 'imgdata' not found"
#lr.imgdata.params.bright(2)

lr.libraw_dcraw_process(handle)
lr.libraw_dcraw_ppm_tiff_writer(handle,'test.ppm')
lr.libraw_close(handle)



These are the 'exposed' functions, if that is the right term, and will
produce an rgb image. There are a few other functions but they are not
important atm.

I know I don't know what I'm doing with this but it will be worth it if I
can struggle through. Is there a way I can access this struct via python?
Alternatively I could also write a new function in libraw that can access
this struct and be exposed to ctypes.

jt



On Thu, Sep 23, 2010 at 12:28 AM, Simon Brunning
<simon at brunningonline.net>wrote:

> On 22 September 2010 21:13, jay thompson <jayryan.thompson at gmail.com>
> wrote:
> > Hello,
> >
> > I posted in regard to this in the past but it didn't go very far, no ones
> > fault, but I'm again atempting to make this work and could use some help.
> >
> > I would like to use libraw.dll (http://www.libraw.org/  version 0.10)
> from
> > python and can access all the functions fine and produce images but there
> is
> > a structure that holds all the process settings that I cannot access with
> > ctypes. I'm sure it's because I'm going about it the wrong way. I was
> > wondering if there was anyone in this list with experience with this sort
> of
> > thing that could point me in the right direction.
>
> A good start would be to tell us what you've tried, and what goes
> wrong when you try it.
>
> --
> Cheers,
> Simon B.
>



-- 
"It's quite difficult to remind people that all this stuff was here for a
million years before people. So the idea that we are required to manage it
is ridiculous. What we are having to manage is us."   ...Bill Ballantine,
marine biologist.




-- 
"It's quite difficult to remind people that all this stuff was here for a
million years before people. So the idea that we are required to manage it
is ridiculous. What we are having to manage is us."   ...Bill Ballantine,
marine biologist.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100923/2de4f5c6/attachment.html>


More information about the Python-list mailing list