-
Notifications
You must be signed in to change notification settings - Fork 1
/
rawImg.cpp
37 lines (34 loc) · 1021 Bytes
/
rawImg.cpp
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
#include "rawImg.h"
RawImg::RawImg(QImage *src) {
height = src->height();
width = src->width();
data = new int[height * width * 3];
for (int i = 0; i < src->height() * src->width(); i++) {
QColor clrCurrent(src->pixel(i % src->width(), i / src->width()));
data[i * 3 + 0] = clrCurrent.red();
data[i * 3 + 1] = clrCurrent.green();
data[i * 3 + 2] = clrCurrent.blue();
}
}
RawImg::RawImg(int w, int h) {
height = h;
width = w;
data = new int[h * w * 3];
for (int i = 0; i < h * w; i++) {
data[i * 3 + 0] = data[i * 3 + 1] = data[i * 3 + 2] = 0;
}
}
RawImg::RawImg(RawImg &model) {
height = model.height;
width = model.width;
data = new int[height * width * 3];
for (int i = 0; i < height * width; i++) {
data[i * 3 + 0] = model.data[i * 3 + 0];
data[i * 3 + 1] = model.data[i * 3 + 1];
data[i * 3 + 2] = model.data[i * 3 + 2];
}
}
RawImg::~RawImg() {
if (data != NULL)
delete data;
}