Using libraw_dcraw_make_mem_image

I need to get the image as simple rgb-array and it seems that libraw_dcraw_make_mem_image() is the right function for that.
But how to use it? I mean, what is the minimum output-parameters to set? I tried (in c# with SharpLibRaw):

var handler = libraw_init(LibRaw_init_flags.LIBRAW_OPTIONS_NONE);
libraw_open_file(handler, "DSC08185.ARW");
var pointer = libraw_dcraw_make_mem_image(handler, ref  errc);
var image= PtrToStructure<libraw_processed_image_t>(pointer );
libraw_dcraw_clear_mem(pointer );

Now I have these values in image-struct:

bits	8	ushort
colors	3	ushort
@data	{byte[1]}	byte[]
data_size	72721728	uint
height	4024	ushort
@type	LIBRAW_IMAGE_BITMAP	LibRAW.RAWLib.LibRaw_image_formats
width	6024	ushort

data is unfortunate empty. How to get the rgb-pixels in data?


Data is not empty,

Data is not empty,

your pixels are in data[0][data_size-1]

-- Alex Tutubalin

Thanks Alex,

Thanks Alex,

I found the pixels now in data[]. Its an c#-marshaling issue, wish needs a few more steps.

I also realized, that libraw_dcraw_process(handler); takes quiet a lot of time, several seconds, depending on the image-size. Is is really necessary for libraw_dcraw_make_mem_image()? Or is there a faster way to get the image?

One may adjust params.user

One may adjust params.user_qual and/or use half-size interpolation.

-- Alex Tutubalin

Sorry, how? With what

Sorry, how? With what function?
All I need is the pixels, but for 100.000 photos, which takes ages now since libraw_dcraw_process() needs 5-7sec per photo.

And followup: what 'pixels'

And followup: what 'pixels' do you need? Original raw values, or processed RGB pixmap?

-- Alex Tutubalin

If so, you need raw to rgb

If so, you need raw to rgb interpolation that is performed by dcraw_process(). Reducing quality (or using half_mode) will speed-up things.

-- Alex Tutubalin

Ok, so reducing quality is

Ok, so reducing quality is with libraw_set_demosaic(handler, LibRaw_interpolation_quality.LINEAR); ?
I tried it and its speeding up the process already a little bit.

Unfortunate I can't access the params-scruct from SharpLibRaw, its not implemented, so I'm not able to play with  params.user_qual and/or use half-size.

Just to remember, I'm using c#

Sorry, know nothing about C#

Sorry, know nothing about C# (both generally and specific wrapper you use)

-- Alex Tutubalin