From d674856b1800a63dd63275e8281736a03a017d35 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 28 Oct 2024 11:42:44 -0400 Subject: [PATCH] Render API images as pixmaps --- include/ui/overlay.h | 10 +++++----- src/ui/overlay.cpp | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/ui/overlay.h b/include/ui/overlay.h index 8f64d058d..86fe09637 100644 --- a/include/ui/overlay.h +++ b/include/ui/overlay.h @@ -50,19 +50,19 @@ class OverlayPath : public OverlayItem { QColor fillColor; }; -class OverlayImage : public OverlayItem { +class OverlayPixmap : public OverlayItem { public: - OverlayImage(int x, int y, QImage image) { + OverlayPixmap(int x, int y, QPixmap pixmap) { this->x = x; this->y = y; - this->image = image; + this->pixmap = pixmap; } - ~OverlayImage() {} + ~OverlayPixmap() {} virtual void render(QPainter *painter); private: int x; int y; - QImage image; + QPixmap pixmap; }; class Overlay diff --git a/src/ui/overlay.cpp b/src/ui/overlay.cpp index 4642afa1f..d1ba4ef89 100644 --- a/src/ui/overlay.cpp +++ b/src/ui/overlay.cpp @@ -16,8 +16,8 @@ void OverlayPath::render(QPainter *painter) { painter->drawPath(this->path); } -void OverlayImage::render(QPainter *painter) { - painter->drawImage(this->x, this->y, this->image); +void OverlayPixmap::render(QPainter *painter) { + painter->drawPixmap(this->x, this->y, this->pixmap); } void Overlay::renderItems(QPainter *painter) { @@ -244,7 +244,7 @@ bool Overlay::addImage(int x, int y, QString filepath, bool useCache, int width, if (setTransparency) image.setColor(0, qRgba(0, 0, 0, 0)); - this->items.append(new OverlayImage(x, y, image)); + this->items.append(new OverlayPixmap(x, y, QPixmap::fromImage(image))); return true; } @@ -253,6 +253,6 @@ bool Overlay::addImage(int x, int y, QImage image) { logError(QString("Failed to load custom image")); return false; } - this->items.append(new OverlayImage(x, y, image)); + this->items.append(new OverlayPixmap(x, y, QPixmap::fromImage(image))); return true; }