Stefan Schuermans commited on 2016-12-21 10:31:43
Showing 8 changed files, with 103 additions and 25 deletions.
| ... | ... |
@@ -85,7 +85,8 @@ int main(int argc, char *argv[]) |
| 85 | 85 |
for (i = 0; i < 5; ++i) {
|
| 86 | 86 |
|
| 87 | 87 |
printf("on\n");
|
| 88 |
- flp_display_data(p_display, white, 0, 0, 0, 0, width, height); |
|
| 88 |
+ flp_display_data_fmt(p_display, white, 0, 0, 0, 0, width, height, |
|
| 89 |
+ flp_pixfmt_rgb24); |
|
| 89 | 90 |
flp_display_send(p_display); |
| 90 | 91 |
usleep(100000); |
| 91 | 92 |
|
| ... | ... |
@@ -125,10 +125,10 @@ int main(int argc, char *argv[]) |
| 125 | 125 |
} |
| 126 | 126 |
|
| 127 | 127 |
/* set new image */ |
| 128 |
- flp_displayer_data(p_displayer, p_image, |
|
| 128 |
+ flp_displayer_data_fmt(p_displayer, p_image, |
|
| 129 | 129 |
3, /* consecutive pixels are 3 bytes apart */ |
| 130 |
- width*3, /* consecutive lines are width*3 bytes apart */ |
|
| 131 |
- 0, 0, width, height); |
|
| 130 |
+ width*3, /* consecutive lines width*3 bytes apart */ |
|
| 131 |
+ 0, 0, width, height, flp_pixfmt_rgb24); |
|
| 132 | 132 |
/* force sending data to distris immediately */ |
| 133 | 133 |
flp_displayer_send(p_displayer); |
| 134 | 134 |
|
| ... | ... |
@@ -100,10 +100,10 @@ int main(int argc, char *argv[]) |
| 100 | 100 |
} |
| 101 | 101 |
|
| 102 | 102 |
/* output image */ |
| 103 |
- flp_display_data(p_display, p_image, |
|
| 103 |
+ flp_display_data_fmt(p_display, p_image, |
|
| 104 | 104 |
3, /* consecutive pixels are 3 bytes apart */ |
| 105 | 105 |
width*3, /* consecutive lines are width*3 bytes apart */ |
| 106 |
- 0, 0, width, height); |
|
| 106 |
+ 0, 0, width, height, flp_pixfmt_rgb24); |
|
| 107 | 107 |
flp_display_send(p_display); |
| 108 | 108 |
|
| 109 | 109 |
free(p_image); |
| ... | ... |
@@ -72,14 +72,26 @@ void flp_display_data_clear(flp_display_t *p_display); |
| 72 | 72 |
* flp_display_send() |
| 73 | 73 |
* |
| 74 | 74 |
* \param[in] p_display pointer to FlexiPix display |
| 75 |
- * \param[in] p_data pointer to rectangular section of image data, |
|
| 76 |
- * pixels need to be in R8G8B8 format |
|
| 75 |
+ * \param[in] p_data pointer to rectangular section of image data |
|
| 77 | 76 |
* \param[in] stride_x stride between two pixels in X direction |
| 78 | 77 |
* \param[in] stride_y stride between two pixels in Y direction |
| 79 | 78 |
* \param[in] x X coordinate of left side of rectangular area |
| 80 | 79 |
* \param[in] y Y coordinate of top side of rectangular area |
| 81 | 80 |
* \param[in] width with of rectangular area |
| 82 | 81 |
* \param[in] height height of rectangular area |
| 82 |
+ * \param[in] pixfmt format of pixel data |
|
| 83 |
+ */ |
|
| 84 |
+void flp_display_data_fmt(flp_display_t *p_display, flp_u8_t *p_data, |
|
| 85 |
+ int stride_x, int stride_y, |
|
| 86 |
+ unsigned int x, unsigned int y, |
|
| 87 |
+ unsigned int width, unsigned int height, |
|
| 88 |
+ flp_pixfmt_t pixfmt); |
|
| 89 |
+ |
|
| 90 |
+/** |
|
| 91 |
+ * \brief set image data to output on FlexiPix display |
|
| 92 |
+ * |
|
| 93 |
+ * see flp_display_data_fmt for documentation |
|
| 94 |
+ * pixfmt is fixed to flp_pixfmt_rgb24 |
|
| 83 | 95 |
*/ |
| 84 | 96 |
void flp_display_data(flp_display_t *p_display, flp_u8_t *p_data, |
| 85 | 97 |
int stride_x, int stride_y, |
| ... | ... |
@@ -97,14 +97,26 @@ void flp_displayer_data_clear(flp_displayer_t *p_displayer); |
| 97 | 97 |
* updates (part of) the stored image data |
| 98 | 98 |
* |
| 99 | 99 |
* \param[in] p_displayer pointer to FlexiPix displayer |
| 100 |
- * \param[in] p_data pointer to rectangular section of image data, |
|
| 101 |
- * pixels need to be in R8G8B8 format |
|
| 100 |
+ * \param[in] p_data pointer to rectangular section of image data |
|
| 102 | 101 |
* \param[in] stride_x stride between two pixels in X direction |
| 103 | 102 |
* \param[in] stride_y stride between two pixels in Y direction |
| 104 | 103 |
* \param[in] x X coordinate of left side of rectangular area |
| 105 | 104 |
* \param[in] y Y coordinate of top side of rectangular area |
| 106 | 105 |
* \param[in] width with of rectangular area |
| 107 | 106 |
* \param[in] height height of rectangular area |
| 107 |
+ * \param[in] pixfmt format of pixel data |
|
| 108 |
+ */ |
|
| 109 |
+void flp_displayer_data_fmt(flp_displayer_t *p_displayer, flp_u8_t *p_data, |
|
| 110 |
+ int stride_x, int stride_y, |
|
| 111 |
+ unsigned int x, unsigned int y, |
|
| 112 |
+ unsigned int width, unsigned int height, |
|
| 113 |
+ flp_pixfmt_t pixfmt); |
|
| 114 |
+ |
|
| 115 |
+/** |
|
| 116 |
+ * \brief set image data to output on FlexiPix display |
|
| 117 |
+ * |
|
| 118 |
+ * see flp_displayer_data_fmt for documentation |
|
| 119 |
+ * pixfmt is fixed to flp_pixfmt_rgb24 |
|
| 108 | 120 |
*/ |
| 109 | 121 |
void flp_displayer_data(flp_displayer_t *p_displayer, flp_u8_t *p_data, |
| 110 | 122 |
int stride_x, int stride_y, |
| ... | ... |
@@ -28,6 +28,12 @@ typedef uint8_t flp_u8_t; |
| 28 | 28 |
/** a FlexiPix display */ |
| 29 | 29 |
typedef struct flp_display_s flp_display_t; |
| 30 | 30 |
|
| 31 |
+/** format of pixel data */ |
|
| 32 |
+typedef enum flp_pixfmt_e {
|
|
| 33 |
+ flp_pixfmt_rgb24, /**< 24 bit RGB data, 3 bytes: red, green, blue */ |
|
| 34 |
+ flp_pixfmt_bgr24, /**< 24 bit BGR data, 3 bytes: blue, green, red */ |
|
| 35 |
+} flp_pixfmt_t; |
|
| 36 |
+ |
|
| 31 | 37 |
/** |
| 32 | 38 |
* \brief a displayer |
| 33 | 39 |
* |
| ... | ... |
@@ -169,8 +169,9 @@ void flp_display_get_size(flp_display_t *p_display, |
| 169 | 169 |
void flp_display_data_clear(flp_display_t *p_display) |
| 170 | 170 |
{
|
| 171 | 171 |
flp_u8_t black[3] = { 0, 0, 0 };
|
| 172 |
- flp_display_data(p_display, black, 0, 0, |
|
| 173 |
- 0, 0, p_display->size.x, p_display->size.y); |
|
| 172 |
+ flp_display_data_fmt(p_display, black, 0, 0, |
|
| 173 |
+ 0, 0, p_display->size.x, p_display->size.y, |
|
| 174 |
+ flp_pixfmt_rgb24); |
|
| 174 | 175 |
} |
| 175 | 176 |
|
| 176 | 177 |
/** |
| ... | ... |
@@ -181,21 +182,22 @@ void flp_display_data_clear(flp_display_t *p_display) |
| 181 | 182 |
* flp_display_send() |
| 182 | 183 |
* |
| 183 | 184 |
* \param[in] p_display pointer to FlexiPix display |
| 184 |
- * \param[in] p_data pointer to rectangular section of image data, |
|
| 185 |
- * pixels need to be in R8G8B8 format |
|
| 185 |
+ * \param[in] p_data pointer to rectangular section of image data |
|
| 186 | 186 |
* \param[in] stride_x stride between two pixels in X direction |
| 187 | 187 |
* \param[in] stride_y stride between two pixels in Y direction |
| 188 | 188 |
* \param[in] x X coordinate of left side of rectangular area |
| 189 | 189 |
* \param[in] y Y coordinate of top side of rectangular area |
| 190 | 190 |
* \param[in] width with of rectangular area |
| 191 | 191 |
* \param[in] height height of rectangular area |
| 192 |
+ * \param[in] pixfmt format of pixel data |
|
| 192 | 193 |
*/ |
| 193 |
-void flp_display_data(flp_display_t *p_display, flp_u8_t *p_data, |
|
| 194 |
+void flp_display_data_fmt(flp_display_t *p_display, flp_u8_t *p_data, |
|
| 194 | 195 |
int stride_x, int stride_y, |
| 195 | 196 |
unsigned int x, unsigned int y, |
| 196 |
- unsigned int width, unsigned int height) |
|
| 197 |
+ unsigned int width, unsigned int height, |
|
| 198 |
+ flp_pixfmt_t pixfmt) |
|
| 197 | 199 |
{
|
| 198 |
- unsigned int distri, out, pix, i, c; |
|
| 200 |
+ unsigned int distri, out, pix, i; |
|
| 199 | 201 |
flp_distri_t *p_distri; |
| 200 | 202 |
flp_u8_t *dest, *src; |
| 201 | 203 |
flp_pixel_t *p_pixel; |
| ... | ... |
@@ -223,8 +225,22 @@ void flp_display_data(flp_display_t *p_display, flp_u8_t *p_data, |
| 223 | 225 |
&& ry >= 0 && (unsigned int)ry < height) {
|
| 224 | 226 |
/* get pixel data and map it */ |
| 225 | 227 |
src = (p_data + rx * stride_x + ry * stride_y); |
| 226 |
- for (c = 0; c < 3; c++) |
|
| 227 |
- dest[c] = p_distri->mapping[c].table[src[c]]; |
|
| 228 |
+ switch (pixfmt) {
|
|
| 229 |
+ case flp_pixfmt_rgb24: |
|
| 230 |
+ dest[0] = p_distri->mapping[0].table[src[0]]; |
|
| 231 |
+ dest[1] = p_distri->mapping[1].table[src[1]]; |
|
| 232 |
+ dest[2] = p_distri->mapping[2].table[src[2]]; |
|
| 233 |
+ break; |
|
| 234 |
+ case flp_pixfmt_bgr24: |
|
| 235 |
+ dest[0] = p_distri->mapping[0].table[src[2]]; |
|
| 236 |
+ dest[1] = p_distri->mapping[1].table[src[1]]; |
|
| 237 |
+ dest[2] = p_distri->mapping[2].table[src[0]]; |
|
| 238 |
+ break; |
|
| 239 |
+ default: |
|
| 240 |
+ dest[0] = 0; |
|
| 241 |
+ dest[1] = 0; |
|
| 242 |
+ dest[2] = 0; |
|
| 243 |
+ } |
|
| 228 | 244 |
} |
| 229 | 245 |
|
| 230 | 246 |
dest += 3; |
| ... | ... |
@@ -235,6 +251,21 @@ void flp_display_data(flp_display_t *p_display, flp_u8_t *p_data, |
| 235 | 251 |
} /* for (distri ...) */ |
| 236 | 252 |
} |
| 237 | 253 |
|
| 254 |
+/** |
|
| 255 |
+ * \brief set image data to output on FlexiPix display |
|
| 256 |
+ * |
|
| 257 |
+ * see flp_display_data_fmt for documentation |
|
| 258 |
+ * pixfmt is fixed to flp_pixfmt_rgb24 |
|
| 259 |
+ */ |
|
| 260 |
+void flp_display_data(flp_display_t *p_display, flp_u8_t *p_data, |
|
| 261 |
+ int stride_x, int stride_y, |
|
| 262 |
+ unsigned int x, unsigned int y, |
|
| 263 |
+ unsigned int width, unsigned int height) |
|
| 264 |
+{
|
|
| 265 |
+ flp_display_data_fmt(p_display, p_data, stride_x, stride_y, |
|
| 266 |
+ x, y, width, height, flp_pixfmt_rgb24); |
|
| 267 |
+} |
|
| 268 |
+ |
|
| 238 | 269 |
/** |
| 239 | 270 |
* \brief send image data to distributors |
| 240 | 271 |
* |
| ... | ... |
@@ -202,26 +202,42 @@ void flp_displayer_data_clear(flp_displayer_t *p_displayer) |
| 202 | 202 |
* updates (part of) the stored image data |
| 203 | 203 |
* |
| 204 | 204 |
* \param[in] p_displayer pointer to FlexiPix displayer |
| 205 |
- * \param[in] p_data pointer to rectangular section of image data, |
|
| 206 |
- * pixels need to be in R8G8B8 format |
|
| 205 |
+ * \param[in] p_data pointer to rectangular section of image data |
|
| 207 | 206 |
* \param[in] stride_x stride between two pixels in X direction |
| 208 | 207 |
* \param[in] stride_y stride between two pixels in Y direction |
| 209 | 208 |
* \param[in] x X coordinate of left side of rectangular area |
| 210 | 209 |
* \param[in] y Y coordinate of top side of rectangular area |
| 211 | 210 |
* \param[in] width with of rectangular area |
| 212 | 211 |
* \param[in] height height of rectangular area |
| 212 |
+ * \param[in] pixfmt format of pixel data |
|
| 213 | 213 |
*/ |
| 214 |
-void flp_displayer_data(flp_displayer_t *p_displayer, flp_u8_t *p_data, |
|
| 214 |
+void flp_displayer_data_fmt(flp_displayer_t *p_displayer, flp_u8_t *p_data, |
|
| 215 | 215 |
int stride_x, int stride_y, |
| 216 | 216 |
unsigned int x, unsigned int y, |
| 217 |
- unsigned int width, unsigned int height) |
|
| 217 |
+ unsigned int width, unsigned int height, |
|
| 218 |
+ flp_pixfmt_t pixfmt) |
|
| 218 | 219 |
{
|
| 219 | 220 |
flp_thread_mutex_lock(&p_displayer->mtx); |
| 220 |
- flp_display_data(p_displayer->p_display, p_data, stride_x, stride_y, |
|
| 221 |
- x, y, width, height); |
|
| 221 |
+ flp_display_data_fmt(p_displayer->p_display, p_data, stride_x, stride_y, |
|
| 222 |
+ x, y, width, height, pixfmt); |
|
| 222 | 223 |
flp_thread_mutex_unlock(&p_displayer->mtx); |
| 223 | 224 |
} |
| 224 | 225 |
|
| 226 |
+/** |
|
| 227 |
+ * \brief set image data to output on FlexiPix display |
|
| 228 |
+ * |
|
| 229 |
+ * see flp_displayer_data_fmt for documentation |
|
| 230 |
+ * pixfmt is fixed to flp_pixfmt_rgb24 |
|
| 231 |
+ */ |
|
| 232 |
+void flp_displayer_data(flp_displayer_t *p_displayer, flp_u8_t *p_data, |
|
| 233 |
+ int stride_x, int stride_y, |
|
| 234 |
+ unsigned int x, unsigned int y, |
|
| 235 |
+ unsigned int width, unsigned int height) |
|
| 236 |
+{
|
|
| 237 |
+ flp_displayer_data_fmt(p_displayer, p_data, stride_x, stride_y, |
|
| 238 |
+ x, y, width, height, flp_pixfmt_rgb24); |
|
| 239 |
+} |
|
| 240 |
+ |
|
| 225 | 241 |
/** |
| 226 | 242 |
* \brief trigger immediate sending of new image data to distributors |
| 227 | 243 |
* |
| 228 | 244 |