Fawkes API Fawkes Development Version
rgb.h
1
2/***************************************************************************
3 * rgb.h - RGB specific methods, macros and constants
4 *
5 * Created: Sat Aug 12 14:58:02 2006
6 * based on colorspaces.h from Tue Feb 23 13:49:38 2005
7 * Copyright 2005-2006 Tim Niemueller [www.niemueller.de]
8 *
9 ****************************************************************************/
10
11/* This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version. A runtime exception applies to
15 * this software (see LICENSE.GPL_WRE file mentioned below for details).
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
21 *
22 * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
23 */
24
25#ifndef FIREVISION_UTILS_COLOR_RGB_H_
26#define FIREVISION_UTILS_COLOR_RGB_H_
27
28namespace firevision {
29
30#define RGB_PIXEL_SIZE 3
31#define RGB_PIXEL_AT(RGB, width, x, y) \
32 ((RGB_t *)(RGB + ((y) * (width)*RGB_PIXEL_SIZE) + (x)*RGB_PIXEL_SIZE))
33#define RGB_CLEAR_PIXEL(RGB, width, x, y) \
34 memset(RGB + ((y) * (width)*RGB_PIXEL_SIZE) + (x)*RGB_PIXEL_SIZE, 0, RGB_PIXEL_SIZE);
35#define RGB_RED_AT(RGB, width, x, y) (RGB_PIXEL_AT(RGB, (width), (x), (y))->R)
36#define RGB_GREEN_AT(RGB, width, x, y) (RGB_PIXEL_AT(RGB, (width), (x), (y))->G)
37#define RGB_BLUE_AT(RGB, width, x, y) (RGB_PIXEL_AT(RGB, (width), (x), (y))->B)
38#define RGB_SET_RED(RGB, width, x, y) \
39 { \
40 RGB_t *p = RGB_PIXEL_AT(RGB, (width), (x), (y)); \
41 p->R = 255; \
42 p->G = 0; \
43 p->B = 0; \
44 }
45#define RGB_SET_GREEN(RGB, width, x, y) \
46 { \
47 RGB_t *p = RGB_PIXEL_AT(RGB, (width), (x), (y)); \
48 p->R = 0; \
49 p->G = 255; \
50 p->B = 0; \
51 }
52#define RGB_SET_BLUE(RGB, width, x, y) \
53 { \
54 RGB_t *p = RGB_PIXEL_AT(RGB, (width), (x), (y)); \
55 p->R = 0; \
56 p->G = 0; \
57 p->B = 255; \
58 }
59
60/** Structure defining an RGB pixel (in R-G-B byte ordering). */
61typedef struct
62{
63 unsigned char R; /**< R value */
64 unsigned char G; /**< G value */
65 unsigned char B; /**< B value */
66} RGB_t;
67
68/** Structure defining an RGB pixel (in B-G-R byte ordering). */
69typedef struct
70{
71 unsigned char B; /**< B value */
72 unsigned char G; /**< G value */
73 unsigned char R; /**< R value */
74} BGR_t;
75
76void rgb_to_rgb_with_alpha_plainc(const unsigned char *rgb,
77 unsigned char * rgb_alpha,
78 unsigned int width,
79 unsigned int height);
80
81void rgb_to_rgb_planar_plainc(const unsigned char *rgb,
82 unsigned char * rgb_planar,
83 const unsigned int width,
84 const unsigned int height);
85
86void rgb_planar_to_rgb_plainc(const unsigned char *rgb_planar,
87 unsigned char * rgb,
88 const unsigned int width,
89 const unsigned int height);
90
91void rgb_to_bgr_with_alpha_plainc(const unsigned char *rgb,
92 unsigned char * bgr_alpha,
93 unsigned int width,
94 unsigned int height);
95
96void gray8_to_rgb_plainc(const unsigned char *mono8,
97 unsigned char * rgb,
98 unsigned int width,
99 unsigned int height);
100
101void rgb_to_rgbfloat(const unsigned char *rgb,
102 unsigned char * rgb_float,
103 unsigned int width,
104 unsigned int height);
105
106void rgbfloat_to_rgb(const unsigned char *rgb_float,
107 unsigned char * rgb,
108 unsigned int width,
109 unsigned int height);
110
111void bgr_to_rgb_plainc(const unsigned char *BGR,
112 unsigned char * RGB,
113 unsigned int width,
114 unsigned int height);
115
116void convert_line_bgr_rgb(const unsigned char *BGR,
117 unsigned char * RGB,
118 unsigned int width,
119 unsigned int height);
120
121} // end namespace firevision
122
123#endif
Structure defining an RGB pixel (in B-G-R byte ordering).
Definition: rgb.h:70
unsigned char G
G value.
Definition: rgb.h:72
unsigned char B
B value.
Definition: rgb.h:71
unsigned char R
R value.
Definition: rgb.h:73
Structure defining an RGB pixel (in R-G-B byte ordering).
Definition: rgb.h:62
unsigned char G
G value.
Definition: rgb.h:64
unsigned char R
R value.
Definition: rgb.h:63
unsigned char B
B value.
Definition: rgb.h:65