1
/* -*- c-basic-offset: 8 -*-
2
FreeRDP: A Remote Desktop Protocol client.
3
GDI Color Conversion Routines
5
Copyright (C) Marc-Andre Moreau <marcandre.moreau@gmail.com> 2010
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25
#include "libfreerdpgdi.h"
27
/* COLORREF (RGB 24) */
29
#define RGB(_r, _g, _b) \
30
(0xFF << 24) | (_r << 16) | (_g << 8) | _b;
32
#define PixelRGB(_pixel) \
33
(_pixel.red << 16) | (_pixel.green << 8) | _pixel.blue
35
#define GetRGB(_r, _g, _b, _p) \
36
_r = (_p & 0xFF0000) >> 16; \
37
_g = (_p & 0xFF00) >> 8; \
40
/* RGB 15 (RGB_555) */
42
#define RGB15(_r, _g, _b) \
43
(_r << 10) | (_g << 5) | _b;
45
#define GetRGB15(_r, _g, _b, _p) \
46
_r = (_p & 0x7C00) >> 10; \
47
_g = (_p & 0x3E0) >> 5; \
50
/* BGR 15 (BGR_555) */
52
#define BGR15(_r, _g, _b) \
53
(_b << 10) | (_g << 5) | _r;
55
#define GetBGR15(_r, _g, _b, _p) \
56
_b = ((_p << 3) & 0xF8) | ((_p >> 2) & 0x7); \
57
_g = ((_p >> 2) & 0xF8) | ((_p >> 8) & 0x7); \
58
_r = ((_p >> 7) & 0xF8) | ((_p >> 12) & 0x7);
60
/* RGB 16 (RGB_565) */
62
#define RGB16(_r, _g, _b) \
63
(_r << 11) | (_g << 5) | _b;
65
#define GetRGB16(_r, _g, _b, _p) \
66
_r = (_p & 0xF800) >> 11; \
67
_g = (_p & 0x7E0) >> 5; \
70
/* BGR 16 (BGR_565) */
72
#define BGR16(_r, _g, _b) \
73
(_b << 11) | (_g << 5) | _r;
75
#define GetBGR16(_r, _g, _b, _p) \
76
_b = ((_p << 3) & 0xF8) | ((_p >> 2) & 0x7); \
77
_g = ((_p >> 3) & 0xFC) | ((_p >> 9) & 0x3); \
78
_r = ((_p >> 8) & 0xF8) | ((_p >> 13) & 0x7);
80
/* RGB 24 (RGB_888) */
82
#define RGB24(_r, _g, _b) \
83
(_r << 16) | (_g << 8) | _b;
85
#define GetRGB24(_r, _g, _b, _p) \
86
_r = (_p & 0xFF0000) >> 16; \
87
_g = (_p & 0xFF00) >> 8; \
90
/* BGR 24 (BGR_888) */
92
#define BGR24(_r, _g, _b) \
93
(_b << 16) | (_g << 8) | _r;
95
#define GetBGR24(_r, _g, _b, _p) \
96
_b = (_p & 0xFF0000) >> 16; \
97
_g = (_p & 0xFF00) >> 8; \
100
/* RGB 32 (ARGB_8888), alpha ignored */
102
#define RGB32(_r, _g, _b) \
103
(0xFF << 24) | (_r << 16) | (_g << 8) | _b;
105
#define GetRGB32(_r, _g, _b, _p) \
106
_r = (_p & 0xFF0000) >> 16; \
107
_g = (_p & 0xFF00) >> 8; \
110
/* ARGB 32 (ARGB_8888) */
112
#define ARGB32(_a,_r, _g, _b) \
113
(_a << 24) | (_r << 16) | (_g << 8) | _b;
115
#define GetARGB32(_a, _r, _g, _b, _p) \
116
_a = (_p & 0xFF000000) >> 24; \
117
_r = (_p & 0xFF0000) >> 16; \
118
_g = (_p & 0xFF00) >> 8; \
121
/* BGR 32 (ABGR_8888), alpha ignored */
123
#define BGR32(_r, _g, _b) \
124
(_b << 16) | (_g << 8) | _r;
126
#define GetBGR32(_r, _g, _b, _p) \
127
_b = (_p & 0xFF0000) >> 16; \
128
_g = (_p & 0xFF00) >> 8; \
131
/* BGR 32 (ABGR_8888) */
133
#define ABGR32(_a, _r, _g, _b) \
134
(_a << 24) | (_b << 16) | (_g << 8) | _r;
136
#define GetABGR32(_a, _r, _g, _b, _p) \
137
_a = (_p & 0xFF000000) >> 24; \
138
_b = (_p & 0xFF0000) >> 16; \
139
_g = (_p & 0xFF00) >> 8; \
142
void gdi_color_convert(PIXEL *pixel, int color, int bpp, HPALETTE palette);
143
char* gdi_image_convert(char* srcData, int width, int height, int srcBpp, int dstBpp, HPALETTE palette);
144
char* gdi_glyph_convert(int width, int height, char* data);
146
#endif /* __GDI_COLOR_H */