From bbbf77597a6d7faa2e7628b70f884480eb046952 Mon Sep 17 00:00:00 2001 From: plc-user <74435298+plc-user@users.noreply.github.com> Date: Fri, 7 Feb 2025 11:34:05 +0100 Subject: [PATCH] export: set maximum width / height according limitations in QPainter --- sources/exportdialog.cpp | 15 ++++++--------- sources/exportdialog.h | 14 +++++++------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/sources/exportdialog.cpp b/sources/exportdialog.cpp index 9d171ad8a..2e593ed75 100644 --- a/sources/exportdialog.cpp +++ b/sources/exportdialog.cpp @@ -869,16 +869,13 @@ void ExportDialog::slot_changeFilesExtension(bool force_extension) { QString format_acronym = epw -> exportProperties().format; QString format_extension = "." + format_acronym.toLower(); - // set maximum width / height according specifications of export-type - if (format_extension == ".bmp") { + // set maximum width / height according limitations in QPainter + if ((format_extension == ".bmp") || + (format_extension == ".jpg") || + (format_extension == ".png")) { foreach (auto line, diagram_lines_.values() ) { - line->width ->setRange(1, BMPmaxSize); - line->height->setRange(1, BMPmaxSize); - } - } else if (format_extension == ".jpg") { - foreach (auto line, diagram_lines_.values() ) { - line->width ->setRange(1, JPGmaxSize); - line->height->setRange(1, JPGmaxSize); + line->width ->setRange(1, RasterMaxSize); + line->height->setRange(1, RasterMaxSize); } } else { foreach (auto line, diagram_lines_.values() ) { diff --git a/sources/exportdialog.h b/sources/exportdialog.h index 31bef13f3..abb88ded8 100644 --- a/sources/exportdialog.h +++ b/sources/exportdialog.h @@ -59,7 +59,7 @@ class ExportDialog : public QDialog { QPushButton *preview; QPushButton *clipboard; }; - + // attributes private: QHash diagram_lines_; @@ -78,15 +78,15 @@ class ExportDialog : public QDialog { QSignalMapper *ratio_mapper_; QSignalMapper *reset_mapper_; QSignalMapper *clipboard_mapper_; - + + // QPainter limits size of pixel-images to 2^15 - 1 // constants for exporting images: - static const int BMPmaxSize = 32767; - static const int JPGmaxSize = 65535; + static const int RasterMaxSize = 32767; static const int GeneralMaxSize = 100000; - + // project whose diagrams are to be exported QETProject *project_; - + // methods QWidget *initDiagramsListPart(); void saveReloadDiagramParameters(Diagram *, bool = true); @@ -96,7 +96,7 @@ class ExportDialog : public QDialog { void exportDiagram(ExportDiagramLine *); qreal diagramRatio(Diagram *); QSize diagramSize(Diagram *); - + public slots: void slot_correctWidth(int); void slot_correctHeight(int);