fix issue #96: JKQTPlotter::saveAsPixelImage() does not add a border around the image any longer (can be reacivated by a new optional function parameter)

This commit is contained in:
jkriege2 2023-07-01 22:27:00 +02:00
parent 4207f25bd4
commit d23ea0a79e
25 changed files with 12 additions and 19 deletions

View File

@ -23,6 +23,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
</ul></li>
<li>JKQTPlotter:<ul>
<li>BREAKING/REWORKED: Implement better/more access functions to the graphs (inlcuding sorting, moving up/down, appending/prepending, graphs-iterators ...), solves issue #97</li>
<li>BREAKING/FIXED: fixed issue <a href="https://github.com/jkriege2/JKQtPlotter/pull/96">#96</a>: JKQTPlotter::saveAsPixelImage() does not add a border around the image any longer (can be reacivated by a new optional function parameter), thanks to <a href="https://github.com/nmielcarek">user:nmielcarek</a> for reporting</li>
<li>FIXED issue described in <a href="https://github.com/jkriege2/JKQtPlotter/pull/62">#62: Fix custom labels draw, because giving exactly two label-strings did not display all of them</a>, thanks to <a href="https://github.com/FalsinSoft">user:FalsinSoft</a></li>
<li>FIXED issue <a href="https://github.com/jkriege2/JKQtPlotter/pull/70">#70: Typo in jkqtplotter/CMakeLists.txt</a>, thanks to <a href="https://github.com/tedlinlab">user:tedlinlab</a></li>
<li>FIXED issue <a href="https://github.com/jkriege2/JKQtPlotter/pull/80">#80: Bug with multiple inheritance with Q_GDAGET with CLANG</a>, thanks to <a href="https://github.com/igormironchik">user:igormironchik</a>, caused by <a href="https://bugreports.qt.io/browse/QTBUG-104874">QTBUG-104874</a></li>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -3970,7 +3970,7 @@ void JKQTBasePlotter::saveImage(const QString& filename, bool displayPreview) {
}
void JKQTBasePlotter::saveAsPixelImage(const QString& filename, bool displayPreview, const QByteArray& outputFormat) {
void JKQTBasePlotter::saveAsPixelImage(const QString& filename, bool displayPreview, const QByteArray& outputFormat, const QSize &outputSizeIncrease) {
loadUserSettings();
QString fn=filename;
QStringList filt;
@ -3998,21 +3998,7 @@ void JKQTBasePlotter::saveAsPixelImage(const QString& filename, bool displayPrev
if (outputFormat.size()>0) {
form =outputFormat;
}
/*if (filtID==2 || ext=="tif" || ext=="tiff") { // currentFileFormat
form="TIFF";
} else if (filtID==0 || ext=="png") {
form="PNG";
} else if (filtID==1 || ext=="bmp") {
form="BMP";
} else if (filtID==3 || ext=="jpg" || ext=="jpeg") {
form="JPEG";
} else if (ext=="ppm") {
form="PPM";
} else if (filtID==4 || ext=="xbm") {
form="XBM";
} else if (filtID==5 || ext=="xpm") {
form="XPM";
}*/
emit beforeExporting();; auto __finalpaint=JKQTPFinally([&]() { emit afterExporting();});
gridPrintingCalc();
@ -4025,7 +4011,7 @@ void JKQTBasePlotter::saveAsPixelImage(const QString& filename, bool displayPrev
if (!displayPreview || exportpreview(gridPrintingSize, false)) {
QImage png(QSizeF(double(printSizeX_Millimeter)*1.1, double(printSizeY_Millimeter)*1.1).toSize(), QImage::Format_ARGB32);
QImage png(QSizeF(double(printSizeX_Millimeter)+outputSizeIncrease.width(), double(printSizeY_Millimeter)+outputSizeIncrease.height()).toSize(), QImage::Format_ARGB32);
png.fill(Qt::transparent);
JKQTPEnhancedPainter painter;
painter.begin(&png);

View File

@ -1728,8 +1728,14 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
* */
void setShowZeroAxes(bool showXY);
/** \brief save the current plot as a pixel image image (PNG ...), if filename is empty a file selection dialog is displayed */
void saveAsPixelImage(const QString& filename=QString(""), bool displayPreview=true, const QByteArray &outputFormat=QByteArray());
/** \brief save the current plot as a pixel image image (PNG ...), if filename is empty a file selection dialog is displayed
*
* \param filename name of the stored file, if no \a outputFormat is given, the file format is deduced by the file extension in \a filename
* \param displayPreview if \c true a dialog is shown that allows to modify the generated output (zoo, scaling, ...)
* \param outputFormmat specify the file format for the generated file
* \param outputSizeIncrease if given, the size of the generated pixel image is increased by this number of pixels in addition to the required space
*/
void saveAsPixelImage(const QString& filename=QString(""), bool displayPreview=true, const QByteArray &outputFormat=QByteArray(), const QSize& outputSizeIncrease=QSize(0,0));
/** \brief save the current plot as a pixel image into a QImage with the given size */
QImage grabPixelImage(QSize size=QSize(), bool showPreview=false);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB