Thank you Alex for your answer. I tried with open_bayer as I think the raw file has no metadata. With the code bellow I could see that readb as 1280000 values instead of 640000 for an image 800x8000. The final result with dcraw_process is not satisfactory. I wonder If and how I could retrieve the unpacked values and do the conversion myself.
FILE *in = fopen(fname, "rb");
fseek(in, 0, SEEK_END);
unsigned fsz = ftell(in);
unsigned char *buffer = (unsigned char *)malloc(fsz);
if (!buffer)
return 2;
fseek(in, 0, SEEK_SET);
unsigned readb = fread(buffer, 1, fsz, in);
if (readb != fsz)
return 3;
std::cout << "readb" << readb << std::endl;
LibRaw rp;
rp.imgdata.params.output_tiff = 1;
int ret = rp.open_bayer(buffer, fsz, 800, 800, 0, 0, 0, 0, 0,
LIBRAW_OPENBAYER_BGGR, 0, 0, 0);
if (ret != LIBRAW_SUCCESS)
return 4;
if ((ret = rp.unpack()) != LIBRAW_SUCCESS)
printf("Unpack error: %d\n", ret);
if ((ret = rp.dcraw_process()) != LIBRAW_SUCCESS)
printf("Processing error: %d\n", ret);
char outfn[256];
sprintf(outfn, "%s.tif", fname);
if (LIBRAW_SUCCESS != (ret = rp.dcraw_ppm_tiff_writer(outfn)))
printf("Cannot write %s: %s\n", outfn, libraw_strerror(ret));
else
printf("Created %s\n", outfn);
ret = rp.dcraw_process();
// Check for error using LIBRAW_SUCCESS. I never get an error here
ret = rp.dcraw_ppm_tiff_writer(fname);
Thank you Alex for your answer. I tried with open_bayer as I think the raw file has no metadata. With the code bellow I could see that readb as 1280000 values instead of 640000 for an image 800x8000. The final result with dcraw_process is not satisfactory. I wonder If and how I could retrieve the unpacked values and do the conversion myself.