mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Save downloaded byte array (from GitHub) to file with PNG extension.
This commit is contained in:
parent
7aa66e4ab9
commit
4897e11a12
3 changed files with 7 additions and 17 deletions
|
@ -17,9 +17,6 @@
|
|||
double ImageComparer::compareImages(QImage resultImage, QImage expectedImage) const {
|
||||
// Make sure the image is 8 bits per colour
|
||||
QImage::Format format = expectedImage.format();
|
||||
if (format != QImage::Format::Format_ARGB32) {
|
||||
throw -1;
|
||||
}
|
||||
|
||||
const int L = 255; // (2^number of bits per pixel) - 1
|
||||
const double K1 { 0.01 };
|
||||
|
|
|
@ -81,12 +81,7 @@ bool Test::compareImageLists(bool isInteractiveMode, QProgressBar* progressBar)
|
|||
QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Images are not the same size");
|
||||
similarityIndex = -100.0;
|
||||
} else {
|
||||
try {
|
||||
similarityIndex = imageComparer.compareImages(resultImage, expectedImage);
|
||||
} catch (...) {
|
||||
QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Image not in expected format");
|
||||
exit(-1);
|
||||
}
|
||||
similarityIndex = imageComparer.compareImages(resultImage, expectedImage);
|
||||
}
|
||||
|
||||
if (similarityIndex < THRESHOLD) {
|
||||
|
|
|
@ -127,14 +127,12 @@ void AutoTester::downloadImages(const QStringList& URLs, const QString& director
|
|||
}
|
||||
|
||||
void AutoTester::saveImage(int index) {
|
||||
QPixmap pixmap;
|
||||
pixmap.loadFromData(downloaders[index]->downloadedData());
|
||||
|
||||
QImage image = pixmap.toImage();
|
||||
image = image.convertToFormat(QImage::Format_ARGB32);
|
||||
|
||||
QString fullPathname = _directoryName + "/" + _filenames[index];
|
||||
if (!image.save(fullPathname, 0, 100)) {
|
||||
try {
|
||||
QFile file(_directoryName + "/" + _filenames[index]);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
file.write(downloaders[index]->downloadedData());
|
||||
file.close();
|
||||
} catch (...) {
|
||||
QMessageBox::information(0, "Test Aborted", "Failed to save image: " + _filenames[index]);
|
||||
ui.progressBar->setVisible(false);
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue