You need this only for Microsoft or Intel compilers. For others LIBRAW_WIN32_DLLDEFS is not defined automatically.
For the static library, you must define LIBRAW_NODLL when compiling programs that link to it.
In this specific case LibRaw/dcraw_emu works better (more correctly) than dcraw.
This is especially true for DNG files with multiple sub-images and different color data (e.g. DNG w/ fast-load JPEG data): LibRaw/dcraw will select correct matrix, while dcraw will always use the last one.
Thanks for your reply!
Yes, I've done a side-by-side debug run of dcraw and LibRaw example, and I've found the divergence point.
Can dcraw_emu be used as a replacement of dcraw, or it is just an example program that is not intended for everyday use?
dcraw parses DNG tags one-by-one, in order (in file being processed), both ColorMatrix1 and ColorMatrix2 tags are parsed into same (cmatrix) structure. So, latest one wins.
LibRaw w/ default settings (without LIBRAW_PROCESSING_DONT_CHECK_DNG_ILLUMINANT flag) analyzes CalibrationIlluminant1/2 tags too and selects color matrix which is closer to D65/daylight.
Usually (e.g. files created by Adobe DNG SDK) the last matrix is the one that corresponds to daylight (resulting in same dcraw/dcraw_emu results), but not in this specific file (CameraMatrix1 => D65, CameraMatrix2 => Ill.A).
So, LibRaw is right in this specific case, while dcraw is not.
(dcraw is *much* worse if DNG file contains multiple sub-images w/ different color data).
imgdata.image is already cropped to visible area.
Thank you Alex,
but is the coordinate with or without the border?
If it's with border, is the border always the same size left/right and top/bottom. So the "real" picture is always centred?
And where is the viewport? Is it at top/left or bottom/left or even somewhere else?
Thanks once again!
coordinate is (y * width) + x (unless you use half_size option).
Values in imgdata.image array are 16 bit/linear space, IrfanView values are, most likely, 8bit/gamma corrected.
I do not think that fallback to older model is safe. Newer camera may have different sensor, or different CFA filters, or different calibration, or different raw adjustments in firmware. You could not know it without new raws analysis.
I have removed any .dll or . a librairy before compiling.
Just i use libraw.a as soon as created
( I am probably a dummy with librairies )
In my project just i have this :
INCLUDEPATH += C:\LibRaw-0.19.5\libraw
LIBS += -LC:\LibRaw-0.19.5\lib -llibraw.a
I have still the trouble with static library. but '.exe' files in /bin work well !.
Finally: old DNG SDK 1.4 (dated May 2012) is *not* compatible with LibRaw. Internals of dng_info are very different in May 2012 and June 2015 versions, the older one does not have fChainedSubIFD array.
Implementing support for older version is just a big time waste: it will require lot of testing (already done for modern DNG SDK version) and no benefits.
So, you'll need to go second route (via patched modern DNG SDK 1.4), the DNG SDK provided w/ GPR SDK will not fit.
Readmes are updated to reflect this.
make sure you're linking with (newly created) libraw.a, not (older) libraw.dll
Thanks a lot for your job about LibRaw and FastRawViewer !
To solve my problem of using libraw librairy in Windows8.2 / Qt / C++ / MingW64, and according to your answer ( if i understand well )
i just done this :
> mingw32-make - f Makefile.mingw
This create the librairy : libraw.a with my mingw compiler 64 bits
libraw.a is 1183 ko in /lib folder.
In my minimal project !
i declare the librairy, and the Include/header and try to use it : As above in my first message
LibRaw *processor = new LibRaw ;
When i compile i still have errors like ; undefined reference to symbols...
I don't understand what is wrong with the linking.
Btw, mingw-w64 binaries for libraw are already available through msys2 and easily installable with pacman: https://packages.msys2.org/base/mingw-w64-libraw
1) GPR SDK includes Adobe DNG SDK v1.4 dated May 2012 (according to $datetime in comments).
In this version, dng_info's fIFD and fChainedIFD are AutoPtr arrays of fixed size.
2) In Adobe DNG SDK v1.4 dated June 2015, same fields are std::vector
This is very minor change, it should be easy to adopt, but I do not see any way to distinguish two SDKs at compile time.
It could be selectable by user w/ additional #define (like USE_OUTDATED_DNG_SDK :)
We'll try to solve this problem in beta update (need some time to set-up testbed with outdated DNG SDK included w/ GPR).
Right now we've updated DNG/GPR readme files only: https://github.com/LibRaw/LibRaw/commit/d86f980a5c7d30e7d553156861a108e1...
LibRaw dll coming with binary distributions is built using MS Visual Studio.
It is very likely that C++ name mangling (AND C++ library too!) is not compatible with gcc/MinGW.
You need to rebuild LibRaw using your compiler (Makefile.mingw should help)
Thank you for the feedback.
Current LibRaw (w/ ability to extract any DNG subframe via shot_select option) relies on DNG SDK 1.4 internals, it is not compatible w/ DNG SDK included into GPR SDK.
Looks like we need to update README.GoPro by removing this option:
I. GPR SDK comes with (patched) Adobe DNG SDK source. You may use this DNG SDK instead of
Adobe's one, or use standard Adobe's distribution.
We do not use mkdist/configure internally, but cloned (not commited) Makefile.devel
mem_image_sample problem fixed in this patch: https://github.com/LibRaw/LibRaw/commit/253f7ac76d03163497019302e3d1f967...
Exactly same problem present in our mem_image_sample: channel count assumed to be also 3 :)
We usually do not close threads (unless lot of spam come to specific thread).
Thanks for your fast reply.
I've found what I'm doing wrong. I always assume that resulting image is 3-channel when copying it into my internal RGB buffer for further processing, but this one is obviously 1-channel. Very stupid and obvious error, and I've found it in half of an hour after submitting my first post. Now I check value of
rawImage->colors and for 1-channel images I copy value of first channel into the other two. I'll do some performance tests, maybe your solution with setting proper color space will be faster.
Interesting that digiKam gives similar triple-image result when processing my file. digiKam uses LibRaw for the processing of DNG files, and it's behaviour led my thoughts wrong way. Possibly I should report an issue into digiKam bugtracker.
Anyway, thanks again! The problem is solved. Should I somehow close this forum thread?
Thank you for the sample and for detailed explanation.
Tested with current LibRaw 0.20(beta):
dcraw_emu produces correct pgm file
dcraw_emu -T makes correct tiff file.
So, LibRaw::dcraw_process() and all previous steps are OK.
mem_image_sample.c fails to produce correct results, the problem not in LibRaw::dcraw_make_mem_image() (it is also correct, see below), but in sample source code:
1) write_ppm() do not handle img->colors != 3 case and just returns. This is expected, but need to be fixed.
2) write_jpeg() do not check for colors count, but assumes that 3-color data passed that is wrong.
cinfo.in_color_space = JCS_RGB; /* colorspace of input image */
cinfo.in_color_space = img->colors==3?JCS_RGB:JCS_GRAYSCALE; /* colorspace of input image */
row_stride = img->width * 3; /* JSAMPLEs per row in image_buffer */
row_stride = img->width * img->colors; /* JSAMPLEs per row in image_buffer */
Fixed version will be uploaded to github soon (likely tomorrow, we want to fix write_ppm sample code too).
Here are processing results (pgm file from dcraw_emu and .jpg from fixed mem_image_sample): https://www.dropbox.com/sh/a6aksx5opyzeeyv/AACG3f9GCZ703UksKjc5H5Rta?dl=0
The C-api call you proposed may fit your specific needs, sure. It is not enough if someone want to create generic raw processing tool, that handle non-bayer data (or even if row pitch is not raw_width*2).
Current C-API is limited for single (but most frequently requested) task: create rendered RGB image from RAW. In general, it is possible to create C-wrappers for each LibRaw class data field, but this is out of our goal and scope, sorry. LibRaw is C++ library, no plans to make it fully functional when called from C.
Yes - except that there are significant differences between it and MSVC that would probably lead to a lot of pain trying to even get it compile... I did try, but concluded the work involved would be too great, especially if I want to keep it up to date...
For example, its library does not have the _BitScanReverse function and there's nothing I can find on Google that shows someone has implemented it... I could have a go, but there will be other functions as well...