Version: 1.0.0-beta6 (using KDE 4.3.3) Compiler: gcc (GCC) 4.1.2 (Gentoo 4.1.2 p1.0.2) powerpc OS: Linux Installed from: Compiled From Sources On big-endian systems digikam does not load 16 bits raw files correctly. The following simple patch fixes the bug (it breaks little-endian archs), but I'm not sure if the bug is here or if libkdcraw needs a fix instead. --- digikam-1.0.0-beta6/libs/dimg/loaders/rawloader.cpp__orig 2009-11-22 19:49:05.000000000 +0100 +++ digikam-1.0.0-beta6/libs/dimg/loaders/rawloader.cpp 2009-11-22 21:37:29.000000000 +0100 @@ -182,9 +182,9 @@ bool RAWLoader::loadedFromDcraw(QByteArr dst[1] = (unsigned short)((src[2]*256 + src[3]) * fac); // Green dst[2] = (unsigned short)((src[0]*256 + src[1]) * fac); // Red #else - dst[0] = (unsigned short)((src[5]*256 + src[4]) * fac); // Blue - dst[1] = (unsigned short)((src[3]*256 + src[2]) * fac); // Green - dst[2] = (unsigned short)((src[1]*256 + src[0]) * fac); // Red + dst[0] = (unsigned short)((src[4]*256 + src[5]) * fac); // Blue + dst[1] = (unsigned short)((src[2]*256 + src[3]) * fac); // Green + dst[2] = (unsigned short)((src[0]*256 + src[1]) * fac); // Blue #endif dst[3] = 0xFFFF;
Yes, it's libkdcraw as well... Gilles Caulier
probably in this loop: http://lxr.kde.org/source/KDE/kdegraphics/libs/libkdcraw/libkdcraw/kdcraw.cpp#323
Thanks for the link. Uhm... no, digikam does not use KDcraw::extractRAWData(). It uses KDcraw::loadFromDcraw() instead, which then calls dcraw_make_mem_image() (http://lxr.kde.org/source/KDE/kdegraphics/libs/libkdcraw/libkdcraw/kdcraw.cpp#679). LibRaw docs do not mention the format of the data, but in LibRaw-0.8.4/samples/mem_image.cpp there is a comment that says: "data in img->data is not converted to network byte order. So, we should swap values on some architectures for dcraw compatibility". I think we should fix digikam. If we change libkdcraw we may break some other apps which already convert the data.
I propose another patch that fixes the bug and does not break anything, except, perhaps, big-endian machines with KDCRAW_VERSION<0x000400 (I didn't test). Little-endian archs are not affected. --- digikam-1.0.0-beta6/libs/dimg/loaders/rawloader.cpp__orig 2009-11-24 21:51:58.000000000 +0100 +++ digikam-1.0.0-beta6/libs/dimg/loaders/rawloader.cpp 2009-11-24 22:03:02.000000000 +0100 @@ -177,7 +177,7 @@ bool RAWLoader::loadedFromDcraw(QByteArr for (int w = 0; w < width; ++w) { -#if KDCRAW_VERSION < 0x000400 +#if (KDCRAW_VERSION < 0x000400) ^ (Q_BYTE_ORDER == Q_BIG_ENDIAN) dst[0] = (unsigned short)((src[4]*256 + src[5]) * fac); // Blue dst[1] = (unsigned short)((src[2]*256 + src[3]) * fac); // Green dst[2] = (unsigned short)((src[0]*256 + src[1]) * fac); // Red
SVN commit 1064293 by mwiesweg: Fix 16bit raw loading on big endian. Patch from pochini@shiny.it slightly modified. BUG: 215743 M +2 -1 NEWS M +18 -9 libs/dimg/loaders/rawloader.cpp WebSVN link: http://websvn.kde.org/?view=rev&revision=1064293