Add new comment

open_bayer() creating All-Black 8-bit Images

For several weeks, I have been using LibRaw's 0.19 snapshot open_bayer() call to open and eventually demosaic some 16bit raw images. I got the original source from this thread: https://www.libraw.org/node/2261
It's been working beautifully.

Today I'm trying to add support for 8-bit raw images. I have an 8-bit raw image which is legitimate, as it has been successfully demosaiced using other software. My LibRaw calls were creating all-black images with the 8bit picture, so I went back to basics and tried to open the file using the original sample demonstration of open_bayer(). Still get all-0 images. Here is the code I'm using. No errors are triggered at runtime.

For reference, the first pixels of the RGGB raw image have values of 255. Each pixel is littleendian R-G-G-B one after the other in the file, with no header or borders.

/*
Opened and read the file into unsigned char * buffer, just like in the code sample. Everything appears fine, 
including the filesize, fsz.
*/
 
LibRaw rp;
rp.imgdata.params.output_tiff = 1; // Also tried setting this to 0 for PPM. No luck
rp.imgdata.params.output_bps = 8; // Adding this did not fix the problem
 
int ret = rp.open_bayer(buffer, fsz, width, height, 0, 0, 0, 0, 0, LIBRAW_OPENBAYER_RGGB, 0, 0, 0);
// Check for error using LIBRAW_SUCCESS. I never get an error here
 
std::cout << "Opened bayer... first thing at buffer is " << (int)buffer[0] << "\n"; // This prints 255 :)
 
ret = rp.unpack();
// Check for error using LIBRAW_SUCCESS. I never get an error here
 
std::cout << "Unpacked! first thing at buffer is " << (int)buffer[0] << "\n"; // This prints 255 :)
std::cout << "First thing from imgdata: " << (int)rp.imgdata.image[0] << "\n"; // This prints 0.
// Perhaps imgdata.image is where the error is? 
 
ret = rp.dcraw_process(); 
// Check for error using LIBRAW_SUCCESS. I never get an error here
 
ret = rp.dcraw_ppm_tiff_writer(fileName); // fileName is a char[] with ".tif" at the end. No problems with name.
// Check for error using LIBRAW_SUCCESS. I never get an error here

Are any of those calls incorrect? Could the problem be somewhere in the LibRaw source code? I understand that the 0.19 snapshot is not an official release, so I could have simply found a bug.
I can provide test images.

Thank you for your time!

Forums: