diff --git a/core/imagedownloader.cpp b/core/imagedownloader.cpp index 59f1da8b7..6c2837b20 100644 --- a/core/imagedownloader.cpp +++ b/core/imagedownloader.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -153,12 +154,18 @@ Thumbnailer::Thumbnail Thumbnailer::getHashedImage(const QString &filename, bool return thumbnail; } -Thumbnailer::Thumbnailer() : failImage(renderSVGIcon(":filter-close", maxThumbnailSize(), false)), // TODO: Don't misuse filter close icon - dummyImage(renderSVGIcon(":camera-icon", maxThumbnailSize(), false)), - videoImage(renderSVGIcon(":video-icon", maxThumbnailSize(), false)), - videoOverlayImage(renderSVGIconWidth(":video-overlay", maxThumbnailSize())), - unknownImage(renderSVGIcon(":unknown-icon", maxThumbnailSize(), false)) +Thumbnailer::Thumbnailer() : failImage(QPixmap(":filter-close").scaled(maxThumbnailSize(), maxThumbnailSize(), Qt::KeepAspectRatio).toImage()), // TODO: Don't misuse filter close icon + dummyImage(QPixmap(":camera-icon").scaled(maxThumbnailSize(), maxThumbnailSize(), Qt::KeepAspectRatio).toImage()), + videoImage(QPixmap(":video-icon").scaled(maxThumbnailSize(), maxThumbnailSize(), Qt::KeepAspectRatio).toImage()), + unknownImage(QPixmap(":unknown-icon").scaled(maxThumbnailSize(), maxThumbnailSize(), Qt::KeepAspectRatio).toImage()) { + // We have to do this little song and dance because QSvgRenderer produces artifacts when used with Qt::KeepAspectRatio + QSvgRenderer videoOverlayRenderer{QString(":video-overlay")}; + QSize svgSize = videoOverlayRenderer.defaultSize(); + videoOverlayImage = QImage(maxThumbnailSize(), maxThumbnailSize() * svgSize.height() / svgSize.width(), QImage::Format_ARGB32); + videoOverlayImage.fill(Qt::transparent); + QPainter painter(&videoOverlayImage); + videoOverlayRenderer.render(&painter); // Currently, we only process one image at a time. Stefan Fuchs reported problems when // calculating multiple thumbnails at once and this hopefully helps. pool.setMaxThreadCount(1); diff --git a/core/qthelper.cpp b/core/qthelper.cpp index 09020aaf0..afcf60bd5 100644 --- a/core/qthelper.cpp +++ b/core/qthelper.cpp @@ -36,8 +36,6 @@ #include #include #include -#include -#include #include #include #ifdef Q_OS_UNIX @@ -1687,26 +1685,3 @@ extern "C" void emit_reset_signal() { emit diveListNotifier.dataReset(); } - -QImage renderSVGIcon(const char *id, int size, bool transparent) -{ - QImage res(size, size, transparent ? QImage::Format_ARGB32 : QImage::Format_RGB32); - res.fill(transparent ? Qt::transparent : Qt::white); - QSvgRenderer svg{QString(id)}; - QPainter painter(&res); - svg.render(&painter); - return res; -} - -// As renderSVGIcon(), but render to a fixed width and scale height accordingly -// and have a transparent background. -QImage renderSVGIconWidth(const char *id, int size) -{ - QSvgRenderer svg{QString(id)}; - QSize svgSize = svg.defaultSize(); - QImage res(size, size * svgSize.height() / svgSize.width(), QImage::Format_ARGB32); - res.fill(Qt::transparent); - QPainter painter(&res); - svg.render(&painter); - return res; -} diff --git a/core/qthelper.h b/core/qthelper.h index af73cc813..66df91b20 100644 --- a/core/qthelper.h +++ b/core/qthelper.h @@ -96,8 +96,6 @@ QString getUserAgent(); QString printGPSCoords(const location_t *loc); std::vector get_cylinder_map_for_remove(int count, int n); std::vector get_cylinder_map_for_add(int count, int n); -QImage renderSVGIcon(const char *id, int size, bool transparent); -QImage renderSVGIconWidth(const char *id, int size); extern QString (*changesCallback)(); void uiNotification(const QString &msg); diff --git a/icons/ruler.png b/icons/ruler.png deleted file mode 100644 index 849909c64..000000000 Binary files a/icons/ruler.png and /dev/null differ diff --git a/profile-widget/divepixmapcache.cpp b/profile-widget/divepixmapcache.cpp index d59116022..2dae2f723 100644 --- a/profile-widget/divepixmapcache.cpp +++ b/profile-widget/divepixmapcache.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include "divepixmapcache.h" #include "core/metrics.h" -#include "core/qthelper.h" // for renderSVGIconWidth #include "core/color.h" #include @@ -31,7 +30,7 @@ DivePixmaps::DivePixmaps(int dpr) : dpr(dpr) violation = createPixmap(":status-violation-icon", sz_pix); bailout = createPixmap(":bailout-icon", sz_pix); onCCRLoop = createPixmap(":onCCRLoop-icon", sz_pix); - bookmark = QPixmap::fromImage(renderSVGIconWidth(":dive-bookmark-icon", sz_pix)); + bookmark = createPixmap(":dive-bookmark-icon", sz_pix); gaschangeTrimixICD = createPixmap(":gaschange-trimix-ICD-icon", sz_bigger); gaschangeTrimix = createPixmap(":gaschange-trimix-icon", sz_bigger); gaschangeAirICD = createPixmap(":gaschange-air-ICD-icon", sz_bigger); diff --git a/stats/chartlistmodel.cpp b/stats/chartlistmodel.cpp index 7f7afe4d0..1cf35e6e0 100644 --- a/stats/chartlistmodel.cpp +++ b/stats/chartlistmodel.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include "chartlistmodel.h" #include "core/metrics.h" -#include "core/qthelper.h" #include #include #include @@ -14,7 +13,7 @@ ChartListModel::ChartListModel() : int fontHeight = fm.height(); int iconSize = fontHeight * 2; - warningPixmap = QPixmap::fromImage(renderSVGIcon(":chart-warning-icon", fontHeight, true)); + warningPixmap = QPixmap(":chart-warning-icon").scaled(fontHeight, fontHeight, Qt::KeepAspectRatio); initIcon(ChartSubType::Vertical, ":chart-bar-vertical-icon", iconSize); initIcon(ChartSubType::VerticalGrouped, ":chart-bar-grouped-vertical-icon", iconSize); initIcon(ChartSubType::VerticalStacked, ":chart-bar-stacked-vertical-icon", iconSize); @@ -32,7 +31,7 @@ ChartListModel::~ChartListModel() void ChartListModel::initIcon(ChartSubType type, const char *name, int iconSize) { - QPixmap icon = QPixmap::fromImage(renderSVGIcon(name, iconSize, true)); + QPixmap icon = QPixmap(name).scaled(iconSize, iconSize, Qt::KeepAspectRatio); QPixmap iconWarning = icon.copy(); QPainter painter(&iconWarning); painter.drawPixmap(0, 0, warningPixmap);