aboutsummaryrefslogtreecommitdiff
path: root/app/draw.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'app/draw.cpp')
-rw-r--r--app/draw.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/app/draw.cpp b/app/draw.cpp
new file mode 100644
index 0000000..2f3a947
--- /dev/null
+++ b/app/draw.cpp
@@ -0,0 +1,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;
+}