MCPcopy Create free account
hub / github.com/Theverat/NormalmapGenerator / save

Method save

src_gui/mainwindow.cpp:576–633  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

574}
575
576void MainWindow::save(QUrl url) {
577 //if saving process was aborted or input image is empty
578 if(!url.isValid() || input.isNull())
579 return;
580
581 QString path = url.toLocalFile();
582
583 //if no file suffix was chosen, automatically use the PNG format
584 QFileInfo file(path);
585 if(!file.baseName().isEmpty() && file.suffix().isEmpty())
586 path += ".png";
587
588 QString suffix = file.suffix();
589 //Qt can only read tga, saving is not supported
590 if(suffix.toLower() == "tga")
591 suffix = "png";
592
593 //append a suffix to the map names (result: path/original_normal.png)
594 QString name_normal = file.absolutePath() + "/" + file.baseName() + "_normal." + suffix;
595 QString name_specular = file.absolutePath() + "/" + file.baseName() + "_spec." + suffix;
596 QString name_displace = file.absolutePath() + "/" + file.baseName() + "_displace." + suffix;
597
598 bool successfullySaved = true;
599
600 if(ui->checkBox_queue_generateNormal->isChecked()) {
601 if(normalmap.isNull())
602 ui->statusBar->showMessage("calculating normalmap...");
603 calcNormal();
604
605 successfullySaved &= normalmap.save(name_normal);
606 }
607
608 if(ui->checkBox_queue_generateSpec->isChecked()) {
609 if(specmap.isNull())
610 ui->statusBar->showMessage("calculating specularmap...");
611 calcSpec();
612
613 successfullySaved &= specmap.save(name_specular);
614 }
615
616 if(ui->checkBox_queue_generateDisplace->isChecked()) {
617 if(displacementmap.isNull())
618 ui->statusBar->showMessage("calculating displacementmap...");
619 calcDisplace();
620
621 successfullySaved &= displacementmap.save(name_displace);
622 }
623
624 if(successfullySaved)
625 ui->statusBar->showMessage("Maps successfully saved", 4000);
626 else
627 QMessageBox::information(this, "Maps not saved", "One or more of the maps was NOT saved!");
628
629 //store export path
630 setExportPath(url.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash));
631 //enable "Open Export Folder" gui button
632 ui->pushButton_openExportFolder->setEnabled(true);
633}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected