Add new comment

Instanciate the libraw class in c#

Hi, I try to work with libraw in my c# project. (Very new with c, c++ ...)
I can convert a raw image to ppm easily with this:

var dataPtr = NativeMethods.libraw_init(LibRaw_constructor_flags.LIBRAW_OPIONS_NO_DATAERR_CALLBACK | LibRaw_constructor_flags.LIBRAW_OPIONS_NO_MEMERR_CALLBACK);

NativeMethods.libraw_open_file(dataPtr, @"C:\Users\me\Desktop\pict.CR2");
NativeMethods.libraw_unpack(dataPtr);
NativeMethods.libraw_dcraw_process(dataPtr);
NativeMethods.libraw_dcraw_ppm_tiff_writer(dataPtr, @"C:\Users\me\Desktop\pict.ppm");

with native methods::

[SuppressUnmanagedCodeSecurity]
internal static class NativeMethods {
[DllImport("libraw")]
public static extern IntPtr libraw_init(LibRaw_constructor_flags flags);

[DllImport("libraw")]
public static extern int libraw_open_file(IntPtr data, string fileName);

[DllImport("libraw")]
public static extern int libraw_unpack(IntPtr data);

[DllImport("libraw")]
public static extern int libraw_dcraw_process(IntPtr lr);

[DllImport("libraw")]
public static extern int libraw_dcraw_ppm_tiff_writer(IntPtr processed,string filename);

But I would like to instanciate the libraw class to pass the out param ....
Tried to write a 'CreateLibraw' Methode in libraw.h.... but doesn't compile

Thanx for help :)

Forums: