forked from rpelorosso/pcb-tracer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageLayer.cpp
More file actions
43 lines (39 loc) · 1.06 KB
/
ImageLayer.cpp
File metadata and controls
43 lines (39 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "ImageLayer.h"
#include <QPixmap>
#include <QDebug>
/*
ImageLayer::ImageLayer(int id) : QGraphicsPixmapItem(), m_id(id) {
setZValue(-1);
setPos(0, 0);
setOpacity(1);
}
bool ImageLayer::loadImage(const QString& imagePath) {
m_imagePath = imagePath;
QPixmap pixmap(imagePath);
if (!pixmap.isNull()) {
setPixmap(pixmap);
return true;
} else {
std::cout << "Failed to load image: " << imagePath.toStdString() << std::endl;
return false;
}
}*/
ImageLayer::ImageLayer(int id) : QGraphicsPixmapItem(), m_id(id) {
setZValue(-1);
setPos(0, 0); // Position image at the top-left corner of the view
setOpacity(1); // Set the image's opacity to 100%
}
bool ImageLayer::loadImage(const QString& imagePath) {
m_imagePath = imagePath;
QPixmap pixmap;
if (!pixmap.load(imagePath)) {
qDebug() << "error";
}
if (!pixmap.isNull()) {
setPixmap(pixmap);
return true;
} else {
qDebug() << "Failed to load image:" << imagePath;
return false;
}
}