-
Notifications
You must be signed in to change notification settings - Fork 0
/
imageitem.h
50 lines (46 loc) · 1.32 KB
/
imageitem.h
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
44
45
46
47
48
49
50
// ImageItem.h
#ifndef IMAGEITEM_H
#define IMAGEITEM_H
#include <QQuickPaintedItem>
#include <QQuickItem>
#include <QPainter>
#include <QImage>
class ImageItem : public QQuickPaintedItem
{
Q_OBJECT
// Q_PROPERTY(bool wisMode)// MEMBER wisMode
float zoomer = 1.f;
QPixmap *current_pixmap = nullptr;
// QImage current_image;
QString source;
// bool wisMode = false;
// int wisX;
// int wisY;
// int wisWid;
// int wisHei;
int displayedStartX = 0, displayedStartY = 0;
int displayedWid, displayedHei;
float imgCoof;
public:
ImageItem(QQuickItem *parent = nullptr);
Q_INVOKABLE void setImage(const QImage &image);
// Q_INVOKABLE void setRect(int x,int y,int wid,int hei);
Q_INVOKABLE void setSource(QString src);
Q_INVOKABLE void setZoom(float proc);
Q_INVOKABLE void clear();
void paint(QPainter *painter);
QImage image() const;
QString getSource() const;
int getImageWid();
int getImageHei();
~ImageItem();
int getRealX(int displayedX);
int getRealY(int displayedy);
Q_PROPERTY(QImage image READ image WRITE setImage NOTIFY imageChanged)
Q_PROPERTY(QString source READ getSource WRITE setSource)
Q_PROPERTY(int imageWidght READ getImageWid)
Q_PROPERTY(int imageHeight READ getImageHei)
signals:
void imageChanged();
};
#endif // IMAGEITEM_H