-
Notifications
You must be signed in to change notification settings - Fork 0
/
painter.h
72 lines (53 loc) · 1.6 KB
/
painter.h
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
65
66
67
68
69
70
71
72
//STL
#include <string>
#include <cmath>
#include <algorithm>
//Qt
#include <QImage>
#include <QString>
#include <QtOpenGL>
#include <QtWidgets>
//cs40
#include "drawable.h"
typedef enum CS40_APP_MODE{
NONE=0,
} app_mode_t;
class Painter : public QOpenGLWidget {
Q_OBJECT
protected:
void initializeGL();
void paintGL();
void resizeGL(int w, int h);
public:
Painter(QWidget *parent = 0);
~Painter();
public slots:
void open();
void paint();
void setThreshold(qreal value);
private:
qreal m_blurFactor; //changes how precise image is blurred
QLabel *m_imageLabel; //box for image
QImage m_img; //image being processed
QOpenGLTexture* m_texture; //texture version of image
QList<cs40::Drawable*> m_strokes;
qreal m_threshold;
QScrollArea *m_scrollArea; /* scrollbars if image is too small */
QGridLayout *m_layout; /* declare layout of widget */
//shaders and program
QOpenGLShader *m_vertexShader;
QOpenGLShader *m_fragmentShader;
QOpenGLShaderProgram *m_shaderProgram;
//buffers
QVector3D *vertices;
QOpenGLBuffer *vboVertices;
QOpenGLVertexArrayObject *vao;
void createShaders();
void destroyShaders();
void createVBOs();
void setupVAO();
QImage createReferenceImage(qreal brushSize); //get blurred image
QList<cs40::Drawable*> getLayer(qreal brushSize, QImage canvas, qreal threshold); //compute strokes for layer
QVector3D toVector(QRgb color);
QImage paintImage(int layers, int stopSize=1); //main paint function, specify # layers or stopping brush size
};