-
Notifications
You must be signed in to change notification settings - Fork 0
/
animationframe.cpp
82 lines (69 loc) · 1.64 KB
/
animationframe.cpp
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
#include "animationframe.h"
#include <QPainter>
#include <memory>
AnimationFrame::AnimationFrame(int width, int height, QObject *parent)
: QObject(parent)
, image(width, height, QImage::Format::Format_ARGB32)
, tableWidget(" ")
, height(height)
, width(width)
{
clear();
}
AnimationFrame::AnimationFrame(const AnimationFrame &frame, QObject *parent)
: QObject(parent)
, image(frame.image)
, tableWidget(frame.tableWidget)
, height(frame.height)
, width(frame.width)
{
}
AnimationFrame &AnimationFrame::operator=(const AnimationFrame &frame)
{
image = frame.image;
tableWidget = frame.tableWidget;
height = frame.height;
width = frame.width;
return *this;
}
void AnimationFrame::clear()
{
image.fill(QColor(255, 255, 255));
blank = true;
}
void AnimationFrame::resize(const QSize newSize)
{
if (image.size() == newSize)
return;
QImage newImage(newSize, QImage::Format_RGB32);
newImage.fill(qRgb(255, 255, 255));
QPainter painter(&newImage);
painter.drawImage(QPoint(0, 0), image);
image = newImage;
}
void AnimationFrame::update()
{
blank = false;
tableWidget.setText("•");
QFont font{};
font.setPixelSize(32);
tableWidget.setFont(font);
tableWidget.setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
tableWidget.setTextColor(QColor(252, 190, 3));
}
bool AnimationFrame::getIsBlank()
{
return blank;
}
int AnimationFrame::getHeight() const
{
return height;
}
int AnimationFrame::getWidth() const
{
return width;
}
bool AnimationFrame::saveTo(QString path, const char *format)
{
return image.save(path, format);
}