-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrenderarea.cpp
More file actions
35 lines (30 loc) · 770 Bytes
/
renderarea.cpp
File metadata and controls
35 lines (30 loc) · 770 Bytes
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
#include "renderarea.h"
#include <qpainter.h>
#include <QDebug>
#include <QImage>
#include <iostream>
RenderArea::RenderArea(QWidget *parent) : QWidget{parent}
{
setBackgroundRole(QPalette::Base);
setAutoFillBackground(true);
}
void RenderArea::paintEvent(QPaintEvent* event)
{
QPainter painter(this);
int intSize = sizeof(int);
int numberOfBytesPerWidth{widthVal*intSize};
QImage gridImage{dataVal,widthVal,heightVal,numberOfBytesPerWidth,QImage::Format_ARGB32};
painter.drawImage(QRect{0,0,this->width(),this->height()},gridImage);
}
void RenderArea::set_data(const uchar* data)
{
dataVal = data;
}
void RenderArea::set_width(int width)
{
widthVal = width;
}
void RenderArea::set_height(int height)
{
heightVal = height;
}