jcelaya / hdrmerge

HDR exposure merging
http://jcelaya.github.io/hdrmerge/
Other
362 stars 78 forks source link

libraw-0.17 no longer supports LIBRAW_DECODER_FLATFIELD #85

Closed Beep6581 closed 8 years ago

Beep6581 commented 8 years ago

Compiling using libraw-0.17.* will fail with:

/home/beep/programs/code-hdrmerge/ImageIO.cpp: In static member function ‘static hdrmerge::Image hdrmerge::ImageIO::loadRawImage(hdrmerge::RawParameters&)’:
/home/beep/programs/code-hdrmerge/ImageIO.cpp:42:42: error: ‘LIBRAW_DECODER_FLATFIELD’ was not declared in this scope
         if(!decoder_info.decoder_flags & LIBRAW_DECODER_FLATFIELD) {
                                          ^

What OpenImageIO did about this: https://github.com/OpenImageIO/oiio/pull/1204 What LIBRAW_DECODER_FLATFIELD is: http://www.libraw.org/docs/API-datastruct-eng.html

Beep6581 commented 8 years ago

The attached patch seems to work.

hdrmerge_85.txt

diff --git a/ImageIO.cpp b/ImageIO.cpp
index 6377c55..64a2923 100644
--- a/ImageIO.cpp
+++ b/ImageIO.cpp
@@ -39,10 +39,12 @@ Image ImageIO::loadRawImage(RawParameters & rawParameters) {
     if (rawProcessor.open_file(rawParameters.fileName.toLocal8Bit().constData()) == LIBRAW_SUCCESS) {
         libraw_decoder_info_t decoder_info;
         rawProcessor.get_decoder_info(&decoder_info);
-        if(!decoder_info.decoder_flags & LIBRAW_DECODER_FLATFIELD) {
-            Log::msg(Log::DEBUG, "LibRaw decoder is not flatfield (", ios::hex, decoder_info.decoder_flags, ").");
-        } else if (d.idata.filters <= 1000 && d.idata.filters != 9) {
+        if (d.idata.filters <= 1000 && d.idata.filters != 9) {
             Log::msg(Log::DEBUG, "Unsupported filter array (", d.idata.filters, ").");
+#ifdef LIBRAW_DECODER_FLATFIELD
+        } else if (!decoder_info.decoder_flags & LIBRAW_DECODER_FLATFIELD) {
+            Log::msg(Log::DEBUG, "LibRaw decoder is not flatfield (", ios::hex, decoder_info.decoder_flags, ").");
+#endif
         } else if (rawProcessor.unpack() != LIBRAW_SUCCESS) {
             Log::msg(Log::DEBUG, "LibRaw::unpack() failed.");
         } else {
Beep6581 commented 8 years ago

Fixed https://github.com/jcelaya/hdrmerge/commit/413bccd9f38594a5fca0b0a1fb01c23d4fda6843