png8 converter

i did it again.
This commit is contained in:
Jan Schuffenhauer
2019-12-05 17:38:35 +01:00
parent ef65bcd983
commit 44ddebf701
3 changed files with 25 additions and 3 deletions

View File

@@ -216,6 +216,17 @@ void IntelliPhotoGui::createActions()
saveAsActs.append(action); saveAsActs.append(action);
} }
QAction *action = new QAction("PNG-8", this);
// Set an action for each file format
action->setData("PNG");
// When clicked call IntelliPhotoGui::save()
connect(action, SIGNAL(triggered()), this, SLOT(save()));
// Attach each file format option menu item to Save As
saveAsActs.append(action);
// Create exit action and tie to IntelliPhotoGui::close() // Create exit action and tie to IntelliPhotoGui::close()
exitAct = new QAction(tr("&Exit"), this); exitAct = new QAction(tr("&Exit"), this);
@@ -298,7 +309,7 @@ void IntelliPhotoGui::createGui(){
BlueLabel = new QLabel("Blue:"); BlueLabel = new QLabel("Blue:");
RedEdit = new QLineEdit("255"); RedEdit = new QLineEdit("255");
GreenEdit = new QLineEdit("255"); GreenEdit = new QLineEdit("255");
BlueEdit = new QLineEdit("255");; BlueEdit = new QLineEdit("255");
RedEdit->setMaximumSize(150,20); RedEdit->setMaximumSize(150,20);
GreenEdit->setMaximumSize(150,20); GreenEdit->setMaximumSize(150,20);
BlueEdit->setMaximumSize(150,20); BlueEdit->setMaximumSize(150,20);

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.10.2, 2019-12-05T17:30:15. --> <!-- Written by QtCreator 4.10.2, 2019-12-05T17:31:18. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>
@@ -317,7 +317,7 @@
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value> <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value> <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory"></value> <value type="QString" key="RunConfiguration.WorkingDirectory"></value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">Z:/Uni/ws 19_20/mathe/intelliphoto/IntelliPhoto/build-IntelliPhoto-Desktop_x86_windows_msvc2017_pe_64bit-Debug</value> <value type="QString" key="RunConfiguration.WorkingDirectory.default"></value>
</valuemap> </valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value> <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap> </valuemap>

View File

@@ -111,6 +111,17 @@ bool PaintingArea::saveImage(const QString &fileName, const char *fileFormat)
} }
this->assembleLayers(true); this->assembleLayers(true);
if(!std::strcmp(fileFormat,"PNG")){
QImage visibleImage = Canvas->convertToFormat(QImage::Format_Indexed8);
fileFormat = "png";
if (visibleImage.save(fileName, fileFormat)) {
return true;
} else {
return false;
}
}
if (Canvas->save(fileName, fileFormat)) { if (Canvas->save(fileName, fileFormat)) {
return true; return true;
} else { } else {