How do I correct white balance?

I am using libraw to convert a NEF file to a bmp file.
The order I call the functions are as follows -

LibRaw RawProcessor;
RawProcessor.open_file();
libraw_data_t imgD=RawProcessor.imgdata;
imgD.params.use_camera_wb=1;
imgD.params.user_flip = 3;
RawProcessor.unpack()
RawProcessor.dcraw_process();
processedImg=RawProcessor.dcraw_make_mem_image()

Now I have tried to write my bitmap in two ways -
1. processedImg->data[]
2. RawProcessor.copy_mem_image();

Neither have created me a .bmp file with the correct white balance. However, creating a ppm file using one of the samples produces a faithful reproduction. What am I doing wrong?

Sorry if this is a duplicate - My first post did not show up and stated unpublished.

Forums: 

use_camera_wb uses camera

use_camera_wb uses camera White Balance ('As Shot').

If you need to specify your own white balance, use user_mul[] coeffs

P.S. All user comment/posts are published only after approval due to heavy comment spam

-- Alex Tutubalin @LibRaw LLC

It turned out to be a colour space issue.

I later discovered that my problem was due to colour space. I got more vibrant colors once I specified the color space to sRGB (My camera is set to sRGB) - This matched the colours reproduced from LightRoom / Photoshop.

And another thing was that my pointers were incorrect. imgD.params.use_camera_wb=1; was not finding it's way back into the LibRaw RawProcessor structure.

Thank you :-)

Bharath

Bharath Bhushan Lohray
http://bharath.lohray.com/weblog/