GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
gp_convert.gen.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.1-or-later
2/*
3 * gp_convert.gen.h
4 *
5 * GENERATED on 2024 04 14 13:01:17 from gp_convert.gen.h.t
6 *
7 * DO NOT MODIFY THIS FILE DIRECTLY!
8 */
9#ifndef GP_CONVERT_GEN_H
10#define GP_CONVERT_GEN_H
11
12/*
13 * Copyright (C) 2011-2024 Cyril Hrubis <metan@ucw.cz>
14 * Copyright (C) 2011 Tomas Gavenciak <gavento@ucw.cz>
15 */
16
23#include <core/gp_pixmap.h>
24#include <core/gp_pixel.h>
25
26/*
27 * Converts RGB888 -> RGB101010
28 *
29 * macro reads p1 (RGB888 at bit-offset o1)
30 * and writes to p2 (RGB101010 at bit-offset o2)
31 * the relevant part of p2 is assumed to be cleared (zero)
32 */
33#define GP_PIXEL_RGB888_TO_RGB101010_OFFSET(p1, o1, p2, o2) do { \
34 /* R:=R */ GP_SET_BITS(20+o2, 10, p2,\
35 GP_SCALE_VAL_8_10(GP_GET_BITS(16+o1, 8, p1))); \
36 /* G:=G */ GP_SET_BITS(10+o2, 10, p2,\
37 GP_SCALE_VAL_8_10(GP_GET_BITS(8+o1, 8, p1))); \
38 /* B:=B */ GP_SET_BITS(0+o2, 10, p2,\
39 GP_SCALE_VAL_8_10(GP_GET_BITS(0+o1, 8, p1))); \
40} while (0)
41
42/* a version without offsets */
43#define GP_PIXEL_RGB888_TO_RGB101010(p1, p2) \
44 GP_PIXEL_RGB888_TO_RGB101010_OFFSET(p1, 0, p2, 0)
45
46/*
47 * Converts RGB101010 -> RGB888
48 *
49 * macro reads p1 (RGB101010 at bit-offset o1)
50 * and writes to p2 (RGB888 at bit-offset o2)
51 * the relevant part of p2 is assumed to be cleared (zero)
52 */
53#define GP_PIXEL_RGB101010_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
54 /* R:=R */ GP_SET_BITS(16+o2, 8, p2,\
55 GP_SCALE_VAL_10_8(GP_GET_BITS(20+o1, 10, p1))); \
56 /* G:=G */ GP_SET_BITS(8+o2, 8, p2,\
57 GP_SCALE_VAL_10_8(GP_GET_BITS(10+o1, 10, p1))); \
58 /* B:=B */ GP_SET_BITS(0+o2, 8, p2,\
59 GP_SCALE_VAL_10_8(GP_GET_BITS(0+o1, 10, p1))); \
60} while (0)
61
62/* a version without offsets */
63#define GP_PIXEL_RGB101010_TO_RGB888(p1, p2) \
64 GP_PIXEL_RGB101010_TO_RGB888_OFFSET(p1, 0, p2, 0)
65
66/*
67 * Converts RGB888 -> xRGB8888
68 *
69 * macro reads p1 (RGB888 at bit-offset o1)
70 * and writes to p2 (xRGB8888 at bit-offset o2)
71 * the relevant part of p2 is assumed to be cleared (zero)
72 */
73#define GP_PIXEL_RGB888_TO_xRGB8888_OFFSET(p1, o1, p2, o2) do { \
74 /* R:=R */ GP_SET_BITS(16+o2, 8, p2,\
75 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1))); \
76 /* G:=G */ GP_SET_BITS(8+o2, 8, p2,\
77 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
78 /* B:=B */ GP_SET_BITS(0+o2, 8, p2,\
79 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
80} while (0)
81
82/* a version without offsets */
83#define GP_PIXEL_RGB888_TO_xRGB8888(p1, p2) \
84 GP_PIXEL_RGB888_TO_xRGB8888_OFFSET(p1, 0, p2, 0)
85
86/*
87 * Converts xRGB8888 -> RGB888
88 *
89 * macro reads p1 (xRGB8888 at bit-offset o1)
90 * and writes to p2 (RGB888 at bit-offset o2)
91 * the relevant part of p2 is assumed to be cleared (zero)
92 */
93#define GP_PIXEL_xRGB8888_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
94 /* R:=R */ GP_SET_BITS(16+o2, 8, p2,\
95 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1))); \
96 /* G:=G */ GP_SET_BITS(8+o2, 8, p2,\
97 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
98 /* B:=B */ GP_SET_BITS(0+o2, 8, p2,\
99 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
100} while (0)
101
102/* a version without offsets */
103#define GP_PIXEL_xRGB8888_TO_RGB888(p1, p2) \
104 GP_PIXEL_xRGB8888_TO_RGB888_OFFSET(p1, 0, p2, 0)
105
106/*
107 * Converts RGB888 -> RGBA8888
108 *
109 * macro reads p1 (RGB888 at bit-offset o1)
110 * and writes to p2 (RGBA8888 at bit-offset o2)
111 * the relevant part of p2 is assumed to be cleared (zero)
112 */
113#define GP_PIXEL_RGB888_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
114 /* R:=R */ GP_SET_BITS(24+o2, 8, p2,\
115 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1))); \
116 /* G:=G */ GP_SET_BITS(16+o2, 8, p2,\
117 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
118 /* B:=B */ GP_SET_BITS(8+o2, 8, p2,\
119 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
120 /* A:=0xff */GP_SET_BITS(0+o2, 8, p2, 0xff); \
121} while (0)
122
123/* a version without offsets */
124#define GP_PIXEL_RGB888_TO_RGBA8888(p1, p2) \
125 GP_PIXEL_RGB888_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
126
127/*
128 * Converts RGB888 -> RGB888
129 *
130 * macro reads p1 (RGB888 at bit-offset o1)
131 * and writes to p2 (RGB888 at bit-offset o2)
132 * the relevant part of p2 is assumed to be cleared (zero)
133 */
134#define GP_PIXEL_RGB888_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
135 /* R:=R */ GP_SET_BITS(16+o2, 8, p2,\
136 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1))); \
137 /* G:=G */ GP_SET_BITS(8+o2, 8, p2,\
138 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
139 /* B:=B */ GP_SET_BITS(0+o2, 8, p2,\
140 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
141} while (0)
142
143/* a version without offsets */
144#define GP_PIXEL_RGB888_TO_RGB888(p1, p2) \
145 GP_PIXEL_RGB888_TO_RGB888_OFFSET(p1, 0, p2, 0)
146
147/*
148 * Converts RGB888 -> BGR888
149 *
150 * macro reads p1 (RGB888 at bit-offset o1)
151 * and writes to p2 (BGR888 at bit-offset o2)
152 * the relevant part of p2 is assumed to be cleared (zero)
153 */
154#define GP_PIXEL_RGB888_TO_BGR888_OFFSET(p1, o1, p2, o2) do { \
155 /* B:=B */ GP_SET_BITS(16+o2, 8, p2,\
156 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
157 /* G:=G */ GP_SET_BITS(8+o2, 8, p2,\
158 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
159 /* R:=R */ GP_SET_BITS(0+o2, 8, p2,\
160 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1))); \
161} while (0)
162
163/* a version without offsets */
164#define GP_PIXEL_RGB888_TO_BGR888(p1, p2) \
165 GP_PIXEL_RGB888_TO_BGR888_OFFSET(p1, 0, p2, 0)
166
167/*
168 * Converts BGR888 -> RGB888
169 *
170 * macro reads p1 (BGR888 at bit-offset o1)
171 * and writes to p2 (RGB888 at bit-offset o2)
172 * the relevant part of p2 is assumed to be cleared (zero)
173 */
174#define GP_PIXEL_BGR888_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
175 /* R:=R */ GP_SET_BITS(16+o2, 8, p2,\
176 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
177 /* G:=G */ GP_SET_BITS(8+o2, 8, p2,\
178 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
179 /* B:=B */ GP_SET_BITS(0+o2, 8, p2,\
180 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1))); \
181} while (0)
182
183/* a version without offsets */
184#define GP_PIXEL_BGR888_TO_RGB888(p1, p2) \
185 GP_PIXEL_BGR888_TO_RGB888_OFFSET(p1, 0, p2, 0)
186
187/*
188 * Converts RGB888 -> RGB555
189 *
190 * macro reads p1 (RGB888 at bit-offset o1)
191 * and writes to p2 (RGB555 at bit-offset o2)
192 * the relevant part of p2 is assumed to be cleared (zero)
193 */
194#define GP_PIXEL_RGB888_TO_RGB555_OFFSET(p1, o1, p2, o2) do { \
195 /* R:=R */ GP_SET_BITS(10+o2, 5, p2,\
196 GP_SCALE_VAL_8_5(GP_GET_BITS(16+o1, 8, p1))); \
197 /* G:=G */ GP_SET_BITS(5+o2, 5, p2,\
198 GP_SCALE_VAL_8_5(GP_GET_BITS(8+o1, 8, p1))); \
199 /* B:=B */ GP_SET_BITS(0+o2, 5, p2,\
200 GP_SCALE_VAL_8_5(GP_GET_BITS(0+o1, 8, p1))); \
201} while (0)
202
203/* a version without offsets */
204#define GP_PIXEL_RGB888_TO_RGB555(p1, p2) \
205 GP_PIXEL_RGB888_TO_RGB555_OFFSET(p1, 0, p2, 0)
206
207/*
208 * Converts RGB555 -> RGB888
209 *
210 * macro reads p1 (RGB555 at bit-offset o1)
211 * and writes to p2 (RGB888 at bit-offset o2)
212 * the relevant part of p2 is assumed to be cleared (zero)
213 */
214#define GP_PIXEL_RGB555_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
215 /* R:=R */ GP_SET_BITS(16+o2, 8, p2,\
216 GP_SCALE_VAL_5_8(GP_GET_BITS(10+o1, 5, p1))); \
217 /* G:=G */ GP_SET_BITS(8+o2, 8, p2,\
218 GP_SCALE_VAL_5_8(GP_GET_BITS(5+o1, 5, p1))); \
219 /* B:=B */ GP_SET_BITS(0+o2, 8, p2,\
220 GP_SCALE_VAL_5_8(GP_GET_BITS(0+o1, 5, p1))); \
221} while (0)
222
223/* a version without offsets */
224#define GP_PIXEL_RGB555_TO_RGB888(p1, p2) \
225 GP_PIXEL_RGB555_TO_RGB888_OFFSET(p1, 0, p2, 0)
226
227/*
228 * Converts RGB888 -> RGB565
229 *
230 * macro reads p1 (RGB888 at bit-offset o1)
231 * and writes to p2 (RGB565 at bit-offset o2)
232 * the relevant part of p2 is assumed to be cleared (zero)
233 */
234#define GP_PIXEL_RGB888_TO_RGB565_OFFSET(p1, o1, p2, o2) do { \
235 /* R:=R */ GP_SET_BITS(11+o2, 5, p2,\
236 GP_SCALE_VAL_8_5(GP_GET_BITS(16+o1, 8, p1))); \
237 /* G:=G */ GP_SET_BITS(5+o2, 6, p2,\
238 GP_SCALE_VAL_8_6(GP_GET_BITS(8+o1, 8, p1))); \
239 /* B:=B */ GP_SET_BITS(0+o2, 5, p2,\
240 GP_SCALE_VAL_8_5(GP_GET_BITS(0+o1, 8, p1))); \
241} while (0)
242
243/* a version without offsets */
244#define GP_PIXEL_RGB888_TO_RGB565(p1, p2) \
245 GP_PIXEL_RGB888_TO_RGB565_OFFSET(p1, 0, p2, 0)
246
247/*
248 * Converts RGB565 -> RGB888
249 *
250 * macro reads p1 (RGB565 at bit-offset o1)
251 * and writes to p2 (RGB888 at bit-offset o2)
252 * the relevant part of p2 is assumed to be cleared (zero)
253 */
254#define GP_PIXEL_RGB565_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
255 /* R:=R */ GP_SET_BITS(16+o2, 8, p2,\
256 GP_SCALE_VAL_5_8(GP_GET_BITS(11+o1, 5, p1))); \
257 /* G:=G */ GP_SET_BITS(8+o2, 8, p2,\
258 GP_SCALE_VAL_6_8(GP_GET_BITS(5+o1, 6, p1))); \
259 /* B:=B */ GP_SET_BITS(0+o2, 8, p2,\
260 GP_SCALE_VAL_5_8(GP_GET_BITS(0+o1, 5, p1))); \
261} while (0)
262
263/* a version without offsets */
264#define GP_PIXEL_RGB565_TO_RGB888(p1, p2) \
265 GP_PIXEL_RGB565_TO_RGB888_OFFSET(p1, 0, p2, 0)
266
267/*
268 * Converts RGB888 -> RGB666
269 *
270 * macro reads p1 (RGB888 at bit-offset o1)
271 * and writes to p2 (RGB666 at bit-offset o2)
272 * the relevant part of p2 is assumed to be cleared (zero)
273 */
274#define GP_PIXEL_RGB888_TO_RGB666_OFFSET(p1, o1, p2, o2) do { \
275 /* R:=R */ GP_SET_BITS(12+o2, 6, p2,\
276 GP_SCALE_VAL_8_6(GP_GET_BITS(16+o1, 8, p1))); \
277 /* G:=G */ GP_SET_BITS(6+o2, 6, p2,\
278 GP_SCALE_VAL_8_6(GP_GET_BITS(8+o1, 8, p1))); \
279 /* B:=B */ GP_SET_BITS(0+o2, 6, p2,\
280 GP_SCALE_VAL_8_6(GP_GET_BITS(0+o1, 8, p1))); \
281} while (0)
282
283/* a version without offsets */
284#define GP_PIXEL_RGB888_TO_RGB666(p1, p2) \
285 GP_PIXEL_RGB888_TO_RGB666_OFFSET(p1, 0, p2, 0)
286
287/*
288 * Converts RGB666 -> RGB888
289 *
290 * macro reads p1 (RGB666 at bit-offset o1)
291 * and writes to p2 (RGB888 at bit-offset o2)
292 * the relevant part of p2 is assumed to be cleared (zero)
293 */
294#define GP_PIXEL_RGB666_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
295 /* R:=R */ GP_SET_BITS(16+o2, 8, p2,\
296 GP_SCALE_VAL_6_8(GP_GET_BITS(12+o1, 6, p1))); \
297 /* G:=G */ GP_SET_BITS(8+o2, 8, p2,\
298 GP_SCALE_VAL_6_8(GP_GET_BITS(6+o1, 6, p1))); \
299 /* B:=B */ GP_SET_BITS(0+o2, 8, p2,\
300 GP_SCALE_VAL_6_8(GP_GET_BITS(0+o1, 6, p1))); \
301} while (0)
302
303/* a version without offsets */
304#define GP_PIXEL_RGB666_TO_RGB888(p1, p2) \
305 GP_PIXEL_RGB666_TO_RGB888_OFFSET(p1, 0, p2, 0)
306
307/*
308 * Converts RGB888 -> RGB332
309 *
310 * macro reads p1 (RGB888 at bit-offset o1)
311 * and writes to p2 (RGB332 at bit-offset o2)
312 * the relevant part of p2 is assumed to be cleared (zero)
313 */
314#define GP_PIXEL_RGB888_TO_RGB332_OFFSET(p1, o1, p2, o2) do { \
315 /* R:=R */ GP_SET_BITS(5+o2, 3, p2,\
316 GP_SCALE_VAL_8_3(GP_GET_BITS(16+o1, 8, p1))); \
317 /* G:=G */ GP_SET_BITS(2+o2, 3, p2,\
318 GP_SCALE_VAL_8_3(GP_GET_BITS(8+o1, 8, p1))); \
319 /* B:=B */ GP_SET_BITS(0+o2, 2, p2,\
320 GP_SCALE_VAL_8_2(GP_GET_BITS(0+o1, 8, p1))); \
321} while (0)
322
323/* a version without offsets */
324#define GP_PIXEL_RGB888_TO_RGB332(p1, p2) \
325 GP_PIXEL_RGB888_TO_RGB332_OFFSET(p1, 0, p2, 0)
326
327/*
328 * Converts RGB332 -> RGB888
329 *
330 * macro reads p1 (RGB332 at bit-offset o1)
331 * and writes to p2 (RGB888 at bit-offset o2)
332 * the relevant part of p2 is assumed to be cleared (zero)
333 */
334#define GP_PIXEL_RGB332_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
335 /* R:=R */ GP_SET_BITS(16+o2, 8, p2,\
336 GP_SCALE_VAL_3_8(GP_GET_BITS(5+o1, 3, p1))); \
337 /* G:=G */ GP_SET_BITS(8+o2, 8, p2,\
338 GP_SCALE_VAL_3_8(GP_GET_BITS(2+o1, 3, p1))); \
339 /* B:=B */ GP_SET_BITS(0+o2, 8, p2,\
340 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
341} while (0)
342
343/* a version without offsets */
344#define GP_PIXEL_RGB332_TO_RGB888(p1, p2) \
345 GP_PIXEL_RGB332_TO_RGB888_OFFSET(p1, 0, p2, 0)
346
347/*
348 * Converts RGB888 -> CMYK8888
349 *
350 * macro reads p1 (RGB888 at bit-offset o1)
351 * and writes to p2 (CMYK8888 at bit-offset o2)
352 * the relevant part of p2 is assumed to be cleared (zero)
353 */
354#define GP_PIXEL_RGB888_TO_CMYK8888_OFFSET(p1, o1, p2, o2) do { \
355 gp_pixel gp_r = GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1)); \
356 gp_pixel gp_g = GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1)); \
357 gp_pixel gp_b = GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1)); \
358 gp_pixel gp_k = GP_MAX3(gp_r, gp_g, gp_b); \
359 GP_SET_BITS(0+o2, 8, p2, GP_SCALE_VAL_8_8((gp_k - gp_r))); \
360 GP_SET_BITS(8+o2, 8, p2, GP_SCALE_VAL_8_8((gp_k - gp_g))); \
361 GP_SET_BITS(16+o2, 8, p2, GP_SCALE_VAL_8_8((gp_k - gp_b))); \
362 GP_SET_BITS(24+o2, 8, p2, GP_SCALE_VAL_8_8(255 - gp_k)); \
363} while (0)
364
365/* a version without offsets */
366#define GP_PIXEL_RGB888_TO_CMYK8888(p1, p2) \
367 GP_PIXEL_RGB888_TO_CMYK8888_OFFSET(p1, 0, p2, 0)
368
369/*
370 * Converts CMYK8888 -> RGB888
371 *
372 * macro reads p1 (CMYK8888 at bit-offset o1)
373 * and writes to p2 (RGB888 at bit-offset o2)
374 * the relevant part of p2 is assumed to be cleared (zero)
375 */
376#define GP_PIXEL_CMYK8888_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
377 GP_SET_BITS(16+o2, 8, p2,\
378 ((0xff * (0xff - GP_GET_BITS(24+o1, 8, p1)) * \
379 (0xff - GP_GET_BITS(0+o1, 8, p1)))) / (0xff * 0xff) \
380 ); \
381 GP_SET_BITS(8+o2, 8, p2,\
382 ((0xff * (0xff - GP_GET_BITS(24+o1, 8, p1)) * \
383 (0xff - GP_GET_BITS(8+o1, 8, p1)))) / (0xff * 0xff) \
384 ); \
385 GP_SET_BITS(0+o2, 8, p2,\
386 ((0xff * (0xff - GP_GET_BITS(24+o1, 8, p1)) * \
387 (0xff - GP_GET_BITS(16+o1, 8, p1)))) / (0xff * 0xff) \
388 ); \
389} while (0)
390
391/* a version without offsets */
392#define GP_PIXEL_CMYK8888_TO_RGB888(p1, p2) \
393 GP_PIXEL_CMYK8888_TO_RGB888_OFFSET(p1, 0, p2, 0)
394
395/*
396 * Converts RGB888 -> G1_DB
397 *
398 * macro reads p1 (RGB888 at bit-offset o1)
399 * and writes to p2 (G1_DB at bit-offset o2)
400 * the relevant part of p2 is assumed to be cleared (zero)
401 */
402#define GP_PIXEL_RGB888_TO_G1_DB_OFFSET(p1, o1, p2, o2) do { \
403 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 1, p2, ( \
404 /* R */ GP_SCALE_VAL_8_1(GP_GET_BITS(16+o1, 8, p1)) + \
405 /* G */ GP_SCALE_VAL_8_1(GP_GET_BITS(8+o1, 8, p1)) + \
406 /* B */ GP_SCALE_VAL_8_1(GP_GET_BITS(0+o1, 8, p1)) + \
407 0)/3);\
408} while (0)
409
410/* a version without offsets */
411#define GP_PIXEL_RGB888_TO_G1_DB(p1, p2) \
412 GP_PIXEL_RGB888_TO_G1_DB_OFFSET(p1, 0, p2, 0)
413
414/*
415 * Converts G1_DB -> RGB888
416 *
417 * macro reads p1 (G1_DB at bit-offset o1)
418 * and writes to p2 (RGB888 at bit-offset o2)
419 * the relevant part of p2 is assumed to be cleared (zero)
420 */
421#define GP_PIXEL_G1_DB_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
422 /* R:=V */ GP_SET_BITS(16+o2, 8, p2,\
423 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
424 /* G:=V */ GP_SET_BITS(8+o2, 8, p2,\
425 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
426 /* B:=V */ GP_SET_BITS(0+o2, 8, p2,\
427 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
428} while (0)
429
430/* a version without offsets */
431#define GP_PIXEL_G1_DB_TO_RGB888(p1, p2) \
432 GP_PIXEL_G1_DB_TO_RGB888_OFFSET(p1, 0, p2, 0)
433
434/*
435 * Converts RGB888 -> G2_DB
436 *
437 * macro reads p1 (RGB888 at bit-offset o1)
438 * and writes to p2 (G2_DB at bit-offset o2)
439 * the relevant part of p2 is assumed to be cleared (zero)
440 */
441#define GP_PIXEL_RGB888_TO_G2_DB_OFFSET(p1, o1, p2, o2) do { \
442 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 2, p2, ( \
443 /* R */ GP_SCALE_VAL_8_2(GP_GET_BITS(16+o1, 8, p1)) + \
444 /* G */ GP_SCALE_VAL_8_2(GP_GET_BITS(8+o1, 8, p1)) + \
445 /* B */ GP_SCALE_VAL_8_2(GP_GET_BITS(0+o1, 8, p1)) + \
446 0)/3);\
447} while (0)
448
449/* a version without offsets */
450#define GP_PIXEL_RGB888_TO_G2_DB(p1, p2) \
451 GP_PIXEL_RGB888_TO_G2_DB_OFFSET(p1, 0, p2, 0)
452
453/*
454 * Converts G2_DB -> RGB888
455 *
456 * macro reads p1 (G2_DB at bit-offset o1)
457 * and writes to p2 (RGB888 at bit-offset o2)
458 * the relevant part of p2 is assumed to be cleared (zero)
459 */
460#define GP_PIXEL_G2_DB_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
461 /* R:=V */ GP_SET_BITS(16+o2, 8, p2,\
462 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
463 /* G:=V */ GP_SET_BITS(8+o2, 8, p2,\
464 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
465 /* B:=V */ GP_SET_BITS(0+o2, 8, p2,\
466 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
467} while (0)
468
469/* a version without offsets */
470#define GP_PIXEL_G2_DB_TO_RGB888(p1, p2) \
471 GP_PIXEL_G2_DB_TO_RGB888_OFFSET(p1, 0, p2, 0)
472
473/*
474 * Converts RGB888 -> G4_DB
475 *
476 * macro reads p1 (RGB888 at bit-offset o1)
477 * and writes to p2 (G4_DB at bit-offset o2)
478 * the relevant part of p2 is assumed to be cleared (zero)
479 */
480#define GP_PIXEL_RGB888_TO_G4_DB_OFFSET(p1, o1, p2, o2) do { \
481 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 4, p2, ( \
482 /* R */ GP_SCALE_VAL_8_4(GP_GET_BITS(16+o1, 8, p1)) + \
483 /* G */ GP_SCALE_VAL_8_4(GP_GET_BITS(8+o1, 8, p1)) + \
484 /* B */ GP_SCALE_VAL_8_4(GP_GET_BITS(0+o1, 8, p1)) + \
485 0)/3);\
486} while (0)
487
488/* a version without offsets */
489#define GP_PIXEL_RGB888_TO_G4_DB(p1, p2) \
490 GP_PIXEL_RGB888_TO_G4_DB_OFFSET(p1, 0, p2, 0)
491
492/*
493 * Converts G4_DB -> RGB888
494 *
495 * macro reads p1 (G4_DB at bit-offset o1)
496 * and writes to p2 (RGB888 at bit-offset o2)
497 * the relevant part of p2 is assumed to be cleared (zero)
498 */
499#define GP_PIXEL_G4_DB_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
500 /* R:=V */ GP_SET_BITS(16+o2, 8, p2,\
501 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
502 /* G:=V */ GP_SET_BITS(8+o2, 8, p2,\
503 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
504 /* B:=V */ GP_SET_BITS(0+o2, 8, p2,\
505 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
506} while (0)
507
508/* a version without offsets */
509#define GP_PIXEL_G4_DB_TO_RGB888(p1, p2) \
510 GP_PIXEL_G4_DB_TO_RGB888_OFFSET(p1, 0, p2, 0)
511
512/*
513 * Converts RGB888 -> G1_UB
514 *
515 * macro reads p1 (RGB888 at bit-offset o1)
516 * and writes to p2 (G1_UB at bit-offset o2)
517 * the relevant part of p2 is assumed to be cleared (zero)
518 */
519#define GP_PIXEL_RGB888_TO_G1_UB_OFFSET(p1, o1, p2, o2) do { \
520 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 1, p2, ( \
521 /* R */ GP_SCALE_VAL_8_1(GP_GET_BITS(16+o1, 8, p1)) + \
522 /* G */ GP_SCALE_VAL_8_1(GP_GET_BITS(8+o1, 8, p1)) + \
523 /* B */ GP_SCALE_VAL_8_1(GP_GET_BITS(0+o1, 8, p1)) + \
524 0)/3);\
525} while (0)
526
527/* a version without offsets */
528#define GP_PIXEL_RGB888_TO_G1_UB(p1, p2) \
529 GP_PIXEL_RGB888_TO_G1_UB_OFFSET(p1, 0, p2, 0)
530
531/*
532 * Converts G1_UB -> RGB888
533 *
534 * macro reads p1 (G1_UB at bit-offset o1)
535 * and writes to p2 (RGB888 at bit-offset o2)
536 * the relevant part of p2 is assumed to be cleared (zero)
537 */
538#define GP_PIXEL_G1_UB_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
539 /* R:=V */ GP_SET_BITS(16+o2, 8, p2,\
540 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
541 /* G:=V */ GP_SET_BITS(8+o2, 8, p2,\
542 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
543 /* B:=V */ GP_SET_BITS(0+o2, 8, p2,\
544 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
545} while (0)
546
547/* a version without offsets */
548#define GP_PIXEL_G1_UB_TO_RGB888(p1, p2) \
549 GP_PIXEL_G1_UB_TO_RGB888_OFFSET(p1, 0, p2, 0)
550
551/*
552 * Converts RGB888 -> G2_UB
553 *
554 * macro reads p1 (RGB888 at bit-offset o1)
555 * and writes to p2 (G2_UB at bit-offset o2)
556 * the relevant part of p2 is assumed to be cleared (zero)
557 */
558#define GP_PIXEL_RGB888_TO_G2_UB_OFFSET(p1, o1, p2, o2) do { \
559 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 2, p2, ( \
560 /* R */ GP_SCALE_VAL_8_2(GP_GET_BITS(16+o1, 8, p1)) + \
561 /* G */ GP_SCALE_VAL_8_2(GP_GET_BITS(8+o1, 8, p1)) + \
562 /* B */ GP_SCALE_VAL_8_2(GP_GET_BITS(0+o1, 8, p1)) + \
563 0)/3);\
564} while (0)
565
566/* a version without offsets */
567#define GP_PIXEL_RGB888_TO_G2_UB(p1, p2) \
568 GP_PIXEL_RGB888_TO_G2_UB_OFFSET(p1, 0, p2, 0)
569
570/*
571 * Converts G2_UB -> RGB888
572 *
573 * macro reads p1 (G2_UB at bit-offset o1)
574 * and writes to p2 (RGB888 at bit-offset o2)
575 * the relevant part of p2 is assumed to be cleared (zero)
576 */
577#define GP_PIXEL_G2_UB_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
578 /* R:=V */ GP_SET_BITS(16+o2, 8, p2,\
579 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
580 /* G:=V */ GP_SET_BITS(8+o2, 8, p2,\
581 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
582 /* B:=V */ GP_SET_BITS(0+o2, 8, p2,\
583 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
584} while (0)
585
586/* a version without offsets */
587#define GP_PIXEL_G2_UB_TO_RGB888(p1, p2) \
588 GP_PIXEL_G2_UB_TO_RGB888_OFFSET(p1, 0, p2, 0)
589
590/*
591 * Converts RGB888 -> G4_UB
592 *
593 * macro reads p1 (RGB888 at bit-offset o1)
594 * and writes to p2 (G4_UB at bit-offset o2)
595 * the relevant part of p2 is assumed to be cleared (zero)
596 */
597#define GP_PIXEL_RGB888_TO_G4_UB_OFFSET(p1, o1, p2, o2) do { \
598 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 4, p2, ( \
599 /* R */ GP_SCALE_VAL_8_4(GP_GET_BITS(16+o1, 8, p1)) + \
600 /* G */ GP_SCALE_VAL_8_4(GP_GET_BITS(8+o1, 8, p1)) + \
601 /* B */ GP_SCALE_VAL_8_4(GP_GET_BITS(0+o1, 8, p1)) + \
602 0)/3);\
603} while (0)
604
605/* a version without offsets */
606#define GP_PIXEL_RGB888_TO_G4_UB(p1, p2) \
607 GP_PIXEL_RGB888_TO_G4_UB_OFFSET(p1, 0, p2, 0)
608
609/*
610 * Converts G4_UB -> RGB888
611 *
612 * macro reads p1 (G4_UB at bit-offset o1)
613 * and writes to p2 (RGB888 at bit-offset o2)
614 * the relevant part of p2 is assumed to be cleared (zero)
615 */
616#define GP_PIXEL_G4_UB_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
617 /* R:=V */ GP_SET_BITS(16+o2, 8, p2,\
618 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
619 /* G:=V */ GP_SET_BITS(8+o2, 8, p2,\
620 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
621 /* B:=V */ GP_SET_BITS(0+o2, 8, p2,\
622 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
623} while (0)
624
625/* a version without offsets */
626#define GP_PIXEL_G4_UB_TO_RGB888(p1, p2) \
627 GP_PIXEL_G4_UB_TO_RGB888_OFFSET(p1, 0, p2, 0)
628
629/*
630 * Converts RGB888 -> G8
631 *
632 * macro reads p1 (RGB888 at bit-offset o1)
633 * and writes to p2 (G8 at bit-offset o2)
634 * the relevant part of p2 is assumed to be cleared (zero)
635 */
636#define GP_PIXEL_RGB888_TO_G8_OFFSET(p1, o1, p2, o2) do { \
637 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 8, p2, ( \
638 /* R */ GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1)) + \
639 /* G */ GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1)) + \
640 /* B */ GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1)) + \
641 0)/3);\
642} while (0)
643
644/* a version without offsets */
645#define GP_PIXEL_RGB888_TO_G8(p1, p2) \
646 GP_PIXEL_RGB888_TO_G8_OFFSET(p1, 0, p2, 0)
647
648/*
649 * Converts RGB888 -> GA88
650 *
651 * macro reads p1 (RGB888 at bit-offset o1)
652 * and writes to p2 (GA88 at bit-offset o2)
653 * the relevant part of p2 is assumed to be cleared (zero)
654 */
655#define GP_PIXEL_RGB888_TO_GA88_OFFSET(p1, o1, p2, o2) do { \
656 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 8, p2, ( \
657 /* R */ GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1)) + \
658 /* G */ GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1)) + \
659 /* B */ GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1)) + \
660 0)/3);\
661 /* A:=0xff */GP_SET_BITS(8+o2, 8, p2, 0xff); \
662} while (0)
663
664/* a version without offsets */
665#define GP_PIXEL_RGB888_TO_GA88(p1, p2) \
666 GP_PIXEL_RGB888_TO_GA88_OFFSET(p1, 0, p2, 0)
667
668/*
669 * Converts GA88 -> RGB888
670 *
671 * macro reads p1 (GA88 at bit-offset o1)
672 * and writes to p2 (RGB888 at bit-offset o2)
673 * the relevant part of p2 is assumed to be cleared (zero)
674 */
675#define GP_PIXEL_GA88_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
676 /* R:=V */ GP_SET_BITS(16+o2, 8, p2,\
677 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
678 /* G:=V */ GP_SET_BITS(8+o2, 8, p2,\
679 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
680 /* B:=V */ GP_SET_BITS(0+o2, 8, p2,\
681 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
682} while (0)
683
684/* a version without offsets */
685#define GP_PIXEL_GA88_TO_RGB888(p1, p2) \
686 GP_PIXEL_GA88_TO_RGB888_OFFSET(p1, 0, p2, 0)
687
688/*
689 * Converts RGB888 -> G16
690 *
691 * macro reads p1 (RGB888 at bit-offset o1)
692 * and writes to p2 (G16 at bit-offset o2)
693 * the relevant part of p2 is assumed to be cleared (zero)
694 */
695#define GP_PIXEL_RGB888_TO_G16_OFFSET(p1, o1, p2, o2) do { \
696 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 16, p2, ( \
697 /* R */ GP_SCALE_VAL_8_16(GP_GET_BITS(16+o1, 8, p1)) + \
698 /* G */ GP_SCALE_VAL_8_16(GP_GET_BITS(8+o1, 8, p1)) + \
699 /* B */ GP_SCALE_VAL_8_16(GP_GET_BITS(0+o1, 8, p1)) + \
700 0)/3);\
701} while (0)
702
703/* a version without offsets */
704#define GP_PIXEL_RGB888_TO_G16(p1, p2) \
705 GP_PIXEL_RGB888_TO_G16_OFFSET(p1, 0, p2, 0)
706
707/*
708 * Converts G16 -> RGB888
709 *
710 * macro reads p1 (G16 at bit-offset o1)
711 * and writes to p2 (RGB888 at bit-offset o2)
712 * the relevant part of p2 is assumed to be cleared (zero)
713 */
714#define GP_PIXEL_G16_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
715 /* R:=V */ GP_SET_BITS(16+o2, 8, p2,\
716 GP_SCALE_VAL_16_8(GP_GET_BITS(0+o1, 16, p1))); \
717 /* G:=V */ GP_SET_BITS(8+o2, 8, p2,\
718 GP_SCALE_VAL_16_8(GP_GET_BITS(0+o1, 16, p1))); \
719 /* B:=V */ GP_SET_BITS(0+o2, 8, p2,\
720 GP_SCALE_VAL_16_8(GP_GET_BITS(0+o1, 16, p1))); \
721} while (0)
722
723/* a version without offsets */
724#define GP_PIXEL_G16_TO_RGB888(p1, p2) \
725 GP_PIXEL_G16_TO_RGB888_OFFSET(p1, 0, p2, 0)
726
727
739
751
752/*
753 * Converts RGBA8888 -> RGB101010
754 *
755 * macro reads p1 (RGBA8888 at bit-offset o1)
756 * and writes to p2 (RGB101010 at bit-offset o2)
757 * the relevant part of p2 is assumed to be cleared (zero)
758 */
759#define GP_PIXEL_RGBA8888_TO_RGB101010_OFFSET(p1, o1, p2, o2) do { \
760 /* R:=R */ GP_SET_BITS(20+o2, 10, p2,\
761 GP_SCALE_VAL_8_10(GP_GET_BITS(24+o1, 8, p1))); \
762 /* G:=G */ GP_SET_BITS(10+o2, 10, p2,\
763 GP_SCALE_VAL_8_10(GP_GET_BITS(16+o1, 8, p1))); \
764 /* B:=B */ GP_SET_BITS(0+o2, 10, p2,\
765 GP_SCALE_VAL_8_10(GP_GET_BITS(8+o1, 8, p1))); \
766} while (0)
767
768/* a version without offsets */
769#define GP_PIXEL_RGBA8888_TO_RGB101010(p1, p2) \
770 GP_PIXEL_RGBA8888_TO_RGB101010_OFFSET(p1, 0, p2, 0)
771
772/*
773 * Converts RGB101010 -> RGBA8888
774 *
775 * macro reads p1 (RGB101010 at bit-offset o1)
776 * and writes to p2 (RGBA8888 at bit-offset o2)
777 * the relevant part of p2 is assumed to be cleared (zero)
778 */
779#define GP_PIXEL_RGB101010_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
780 /* R:=R */ GP_SET_BITS(24+o2, 8, p2,\
781 GP_SCALE_VAL_10_8(GP_GET_BITS(20+o1, 10, p1))); \
782 /* G:=G */ GP_SET_BITS(16+o2, 8, p2,\
783 GP_SCALE_VAL_10_8(GP_GET_BITS(10+o1, 10, p1))); \
784 /* B:=B */ GP_SET_BITS(8+o2, 8, p2,\
785 GP_SCALE_VAL_10_8(GP_GET_BITS(0+o1, 10, p1))); \
786 /* A:=0xff */GP_SET_BITS(0+o2, 8, p2, 0xff); \
787} while (0)
788
789/* a version without offsets */
790#define GP_PIXEL_RGB101010_TO_RGBA8888(p1, p2) \
791 GP_PIXEL_RGB101010_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
792
793/*
794 * Converts RGBA8888 -> xRGB8888
795 *
796 * macro reads p1 (RGBA8888 at bit-offset o1)
797 * and writes to p2 (xRGB8888 at bit-offset o2)
798 * the relevant part of p2 is assumed to be cleared (zero)
799 */
800#define GP_PIXEL_RGBA8888_TO_xRGB8888_OFFSET(p1, o1, p2, o2) do { \
801 /* R:=R */ GP_SET_BITS(16+o2, 8, p2,\
802 GP_SCALE_VAL_8_8(GP_GET_BITS(24+o1, 8, p1))); \
803 /* G:=G */ GP_SET_BITS(8+o2, 8, p2,\
804 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1))); \
805 /* B:=B */ GP_SET_BITS(0+o2, 8, p2,\
806 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
807} while (0)
808
809/* a version without offsets */
810#define GP_PIXEL_RGBA8888_TO_xRGB8888(p1, p2) \
811 GP_PIXEL_RGBA8888_TO_xRGB8888_OFFSET(p1, 0, p2, 0)
812
813/*
814 * Converts xRGB8888 -> RGBA8888
815 *
816 * macro reads p1 (xRGB8888 at bit-offset o1)
817 * and writes to p2 (RGBA8888 at bit-offset o2)
818 * the relevant part of p2 is assumed to be cleared (zero)
819 */
820#define GP_PIXEL_xRGB8888_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
821 /* R:=R */ GP_SET_BITS(24+o2, 8, p2,\
822 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1))); \
823 /* G:=G */ GP_SET_BITS(16+o2, 8, p2,\
824 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
825 /* B:=B */ GP_SET_BITS(8+o2, 8, p2,\
826 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
827 /* A:=0xff */GP_SET_BITS(0+o2, 8, p2, 0xff); \
828} while (0)
829
830/* a version without offsets */
831#define GP_PIXEL_xRGB8888_TO_RGBA8888(p1, p2) \
832 GP_PIXEL_xRGB8888_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
833
834/*
835 * Converts RGBA8888 -> RGBA8888
836 *
837 * macro reads p1 (RGBA8888 at bit-offset o1)
838 * and writes to p2 (RGBA8888 at bit-offset o2)
839 * the relevant part of p2 is assumed to be cleared (zero)
840 */
841#define GP_PIXEL_RGBA8888_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
842 /* R:=R */ GP_SET_BITS(24+o2, 8, p2,\
843 GP_SCALE_VAL_8_8(GP_GET_BITS(24+o1, 8, p1))); \
844 /* G:=G */ GP_SET_BITS(16+o2, 8, p2,\
845 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1))); \
846 /* B:=B */ GP_SET_BITS(8+o2, 8, p2,\
847 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
848 /* A:=A */ GP_SET_BITS(0+o2, 8, p2,\
849 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
850} while (0)
851
852/* a version without offsets */
853#define GP_PIXEL_RGBA8888_TO_RGBA8888(p1, p2) \
854 GP_PIXEL_RGBA8888_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
855
856/*
857 * Converts RGBA8888 -> RGB888
858 *
859 * macro reads p1 (RGBA8888 at bit-offset o1)
860 * and writes to p2 (RGB888 at bit-offset o2)
861 * the relevant part of p2 is assumed to be cleared (zero)
862 */
863#define GP_PIXEL_RGBA8888_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
864 /* R:=R */ GP_SET_BITS(16+o2, 8, p2,\
865 GP_SCALE_VAL_8_8(GP_GET_BITS(24+o1, 8, p1))); \
866 /* G:=G */ GP_SET_BITS(8+o2, 8, p2,\
867 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1))); \
868 /* B:=B */ GP_SET_BITS(0+o2, 8, p2,\
869 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
870} while (0)
871
872/* a version without offsets */
873#define GP_PIXEL_RGBA8888_TO_RGB888(p1, p2) \
874 GP_PIXEL_RGBA8888_TO_RGB888_OFFSET(p1, 0, p2, 0)
875
876/*
877 * Converts RGBA8888 -> BGR888
878 *
879 * macro reads p1 (RGBA8888 at bit-offset o1)
880 * and writes to p2 (BGR888 at bit-offset o2)
881 * the relevant part of p2 is assumed to be cleared (zero)
882 */
883#define GP_PIXEL_RGBA8888_TO_BGR888_OFFSET(p1, o1, p2, o2) do { \
884 /* B:=B */ GP_SET_BITS(16+o2, 8, p2,\
885 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
886 /* G:=G */ GP_SET_BITS(8+o2, 8, p2,\
887 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1))); \
888 /* R:=R */ GP_SET_BITS(0+o2, 8, p2,\
889 GP_SCALE_VAL_8_8(GP_GET_BITS(24+o1, 8, p1))); \
890} while (0)
891
892/* a version without offsets */
893#define GP_PIXEL_RGBA8888_TO_BGR888(p1, p2) \
894 GP_PIXEL_RGBA8888_TO_BGR888_OFFSET(p1, 0, p2, 0)
895
896/*
897 * Converts BGR888 -> RGBA8888
898 *
899 * macro reads p1 (BGR888 at bit-offset o1)
900 * and writes to p2 (RGBA8888 at bit-offset o2)
901 * the relevant part of p2 is assumed to be cleared (zero)
902 */
903#define GP_PIXEL_BGR888_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
904 /* R:=R */ GP_SET_BITS(24+o2, 8, p2,\
905 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
906 /* G:=G */ GP_SET_BITS(16+o2, 8, p2,\
907 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
908 /* B:=B */ GP_SET_BITS(8+o2, 8, p2,\
909 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1))); \
910 /* A:=0xff */GP_SET_BITS(0+o2, 8, p2, 0xff); \
911} while (0)
912
913/* a version without offsets */
914#define GP_PIXEL_BGR888_TO_RGBA8888(p1, p2) \
915 GP_PIXEL_BGR888_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
916
917/*
918 * Converts RGBA8888 -> RGB555
919 *
920 * macro reads p1 (RGBA8888 at bit-offset o1)
921 * and writes to p2 (RGB555 at bit-offset o2)
922 * the relevant part of p2 is assumed to be cleared (zero)
923 */
924#define GP_PIXEL_RGBA8888_TO_RGB555_OFFSET(p1, o1, p2, o2) do { \
925 /* R:=R */ GP_SET_BITS(10+o2, 5, p2,\
926 GP_SCALE_VAL_8_5(GP_GET_BITS(24+o1, 8, p1))); \
927 /* G:=G */ GP_SET_BITS(5+o2, 5, p2,\
928 GP_SCALE_VAL_8_5(GP_GET_BITS(16+o1, 8, p1))); \
929 /* B:=B */ GP_SET_BITS(0+o2, 5, p2,\
930 GP_SCALE_VAL_8_5(GP_GET_BITS(8+o1, 8, p1))); \
931} while (0)
932
933/* a version without offsets */
934#define GP_PIXEL_RGBA8888_TO_RGB555(p1, p2) \
935 GP_PIXEL_RGBA8888_TO_RGB555_OFFSET(p1, 0, p2, 0)
936
937/*
938 * Converts RGB555 -> RGBA8888
939 *
940 * macro reads p1 (RGB555 at bit-offset o1)
941 * and writes to p2 (RGBA8888 at bit-offset o2)
942 * the relevant part of p2 is assumed to be cleared (zero)
943 */
944#define GP_PIXEL_RGB555_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
945 /* R:=R */ GP_SET_BITS(24+o2, 8, p2,\
946 GP_SCALE_VAL_5_8(GP_GET_BITS(10+o1, 5, p1))); \
947 /* G:=G */ GP_SET_BITS(16+o2, 8, p2,\
948 GP_SCALE_VAL_5_8(GP_GET_BITS(5+o1, 5, p1))); \
949 /* B:=B */ GP_SET_BITS(8+o2, 8, p2,\
950 GP_SCALE_VAL_5_8(GP_GET_BITS(0+o1, 5, p1))); \
951 /* A:=0xff */GP_SET_BITS(0+o2, 8, p2, 0xff); \
952} while (0)
953
954/* a version without offsets */
955#define GP_PIXEL_RGB555_TO_RGBA8888(p1, p2) \
956 GP_PIXEL_RGB555_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
957
958/*
959 * Converts RGBA8888 -> RGB565
960 *
961 * macro reads p1 (RGBA8888 at bit-offset o1)
962 * and writes to p2 (RGB565 at bit-offset o2)
963 * the relevant part of p2 is assumed to be cleared (zero)
964 */
965#define GP_PIXEL_RGBA8888_TO_RGB565_OFFSET(p1, o1, p2, o2) do { \
966 /* R:=R */ GP_SET_BITS(11+o2, 5, p2,\
967 GP_SCALE_VAL_8_5(GP_GET_BITS(24+o1, 8, p1))); \
968 /* G:=G */ GP_SET_BITS(5+o2, 6, p2,\
969 GP_SCALE_VAL_8_6(GP_GET_BITS(16+o1, 8, p1))); \
970 /* B:=B */ GP_SET_BITS(0+o2, 5, p2,\
971 GP_SCALE_VAL_8_5(GP_GET_BITS(8+o1, 8, p1))); \
972} while (0)
973
974/* a version without offsets */
975#define GP_PIXEL_RGBA8888_TO_RGB565(p1, p2) \
976 GP_PIXEL_RGBA8888_TO_RGB565_OFFSET(p1, 0, p2, 0)
977
978/*
979 * Converts RGB565 -> RGBA8888
980 *
981 * macro reads p1 (RGB565 at bit-offset o1)
982 * and writes to p2 (RGBA8888 at bit-offset o2)
983 * the relevant part of p2 is assumed to be cleared (zero)
984 */
985#define GP_PIXEL_RGB565_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
986 /* R:=R */ GP_SET_BITS(24+o2, 8, p2,\
987 GP_SCALE_VAL_5_8(GP_GET_BITS(11+o1, 5, p1))); \
988 /* G:=G */ GP_SET_BITS(16+o2, 8, p2,\
989 GP_SCALE_VAL_6_8(GP_GET_BITS(5+o1, 6, p1))); \
990 /* B:=B */ GP_SET_BITS(8+o2, 8, p2,\
991 GP_SCALE_VAL_5_8(GP_GET_BITS(0+o1, 5, p1))); \
992 /* A:=0xff */GP_SET_BITS(0+o2, 8, p2, 0xff); \
993} while (0)
994
995/* a version without offsets */
996#define GP_PIXEL_RGB565_TO_RGBA8888(p1, p2) \
997 GP_PIXEL_RGB565_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
998
999/*
1000 * Converts RGBA8888 -> RGB666
1001 *
1002 * macro reads p1 (RGBA8888 at bit-offset o1)
1003 * and writes to p2 (RGB666 at bit-offset o2)
1004 * the relevant part of p2 is assumed to be cleared (zero)
1005 */
1006#define GP_PIXEL_RGBA8888_TO_RGB666_OFFSET(p1, o1, p2, o2) do { \
1007 /* R:=R */ GP_SET_BITS(12+o2, 6, p2,\
1008 GP_SCALE_VAL_8_6(GP_GET_BITS(24+o1, 8, p1))); \
1009 /* G:=G */ GP_SET_BITS(6+o2, 6, p2,\
1010 GP_SCALE_VAL_8_6(GP_GET_BITS(16+o1, 8, p1))); \
1011 /* B:=B */ GP_SET_BITS(0+o2, 6, p2,\
1012 GP_SCALE_VAL_8_6(GP_GET_BITS(8+o1, 8, p1))); \
1013} while (0)
1014
1015/* a version without offsets */
1016#define GP_PIXEL_RGBA8888_TO_RGB666(p1, p2) \
1017 GP_PIXEL_RGBA8888_TO_RGB666_OFFSET(p1, 0, p2, 0)
1018
1019/*
1020 * Converts RGB666 -> RGBA8888
1021 *
1022 * macro reads p1 (RGB666 at bit-offset o1)
1023 * and writes to p2 (RGBA8888 at bit-offset o2)
1024 * the relevant part of p2 is assumed to be cleared (zero)
1025 */
1026#define GP_PIXEL_RGB666_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
1027 /* R:=R */ GP_SET_BITS(24+o2, 8, p2,\
1028 GP_SCALE_VAL_6_8(GP_GET_BITS(12+o1, 6, p1))); \
1029 /* G:=G */ GP_SET_BITS(16+o2, 8, p2,\
1030 GP_SCALE_VAL_6_8(GP_GET_BITS(6+o1, 6, p1))); \
1031 /* B:=B */ GP_SET_BITS(8+o2, 8, p2,\
1032 GP_SCALE_VAL_6_8(GP_GET_BITS(0+o1, 6, p1))); \
1033 /* A:=0xff */GP_SET_BITS(0+o2, 8, p2, 0xff); \
1034} while (0)
1035
1036/* a version without offsets */
1037#define GP_PIXEL_RGB666_TO_RGBA8888(p1, p2) \
1038 GP_PIXEL_RGB666_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
1039
1040/*
1041 * Converts RGBA8888 -> RGB332
1042 *
1043 * macro reads p1 (RGBA8888 at bit-offset o1)
1044 * and writes to p2 (RGB332 at bit-offset o2)
1045 * the relevant part of p2 is assumed to be cleared (zero)
1046 */
1047#define GP_PIXEL_RGBA8888_TO_RGB332_OFFSET(p1, o1, p2, o2) do { \
1048 /* R:=R */ GP_SET_BITS(5+o2, 3, p2,\
1049 GP_SCALE_VAL_8_3(GP_GET_BITS(24+o1, 8, p1))); \
1050 /* G:=G */ GP_SET_BITS(2+o2, 3, p2,\
1051 GP_SCALE_VAL_8_3(GP_GET_BITS(16+o1, 8, p1))); \
1052 /* B:=B */ GP_SET_BITS(0+o2, 2, p2,\
1053 GP_SCALE_VAL_8_2(GP_GET_BITS(8+o1, 8, p1))); \
1054} while (0)
1055
1056/* a version without offsets */
1057#define GP_PIXEL_RGBA8888_TO_RGB332(p1, p2) \
1058 GP_PIXEL_RGBA8888_TO_RGB332_OFFSET(p1, 0, p2, 0)
1059
1060/*
1061 * Converts RGB332 -> RGBA8888
1062 *
1063 * macro reads p1 (RGB332 at bit-offset o1)
1064 * and writes to p2 (RGBA8888 at bit-offset o2)
1065 * the relevant part of p2 is assumed to be cleared (zero)
1066 */
1067#define GP_PIXEL_RGB332_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
1068 /* R:=R */ GP_SET_BITS(24+o2, 8, p2,\
1069 GP_SCALE_VAL_3_8(GP_GET_BITS(5+o1, 3, p1))); \
1070 /* G:=G */ GP_SET_BITS(16+o2, 8, p2,\
1071 GP_SCALE_VAL_3_8(GP_GET_BITS(2+o1, 3, p1))); \
1072 /* B:=B */ GP_SET_BITS(8+o2, 8, p2,\
1073 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
1074 /* A:=0xff */GP_SET_BITS(0+o2, 8, p2, 0xff); \
1075} while (0)
1076
1077/* a version without offsets */
1078#define GP_PIXEL_RGB332_TO_RGBA8888(p1, p2) \
1079 GP_PIXEL_RGB332_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
1080
1081/*
1082 * Converts RGBA8888 -> CMYK8888
1083 *
1084 * macro reads p1 (RGBA8888 at bit-offset o1)
1085 * and writes to p2 (CMYK8888 at bit-offset o2)
1086 * the relevant part of p2 is assumed to be cleared (zero)
1087 */
1088#define GP_PIXEL_RGBA8888_TO_CMYK8888_OFFSET(p1, o1, p2, o2) do { \
1089 gp_pixel gp_r = GP_SCALE_VAL_8_8(GP_GET_BITS(24+o1, 8, p1)); \
1090 gp_pixel gp_g = GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1)); \
1091 gp_pixel gp_b = GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1)); \
1092 gp_pixel gp_k = GP_MAX3(gp_r, gp_g, gp_b); \
1093 GP_SET_BITS(0+o2, 8, p2, GP_SCALE_VAL_8_8((gp_k - gp_r))); \
1094 GP_SET_BITS(8+o2, 8, p2, GP_SCALE_VAL_8_8((gp_k - gp_g))); \
1095 GP_SET_BITS(16+o2, 8, p2, GP_SCALE_VAL_8_8((gp_k - gp_b))); \
1096 GP_SET_BITS(24+o2, 8, p2, GP_SCALE_VAL_8_8(255 - gp_k)); \
1097} while (0)
1098
1099/* a version without offsets */
1100#define GP_PIXEL_RGBA8888_TO_CMYK8888(p1, p2) \
1101 GP_PIXEL_RGBA8888_TO_CMYK8888_OFFSET(p1, 0, p2, 0)
1102
1103/*
1104 * Converts CMYK8888 -> RGBA8888
1105 *
1106 * macro reads p1 (CMYK8888 at bit-offset o1)
1107 * and writes to p2 (RGBA8888 at bit-offset o2)
1108 * the relevant part of p2 is assumed to be cleared (zero)
1109 */
1110#define GP_PIXEL_CMYK8888_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
1111 GP_SET_BITS(24+o2, 8, p2,\
1112 ((0xff * (0xff - GP_GET_BITS(24+o1, 8, p1)) * \
1113 (0xff - GP_GET_BITS(0+o1, 8, p1)))) / (0xff * 0xff) \
1114 ); \
1115 GP_SET_BITS(16+o2, 8, p2,\
1116 ((0xff * (0xff - GP_GET_BITS(24+o1, 8, p1)) * \
1117 (0xff - GP_GET_BITS(8+o1, 8, p1)))) / (0xff * 0xff) \
1118 ); \
1119 GP_SET_BITS(8+o2, 8, p2,\
1120 ((0xff * (0xff - GP_GET_BITS(24+o1, 8, p1)) * \
1121 (0xff - GP_GET_BITS(16+o1, 8, p1)))) / (0xff * 0xff) \
1122 ); \
1123 /* A:=0xff */GP_SET_BITS(0+o2, 8, p2, 0xff); \
1124} while (0)
1125
1126/* a version without offsets */
1127#define GP_PIXEL_CMYK8888_TO_RGBA8888(p1, p2) \
1128 GP_PIXEL_CMYK8888_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
1129
1130/*
1131 * Converts RGBA8888 -> G1_DB
1132 *
1133 * macro reads p1 (RGBA8888 at bit-offset o1)
1134 * and writes to p2 (G1_DB at bit-offset o2)
1135 * the relevant part of p2 is assumed to be cleared (zero)
1136 */
1137#define GP_PIXEL_RGBA8888_TO_G1_DB_OFFSET(p1, o1, p2, o2) do { \
1138 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 1, p2, ( \
1139 /* R */ GP_SCALE_VAL_8_1(GP_GET_BITS(24+o1, 8, p1)) + \
1140 /* G */ GP_SCALE_VAL_8_1(GP_GET_BITS(16+o1, 8, p1)) + \
1141 /* B */ GP_SCALE_VAL_8_1(GP_GET_BITS(8+o1, 8, p1)) + \
1142 0)/3);\
1143} while (0)
1144
1145/* a version without offsets */
1146#define GP_PIXEL_RGBA8888_TO_G1_DB(p1, p2) \
1147 GP_PIXEL_RGBA8888_TO_G1_DB_OFFSET(p1, 0, p2, 0)
1148
1149/*
1150 * Converts G1_DB -> RGBA8888
1151 *
1152 * macro reads p1 (G1_DB at bit-offset o1)
1153 * and writes to p2 (RGBA8888 at bit-offset o2)
1154 * the relevant part of p2 is assumed to be cleared (zero)
1155 */
1156#define GP_PIXEL_G1_DB_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
1157 /* R:=V */ GP_SET_BITS(24+o2, 8, p2,\
1158 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
1159 /* G:=V */ GP_SET_BITS(16+o2, 8, p2,\
1160 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
1161 /* B:=V */ GP_SET_BITS(8+o2, 8, p2,\
1162 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
1163 /* A:=0xff */GP_SET_BITS(0+o2, 8, p2, 0xff); \
1164} while (0)
1165
1166/* a version without offsets */
1167#define GP_PIXEL_G1_DB_TO_RGBA8888(p1, p2) \
1168 GP_PIXEL_G1_DB_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
1169
1170/*
1171 * Converts RGBA8888 -> G2_DB
1172 *
1173 * macro reads p1 (RGBA8888 at bit-offset o1)
1174 * and writes to p2 (G2_DB at bit-offset o2)
1175 * the relevant part of p2 is assumed to be cleared (zero)
1176 */
1177#define GP_PIXEL_RGBA8888_TO_G2_DB_OFFSET(p1, o1, p2, o2) do { \
1178 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 2, p2, ( \
1179 /* R */ GP_SCALE_VAL_8_2(GP_GET_BITS(24+o1, 8, p1)) + \
1180 /* G */ GP_SCALE_VAL_8_2(GP_GET_BITS(16+o1, 8, p1)) + \
1181 /* B */ GP_SCALE_VAL_8_2(GP_GET_BITS(8+o1, 8, p1)) + \
1182 0)/3);\
1183} while (0)
1184
1185/* a version without offsets */
1186#define GP_PIXEL_RGBA8888_TO_G2_DB(p1, p2) \
1187 GP_PIXEL_RGBA8888_TO_G2_DB_OFFSET(p1, 0, p2, 0)
1188
1189/*
1190 * Converts G2_DB -> RGBA8888
1191 *
1192 * macro reads p1 (G2_DB at bit-offset o1)
1193 * and writes to p2 (RGBA8888 at bit-offset o2)
1194 * the relevant part of p2 is assumed to be cleared (zero)
1195 */
1196#define GP_PIXEL_G2_DB_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
1197 /* R:=V */ GP_SET_BITS(24+o2, 8, p2,\
1198 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
1199 /* G:=V */ GP_SET_BITS(16+o2, 8, p2,\
1200 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
1201 /* B:=V */ GP_SET_BITS(8+o2, 8, p2,\
1202 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
1203 /* A:=0xff */GP_SET_BITS(0+o2, 8, p2, 0xff); \
1204} while (0)
1205
1206/* a version without offsets */
1207#define GP_PIXEL_G2_DB_TO_RGBA8888(p1, p2) \
1208 GP_PIXEL_G2_DB_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
1209
1210/*
1211 * Converts RGBA8888 -> G4_DB
1212 *
1213 * macro reads p1 (RGBA8888 at bit-offset o1)
1214 * and writes to p2 (G4_DB at bit-offset o2)
1215 * the relevant part of p2 is assumed to be cleared (zero)
1216 */
1217#define GP_PIXEL_RGBA8888_TO_G4_DB_OFFSET(p1, o1, p2, o2) do { \
1218 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 4, p2, ( \
1219 /* R */ GP_SCALE_VAL_8_4(GP_GET_BITS(24+o1, 8, p1)) + \
1220 /* G */ GP_SCALE_VAL_8_4(GP_GET_BITS(16+o1, 8, p1)) + \
1221 /* B */ GP_SCALE_VAL_8_4(GP_GET_BITS(8+o1, 8, p1)) + \
1222 0)/3);\
1223} while (0)
1224
1225/* a version without offsets */
1226#define GP_PIXEL_RGBA8888_TO_G4_DB(p1, p2) \
1227 GP_PIXEL_RGBA8888_TO_G4_DB_OFFSET(p1, 0, p2, 0)
1228
1229/*
1230 * Converts G4_DB -> RGBA8888
1231 *
1232 * macro reads p1 (G4_DB at bit-offset o1)
1233 * and writes to p2 (RGBA8888 at bit-offset o2)
1234 * the relevant part of p2 is assumed to be cleared (zero)
1235 */
1236#define GP_PIXEL_G4_DB_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
1237 /* R:=V */ GP_SET_BITS(24+o2, 8, p2,\
1238 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
1239 /* G:=V */ GP_SET_BITS(16+o2, 8, p2,\
1240 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
1241 /* B:=V */ GP_SET_BITS(8+o2, 8, p2,\
1242 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
1243 /* A:=0xff */GP_SET_BITS(0+o2, 8, p2, 0xff); \
1244} while (0)
1245
1246/* a version without offsets */
1247#define GP_PIXEL_G4_DB_TO_RGBA8888(p1, p2) \
1248 GP_PIXEL_G4_DB_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
1249
1250/*
1251 * Converts RGBA8888 -> G1_UB
1252 *
1253 * macro reads p1 (RGBA8888 at bit-offset o1)
1254 * and writes to p2 (G1_UB at bit-offset o2)
1255 * the relevant part of p2 is assumed to be cleared (zero)
1256 */
1257#define GP_PIXEL_RGBA8888_TO_G1_UB_OFFSET(p1, o1, p2, o2) do { \
1258 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 1, p2, ( \
1259 /* R */ GP_SCALE_VAL_8_1(GP_GET_BITS(24+o1, 8, p1)) + \
1260 /* G */ GP_SCALE_VAL_8_1(GP_GET_BITS(16+o1, 8, p1)) + \
1261 /* B */ GP_SCALE_VAL_8_1(GP_GET_BITS(8+o1, 8, p1)) + \
1262 0)/3);\
1263} while (0)
1264
1265/* a version without offsets */
1266#define GP_PIXEL_RGBA8888_TO_G1_UB(p1, p2) \
1267 GP_PIXEL_RGBA8888_TO_G1_UB_OFFSET(p1, 0, p2, 0)
1268
1269/*
1270 * Converts G1_UB -> RGBA8888
1271 *
1272 * macro reads p1 (G1_UB at bit-offset o1)
1273 * and writes to p2 (RGBA8888 at bit-offset o2)
1274 * the relevant part of p2 is assumed to be cleared (zero)
1275 */
1276#define GP_PIXEL_G1_UB_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
1277 /* R:=V */ GP_SET_BITS(24+o2, 8, p2,\
1278 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
1279 /* G:=V */ GP_SET_BITS(16+o2, 8, p2,\
1280 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
1281 /* B:=V */ GP_SET_BITS(8+o2, 8, p2,\
1282 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
1283 /* A:=0xff */GP_SET_BITS(0+o2, 8, p2, 0xff); \
1284} while (0)
1285
1286/* a version without offsets */
1287#define GP_PIXEL_G1_UB_TO_RGBA8888(p1, p2) \
1288 GP_PIXEL_G1_UB_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
1289
1290/*
1291 * Converts RGBA8888 -> G2_UB
1292 *
1293 * macro reads p1 (RGBA8888 at bit-offset o1)
1294 * and writes to p2 (G2_UB at bit-offset o2)
1295 * the relevant part of p2 is assumed to be cleared (zero)
1296 */
1297#define GP_PIXEL_RGBA8888_TO_G2_UB_OFFSET(p1, o1, p2, o2) do { \
1298 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 2, p2, ( \
1299 /* R */ GP_SCALE_VAL_8_2(GP_GET_BITS(24+o1, 8, p1)) + \
1300 /* G */ GP_SCALE_VAL_8_2(GP_GET_BITS(16+o1, 8, p1)) + \
1301 /* B */ GP_SCALE_VAL_8_2(GP_GET_BITS(8+o1, 8, p1)) + \
1302 0)/3);\
1303} while (0)
1304
1305/* a version without offsets */
1306#define GP_PIXEL_RGBA8888_TO_G2_UB(p1, p2) \
1307 GP_PIXEL_RGBA8888_TO_G2_UB_OFFSET(p1, 0, p2, 0)
1308
1309/*
1310 * Converts G2_UB -> RGBA8888
1311 *
1312 * macro reads p1 (G2_UB at bit-offset o1)
1313 * and writes to p2 (RGBA8888 at bit-offset o2)
1314 * the relevant part of p2 is assumed to be cleared (zero)
1315 */
1316#define GP_PIXEL_G2_UB_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
1317 /* R:=V */ GP_SET_BITS(24+o2, 8, p2,\
1318 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
1319 /* G:=V */ GP_SET_BITS(16+o2, 8, p2,\
1320 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
1321 /* B:=V */ GP_SET_BITS(8+o2, 8, p2,\
1322 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
1323 /* A:=0xff */GP_SET_BITS(0+o2, 8, p2, 0xff); \
1324} while (0)
1325
1326/* a version without offsets */
1327#define GP_PIXEL_G2_UB_TO_RGBA8888(p1, p2) \
1328 GP_PIXEL_G2_UB_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
1329
1330/*
1331 * Converts RGBA8888 -> G4_UB
1332 *
1333 * macro reads p1 (RGBA8888 at bit-offset o1)
1334 * and writes to p2 (G4_UB at bit-offset o2)
1335 * the relevant part of p2 is assumed to be cleared (zero)
1336 */
1337#define GP_PIXEL_RGBA8888_TO_G4_UB_OFFSET(p1, o1, p2, o2) do { \
1338 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 4, p2, ( \
1339 /* R */ GP_SCALE_VAL_8_4(GP_GET_BITS(24+o1, 8, p1)) + \
1340 /* G */ GP_SCALE_VAL_8_4(GP_GET_BITS(16+o1, 8, p1)) + \
1341 /* B */ GP_SCALE_VAL_8_4(GP_GET_BITS(8+o1, 8, p1)) + \
1342 0)/3);\
1343} while (0)
1344
1345/* a version without offsets */
1346#define GP_PIXEL_RGBA8888_TO_G4_UB(p1, p2) \
1347 GP_PIXEL_RGBA8888_TO_G4_UB_OFFSET(p1, 0, p2, 0)
1348
1349/*
1350 * Converts G4_UB -> RGBA8888
1351 *
1352 * macro reads p1 (G4_UB at bit-offset o1)
1353 * and writes to p2 (RGBA8888 at bit-offset o2)
1354 * the relevant part of p2 is assumed to be cleared (zero)
1355 */
1356#define GP_PIXEL_G4_UB_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
1357 /* R:=V */ GP_SET_BITS(24+o2, 8, p2,\
1358 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
1359 /* G:=V */ GP_SET_BITS(16+o2, 8, p2,\
1360 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
1361 /* B:=V */ GP_SET_BITS(8+o2, 8, p2,\
1362 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
1363 /* A:=0xff */GP_SET_BITS(0+o2, 8, p2, 0xff); \
1364} while (0)
1365
1366/* a version without offsets */
1367#define GP_PIXEL_G4_UB_TO_RGBA8888(p1, p2) \
1368 GP_PIXEL_G4_UB_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
1369
1370/*
1371 * Converts RGBA8888 -> G8
1372 *
1373 * macro reads p1 (RGBA8888 at bit-offset o1)
1374 * and writes to p2 (G8 at bit-offset o2)
1375 * the relevant part of p2 is assumed to be cleared (zero)
1376 */
1377#define GP_PIXEL_RGBA8888_TO_G8_OFFSET(p1, o1, p2, o2) do { \
1378 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 8, p2, ( \
1379 /* R */ GP_SCALE_VAL_8_8(GP_GET_BITS(24+o1, 8, p1)) + \
1380 /* G */ GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1)) + \
1381 /* B */ GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1)) + \
1382 0)/3);\
1383} while (0)
1384
1385/* a version without offsets */
1386#define GP_PIXEL_RGBA8888_TO_G8(p1, p2) \
1387 GP_PIXEL_RGBA8888_TO_G8_OFFSET(p1, 0, p2, 0)
1388
1389/*
1390 * Converts RGBA8888 -> GA88
1391 *
1392 * macro reads p1 (RGBA8888 at bit-offset o1)
1393 * and writes to p2 (GA88 at bit-offset o2)
1394 * the relevant part of p2 is assumed to be cleared (zero)
1395 */
1396#define GP_PIXEL_RGBA8888_TO_GA88_OFFSET(p1, o1, p2, o2) do { \
1397 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 8, p2, ( \
1398 /* R */ GP_SCALE_VAL_8_8(GP_GET_BITS(24+o1, 8, p1)) + \
1399 /* G */ GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1)) + \
1400 /* B */ GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1)) + \
1401 0)/3);\
1402 /* A:=A */ GP_SET_BITS(8+o2, 8, p2,\
1403 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1404} while (0)
1405
1406/* a version without offsets */
1407#define GP_PIXEL_RGBA8888_TO_GA88(p1, p2) \
1408 GP_PIXEL_RGBA8888_TO_GA88_OFFSET(p1, 0, p2, 0)
1409
1410/*
1411 * Converts GA88 -> RGBA8888
1412 *
1413 * macro reads p1 (GA88 at bit-offset o1)
1414 * and writes to p2 (RGBA8888 at bit-offset o2)
1415 * the relevant part of p2 is assumed to be cleared (zero)
1416 */
1417#define GP_PIXEL_GA88_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
1418 /* R:=V */ GP_SET_BITS(24+o2, 8, p2,\
1419 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1420 /* G:=V */ GP_SET_BITS(16+o2, 8, p2,\
1421 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1422 /* B:=V */ GP_SET_BITS(8+o2, 8, p2,\
1423 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1424 /* A:=A */ GP_SET_BITS(0+o2, 8, p2,\
1425 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
1426} while (0)
1427
1428/* a version without offsets */
1429#define GP_PIXEL_GA88_TO_RGBA8888(p1, p2) \
1430 GP_PIXEL_GA88_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
1431
1432/*
1433 * Converts RGBA8888 -> G16
1434 *
1435 * macro reads p1 (RGBA8888 at bit-offset o1)
1436 * and writes to p2 (G16 at bit-offset o2)
1437 * the relevant part of p2 is assumed to be cleared (zero)
1438 */
1439#define GP_PIXEL_RGBA8888_TO_G16_OFFSET(p1, o1, p2, o2) do { \
1440 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 16, p2, ( \
1441 /* R */ GP_SCALE_VAL_8_16(GP_GET_BITS(24+o1, 8, p1)) + \
1442 /* G */ GP_SCALE_VAL_8_16(GP_GET_BITS(16+o1, 8, p1)) + \
1443 /* B */ GP_SCALE_VAL_8_16(GP_GET_BITS(8+o1, 8, p1)) + \
1444 0)/3);\
1445} while (0)
1446
1447/* a version without offsets */
1448#define GP_PIXEL_RGBA8888_TO_G16(p1, p2) \
1449 GP_PIXEL_RGBA8888_TO_G16_OFFSET(p1, 0, p2, 0)
1450
1451/*
1452 * Converts G16 -> RGBA8888
1453 *
1454 * macro reads p1 (G16 at bit-offset o1)
1455 * and writes to p2 (RGBA8888 at bit-offset o2)
1456 * the relevant part of p2 is assumed to be cleared (zero)
1457 */
1458#define GP_PIXEL_G16_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
1459 /* R:=V */ GP_SET_BITS(24+o2, 8, p2,\
1460 GP_SCALE_VAL_16_8(GP_GET_BITS(0+o1, 16, p1))); \
1461 /* G:=V */ GP_SET_BITS(16+o2, 8, p2,\
1462 GP_SCALE_VAL_16_8(GP_GET_BITS(0+o1, 16, p1))); \
1463 /* B:=V */ GP_SET_BITS(8+o2, 8, p2,\
1464 GP_SCALE_VAL_16_8(GP_GET_BITS(0+o1, 16, p1))); \
1465 /* A:=0xff */GP_SET_BITS(0+o2, 8, p2, 0xff); \
1466} while (0)
1467
1468/* a version without offsets */
1469#define GP_PIXEL_G16_TO_RGBA8888(p1, p2) \
1470 GP_PIXEL_G16_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
1471
1472
1484
1496
1497/*
1498 * Converts G8 -> RGB101010
1499 *
1500 * macro reads p1 (G8 at bit-offset o1)
1501 * and writes to p2 (RGB101010 at bit-offset o2)
1502 * the relevant part of p2 is assumed to be cleared (zero)
1503 */
1504#define GP_PIXEL_G8_TO_RGB101010_OFFSET(p1, o1, p2, o2) do { \
1505 /* R:=V */ GP_SET_BITS(20+o2, 10, p2,\
1506 GP_SCALE_VAL_8_10(GP_GET_BITS(0+o1, 8, p1))); \
1507 /* G:=V */ GP_SET_BITS(10+o2, 10, p2,\
1508 GP_SCALE_VAL_8_10(GP_GET_BITS(0+o1, 8, p1))); \
1509 /* B:=V */ GP_SET_BITS(0+o2, 10, p2,\
1510 GP_SCALE_VAL_8_10(GP_GET_BITS(0+o1, 8, p1))); \
1511} while (0)
1512
1513/* a version without offsets */
1514#define GP_PIXEL_G8_TO_RGB101010(p1, p2) \
1515 GP_PIXEL_G8_TO_RGB101010_OFFSET(p1, 0, p2, 0)
1516
1517/*
1518 * Converts RGB101010 -> G8
1519 *
1520 * macro reads p1 (RGB101010 at bit-offset o1)
1521 * and writes to p2 (G8 at bit-offset o2)
1522 * the relevant part of p2 is assumed to be cleared (zero)
1523 */
1524#define GP_PIXEL_RGB101010_TO_G8_OFFSET(p1, o1, p2, o2) do { \
1525 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 8, p2, ( \
1526 /* R */ GP_SCALE_VAL_10_8(GP_GET_BITS(20+o1, 10, p1)) + \
1527 /* G */ GP_SCALE_VAL_10_8(GP_GET_BITS(10+o1, 10, p1)) + \
1528 /* B */ GP_SCALE_VAL_10_8(GP_GET_BITS(0+o1, 10, p1)) + \
1529 0)/3);\
1530} while (0)
1531
1532/* a version without offsets */
1533#define GP_PIXEL_RGB101010_TO_G8(p1, p2) \
1534 GP_PIXEL_RGB101010_TO_G8_OFFSET(p1, 0, p2, 0)
1535
1536/*
1537 * Converts G8 -> xRGB8888
1538 *
1539 * macro reads p1 (G8 at bit-offset o1)
1540 * and writes to p2 (xRGB8888 at bit-offset o2)
1541 * the relevant part of p2 is assumed to be cleared (zero)
1542 */
1543#define GP_PIXEL_G8_TO_xRGB8888_OFFSET(p1, o1, p2, o2) do { \
1544 /* R:=V */ GP_SET_BITS(16+o2, 8, p2,\
1545 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1546 /* G:=V */ GP_SET_BITS(8+o2, 8, p2,\
1547 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1548 /* B:=V */ GP_SET_BITS(0+o2, 8, p2,\
1549 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1550} while (0)
1551
1552/* a version without offsets */
1553#define GP_PIXEL_G8_TO_xRGB8888(p1, p2) \
1554 GP_PIXEL_G8_TO_xRGB8888_OFFSET(p1, 0, p2, 0)
1555
1556/*
1557 * Converts xRGB8888 -> G8
1558 *
1559 * macro reads p1 (xRGB8888 at bit-offset o1)
1560 * and writes to p2 (G8 at bit-offset o2)
1561 * the relevant part of p2 is assumed to be cleared (zero)
1562 */
1563#define GP_PIXEL_xRGB8888_TO_G8_OFFSET(p1, o1, p2, o2) do { \
1564 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 8, p2, ( \
1565 /* R */ GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1)) + \
1566 /* G */ GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1)) + \
1567 /* B */ GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1)) + \
1568 0)/3);\
1569} while (0)
1570
1571/* a version without offsets */
1572#define GP_PIXEL_xRGB8888_TO_G8(p1, p2) \
1573 GP_PIXEL_xRGB8888_TO_G8_OFFSET(p1, 0, p2, 0)
1574
1575/*
1576 * Converts G8 -> RGBA8888
1577 *
1578 * macro reads p1 (G8 at bit-offset o1)
1579 * and writes to p2 (RGBA8888 at bit-offset o2)
1580 * the relevant part of p2 is assumed to be cleared (zero)
1581 */
1582#define GP_PIXEL_G8_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
1583 /* R:=V */ GP_SET_BITS(24+o2, 8, p2,\
1584 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1585 /* G:=V */ GP_SET_BITS(16+o2, 8, p2,\
1586 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1587 /* B:=V */ GP_SET_BITS(8+o2, 8, p2,\
1588 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1589 /* A:=0xff */GP_SET_BITS(0+o2, 8, p2, 0xff); \
1590} while (0)
1591
1592/* a version without offsets */
1593#define GP_PIXEL_G8_TO_RGBA8888(p1, p2) \
1594 GP_PIXEL_G8_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
1595
1596/*
1597 * Converts G8 -> RGB888
1598 *
1599 * macro reads p1 (G8 at bit-offset o1)
1600 * and writes to p2 (RGB888 at bit-offset o2)
1601 * the relevant part of p2 is assumed to be cleared (zero)
1602 */
1603#define GP_PIXEL_G8_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
1604 /* R:=V */ GP_SET_BITS(16+o2, 8, p2,\
1605 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1606 /* G:=V */ GP_SET_BITS(8+o2, 8, p2,\
1607 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1608 /* B:=V */ GP_SET_BITS(0+o2, 8, p2,\
1609 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1610} while (0)
1611
1612/* a version without offsets */
1613#define GP_PIXEL_G8_TO_RGB888(p1, p2) \
1614 GP_PIXEL_G8_TO_RGB888_OFFSET(p1, 0, p2, 0)
1615
1616/*
1617 * Converts G8 -> BGR888
1618 *
1619 * macro reads p1 (G8 at bit-offset o1)
1620 * and writes to p2 (BGR888 at bit-offset o2)
1621 * the relevant part of p2 is assumed to be cleared (zero)
1622 */
1623#define GP_PIXEL_G8_TO_BGR888_OFFSET(p1, o1, p2, o2) do { \
1624 /* B:=V */ GP_SET_BITS(16+o2, 8, p2,\
1625 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1626 /* G:=V */ GP_SET_BITS(8+o2, 8, p2,\
1627 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1628 /* R:=V */ GP_SET_BITS(0+o2, 8, p2,\
1629 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1630} while (0)
1631
1632/* a version without offsets */
1633#define GP_PIXEL_G8_TO_BGR888(p1, p2) \
1634 GP_PIXEL_G8_TO_BGR888_OFFSET(p1, 0, p2, 0)
1635
1636/*
1637 * Converts BGR888 -> G8
1638 *
1639 * macro reads p1 (BGR888 at bit-offset o1)
1640 * and writes to p2 (G8 at bit-offset o2)
1641 * the relevant part of p2 is assumed to be cleared (zero)
1642 */
1643#define GP_PIXEL_BGR888_TO_G8_OFFSET(p1, o1, p2, o2) do { \
1644 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 8, p2, ( \
1645 /* R */ GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1)) + \
1646 /* G */ GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1)) + \
1647 /* B */ GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1)) + \
1648 0)/3);\
1649} while (0)
1650
1651/* a version without offsets */
1652#define GP_PIXEL_BGR888_TO_G8(p1, p2) \
1653 GP_PIXEL_BGR888_TO_G8_OFFSET(p1, 0, p2, 0)
1654
1655/*
1656 * Converts G8 -> RGB555
1657 *
1658 * macro reads p1 (G8 at bit-offset o1)
1659 * and writes to p2 (RGB555 at bit-offset o2)
1660 * the relevant part of p2 is assumed to be cleared (zero)
1661 */
1662#define GP_PIXEL_G8_TO_RGB555_OFFSET(p1, o1, p2, o2) do { \
1663 /* R:=V */ GP_SET_BITS(10+o2, 5, p2,\
1664 GP_SCALE_VAL_8_5(GP_GET_BITS(0+o1, 8, p1))); \
1665 /* G:=V */ GP_SET_BITS(5+o2, 5, p2,\
1666 GP_SCALE_VAL_8_5(GP_GET_BITS(0+o1, 8, p1))); \
1667 /* B:=V */ GP_SET_BITS(0+o2, 5, p2,\
1668 GP_SCALE_VAL_8_5(GP_GET_BITS(0+o1, 8, p1))); \
1669} while (0)
1670
1671/* a version without offsets */
1672#define GP_PIXEL_G8_TO_RGB555(p1, p2) \
1673 GP_PIXEL_G8_TO_RGB555_OFFSET(p1, 0, p2, 0)
1674
1675/*
1676 * Converts RGB555 -> G8
1677 *
1678 * macro reads p1 (RGB555 at bit-offset o1)
1679 * and writes to p2 (G8 at bit-offset o2)
1680 * the relevant part of p2 is assumed to be cleared (zero)
1681 */
1682#define GP_PIXEL_RGB555_TO_G8_OFFSET(p1, o1, p2, o2) do { \
1683 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 8, p2, ( \
1684 /* R */ GP_SCALE_VAL_5_8(GP_GET_BITS(10+o1, 5, p1)) + \
1685 /* G */ GP_SCALE_VAL_5_8(GP_GET_BITS(5+o1, 5, p1)) + \
1686 /* B */ GP_SCALE_VAL_5_8(GP_GET_BITS(0+o1, 5, p1)) + \
1687 0)/3);\
1688} while (0)
1689
1690/* a version without offsets */
1691#define GP_PIXEL_RGB555_TO_G8(p1, p2) \
1692 GP_PIXEL_RGB555_TO_G8_OFFSET(p1, 0, p2, 0)
1693
1694/*
1695 * Converts G8 -> RGB565
1696 *
1697 * macro reads p1 (G8 at bit-offset o1)
1698 * and writes to p2 (RGB565 at bit-offset o2)
1699 * the relevant part of p2 is assumed to be cleared (zero)
1700 */
1701#define GP_PIXEL_G8_TO_RGB565_OFFSET(p1, o1, p2, o2) do { \
1702 /* R:=V */ GP_SET_BITS(11+o2, 5, p2,\
1703 GP_SCALE_VAL_8_5(GP_GET_BITS(0+o1, 8, p1))); \
1704 /* G:=V */ GP_SET_BITS(5+o2, 6, p2,\
1705 GP_SCALE_VAL_8_6(GP_GET_BITS(0+o1, 8, p1))); \
1706 /* B:=V */ GP_SET_BITS(0+o2, 5, p2,\
1707 GP_SCALE_VAL_8_5(GP_GET_BITS(0+o1, 8, p1))); \
1708} while (0)
1709
1710/* a version without offsets */
1711#define GP_PIXEL_G8_TO_RGB565(p1, p2) \
1712 GP_PIXEL_G8_TO_RGB565_OFFSET(p1, 0, p2, 0)
1713
1714/*
1715 * Converts RGB565 -> G8
1716 *
1717 * macro reads p1 (RGB565 at bit-offset o1)
1718 * and writes to p2 (G8 at bit-offset o2)
1719 * the relevant part of p2 is assumed to be cleared (zero)
1720 */
1721#define GP_PIXEL_RGB565_TO_G8_OFFSET(p1, o1, p2, o2) do { \
1722 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 8, p2, ( \
1723 /* R */ GP_SCALE_VAL_5_8(GP_GET_BITS(11+o1, 5, p1)) + \
1724 /* G */ GP_SCALE_VAL_6_8(GP_GET_BITS(5+o1, 6, p1)) + \
1725 /* B */ GP_SCALE_VAL_5_8(GP_GET_BITS(0+o1, 5, p1)) + \
1726 0)/3);\
1727} while (0)
1728
1729/* a version without offsets */
1730#define GP_PIXEL_RGB565_TO_G8(p1, p2) \
1731 GP_PIXEL_RGB565_TO_G8_OFFSET(p1, 0, p2, 0)
1732
1733/*
1734 * Converts G8 -> RGB666
1735 *
1736 * macro reads p1 (G8 at bit-offset o1)
1737 * and writes to p2 (RGB666 at bit-offset o2)
1738 * the relevant part of p2 is assumed to be cleared (zero)
1739 */
1740#define GP_PIXEL_G8_TO_RGB666_OFFSET(p1, o1, p2, o2) do { \
1741 /* R:=V */ GP_SET_BITS(12+o2, 6, p2,\
1742 GP_SCALE_VAL_8_6(GP_GET_BITS(0+o1, 8, p1))); \
1743 /* G:=V */ GP_SET_BITS(6+o2, 6, p2,\
1744 GP_SCALE_VAL_8_6(GP_GET_BITS(0+o1, 8, p1))); \
1745 /* B:=V */ GP_SET_BITS(0+o2, 6, p2,\
1746 GP_SCALE_VAL_8_6(GP_GET_BITS(0+o1, 8, p1))); \
1747} while (0)
1748
1749/* a version without offsets */
1750#define GP_PIXEL_G8_TO_RGB666(p1, p2) \
1751 GP_PIXEL_G8_TO_RGB666_OFFSET(p1, 0, p2, 0)
1752
1753/*
1754 * Converts RGB666 -> G8
1755 *
1756 * macro reads p1 (RGB666 at bit-offset o1)
1757 * and writes to p2 (G8 at bit-offset o2)
1758 * the relevant part of p2 is assumed to be cleared (zero)
1759 */
1760#define GP_PIXEL_RGB666_TO_G8_OFFSET(p1, o1, p2, o2) do { \
1761 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 8, p2, ( \
1762 /* R */ GP_SCALE_VAL_6_8(GP_GET_BITS(12+o1, 6, p1)) + \
1763 /* G */ GP_SCALE_VAL_6_8(GP_GET_BITS(6+o1, 6, p1)) + \
1764 /* B */ GP_SCALE_VAL_6_8(GP_GET_BITS(0+o1, 6, p1)) + \
1765 0)/3);\
1766} while (0)
1767
1768/* a version without offsets */
1769#define GP_PIXEL_RGB666_TO_G8(p1, p2) \
1770 GP_PIXEL_RGB666_TO_G8_OFFSET(p1, 0, p2, 0)
1771
1772/*
1773 * Converts G8 -> RGB332
1774 *
1775 * macro reads p1 (G8 at bit-offset o1)
1776 * and writes to p2 (RGB332 at bit-offset o2)
1777 * the relevant part of p2 is assumed to be cleared (zero)
1778 */
1779#define GP_PIXEL_G8_TO_RGB332_OFFSET(p1, o1, p2, o2) do { \
1780 /* R:=V */ GP_SET_BITS(5+o2, 3, p2,\
1781 GP_SCALE_VAL_8_3(GP_GET_BITS(0+o1, 8, p1))); \
1782 /* G:=V */ GP_SET_BITS(2+o2, 3, p2,\
1783 GP_SCALE_VAL_8_3(GP_GET_BITS(0+o1, 8, p1))); \
1784 /* B:=V */ GP_SET_BITS(0+o2, 2, p2,\
1785 GP_SCALE_VAL_8_2(GP_GET_BITS(0+o1, 8, p1))); \
1786} while (0)
1787
1788/* a version without offsets */
1789#define GP_PIXEL_G8_TO_RGB332(p1, p2) \
1790 GP_PIXEL_G8_TO_RGB332_OFFSET(p1, 0, p2, 0)
1791
1792/*
1793 * Converts RGB332 -> G8
1794 *
1795 * macro reads p1 (RGB332 at bit-offset o1)
1796 * and writes to p2 (G8 at bit-offset o2)
1797 * the relevant part of p2 is assumed to be cleared (zero)
1798 */
1799#define GP_PIXEL_RGB332_TO_G8_OFFSET(p1, o1, p2, o2) do { \
1800 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 8, p2, ( \
1801 /* R */ GP_SCALE_VAL_3_8(GP_GET_BITS(5+o1, 3, p1)) + \
1802 /* G */ GP_SCALE_VAL_3_8(GP_GET_BITS(2+o1, 3, p1)) + \
1803 /* B */ GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1)) + \
1804 0)/3);\
1805} while (0)
1806
1807/* a version without offsets */
1808#define GP_PIXEL_RGB332_TO_G8(p1, p2) \
1809 GP_PIXEL_RGB332_TO_G8_OFFSET(p1, 0, p2, 0)
1810
1811/*
1812 * Converts G8 -> CMYK8888
1813 *
1814 * macro reads p1 (G8 at bit-offset o1)
1815 * and writes to p2 (CMYK8888 at bit-offset o2)
1816 * the relevant part of p2 is assumed to be cleared (zero)
1817 */
1818#define GP_PIXEL_G8_TO_CMYK8888_OFFSET(p1, o1, p2, o2) do { \
1819GP_ABORT("Channel conversion G8 to CMYK8888 not supported."); \
1820GP_ABORT("Channel conversion G8 to CMYK8888 not supported."); \
1821GP_ABORT("Channel conversion G8 to CMYK8888 not supported."); \
1822GP_ABORT("Channel conversion G8 to CMYK8888 not supported."); \
1823} while (0)
1824
1825/* a version without offsets */
1826#define GP_PIXEL_G8_TO_CMYK8888(p1, p2) \
1827 GP_PIXEL_G8_TO_CMYK8888_OFFSET(p1, 0, p2, 0)
1828
1829/*
1830 * Converts CMYK8888 -> G8
1831 *
1832 * macro reads p1 (CMYK8888 at bit-offset o1)
1833 * and writes to p2 (G8 at bit-offset o2)
1834 * the relevant part of p2 is assumed to be cleared (zero)
1835 */
1836#define GP_PIXEL_CMYK8888_TO_G8_OFFSET(p1, o1, p2, o2) do { \
1837 GP_SET_BITS(0+o2, 8, p2, (\
1838 ((0xff * (0xff - GP_GET_BITS(24+o1, 8, p1)) * \
1839 (0xff - GP_GET_BITS(0+o1, 8, p1)))) / (0xff * 0xff) \
1840 + ((0xff * (0xff - GP_GET_BITS(24+o1, 8, p1)) * \
1841 + (0xff - GP_GET_BITS(8+o1, 8, p1)))) / (0xff * 0xff) \
1842 + ((0xff * (0xff - GP_GET_BITS(24+o1, 8, p1)) * \
1843 + (0xff - GP_GET_BITS(16+o1, 8, p1)))) / (0xff * 0xff) \
1844 )/3); \
1845} while (0)
1846
1847/* a version without offsets */
1848#define GP_PIXEL_CMYK8888_TO_G8(p1, p2) \
1849 GP_PIXEL_CMYK8888_TO_G8_OFFSET(p1, 0, p2, 0)
1850
1851/*
1852 * Converts G8 -> G1_DB
1853 *
1854 * macro reads p1 (G8 at bit-offset o1)
1855 * and writes to p2 (G1_DB at bit-offset o2)
1856 * the relevant part of p2 is assumed to be cleared (zero)
1857 */
1858#define GP_PIXEL_G8_TO_G1_DB_OFFSET(p1, o1, p2, o2) do { \
1859 /* V:=V */ GP_SET_BITS(0+o2, 1, p2,\
1860 GP_SCALE_VAL_8_1(GP_GET_BITS(0+o1, 8, p1))); \
1861} while (0)
1862
1863/* a version without offsets */
1864#define GP_PIXEL_G8_TO_G1_DB(p1, p2) \
1865 GP_PIXEL_G8_TO_G1_DB_OFFSET(p1, 0, p2, 0)
1866
1867/*
1868 * Converts G1_DB -> G8
1869 *
1870 * macro reads p1 (G1_DB at bit-offset o1)
1871 * and writes to p2 (G8 at bit-offset o2)
1872 * the relevant part of p2 is assumed to be cleared (zero)
1873 */
1874#define GP_PIXEL_G1_DB_TO_G8_OFFSET(p1, o1, p2, o2) do { \
1875 /* V:=V */ GP_SET_BITS(0+o2, 8, p2,\
1876 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
1877} while (0)
1878
1879/* a version without offsets */
1880#define GP_PIXEL_G1_DB_TO_G8(p1, p2) \
1881 GP_PIXEL_G1_DB_TO_G8_OFFSET(p1, 0, p2, 0)
1882
1883/*
1884 * Converts G8 -> G2_DB
1885 *
1886 * macro reads p1 (G8 at bit-offset o1)
1887 * and writes to p2 (G2_DB at bit-offset o2)
1888 * the relevant part of p2 is assumed to be cleared (zero)
1889 */
1890#define GP_PIXEL_G8_TO_G2_DB_OFFSET(p1, o1, p2, o2) do { \
1891 /* V:=V */ GP_SET_BITS(0+o2, 2, p2,\
1892 GP_SCALE_VAL_8_2(GP_GET_BITS(0+o1, 8, p1))); \
1893} while (0)
1894
1895/* a version without offsets */
1896#define GP_PIXEL_G8_TO_G2_DB(p1, p2) \
1897 GP_PIXEL_G8_TO_G2_DB_OFFSET(p1, 0, p2, 0)
1898
1899/*
1900 * Converts G2_DB -> G8
1901 *
1902 * macro reads p1 (G2_DB at bit-offset o1)
1903 * and writes to p2 (G8 at bit-offset o2)
1904 * the relevant part of p2 is assumed to be cleared (zero)
1905 */
1906#define GP_PIXEL_G2_DB_TO_G8_OFFSET(p1, o1, p2, o2) do { \
1907 /* V:=V */ GP_SET_BITS(0+o2, 8, p2,\
1908 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
1909} while (0)
1910
1911/* a version without offsets */
1912#define GP_PIXEL_G2_DB_TO_G8(p1, p2) \
1913 GP_PIXEL_G2_DB_TO_G8_OFFSET(p1, 0, p2, 0)
1914
1915/*
1916 * Converts G8 -> G4_DB
1917 *
1918 * macro reads p1 (G8 at bit-offset o1)
1919 * and writes to p2 (G4_DB at bit-offset o2)
1920 * the relevant part of p2 is assumed to be cleared (zero)
1921 */
1922#define GP_PIXEL_G8_TO_G4_DB_OFFSET(p1, o1, p2, o2) do { \
1923 /* V:=V */ GP_SET_BITS(0+o2, 4, p2,\
1924 GP_SCALE_VAL_8_4(GP_GET_BITS(0+o1, 8, p1))); \
1925} while (0)
1926
1927/* a version without offsets */
1928#define GP_PIXEL_G8_TO_G4_DB(p1, p2) \
1929 GP_PIXEL_G8_TO_G4_DB_OFFSET(p1, 0, p2, 0)
1930
1931/*
1932 * Converts G4_DB -> G8
1933 *
1934 * macro reads p1 (G4_DB at bit-offset o1)
1935 * and writes to p2 (G8 at bit-offset o2)
1936 * the relevant part of p2 is assumed to be cleared (zero)
1937 */
1938#define GP_PIXEL_G4_DB_TO_G8_OFFSET(p1, o1, p2, o2) do { \
1939 /* V:=V */ GP_SET_BITS(0+o2, 8, p2,\
1940 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
1941} while (0)
1942
1943/* a version without offsets */
1944#define GP_PIXEL_G4_DB_TO_G8(p1, p2) \
1945 GP_PIXEL_G4_DB_TO_G8_OFFSET(p1, 0, p2, 0)
1946
1947/*
1948 * Converts G8 -> G1_UB
1949 *
1950 * macro reads p1 (G8 at bit-offset o1)
1951 * and writes to p2 (G1_UB at bit-offset o2)
1952 * the relevant part of p2 is assumed to be cleared (zero)
1953 */
1954#define GP_PIXEL_G8_TO_G1_UB_OFFSET(p1, o1, p2, o2) do { \
1955 /* V:=V */ GP_SET_BITS(0+o2, 1, p2,\
1956 GP_SCALE_VAL_8_1(GP_GET_BITS(0+o1, 8, p1))); \
1957} while (0)
1958
1959/* a version without offsets */
1960#define GP_PIXEL_G8_TO_G1_UB(p1, p2) \
1961 GP_PIXEL_G8_TO_G1_UB_OFFSET(p1, 0, p2, 0)
1962
1963/*
1964 * Converts G1_UB -> G8
1965 *
1966 * macro reads p1 (G1_UB at bit-offset o1)
1967 * and writes to p2 (G8 at bit-offset o2)
1968 * the relevant part of p2 is assumed to be cleared (zero)
1969 */
1970#define GP_PIXEL_G1_UB_TO_G8_OFFSET(p1, o1, p2, o2) do { \
1971 /* V:=V */ GP_SET_BITS(0+o2, 8, p2,\
1972 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
1973} while (0)
1974
1975/* a version without offsets */
1976#define GP_PIXEL_G1_UB_TO_G8(p1, p2) \
1977 GP_PIXEL_G1_UB_TO_G8_OFFSET(p1, 0, p2, 0)
1978
1979/*
1980 * Converts G8 -> G2_UB
1981 *
1982 * macro reads p1 (G8 at bit-offset o1)
1983 * and writes to p2 (G2_UB at bit-offset o2)
1984 * the relevant part of p2 is assumed to be cleared (zero)
1985 */
1986#define GP_PIXEL_G8_TO_G2_UB_OFFSET(p1, o1, p2, o2) do { \
1987 /* V:=V */ GP_SET_BITS(0+o2, 2, p2,\
1988 GP_SCALE_VAL_8_2(GP_GET_BITS(0+o1, 8, p1))); \
1989} while (0)
1990
1991/* a version without offsets */
1992#define GP_PIXEL_G8_TO_G2_UB(p1, p2) \
1993 GP_PIXEL_G8_TO_G2_UB_OFFSET(p1, 0, p2, 0)
1994
1995/*
1996 * Converts G2_UB -> G8
1997 *
1998 * macro reads p1 (G2_UB at bit-offset o1)
1999 * and writes to p2 (G8 at bit-offset o2)
2000 * the relevant part of p2 is assumed to be cleared (zero)
2001 */
2002#define GP_PIXEL_G2_UB_TO_G8_OFFSET(p1, o1, p2, o2) do { \
2003 /* V:=V */ GP_SET_BITS(0+o2, 8, p2,\
2004 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
2005} while (0)
2006
2007/* a version without offsets */
2008#define GP_PIXEL_G2_UB_TO_G8(p1, p2) \
2009 GP_PIXEL_G2_UB_TO_G8_OFFSET(p1, 0, p2, 0)
2010
2011/*
2012 * Converts G8 -> G4_UB
2013 *
2014 * macro reads p1 (G8 at bit-offset o1)
2015 * and writes to p2 (G4_UB at bit-offset o2)
2016 * the relevant part of p2 is assumed to be cleared (zero)
2017 */
2018#define GP_PIXEL_G8_TO_G4_UB_OFFSET(p1, o1, p2, o2) do { \
2019 /* V:=V */ GP_SET_BITS(0+o2, 4, p2,\
2020 GP_SCALE_VAL_8_4(GP_GET_BITS(0+o1, 8, p1))); \
2021} while (0)
2022
2023/* a version without offsets */
2024#define GP_PIXEL_G8_TO_G4_UB(p1, p2) \
2025 GP_PIXEL_G8_TO_G4_UB_OFFSET(p1, 0, p2, 0)
2026
2027/*
2028 * Converts G4_UB -> G8
2029 *
2030 * macro reads p1 (G4_UB at bit-offset o1)
2031 * and writes to p2 (G8 at bit-offset o2)
2032 * the relevant part of p2 is assumed to be cleared (zero)
2033 */
2034#define GP_PIXEL_G4_UB_TO_G8_OFFSET(p1, o1, p2, o2) do { \
2035 /* V:=V */ GP_SET_BITS(0+o2, 8, p2,\
2036 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
2037} while (0)
2038
2039/* a version without offsets */
2040#define GP_PIXEL_G4_UB_TO_G8(p1, p2) \
2041 GP_PIXEL_G4_UB_TO_G8_OFFSET(p1, 0, p2, 0)
2042
2043/*
2044 * Converts G8 -> G8
2045 *
2046 * macro reads p1 (G8 at bit-offset o1)
2047 * and writes to p2 (G8 at bit-offset o2)
2048 * the relevant part of p2 is assumed to be cleared (zero)
2049 */
2050#define GP_PIXEL_G8_TO_G8_OFFSET(p1, o1, p2, o2) do { \
2051 /* V:=V */ GP_SET_BITS(0+o2, 8, p2,\
2052 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
2053} while (0)
2054
2055/* a version without offsets */
2056#define GP_PIXEL_G8_TO_G8(p1, p2) \
2057 GP_PIXEL_G8_TO_G8_OFFSET(p1, 0, p2, 0)
2058
2059/*
2060 * Converts G8 -> GA88
2061 *
2062 * macro reads p1 (G8 at bit-offset o1)
2063 * and writes to p2 (GA88 at bit-offset o2)
2064 * the relevant part of p2 is assumed to be cleared (zero)
2065 */
2066#define GP_PIXEL_G8_TO_GA88_OFFSET(p1, o1, p2, o2) do { \
2067 /* V:=V */ GP_SET_BITS(0+o2, 8, p2,\
2068 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
2069 /* A:=0xff */GP_SET_BITS(8+o2, 8, p2, 0xff); \
2070} while (0)
2071
2072/* a version without offsets */
2073#define GP_PIXEL_G8_TO_GA88(p1, p2) \
2074 GP_PIXEL_G8_TO_GA88_OFFSET(p1, 0, p2, 0)
2075
2076/*
2077 * Converts GA88 -> G8
2078 *
2079 * macro reads p1 (GA88 at bit-offset o1)
2080 * and writes to p2 (G8 at bit-offset o2)
2081 * the relevant part of p2 is assumed to be cleared (zero)
2082 */
2083#define GP_PIXEL_GA88_TO_G8_OFFSET(p1, o1, p2, o2) do { \
2084 /* V:=V */ GP_SET_BITS(0+o2, 8, p2,\
2085 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
2086} while (0)
2087
2088/* a version without offsets */
2089#define GP_PIXEL_GA88_TO_G8(p1, p2) \
2090 GP_PIXEL_GA88_TO_G8_OFFSET(p1, 0, p2, 0)
2091
2092/*
2093 * Converts G8 -> G16
2094 *
2095 * macro reads p1 (G8 at bit-offset o1)
2096 * and writes to p2 (G16 at bit-offset o2)
2097 * the relevant part of p2 is assumed to be cleared (zero)
2098 */
2099#define GP_PIXEL_G8_TO_G16_OFFSET(p1, o1, p2, o2) do { \
2100 /* V:=V */ GP_SET_BITS(0+o2, 16, p2,\
2101 GP_SCALE_VAL_8_16(GP_GET_BITS(0+o1, 8, p1))); \
2102} while (0)
2103
2104/* a version without offsets */
2105#define GP_PIXEL_G8_TO_G16(p1, p2) \
2106 GP_PIXEL_G8_TO_G16_OFFSET(p1, 0, p2, 0)
2107
2108/*
2109 * Converts G16 -> G8
2110 *
2111 * macro reads p1 (G16 at bit-offset o1)
2112 * and writes to p2 (G8 at bit-offset o2)
2113 * the relevant part of p2 is assumed to be cleared (zero)
2114 */
2115#define GP_PIXEL_G16_TO_G8_OFFSET(p1, o1, p2, o2) do { \
2116 /* V:=V */ GP_SET_BITS(0+o2, 8, p2,\
2117 GP_SCALE_VAL_16_8(GP_GET_BITS(0+o1, 16, p1))); \
2118} while (0)
2119
2120/* a version without offsets */
2121#define GP_PIXEL_G16_TO_G8(p1, p2) \
2122 GP_PIXEL_G16_TO_G8_OFFSET(p1, 0, p2, 0)
2123
2124
2136
2148
2149
2150/* Experimental macros testing generated scripts */
2151/*
2152 * Converts RGB565 -> RGBA8888
2153 *
2154 * macro reads p1 (RGB565 at bit-offset o1)
2155 * and writes to p2 (RGBA8888 at bit-offset o2)
2156 * the relevant part of p2 is assumed to be cleared (zero)
2157 */
2158#define GP_PIXEL_RGB565_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
2159 /* R:=R */ GP_SET_BITS(24+o2, 8, p2,\
2160 GP_SCALE_VAL_5_8(GP_GET_BITS(11+o1, 5, p1))); \
2161 /* G:=G */ GP_SET_BITS(16+o2, 8, p2,\
2162 GP_SCALE_VAL_6_8(GP_GET_BITS(5+o1, 6, p1))); \
2163 /* B:=B */ GP_SET_BITS(8+o2, 8, p2,\
2164 GP_SCALE_VAL_5_8(GP_GET_BITS(0+o1, 5, p1))); \
2165 /* A:=0xff */GP_SET_BITS(0+o2, 8, p2, 0xff); \
2166} while (0)
2167
2168/* a version without offsets */
2169#define GP_PIXEL_RGB565_TO_RGBA8888(p1, p2) \
2170 GP_PIXEL_RGB565_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
2171
2172/*
2173 * Converts RGBA8888 -> G2_UB
2174 *
2175 * macro reads p1 (RGBA8888 at bit-offset o1)
2176 * and writes to p2 (G2_UB at bit-offset o2)
2177 * the relevant part of p2 is assumed to be cleared (zero)
2178 */
2179#define GP_PIXEL_RGBA8888_TO_G2_UB_OFFSET(p1, o1, p2, o2) do { \
2180 /* V:=RGB_avg */ GP_SET_BITS(0+o2, 2, p2, ( \
2181 /* R */ GP_SCALE_VAL_8_2(GP_GET_BITS(24+o1, 8, p1)) + \
2182 /* G */ GP_SCALE_VAL_8_2(GP_GET_BITS(16+o1, 8, p1)) + \
2183 /* B */ GP_SCALE_VAL_8_2(GP_GET_BITS(8+o1, 8, p1)) + \
2184 0)/3);\
2185} while (0)
2186
2187/* a version without offsets */
2188#define GP_PIXEL_RGBA8888_TO_G2_UB(p1, p2) \
2189 GP_PIXEL_RGBA8888_TO_G2_UB_OFFSET(p1, 0, p2, 0)
2190
2191#endif /* GP_CONVERT_GEN_H */
uint32_t gp_pixel
Pixel integer value.
Definition gp_types.h:33
gp_pixel gp_pixel_to_G8(gp_pixel pixel, gp_pixel_type type)
Converts to G8 from any other pixel type.
gp_pixel gp_pixel_to_RGBA8888(gp_pixel pixel, gp_pixel_type type)
Converts to RGBA8888 from any other pixel type.
gp_pixel gp_pixel_to_RGB888(gp_pixel pixel, gp_pixel_type type)
Converts to RGB888 from any other pixel type.
gp_pixel gp_G8_to_pixel(gp_pixel pixel, gp_pixel_type type)
Convert G8 to any other pixel type.
gp_pixel gp_RGB888_to_pixel(gp_pixel pixel, gp_pixel_type type)
Convert RGB888 to any other pixel type.
gp_pixel gp_RGBA8888_to_pixel(gp_pixel pixel, gp_pixel_type type)
Convert RGBA8888 to any other pixel type.
Helper macros to get and set bits given offset and length.
gp_pixel_type
List of all pixel types.
A pixel description.
A pixel buffer.