-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilm.cpp
More file actions
34 lines (29 loc) · 733 Bytes
/
film.cpp
File metadata and controls
34 lines (29 loc) · 733 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
#include <FreeImage.h>
#define BPP 24
class Film {
public:
int width;
int height;
FIBITMAP* bitmap;
RGBQUAD pixel;
inline void init(int w, int h) {
width = w;
height = h;
FreeImage_Initialise();
bitmap = FreeImage_Allocate(w, h, BPP);
}
// Will write the color to (sample.x, sample.y) on the image
void commit(Sample& sample, Color& color);
// Output image to a file
void writeImage();
};
void Film::commit(Sample& sample, Color& color) {
pixel.rgbRed = color.r;
pixel.rgbGreen = color.g;
pixel.rgbBlue = color.b;
FreeImage_SetPixelColor(bitmap, sample.x, sample.y, &pixel);
}
void Film::writeImage() {
FreeImage_Save(FIF_PNG, bitmap, "image.png", 0);
FreeImage_DeInitialise();
}