aboutsummaryrefslogtreecommitdiff
path: root/app/draw.cpp
blob: b3187be29bc7b0bb2d3aff62ab696b14d7268fbf (plain)
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
#include "draw.hpp"
#include <qpainter.h>
#include <qglobal.h>
#include <qimage.h>
#include <qrgb.h>
#include <qtimer.h>
#include <qwindowdefs.h>
#include <iostream>

DrawWidget::DrawWidget(unsigned width, unsigned height) : QWidget() {
    m_width = width;
    m_height = height;
    m_drawbuffer = new QRgb[width * height];

    m_img = QImage((uchar*)m_drawbuffer, width, height, QImage::Format_ARGB32);
}

void DrawWidget::paintEvent(QPaintEvent*) {
    QPainter painter(this);
    painter.drawImage(0, 0, m_img);
}

void DrawWidget::redraw() {
    repaint();
}

DrawWidget::~DrawWidget() {
    delete[] m_drawbuffer;
}