Make sure that the extracted "cover art" image file is valid.

This commit is contained in:
LoRd_MuldeR 2011-11-19 14:06:39 +01:00
parent 16aaebec22
commit 5cac3faa8b
2 changed files with 14 additions and 6 deletions

View File

@ -30,7 +30,7 @@
#define VER_LAMEXP_MINOR_LO 4 #define VER_LAMEXP_MINOR_LO 4
#define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_TYPE Alpha
#define VER_LAMEXP_PATCH 1 #define VER_LAMEXP_PATCH 1
#define VER_LAMEXP_BUILD 780 #define VER_LAMEXP_BUILD 781
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Tools versions // Tools versions

View File

@ -32,6 +32,7 @@
#include <QDate> #include <QDate>
#include <QTime> #include <QTime>
#include <QDebug> #include <QDebug>
#include <QImage>
#include <math.h> #include <math.h>
@ -582,6 +583,8 @@ void FileAnalyzer::retrieveCover(AudioFileModel &audioFile, const QString &fileP
val = val.split(" ", QString::SkipEmptyParts, Qt::CaseInsensitive).first(); val = val.split(" ", QString::SkipEmptyParts, Qt::CaseInsensitive).first();
} }
QByteArray coverData = QByteArray::fromBase64(val.toLatin1()); QByteArray coverData = QByteArray::fromBase64(val.toLatin1());
if(!(QImage::fromData(coverData, extension.toUpper().toLatin1().constData()).isNull()))
{
QFile coverFile(QString("%1/%2.%3").arg(lamexp_temp_folder2(), lamexp_rand_str(), extension)); QFile coverFile(QString("%1/%2.%3").arg(lamexp_temp_folder2(), lamexp_rand_str(), extension));
if(coverFile.open(QIODevice::WriteOnly)) if(coverFile.open(QIODevice::WriteOnly))
{ {
@ -589,6 +592,11 @@ void FileAnalyzer::retrieveCover(AudioFileModel &audioFile, const QString &fileP
coverFile.close(); coverFile.close();
audioFile.setFileCover(coverFile.fileName(), true); audioFile.setFileCover(coverFile.fileName(), true);
} }
}
else
{
qWarning("Image data seems to be invalid :-(");
}
break; break;
} }
} }