Support of monochromatic DNG in LibRAW
Hello,
First of all, thanks for your great work.
I have an issue with reading monochromatic DNG image. The result is pretty weird. I can't figure out if there are problems with the source DNG image itself, or with LibRaw. Maybe I'm using it wrong, but usually DNG images are loaded pretty well. But not this one.
In the attachement there is comparison image just to take a quick look at the problem.
- Here is the source DNG file
- Here is the result of processing source DNG with LibRaw
- Here is the result of processing source DNG with Adobe DNG SDK (the expected result)
- Here is the result of processing source DNG with RawTherapee (slightly different, but still close to correct)
I'm using LibRaw 0.17.3, but I've tried latest LibRaw 0.20 beta, with the same results.
My LibRaw-related code (slightly simplified):
LibRaw rawProcessor; int errCode = 0; errCode = rawProcessor.open_file(fileName.toUtf8().data()); if (errCode != LIBRAW_SUCCESS) { setLastError(QString("Can not open raw image: %1").arg(QString(libraw_strerror(errCode)))); return nullptr; } rawProcessor.imgdata.params.use_camera_wb = applyWhiteBalance; rawProcessor.imgdata.params.use_auto_wb = 0; rawProcessor.imgdata.params.no_auto_bright = 1; rawProcessor.imgdata.params.no_interpolation = 0; rawProcessor.imgdata.params.use_camera_matrix = applyColorMatrix; rawProcessor.imgdata.params.output_color = 0; // Raw rawProcessor.imgdata.params.output_bps = 16; // 16 bits per sample rawProcessor.imgdata.params.user_qual = 12; // AHD interpolation if ((errCode = rawProcessor.unpack()) != LIBRAW_SUCCESS) { setLastError(QString("Can not unpack raw image: %1").arg(QString(libraw_strerror(errCode)))); return nullptr; } errCode = rawProcessor.dcraw_process(); if (errCode != LIBRAW_SUCCESS) { qDebug() << "LibRaw dcraw error:" << libraw_strerror(errCode); if (LIBRAW_FATAL_ERROR(errCode)) { setLastError(QString("Can not process raw image: %1").arg(QString(libraw_strerror(errCode)))); return nullptr; } } libraw_processed_image_t *rawImage = rawProcessor.dcraw_make_mem_image(&errCode); if (!rawImage) { setLastError(QString("Can not unpack raw image: %1").arg(QString(libraw_strerror(errCode)))); return nullptr; } if (rawImage->type != LIBRAW_IMAGE_BITMAP) { setLastError("LibRaw unpacked image into JPEG instead of bitmap, this is not supported yet."); LibRaw::dcraw_clear_mem(rawImage); return nullptr; } if (rawImage->bits == 8) { // ... No sense for this case ... } else { // rawImage->bits == 16 RgbBufferFloat *realBuf = new RgbBufferFloat(QSize(rawImage->width, rawImage->height)); if (realBuf->data() == nullptr) { setLastError("Out of memory"); return nullptr; } float *imgPtr = realBuf->data(); unsigned short *rawPtr = reinterpret_cast<unsigned short *>(rawImage->data); for (unsigned i = 0; i < rawImage->data_size; i += 2) { *(imgPtr++) = *(rawPtr++) / 65535.0f; // Convert into floating point values normalized to 0..1 } return realBuf; }
Attachment | Size |
---|---|
Comparison: Adobe DNG SDK result v.s. LibRaw result | 265.59 KB |
Recent comments