-
Notifications
You must be signed in to change notification settings - Fork 0
/
bitmap.h
62 lines (47 loc) · 1.21 KB
/
bitmap.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
#ifndef BITMAP_H
#define BITMAP_H
// Constant definitions
#define SIZE_OFFSET 2
#define PIXELS_OFFSET_OFFSET 10
#define WIDTH_OFFSET 18
#define HEIGHT_OFFSET 22
#define ROW_SIZE_OFFSET 34
#define HEADER_BYTE_SIZE 14
#define DIB_HEADER_BYTE_SIZE 40
#define WIDTH_BYTE_SIZE 4
#define HEIGHT_BYTE_SIZE 4
#define SIZE_BYTE_SIZE 4
#define PIXELS_OFFSET_BYTE_SIZE 4
#define ROW_SIZE_SIZE 4
#define ROW_REMAINING 4
// Includes
#include <vector>
// Type definitions
typedef std::vector<char> Bytes;
struct Bitmap
{
int file_size;
int width;
int height;
int pixels_offset;
int end_line_zeros;
Bytes raw_data;
};
struct Color
{
int red;
int green;
int blue;
};
// Function declarations
Bitmap read_bitmap_from_stdin();
void write_bitmap_to_stdout(const Bitmap& bitmap);
int extract_int_from_bytes(const Bytes& bytes, int offset, int size);
Color extract_color_from_bytes(const Bytes& bytes, int offset);
void copy_bitmap(const Bitmap& source, Bitmap& destination);
void set_pixel(Bitmap& bitmap, int row, int column, Color color);
Color get_pixel(const Bitmap& bitmap, int row, int column);
int find_pixel_offset(const Bitmap& bitmap, int row, int column);
int char2uint(char input);
char uint2char(int input);
#endif