[Digikam-devel] [Bug 121646] Digikam on PPC has problem identifying JPEG and tries to use dcraw with them
Gilles Caulier
caulier.gilles at free.fr
Thu Feb 9 16:01:08 GMT 2006
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
http://bugs.kde.org/show_bug.cgi?id=121646
------- Additional Comments From caulier.gilles free fr 2006-02-09 17:01 -------
SVN commit 507591 by cgilles:
digikam from stable : using uchar bytes array always working to detect JPEG/TIFF file format.
CCBUGS: 121646
M +21 -21 imlibinterface.cpp
--- branches/stable/extragear/graphics/digikam/utilities/imageeditor/imlibinterface.cpp #507590:507591
@ -70,7 +70,8 @
#define MaxRGB 255L
-class ImlibInterfacePrivate {
+class ImlibInterfacePrivate
+{
public:
@ -174,20 +175,8 @
if ( filePath == QString::null )
return NONE_IMAGE;
- KFileMetaInfo metaInfo(filePath, QString::null, KFileMetaInfo::Fastest);
-
- if (metaInfo.isValid())
- {
- kdDebug() << k_funcinfo << " : Mime type: " << metaInfo.mimeType() << endl;
-
- if (metaInfo.mimeType() == "image/jpeg")
- return JPEG_IMAGE;
-
- if (metaInfo.mimeType() == "image/png")
- return PNG_IMAGE;
- }
-
FILE* f = fopen(QFile::encodeName(filePath), "rb");
+
if (!f)
{
kdWarning() << "Failed to open file" << endl;
@ -206,12 +195,22 @
fclose(f);
- DcrawParse rawFileParser;
- unsigned short tiffBigID = 0x4d4d;
- unsigned short tiffLilID = 0x4949;
-
- if (rawFileParser.getCameraModel( QFile::encodeName(filePath), NULL, NULL) == 0)
+ DcrawParse rawFileParser;
+ uchar jpegID[2] = { 0xFF, 0xD8 };
+ uchar tiffBigID[2] = { 0x4D, 0x4D };
+ uchar tiffLilID[2] = { 0x49, 0x49 };
+ uchar pngID[8] = {'\211', 'P', 'N', 'G', '\r', '\n', '\032', '\n'};
+
+ if (memcmp(&header, &jpegID, 2) == 0) // JPEG file ?
{
+ return JPEG_IMAGE;
+ }
+ else if (memcmp(&header, &pngID, 8) == 0) // PNG file ?
+ {
+ return PNG_IMAGE;
+ }
+ else if (rawFileParser.getCameraModel( QFile::encodeName(filePath), NULL, NULL) == 0)
+ {
// RAW File test using dcraw.
// Need to test it before TIFF because any RAW file
// formats using TIFF header.
@ -222,9 +221,10 @
{
return TIFF_IMAGE;
}
+
+ // In others cases, QImage will be used to try to open file.
+ return QIMAGE_IMAGE;
- // In others cases, QImage will be used to open file.
- return QIMAGE_IMAGE;
}
bool ImlibInterface::load(const QString& filename, bool *isReadOnly)
More information about the Digikam-devel
mailing list