scaling pictures at export

This commit is contained in:
Rafael 2016-04-26 23:12:17 +02:00
parent 26f20e2e98
commit 02088c2f89
3 changed files with 77 additions and 7 deletions

View file

@ -314,6 +314,22 @@ void OptionsDialog::setupPictureSettings()
// Size Settings // Size Settings
cusExportSize = settings->value("CustomSize", defExportSize).toSize(); cusExportSize = settings->value("CustomSize", defExportSize).toSize();
if (cusExportSize.width() > 3840)
{
cusExportSize.setWidth(3840);
}
else if (cusExportSize.height() > 2160)
{
cusExportSize.setHeight(2160);
}
if (cusExportSize.width() < 1)
{
cusExportSize.setWidth(1);
}
else if (cusExportSize.height() < 1)
{
cusExportSize.setHeight(1);
}
ui->sbPicExportWidth->setValue(cusExportSize.width()); ui->sbPicExportWidth->setValue(cusExportSize.width());
ui->sbPicExportHeight->setValue(cusExportSize.height()); ui->sbPicExportHeight->setValue(cusExportSize.height());

View file

@ -20,7 +20,7 @@
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="tabProfile"> <widget class="QWidget" name="tabProfile">
<attribute name="title"> <attribute name="title">

View file

@ -21,6 +21,8 @@
#include "PictureDialog.h" #include "PictureDialog.h"
#include "StandardPaths.h" #include "StandardPaths.h"
#include "SidebarGenerator.h" #include "SidebarGenerator.h"
#include <QDesktopWidget>
#include <QApplication>
#include <QMessageBox> #include <QMessageBox>
#include <QFileDialog> #include <QFileDialog>
#include <QSettings> #include <QSettings>
@ -34,6 +36,41 @@ PictureExport::PictureExport()
void PictureExport::exportPicture(QWidget *parent, SnapmaticPicture *picture) void PictureExport::exportPicture(QWidget *parent, SnapmaticPicture *picture)
{ {
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
// Picture Settings
// Quality Settings
settings.beginGroup("Pictures");
int defaultQuality = 100;
QSize defExportSize = QSize(960, 536);
int customQuality = settings.value("CustomQuality", defaultQuality).toInt();
if (customQuality < 1 || customQuality > 100)
{
customQuality = 100;
}
bool useCustomQuality = settings.value("CustomQualityEnabled", false).toBool();
// Size Settings
QSize cusExportSize = settings.value("CustomSize", defExportSize).toSize();
if (cusExportSize.width() > 3840)
{
cusExportSize.setWidth(3840);
}
else if (cusExportSize.height() > 2160)
{
cusExportSize.setHeight(2160);
}
if (cusExportSize.width() < 1)
{
cusExportSize.setWidth(1);
}
else if (cusExportSize.height() < 1)
{
cusExportSize.setHeight(1);
}
QString sizeMode = settings.value("ExportSizeMode", "Default").toString();
settings.endGroup();
// End Picture Settings
settings.beginGroup("FileDialogs"); settings.beginGroup("FileDialogs");
settings.beginGroup("ExportPicture"); settings.beginGroup("ExportPicture");
@ -60,11 +97,8 @@ fileDialogPreSave:
fileDialog.setDirectory(settings.value("Directory", StandardPaths::picturesLocation()).toString()); fileDialog.setDirectory(settings.value("Directory", StandardPaths::picturesLocation()).toString());
fileDialog.restoreGeometry(settings.value(parent->objectName() + "+Geomtery", "").toByteArray()); fileDialog.restoreGeometry(settings.value(parent->objectName() + "+Geomtery", "").toByteArray());
if (picture != 0) QString newPictureFileName = getPictureFileName(picture);
{ fileDialog.selectFile(newPictureFileName);
QString newPictureFileName = getPictureFileName(picture);
fileDialog.selectFile(newPictureFileName);
}
if (fileDialog.exec()) if (fileDialog.exec())
{ {
@ -118,7 +152,27 @@ fileDialogPreSave:
} }
} }
bool isSaved = picture->getPicture().save(selectedFile, saveFileFormat.toStdString().c_str(), 100); // Scale Picture
QImage exportPicture = picture->getPicture();
if (sizeMode == "Desktop")
{
QRect desktopResolution = QApplication::desktop()->screenGeometry();
exportPicture = exportPicture.scaled(desktopResolution.width(), desktopResolution.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
else if (sizeMode == "Custom")
{
exportPicture = exportPicture.scaled(cusExportSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
bool isSaved;
if (useCustomQuality)
{
isSaved = exportPicture.save(selectedFile, saveFileFormat.toStdString().c_str(), customQuality);
}
else
{
isSaved = exportPicture.save(selectedFile, saveFileFormat.toStdString().c_str(), 100);
}
if (!isSaved) if (!isSaved)
{ {