-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCForgegroungImageItem.h
90 lines (73 loc) · 1.89 KB
/
CForgegroungImageItem.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#ifndef CFORGEGROUNGIMAGEITEM_H
#define CFORGEGROUNGIMAGEITEM_H
#include <QGraphicsObject>
#include <QImage>
class CForgegroungImageItem : public QGraphicsObject
{
Q_OBJECT
public:
explicit CForgegroungImageItem(QGraphicsItem* parent = nullptr);
virtual ~CForgegroungImageItem();
void setImage(const QImage& img);
QImage image() const;
QRectF boundingRect() const override;
void setSize(const QSize& sz);
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr) override;
void setBrushColor(const QColor& cr)
{
m_brushColor = cr;
m_PaintImage.fill(m_brushColor);
updateAlphaChannel(m_image);
}
void updateAlphaChannel(const QImage& alphaImg);
void setBrushSize(int sz)
{
if (sz == 0)
{
return;
}
m_brushSize = sz;
}
int getBrushSize(){
return m_brushSize;
}
int getClearSize(){
return m_clearSize;
}
QColor getBrushColor()
{
return m_brushColor;
}
void setClearSize(int sz)
{
if (sz == 0)
{
return;
}
m_clearSize = sz;
}
qreal getPathIMC(const QPainterPath& path);
void updatePath(const QPainterPath& path,const QImage& img,bool isMove);
void clearBrush();
void setoOacity(qreal opy)
{
m_opacity = opy;
update();
}
protected:
void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
private:
QImage m_image;
QImage m_PaintImage;
QImage m_oldImage;
QPointF m_lastPos;
bool m_isDrawing;
bool m_needModefy;
QColor m_brushColor;
int m_brushSize;
int m_clearSize;
qreal m_opacity;
};
#endif // CFORGEGROUNGIMAGEITEM_H