aboutsummaryrefslogtreecommitdiff
path: root/app/draw.cpp
blob: 2f3a94753e8eaa034e8c30044002a6f0af3c48a8 (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
#include "draw.hpp"
#include <qpainter.h>
#include <qglobal.h>
#include <qimage.h>
#include <qrgb.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);
}

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