! Saves the plot to a rastered image file \a fileName in the image format \a format. The plot is sized to \a width and \a height in pixels and scaled with \a scale. (width 100 and scale 2.0 lead to a full resolution file with width 200.) If the \a format supports compression, \a quality may be between 0 and 100 to control it. Returns true on success. If this function fails, most likely
| 16387 | \see saveBmp, saveJpg, savePng, savePdf |
| 16388 | */ |
| 16389 | bool QCustomPlot::saveRastered(const QString &fileName, int width, int height, double scale, const char *format, int quality, int resolution, QCP::ResolutionUnit resolutionUnit) |
| 16390 | { |
| 16391 | QImage buffer = toPixmap(width, height, scale).toImage(); |
| 16392 | |
| 16393 | int dotsPerMeter = 0; |
| 16394 | switch (resolutionUnit) |
| 16395 | { |
| 16396 | case QCP::ruDotsPerMeter: dotsPerMeter = resolution; break; |
| 16397 | case QCP::ruDotsPerCentimeter: dotsPerMeter = resolution*100; break; |
| 16398 | case QCP::ruDotsPerInch: dotsPerMeter = int(resolution/0.0254); break; |
| 16399 | } |
| 16400 | buffer.setDotsPerMeterX(dotsPerMeter); // this is saved together with some image formats, e.g. PNG, and is relevant when opening image in other tools |
| 16401 | buffer.setDotsPerMeterY(dotsPerMeter); // this is saved together with some image formats, e.g. PNG, and is relevant when opening image in other tools |
| 16402 | if (!buffer.isNull()) |
| 16403 | return buffer.save(fileName, format, quality); |
| 16404 | else |
| 16405 | return false; |
| 16406 | } |
| 16407 | |
| 16408 | /*! |
| 16409 | Renders the plot to a pixmap and returns it. |