-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrtfilm.cpp
64 lines (51 loc) · 944 Bytes
/
rtfilm.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
#include "rtfilm.h"
#include <QRgb>
#include <QColor>
#include <QDebug>
// static
RTFilm *RTFilm::buffer = 0;
bool RTFilm::init(int width, int height)
{
RTFilm::buffer = new RTFilm(width, height);
return true;
}
void RTFilm::close()
{
delete RTFilm::buffer;
RTFilm::buffer = 0;
}
RTFilm * RTFilm::getInstance()
{
return RTFilm::buffer;
}
// instance
RTFilm::RTFilm(int width, int height) :
QObject(0)
{
image = new QImage(width, height, QImage::Format_ARGB32);
image->fill(QColor(0,0,0));
}
RTFilm::~RTFilm()
{
delete image;
}
void RTFilm::commit(int x,int y, RTColor &color)
{
image->setPixel(x,y, qRgb(color.getR(), color.getG(), color.getB()) );
}
void RTFilm::writeImage(QString &filename)
{
image->save(filename);
}
QImage *RTFilm::getQImage()
{
return this->image;
}
int RTFilm::getHeight()
{
return image->height();
}
int RTFilm::getWidth()
{
return image->width();
}