Mercurial > hg > forks > yadex
comparison src/rgbbmp.h @ 109:f05330267c66
Use stdint types.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 06 Oct 2014 12:59:23 +0300 |
parents | a68786b9c74b |
children |
comparison
equal
deleted
inserted
replaced
108:c91965fc33b6 | 109:f05330267c66 |
---|---|
2 * rgbbmp.h | 2 * rgbbmp.h |
3 * Rgbbmp - An RGB bitmap image class. | 3 * Rgbbmp - An RGB bitmap image class. |
4 * | 4 * |
5 * This is a simple bitmap where each pixel is an RGB | 5 * This is a simple bitmap where each pixel is an RGB |
6 * triplet. Each component is coded as an 8-bit unsigned | 6 * triplet. Each component is coded as an 8-bit unsigned |
7 * integer (of type u8). | 7 * integer (of type int8_t). |
8 * | 8 * |
9 * AYM 1999-06-06 | 9 * AYM 1999-06-06 |
10 */ | 10 */ |
11 | 11 |
12 | 12 |
37 #define YH_RGBBMP | 37 #define YH_RGBBMP |
38 | 38 |
39 | 39 |
40 typedef struct | 40 typedef struct |
41 { | 41 { |
42 u8 r; | 42 uint8_t r; |
43 u8 g; | 43 uint8_t g; |
44 u8 b; | 44 uint8_t b; |
45 } Rgbbmp_pixel_t; | 45 } Rgbbmp_pixel_t; |
46 | 46 |
47 | 47 |
48 class Rgbbmp | 48 class Rgbbmp |
49 { | 49 { |
92 { | 92 { |
93 if (pixel) | 93 if (pixel) |
94 memset(pixel, 0, _width * _height * sizeof *pixel); | 94 memset(pixel, 0, _width * _height * sizeof *pixel); |
95 } | 95 } |
96 | 96 |
97 void get(int x, int y, u8 & r, u8 & g, u8 & b) const | 97 void get(int x, int y, uint8_t & r, uint8_t & g, uint8_t & b) const |
98 { | 98 { |
99 r = pixel[y * _width + x].r; | 99 r = pixel[y * _width + x].r; |
100 g = pixel[y * _width + x].g; | 100 g = pixel[y * _width + x].g; |
101 b = pixel[y * _width + x].b; | 101 b = pixel[y * _width + x].b; |
102 } | 102 } |
103 | 103 |
104 u8 get_r(int x, int y) const | 104 uint8_t get_r(int x, int y) const |
105 { | 105 { |
106 return pixel[y * _width + x].r; | 106 return pixel[y * _width + x].r; |
107 } | 107 } |
108 | 108 |
109 u8 get_g(int x, int y) const | 109 uint8_t get_g(int x, int y) const |
110 { | 110 { |
111 return pixel[y * _width + x].g; | 111 return pixel[y * _width + x].g; |
112 } | 112 } |
113 | 113 |
114 u8 get_b(int x, int y) const | 114 uint8_t get_b(int x, int y) const |
115 { | 115 { |
116 return pixel[y * _width + x].b; | 116 return pixel[y * _width + x].b; |
117 } | 117 } |
118 | 118 |
119 void set(int x, int y, u8 r, u8 g, u8 b) | 119 void set(int x, int y, uint8_t r, uint8_t g, uint8_t b) |
120 { | 120 { |
121 pixel[y * _width + x].r = r; | 121 pixel[y * _width + x].r = r; |
122 pixel[y * _width + x].g = g; | 122 pixel[y * _width + x].g = g; |
123 pixel[y * _width + x].b = b; | 123 pixel[y * _width + x].b = b; |
124 } | 124 } |
125 | 125 |
126 void set_r(int x, int y, u8 r) | 126 void set_r(int x, int y, uint8_t r) |
127 { | 127 { |
128 pixel[y * _width + x].r = r; | 128 pixel[y * _width + x].r = r; |
129 } | 129 } |
130 | 130 |
131 void set_g(int x, int y, u8 g) | 131 void set_g(int x, int y, uint8_t g) |
132 { | 132 { |
133 pixel[y * _width + x].g = g; | 133 pixel[y * _width + x].g = g; |
134 } | 134 } |
135 | 135 |
136 void set_b(int x, int y, u8 b) | 136 void set_b(int x, int y, uint8_t b) |
137 { | 137 { |
138 pixel[y * _width + x].b = b; | 138 pixel[y * _width + x].b = b; |
139 } | 139 } |
140 | 140 |
141 private: | 141 private: |