-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbitmap.h
More file actions
51 lines (44 loc) · 1.17 KB
/
bitmap.h
File metadata and controls
51 lines (44 loc) · 1.17 KB
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
#pragma once
#include "matrix.h"
const uint8_t MIN = 0;
class Pixel {
public:
uint8_t blue_ = MIN;
uint8_t green_ = MIN;
uint8_t red_ = MIN;
};
class Bitmap : public Matrix<Pixel> {
public:
class BMPHeader {
public:
uint16_t header_field;
uint32_t size_of_file;
uint16_t reserved_1;
uint16_t reserved_2;
uint32_t offset;
} __attribute__((packed));
class BitmapInfoHeader {
public:
uint32_t size_of_bitmapinfoheader;
uint32_t width;
uint32_t height;
uint16_t color_planes;
uint16_t bits_per_pixel;
uint32_t compression_method;
uint32_t image_size;
uint32_t horizontal_resolution;
uint32_t vertical_resolution;
uint32_t colors_in_palette;
uint32_t important_colors;
} __attribute__((packed));
public:
void Open(const char* path_to_source);
void Save(const char* path_to_result);
void SetInfoHeaderHeightWidth(uint32_t height, uint32_t width) {
bitmapInfoHeader_.height = height;
bitmapInfoHeader_.width = width;
}
protected:
BMPHeader bmp_header_;
BitmapInfoHeader bitmapInfoHeader_;
};