-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage.cpp
More file actions
29 lines (24 loc) · 696 Bytes
/
image.cpp
File metadata and controls
29 lines (24 loc) · 696 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
#include "image.h"
#include "stb_image.h"
#include "stb_image_write.h"
void Image::write_to_file(uint8_t *rgb, char * filename, int x, int y, int n) {
stbi_write_png((char const *)filename, x, y, 3, rgb, 0);
}
Image::Image(int32_t x, int32_t y, uint8_t *rgb) {
x_ = x;
y_ = y;
n_ = 3;
rgb_ = rgb;
}
void Image::interlaced(uint8_t *rgb) {
for (int i = 0; i < x_; i++) {
for (int j = 0; j < y_; j++) {
PixelP pix;
getPixel(&i, &j, &pix);
int pixel_location = (x_ * j + i) * 3;
rgb[pixel_location] = *pix.r;
rgb[pixel_location+1] = *pix.g;
rgb[pixel_location+2] = *pix.b;
}
}
}