calling or wrapping a function from cpp api

14 views
Skip to first unread message

bndp

unread,
Apr 16, 2015, 2:05:44 AM4/16/15
to cython...@googlegroups.com
hello I wanted to use openimageio cpp library for some basic image writing with cython.

I quickly realized I was over my head, here is a basic example from the documentation.
 
//

#include <OpenImageIO/imageio.h>

int main()
{

  const char *filename = "foo.jpeg";
  const int xres = 640, yres = 480;
  const int channels = 3; // RGB
  unsigned char pixels[xres*yres*channels];
  OpenImageIO::ImageOutput *out = OpenImageIO::ImageOutput::create (filename);
    if (! out)
        return false;
  OpenImageIO::ImageSpec spec (xres, yres, channels, OpenImageIO::TypeDesc::UINT8);
  out->open (filename, spec);
  out->write_image (OpenImageIO::TypeDesc::UINT8, pixels);
  out->close ();
  delete out;
}

//

I have spent an embarrassing amount of time trying to work out how to duplicate this example with cython/python. They do provide a python api which works well, but as I only want to write images with it I thought i would try to wrap the image writing part. I would welcome any examples untested even :) . My attempts have led me in circles 

Eujain Ting

unread,
Apr 16, 2015, 12:58:47 PM4/16/15
to cython...@googlegroups.com
Go into the OpenImageIO includes folder and find the header files containing the functions you want to wrap, and have at it. For this example you want to wrap class OIIO_API ImageOutput from imageio.h

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages