Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render API images as pixmaps #633

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions include/ui/overlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/ui/overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}
Loading