SVN commit 530854 by cgilles:
digikam from trunk : DImg API to detect image file formatn we parse file extension in first, and in second, we parse file header.
This way is mandatory because some TIFF files are detected like RAW files by dcraw::parse method.
Please, update svn and give me a feedback (:=)))...
CCMAIL:
[hidden email],
[hidden email],
[hidden email]
M +22 -2 dimg.cpp
--- trunk/extragear/graphics/digikam/libs/dimg/dimg.cpp #530853:530854
@@ -34,6 +34,7 @@
// Qt includes.
#include <qfile.h>
+#include <qfileinfo.h>
#include <qmap.h>
// KDE includes.
@@ -96,7 +97,6 @@
allocateData();
}
-
DImg::~DImg()
{
if (m_priv->deref())
@@ -284,7 +284,6 @@
bool DImg::load(const QString& filePath, DImgLoaderObserver *observer,
RawDecodingSettings rawDecodingSettings)
-
{
FORMAT format = fileFormat(filePath);
@@ -430,6 +429,27 @@
if ( filePath == QString::null )
return NONE;
+ // In first we trying to check the file extension. This is mandatory because
+ // some tiff files are detected like RAW files by dcraw::parse method.
+
+ QFileInfo fileInfo(filePath);
+ if (!fileInfo.exists())
+ {
+ kdDebug() << k_funcinfo << "Failed to open file" << endl;
+ return NONE;
+ }
+
+ QString ext = fileInfo.extension().upper();
+
+ if (ext == QString("JPEG") || ext == QString("JPG"))
+ return JPEG;
+ else if (ext == QString("PNG"))
+ return PNG;
+ else if (ext == QString("TIFF") || ext == QString("TIF"))
+ return TIFF;
+
+ // In second, we trying to parse file header.
+
FILE* f = fopen(QFile::encodeName(filePath), "rb");
if (!f)
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel