Added support for PNG images (both for downloading/saving and loading).
This commit is contained in:
parent
ffed0e00fe
commit
387086cb4c
1 changed files with 25 additions and 21 deletions
|
@ -129,22 +129,24 @@ void PictureLoader::processLoadQueue()
|
||||||
QString setName = ptl.getSetName();
|
QString setName = ptl.getSetName();
|
||||||
|
|
||||||
QImage image;
|
QImage image;
|
||||||
if (!image.load(QString("%1/%2/%3.full.jpg").arg(picsPath).arg("CUSTOM").arg(correctedName))) {
|
//Supports loading JPG and PNG images; default is JPG
|
||||||
if (!image.load(QString("%1/%2/%3.full.jpg").arg(picsPath).arg(setName).arg(correctedName)))
|
if (!image.load(QString("%1/%2/%3.full.jpg").arg(picsPath).arg("CUSTOM").arg(correctedName)))
|
||||||
//if (!image.load(QString("%1/%2/%3%4.full.jpg").arg(picsPath).arg(setName).arg(correctedName).arg(1)))
|
if (!image.load(QString("%1/%2/%3.full.png").arg(picsPath).arg("CUSTOM").arg(correctedName)))
|
||||||
if (!image.load(QString("%1/%2/%3/%4.full.jpg").arg(picsPath).arg("downloadedPics").arg(setName).arg(correctedName))) {
|
if (!image.load(QString("%1/%2/%3.full.jpg").arg(picsPath).arg(setName).arg(correctedName)))
|
||||||
if (picDownload) {
|
if (!image.load(QString("%1/%2/%3.full.png").arg(picsPath).arg(setName).arg(correctedName)))
|
||||||
cardsToDownload.append(ptl);
|
if (!image.load(QString("%1/%2/%3/%4.full.jpg").arg(picsPath).arg("downloadedPics").arg(setName).arg(correctedName)))
|
||||||
if (!downloadRunning)
|
if (!image.load(QString("%1/%2/%3/%4.full.png").arg(picsPath).arg("downloadedPics").arg(setName).arg(correctedName))) {
|
||||||
startNextPicDownload();
|
if (picDownload) {
|
||||||
} else {
|
cardsToDownload.append(ptl);
|
||||||
if (ptl.nextSet())
|
if (!downloadRunning)
|
||||||
loadQueue.prepend(ptl);
|
startNextPicDownload();
|
||||||
else
|
} else {
|
||||||
emit imageLoaded(ptl.getCard(), QImage());
|
if (ptl.nextSet())
|
||||||
}
|
loadQueue.prepend(ptl);
|
||||||
}
|
else
|
||||||
}
|
emit imageLoaded(ptl.getCard(), QImage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
emit imageLoaded(ptl.getCard(), image);
|
emit imageLoaded(ptl.getCard(), image);
|
||||||
}
|
}
|
||||||
|
@ -226,11 +228,13 @@ void PictureLoader::picDownloadFinished(QNetworkReply *reply)
|
||||||
if (!cardBeingDownloaded.getStripped())
|
if (!cardBeingDownloaded.getStripped())
|
||||||
suffix = ".full";
|
suffix = ".full";
|
||||||
|
|
||||||
QFile newPic(picsPath + "/downloadedPics/" + cardBeingDownloaded.getSetName() + "/" + cardBeingDownloaded.getCard()->getCorrectedName() + suffix + ".jpg");
|
//Supports JPG and PNG images; default is JPG
|
||||||
if (!newPic.open(QIODevice::WriteOnly))
|
QString extension = ".jpg";
|
||||||
return;
|
if (picData.left(8) == QByteArray::fromHex("89504E470D0A1A0A"))
|
||||||
newPic.write(picData);
|
extension = ".png";
|
||||||
newPic.close();
|
|
||||||
|
if (!testImage.save(picsPath + "/downloadedPics/" + cardBeingDownloaded.getSetName() + "/" + cardBeingDownloaded.getCard()->getCorrectedName() + suffix + extension))
|
||||||
|
qDebug() << picsPath.toUtf8() + "/downloadedPics/" + cardBeingDownloaded.getSetName().toUtf8() + "/" + cardBeingDownloaded.getCard()->getCorrectedName().toUtf8() + suffix.toUtf8() + extension.toUtf8() + "was not successfully saved.";
|
||||||
|
|
||||||
emit imageLoaded(cardBeingDownloaded.getCard(), testImage);
|
emit imageLoaded(cardBeingDownloaded.getCard(), testImage);
|
||||||
} else if (cardBeingDownloaded.getHq()) {
|
} else if (cardBeingDownloaded.getHq()) {
|
||||||
|
|
Loading…
Reference in a new issue