Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
color.h
Go to the documentation of this file.
1
11#ifndef __COLOR_H__
12#define __COLOR_H__
13
14#ifdef __cplusplus
15extern "C" {
16#endif /* __cplusplus */
17
18#include <inttypes.h>
19
27typedef struct {
28 uint16_t red;
29 uint16_t green;
30 uint16_t blue;
31} color_t;
32
33/*
34 * Extract the red, green, and blue components of a 24-bit RGB value
35 * and convert them from [0,255] to [0,65535]. Colors are 16 bits
36 * because that's what GdkColor used.
37 * We might want to use a more standard, copy+paste-able color scheme
38 * such as #RRGGBB instead.
39 */
40#define RED_COMPONENT(x) (uint16_t) (((((x) >> 16) & 0xff) * 65535 / 255))
41#define GREEN_COMPONENT(x) (uint16_t) (((((x) >> 8) & 0xff) * 65535 / 255))
42#define BLUE_COMPONENT(x) (uint16_t) ( (((x) & 0xff) * 65535 / 255))
43
53inline static unsigned int
54color_t_to_rgb(const color_t *color) {
55 return (((color->red >> 8) << 16)
56 | ((color->green >> 8) << 8)
57 | (color->blue >> 8));
58}
59
60#ifdef __cplusplus
61}
62#endif /* __cplusplus */
63
64#endif
65
66/*
67 * Editor modelines - https://www.wireshark.org/tools/modelines.html
68 *
69 * Local variables:
70 * c-basic-offset: 4
71 * tab-width: 8
72 * indent-tabs-mode: nil
73 * End:
74 *
75 * vi: set shiftwidth=4 tabstop=8 expandtab:
76 * :indentSize=4:tabSize=8:noTabs=true:
77 */
RGB color representation with 16-bit precision per channel.
Definition color.h:27
uint16_t red
Definition color.h:28
uint16_t blue
Definition color.h:30
uint16_t green
Definition color.h:29