9#ifndef GP_CONVERT_GEN_H
10#define GP_CONVERT_GEN_H
33#define GP_PIXEL_RGB888_TO_RGB101010_OFFSET(p1, o1, p2, o2) do { \
34 GP_SET_BITS(20+o2, 10, p2,\
35 GP_SCALE_VAL_8_10(GP_GET_BITS(16+o1, 8, p1))); \
36 GP_SET_BITS(10+o2, 10, p2,\
37 GP_SCALE_VAL_8_10(GP_GET_BITS(8+o1, 8, p1))); \
38 GP_SET_BITS(0+o2, 10, p2,\
39 GP_SCALE_VAL_8_10(GP_GET_BITS(0+o1, 8, p1))); \
43#define GP_PIXEL_RGB888_TO_RGB101010(p1, p2) \
44 GP_PIXEL_RGB888_TO_RGB101010_OFFSET(p1, 0, p2, 0)
53#define GP_PIXEL_RGB101010_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
54 GP_SET_BITS(16+o2, 8, p2,\
55 GP_SCALE_VAL_10_8(GP_GET_BITS(20+o1, 10, p1))); \
56 GP_SET_BITS(8+o2, 8, p2,\
57 GP_SCALE_VAL_10_8(GP_GET_BITS(10+o1, 10, p1))); \
58 GP_SET_BITS(0+o2, 8, p2,\
59 GP_SCALE_VAL_10_8(GP_GET_BITS(0+o1, 10, p1))); \
63#define GP_PIXEL_RGB101010_TO_RGB888(p1, p2) \
64 GP_PIXEL_RGB101010_TO_RGB888_OFFSET(p1, 0, p2, 0)
73#define GP_PIXEL_RGB888_TO_xRGB8888_OFFSET(p1, o1, p2, o2) do { \
74 GP_SET_BITS(16+o2, 8, p2,\
75 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1))); \
76 GP_SET_BITS(8+o2, 8, p2,\
77 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
78 GP_SET_BITS(0+o2, 8, p2,\
79 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
83#define GP_PIXEL_RGB888_TO_xRGB8888(p1, p2) \
84 GP_PIXEL_RGB888_TO_xRGB8888_OFFSET(p1, 0, p2, 0)
93#define GP_PIXEL_xRGB8888_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
94 GP_SET_BITS(16+o2, 8, p2,\
95 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1))); \
96 GP_SET_BITS(8+o2, 8, p2,\
97 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
98 GP_SET_BITS(0+o2, 8, p2,\
99 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
103#define GP_PIXEL_xRGB8888_TO_RGB888(p1, p2) \
104 GP_PIXEL_xRGB8888_TO_RGB888_OFFSET(p1, 0, p2, 0)
113#define GP_PIXEL_RGB888_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
114 GP_SET_BITS(24+o2, 8, p2,\
115 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1))); \
116 GP_SET_BITS(16+o2, 8, p2,\
117 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
118 GP_SET_BITS(8+o2, 8, p2,\
119 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
120 GP_SET_BITS(0+o2, 8, p2, 0xff); \
124#define GP_PIXEL_RGB888_TO_RGBA8888(p1, p2) \
125 GP_PIXEL_RGB888_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
134#define GP_PIXEL_RGB888_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
135 GP_SET_BITS(16+o2, 8, p2,\
136 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1))); \
137 GP_SET_BITS(8+o2, 8, p2,\
138 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
139 GP_SET_BITS(0+o2, 8, p2,\
140 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
144#define GP_PIXEL_RGB888_TO_RGB888(p1, p2) \
145 GP_PIXEL_RGB888_TO_RGB888_OFFSET(p1, 0, p2, 0)
154#define GP_PIXEL_RGB888_TO_BGR888_OFFSET(p1, o1, p2, o2) do { \
155 GP_SET_BITS(16+o2, 8, p2,\
156 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
157 GP_SET_BITS(8+o2, 8, p2,\
158 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
159 GP_SET_BITS(0+o2, 8, p2,\
160 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1))); \
164#define GP_PIXEL_RGB888_TO_BGR888(p1, p2) \
165 GP_PIXEL_RGB888_TO_BGR888_OFFSET(p1, 0, p2, 0)
174#define GP_PIXEL_BGR888_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
175 GP_SET_BITS(16+o2, 8, p2,\
176 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
177 GP_SET_BITS(8+o2, 8, p2,\
178 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
179 GP_SET_BITS(0+o2, 8, p2,\
180 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1))); \
184#define GP_PIXEL_BGR888_TO_RGB888(p1, p2) \
185 GP_PIXEL_BGR888_TO_RGB888_OFFSET(p1, 0, p2, 0)
194#define GP_PIXEL_RGB888_TO_RGB555_OFFSET(p1, o1, p2, o2) do { \
195 GP_SET_BITS(10+o2, 5, p2,\
196 GP_SCALE_VAL_8_5(GP_GET_BITS(16+o1, 8, p1))); \
197 GP_SET_BITS(5+o2, 5, p2,\
198 GP_SCALE_VAL_8_5(GP_GET_BITS(8+o1, 8, p1))); \
199 GP_SET_BITS(0+o2, 5, p2,\
200 GP_SCALE_VAL_8_5(GP_GET_BITS(0+o1, 8, p1))); \
204#define GP_PIXEL_RGB888_TO_RGB555(p1, p2) \
205 GP_PIXEL_RGB888_TO_RGB555_OFFSET(p1, 0, p2, 0)
214#define GP_PIXEL_RGB555_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
215 GP_SET_BITS(16+o2, 8, p2,\
216 GP_SCALE_VAL_5_8(GP_GET_BITS(10+o1, 5, p1))); \
217 GP_SET_BITS(8+o2, 8, p2,\
218 GP_SCALE_VAL_5_8(GP_GET_BITS(5+o1, 5, p1))); \
219 GP_SET_BITS(0+o2, 8, p2,\
220 GP_SCALE_VAL_5_8(GP_GET_BITS(0+o1, 5, p1))); \
224#define GP_PIXEL_RGB555_TO_RGB888(p1, p2) \
225 GP_PIXEL_RGB555_TO_RGB888_OFFSET(p1, 0, p2, 0)
234#define GP_PIXEL_RGB888_TO_RGB565_OFFSET(p1, o1, p2, o2) do { \
235 GP_SET_BITS(11+o2, 5, p2,\
236 GP_SCALE_VAL_8_5(GP_GET_BITS(16+o1, 8, p1))); \
237 GP_SET_BITS(5+o2, 6, p2,\
238 GP_SCALE_VAL_8_6(GP_GET_BITS(8+o1, 8, p1))); \
239 GP_SET_BITS(0+o2, 5, p2,\
240 GP_SCALE_VAL_8_5(GP_GET_BITS(0+o1, 8, p1))); \
244#define GP_PIXEL_RGB888_TO_RGB565(p1, p2) \
245 GP_PIXEL_RGB888_TO_RGB565_OFFSET(p1, 0, p2, 0)
254#define GP_PIXEL_RGB565_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
255 GP_SET_BITS(16+o2, 8, p2,\
256 GP_SCALE_VAL_5_8(GP_GET_BITS(11+o1, 5, p1))); \
257 GP_SET_BITS(8+o2, 8, p2,\
258 GP_SCALE_VAL_6_8(GP_GET_BITS(5+o1, 6, p1))); \
259 GP_SET_BITS(0+o2, 8, p2,\
260 GP_SCALE_VAL_5_8(GP_GET_BITS(0+o1, 5, p1))); \
264#define GP_PIXEL_RGB565_TO_RGB888(p1, p2) \
265 GP_PIXEL_RGB565_TO_RGB888_OFFSET(p1, 0, p2, 0)
274#define GP_PIXEL_RGB888_TO_RGB666_OFFSET(p1, o1, p2, o2) do { \
275 GP_SET_BITS(12+o2, 6, p2,\
276 GP_SCALE_VAL_8_6(GP_GET_BITS(16+o1, 8, p1))); \
277 GP_SET_BITS(6+o2, 6, p2,\
278 GP_SCALE_VAL_8_6(GP_GET_BITS(8+o1, 8, p1))); \
279 GP_SET_BITS(0+o2, 6, p2,\
280 GP_SCALE_VAL_8_6(GP_GET_BITS(0+o1, 8, p1))); \
284#define GP_PIXEL_RGB888_TO_RGB666(p1, p2) \
285 GP_PIXEL_RGB888_TO_RGB666_OFFSET(p1, 0, p2, 0)
294#define GP_PIXEL_RGB666_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
295 GP_SET_BITS(16+o2, 8, p2,\
296 GP_SCALE_VAL_6_8(GP_GET_BITS(12+o1, 6, p1))); \
297 GP_SET_BITS(8+o2, 8, p2,\
298 GP_SCALE_VAL_6_8(GP_GET_BITS(6+o1, 6, p1))); \
299 GP_SET_BITS(0+o2, 8, p2,\
300 GP_SCALE_VAL_6_8(GP_GET_BITS(0+o1, 6, p1))); \
304#define GP_PIXEL_RGB666_TO_RGB888(p1, p2) \
305 GP_PIXEL_RGB666_TO_RGB888_OFFSET(p1, 0, p2, 0)
314#define GP_PIXEL_RGB888_TO_RGB332_OFFSET(p1, o1, p2, o2) do { \
315 GP_SET_BITS(5+o2, 3, p2,\
316 GP_SCALE_VAL_8_3(GP_GET_BITS(16+o1, 8, p1))); \
317 GP_SET_BITS(2+o2, 3, p2,\
318 GP_SCALE_VAL_8_3(GP_GET_BITS(8+o1, 8, p1))); \
319 GP_SET_BITS(0+o2, 2, p2,\
320 GP_SCALE_VAL_8_2(GP_GET_BITS(0+o1, 8, p1))); \
324#define GP_PIXEL_RGB888_TO_RGB332(p1, p2) \
325 GP_PIXEL_RGB888_TO_RGB332_OFFSET(p1, 0, p2, 0)
334#define GP_PIXEL_RGB332_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
335 GP_SET_BITS(16+o2, 8, p2,\
336 GP_SCALE_VAL_3_8(GP_GET_BITS(5+o1, 3, p1))); \
337 GP_SET_BITS(8+o2, 8, p2,\
338 GP_SCALE_VAL_3_8(GP_GET_BITS(2+o1, 3, p1))); \
339 GP_SET_BITS(0+o2, 8, p2,\
340 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
344#define GP_PIXEL_RGB332_TO_RGB888(p1, p2) \
345 GP_PIXEL_RGB332_TO_RGB888_OFFSET(p1, 0, p2, 0)
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)); \
366#define GP_PIXEL_RGB888_TO_CMYK8888(p1, p2) \
367 GP_PIXEL_RGB888_TO_CMYK8888_OFFSET(p1, 0, p2, 0)
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) \
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) \
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) \
392#define GP_PIXEL_CMYK8888_TO_RGB888(p1, p2) \
393 GP_PIXEL_CMYK8888_TO_RGB888_OFFSET(p1, 0, p2, 0)
402#define GP_PIXEL_RGB888_TO_G1_DB_OFFSET(p1, o1, p2, o2) do { \
403 GP_SET_BITS(0+o2, 1, p2, ( \
404 GP_SCALE_VAL_8_1(GP_GET_BITS(16+o1, 8, p1)) + \
405 GP_SCALE_VAL_8_1(GP_GET_BITS(8+o1, 8, p1)) + \
406 GP_SCALE_VAL_8_1(GP_GET_BITS(0+o1, 8, p1)) + \
411#define GP_PIXEL_RGB888_TO_G1_DB(p1, p2) \
412 GP_PIXEL_RGB888_TO_G1_DB_OFFSET(p1, 0, p2, 0)
421#define GP_PIXEL_G1_DB_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
422 GP_SET_BITS(16+o2, 8, p2,\
423 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
424 GP_SET_BITS(8+o2, 8, p2,\
425 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
426 GP_SET_BITS(0+o2, 8, p2,\
427 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
431#define GP_PIXEL_G1_DB_TO_RGB888(p1, p2) \
432 GP_PIXEL_G1_DB_TO_RGB888_OFFSET(p1, 0, p2, 0)
441#define GP_PIXEL_RGB888_TO_G2_DB_OFFSET(p1, o1, p2, o2) do { \
442 GP_SET_BITS(0+o2, 2, p2, ( \
443 GP_SCALE_VAL_8_2(GP_GET_BITS(16+o1, 8, p1)) + \
444 GP_SCALE_VAL_8_2(GP_GET_BITS(8+o1, 8, p1)) + \
445 GP_SCALE_VAL_8_2(GP_GET_BITS(0+o1, 8, p1)) + \
450#define GP_PIXEL_RGB888_TO_G2_DB(p1, p2) \
451 GP_PIXEL_RGB888_TO_G2_DB_OFFSET(p1, 0, p2, 0)
460#define GP_PIXEL_G2_DB_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
461 GP_SET_BITS(16+o2, 8, p2,\
462 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
463 GP_SET_BITS(8+o2, 8, p2,\
464 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
465 GP_SET_BITS(0+o2, 8, p2,\
466 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
470#define GP_PIXEL_G2_DB_TO_RGB888(p1, p2) \
471 GP_PIXEL_G2_DB_TO_RGB888_OFFSET(p1, 0, p2, 0)
480#define GP_PIXEL_RGB888_TO_G4_DB_OFFSET(p1, o1, p2, o2) do { \
481 GP_SET_BITS(0+o2, 4, p2, ( \
482 GP_SCALE_VAL_8_4(GP_GET_BITS(16+o1, 8, p1)) + \
483 GP_SCALE_VAL_8_4(GP_GET_BITS(8+o1, 8, p1)) + \
484 GP_SCALE_VAL_8_4(GP_GET_BITS(0+o1, 8, p1)) + \
489#define GP_PIXEL_RGB888_TO_G4_DB(p1, p2) \
490 GP_PIXEL_RGB888_TO_G4_DB_OFFSET(p1, 0, p2, 0)
499#define GP_PIXEL_G4_DB_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
500 GP_SET_BITS(16+o2, 8, p2,\
501 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
502 GP_SET_BITS(8+o2, 8, p2,\
503 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
504 GP_SET_BITS(0+o2, 8, p2,\
505 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
509#define GP_PIXEL_G4_DB_TO_RGB888(p1, p2) \
510 GP_PIXEL_G4_DB_TO_RGB888_OFFSET(p1, 0, p2, 0)
519#define GP_PIXEL_RGB888_TO_G1_UB_OFFSET(p1, o1, p2, o2) do { \
520 GP_SET_BITS(0+o2, 1, p2, ( \
521 GP_SCALE_VAL_8_1(GP_GET_BITS(16+o1, 8, p1)) + \
522 GP_SCALE_VAL_8_1(GP_GET_BITS(8+o1, 8, p1)) + \
523 GP_SCALE_VAL_8_1(GP_GET_BITS(0+o1, 8, p1)) + \
528#define GP_PIXEL_RGB888_TO_G1_UB(p1, p2) \
529 GP_PIXEL_RGB888_TO_G1_UB_OFFSET(p1, 0, p2, 0)
538#define GP_PIXEL_G1_UB_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
539 GP_SET_BITS(16+o2, 8, p2,\
540 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
541 GP_SET_BITS(8+o2, 8, p2,\
542 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
543 GP_SET_BITS(0+o2, 8, p2,\
544 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
548#define GP_PIXEL_G1_UB_TO_RGB888(p1, p2) \
549 GP_PIXEL_G1_UB_TO_RGB888_OFFSET(p1, 0, p2, 0)
558#define GP_PIXEL_RGB888_TO_G2_UB_OFFSET(p1, o1, p2, o2) do { \
559 GP_SET_BITS(0+o2, 2, p2, ( \
560 GP_SCALE_VAL_8_2(GP_GET_BITS(16+o1, 8, p1)) + \
561 GP_SCALE_VAL_8_2(GP_GET_BITS(8+o1, 8, p1)) + \
562 GP_SCALE_VAL_8_2(GP_GET_BITS(0+o1, 8, p1)) + \
567#define GP_PIXEL_RGB888_TO_G2_UB(p1, p2) \
568 GP_PIXEL_RGB888_TO_G2_UB_OFFSET(p1, 0, p2, 0)
577#define GP_PIXEL_G2_UB_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
578 GP_SET_BITS(16+o2, 8, p2,\
579 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
580 GP_SET_BITS(8+o2, 8, p2,\
581 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
582 GP_SET_BITS(0+o2, 8, p2,\
583 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
587#define GP_PIXEL_G2_UB_TO_RGB888(p1, p2) \
588 GP_PIXEL_G2_UB_TO_RGB888_OFFSET(p1, 0, p2, 0)
597#define GP_PIXEL_RGB888_TO_G4_UB_OFFSET(p1, o1, p2, o2) do { \
598 GP_SET_BITS(0+o2, 4, p2, ( \
599 GP_SCALE_VAL_8_4(GP_GET_BITS(16+o1, 8, p1)) + \
600 GP_SCALE_VAL_8_4(GP_GET_BITS(8+o1, 8, p1)) + \
601 GP_SCALE_VAL_8_4(GP_GET_BITS(0+o1, 8, p1)) + \
606#define GP_PIXEL_RGB888_TO_G4_UB(p1, p2) \
607 GP_PIXEL_RGB888_TO_G4_UB_OFFSET(p1, 0, p2, 0)
616#define GP_PIXEL_G4_UB_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
617 GP_SET_BITS(16+o2, 8, p2,\
618 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
619 GP_SET_BITS(8+o2, 8, p2,\
620 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
621 GP_SET_BITS(0+o2, 8, p2,\
622 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
626#define GP_PIXEL_G4_UB_TO_RGB888(p1, p2) \
627 GP_PIXEL_G4_UB_TO_RGB888_OFFSET(p1, 0, p2, 0)
636#define GP_PIXEL_RGB888_TO_G8_OFFSET(p1, o1, p2, o2) do { \
637 GP_SET_BITS(0+o2, 8, p2, ( \
638 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1)) + \
639 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1)) + \
640 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1)) + \
645#define GP_PIXEL_RGB888_TO_G8(p1, p2) \
646 GP_PIXEL_RGB888_TO_G8_OFFSET(p1, 0, p2, 0)
655#define GP_PIXEL_RGB888_TO_GA88_OFFSET(p1, o1, p2, o2) do { \
656 GP_SET_BITS(0+o2, 8, p2, ( \
657 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1)) + \
658 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1)) + \
659 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1)) + \
661 GP_SET_BITS(8+o2, 8, p2, 0xff); \
665#define GP_PIXEL_RGB888_TO_GA88(p1, p2) \
666 GP_PIXEL_RGB888_TO_GA88_OFFSET(p1, 0, p2, 0)
675#define GP_PIXEL_GA88_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
676 GP_SET_BITS(16+o2, 8, p2,\
677 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
678 GP_SET_BITS(8+o2, 8, p2,\
679 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
680 GP_SET_BITS(0+o2, 8, p2,\
681 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
685#define GP_PIXEL_GA88_TO_RGB888(p1, p2) \
686 GP_PIXEL_GA88_TO_RGB888_OFFSET(p1, 0, p2, 0)
695#define GP_PIXEL_RGB888_TO_G16_OFFSET(p1, o1, p2, o2) do { \
696 GP_SET_BITS(0+o2, 16, p2, ( \
697 GP_SCALE_VAL_8_16(GP_GET_BITS(16+o1, 8, p1)) + \
698 GP_SCALE_VAL_8_16(GP_GET_BITS(8+o1, 8, p1)) + \
699 GP_SCALE_VAL_8_16(GP_GET_BITS(0+o1, 8, p1)) + \
704#define GP_PIXEL_RGB888_TO_G16(p1, p2) \
705 GP_PIXEL_RGB888_TO_G16_OFFSET(p1, 0, p2, 0)
714#define GP_PIXEL_G16_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
715 GP_SET_BITS(16+o2, 8, p2,\
716 GP_SCALE_VAL_16_8(GP_GET_BITS(0+o1, 16, p1))); \
717 GP_SET_BITS(8+o2, 8, p2,\
718 GP_SCALE_VAL_16_8(GP_GET_BITS(0+o1, 16, p1))); \
719 GP_SET_BITS(0+o2, 8, p2,\
720 GP_SCALE_VAL_16_8(GP_GET_BITS(0+o1, 16, p1))); \
724#define GP_PIXEL_G16_TO_RGB888(p1, p2) \
725 GP_PIXEL_G16_TO_RGB888_OFFSET(p1, 0, p2, 0)
759#define GP_PIXEL_RGBA8888_TO_RGB101010_OFFSET(p1, o1, p2, o2) do { \
760 GP_SET_BITS(20+o2, 10, p2,\
761 GP_SCALE_VAL_8_10(GP_GET_BITS(24+o1, 8, p1))); \
762 GP_SET_BITS(10+o2, 10, p2,\
763 GP_SCALE_VAL_8_10(GP_GET_BITS(16+o1, 8, p1))); \
764 GP_SET_BITS(0+o2, 10, p2,\
765 GP_SCALE_VAL_8_10(GP_GET_BITS(8+o1, 8, p1))); \
769#define GP_PIXEL_RGBA8888_TO_RGB101010(p1, p2) \
770 GP_PIXEL_RGBA8888_TO_RGB101010_OFFSET(p1, 0, p2, 0)
779#define GP_PIXEL_RGB101010_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
780 GP_SET_BITS(24+o2, 8, p2,\
781 GP_SCALE_VAL_10_8(GP_GET_BITS(20+o1, 10, p1))); \
782 GP_SET_BITS(16+o2, 8, p2,\
783 GP_SCALE_VAL_10_8(GP_GET_BITS(10+o1, 10, p1))); \
784 GP_SET_BITS(8+o2, 8, p2,\
785 GP_SCALE_VAL_10_8(GP_GET_BITS(0+o1, 10, p1))); \
786 GP_SET_BITS(0+o2, 8, p2, 0xff); \
790#define GP_PIXEL_RGB101010_TO_RGBA8888(p1, p2) \
791 GP_PIXEL_RGB101010_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
800#define GP_PIXEL_RGBA8888_TO_xRGB8888_OFFSET(p1, o1, p2, o2) do { \
801 GP_SET_BITS(16+o2, 8, p2,\
802 GP_SCALE_VAL_8_8(GP_GET_BITS(24+o1, 8, p1))); \
803 GP_SET_BITS(8+o2, 8, p2,\
804 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1))); \
805 GP_SET_BITS(0+o2, 8, p2,\
806 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
810#define GP_PIXEL_RGBA8888_TO_xRGB8888(p1, p2) \
811 GP_PIXEL_RGBA8888_TO_xRGB8888_OFFSET(p1, 0, p2, 0)
820#define GP_PIXEL_xRGB8888_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
821 GP_SET_BITS(24+o2, 8, p2,\
822 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1))); \
823 GP_SET_BITS(16+o2, 8, p2,\
824 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
825 GP_SET_BITS(8+o2, 8, p2,\
826 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
827 GP_SET_BITS(0+o2, 8, p2, 0xff); \
831#define GP_PIXEL_xRGB8888_TO_RGBA8888(p1, p2) \
832 GP_PIXEL_xRGB8888_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
841#define GP_PIXEL_RGBA8888_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
842 GP_SET_BITS(24+o2, 8, p2,\
843 GP_SCALE_VAL_8_8(GP_GET_BITS(24+o1, 8, p1))); \
844 GP_SET_BITS(16+o2, 8, p2,\
845 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1))); \
846 GP_SET_BITS(8+o2, 8, p2,\
847 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
848 GP_SET_BITS(0+o2, 8, p2,\
849 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
853#define GP_PIXEL_RGBA8888_TO_RGBA8888(p1, p2) \
854 GP_PIXEL_RGBA8888_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
863#define GP_PIXEL_RGBA8888_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
864 GP_SET_BITS(16+o2, 8, p2,\
865 GP_SCALE_VAL_8_8(GP_GET_BITS(24+o1, 8, p1))); \
866 GP_SET_BITS(8+o2, 8, p2,\
867 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1))); \
868 GP_SET_BITS(0+o2, 8, p2,\
869 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
873#define GP_PIXEL_RGBA8888_TO_RGB888(p1, p2) \
874 GP_PIXEL_RGBA8888_TO_RGB888_OFFSET(p1, 0, p2, 0)
883#define GP_PIXEL_RGBA8888_TO_BGR888_OFFSET(p1, o1, p2, o2) do { \
884 GP_SET_BITS(16+o2, 8, p2,\
885 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
886 GP_SET_BITS(8+o2, 8, p2,\
887 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1))); \
888 GP_SET_BITS(0+o2, 8, p2,\
889 GP_SCALE_VAL_8_8(GP_GET_BITS(24+o1, 8, p1))); \
893#define GP_PIXEL_RGBA8888_TO_BGR888(p1, p2) \
894 GP_PIXEL_RGBA8888_TO_BGR888_OFFSET(p1, 0, p2, 0)
903#define GP_PIXEL_BGR888_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
904 GP_SET_BITS(24+o2, 8, p2,\
905 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
906 GP_SET_BITS(16+o2, 8, p2,\
907 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
908 GP_SET_BITS(8+o2, 8, p2,\
909 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1))); \
910 GP_SET_BITS(0+o2, 8, p2, 0xff); \
914#define GP_PIXEL_BGR888_TO_RGBA8888(p1, p2) \
915 GP_PIXEL_BGR888_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
924#define GP_PIXEL_RGBA8888_TO_RGB555_OFFSET(p1, o1, p2, o2) do { \
925 GP_SET_BITS(10+o2, 5, p2,\
926 GP_SCALE_VAL_8_5(GP_GET_BITS(24+o1, 8, p1))); \
927 GP_SET_BITS(5+o2, 5, p2,\
928 GP_SCALE_VAL_8_5(GP_GET_BITS(16+o1, 8, p1))); \
929 GP_SET_BITS(0+o2, 5, p2,\
930 GP_SCALE_VAL_8_5(GP_GET_BITS(8+o1, 8, p1))); \
934#define GP_PIXEL_RGBA8888_TO_RGB555(p1, p2) \
935 GP_PIXEL_RGBA8888_TO_RGB555_OFFSET(p1, 0, p2, 0)
944#define GP_PIXEL_RGB555_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
945 GP_SET_BITS(24+o2, 8, p2,\
946 GP_SCALE_VAL_5_8(GP_GET_BITS(10+o1, 5, p1))); \
947 GP_SET_BITS(16+o2, 8, p2,\
948 GP_SCALE_VAL_5_8(GP_GET_BITS(5+o1, 5, p1))); \
949 GP_SET_BITS(8+o2, 8, p2,\
950 GP_SCALE_VAL_5_8(GP_GET_BITS(0+o1, 5, p1))); \
951 GP_SET_BITS(0+o2, 8, p2, 0xff); \
955#define GP_PIXEL_RGB555_TO_RGBA8888(p1, p2) \
956 GP_PIXEL_RGB555_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
965#define GP_PIXEL_RGBA8888_TO_RGB565_OFFSET(p1, o1, p2, o2) do { \
966 GP_SET_BITS(11+o2, 5, p2,\
967 GP_SCALE_VAL_8_5(GP_GET_BITS(24+o1, 8, p1))); \
968 GP_SET_BITS(5+o2, 6, p2,\
969 GP_SCALE_VAL_8_6(GP_GET_BITS(16+o1, 8, p1))); \
970 GP_SET_BITS(0+o2, 5, p2,\
971 GP_SCALE_VAL_8_5(GP_GET_BITS(8+o1, 8, p1))); \
975#define GP_PIXEL_RGBA8888_TO_RGB565(p1, p2) \
976 GP_PIXEL_RGBA8888_TO_RGB565_OFFSET(p1, 0, p2, 0)
985#define GP_PIXEL_RGB565_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
986 GP_SET_BITS(24+o2, 8, p2,\
987 GP_SCALE_VAL_5_8(GP_GET_BITS(11+o1, 5, p1))); \
988 GP_SET_BITS(16+o2, 8, p2,\
989 GP_SCALE_VAL_6_8(GP_GET_BITS(5+o1, 6, p1))); \
990 GP_SET_BITS(8+o2, 8, p2,\
991 GP_SCALE_VAL_5_8(GP_GET_BITS(0+o1, 5, p1))); \
992 GP_SET_BITS(0+o2, 8, p2, 0xff); \
996#define GP_PIXEL_RGB565_TO_RGBA8888(p1, p2) \
997 GP_PIXEL_RGB565_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
1006#define GP_PIXEL_RGBA8888_TO_RGB666_OFFSET(p1, o1, p2, o2) do { \
1007 GP_SET_BITS(12+o2, 6, p2,\
1008 GP_SCALE_VAL_8_6(GP_GET_BITS(24+o1, 8, p1))); \
1009 GP_SET_BITS(6+o2, 6, p2,\
1010 GP_SCALE_VAL_8_6(GP_GET_BITS(16+o1, 8, p1))); \
1011 GP_SET_BITS(0+o2, 6, p2,\
1012 GP_SCALE_VAL_8_6(GP_GET_BITS(8+o1, 8, p1))); \
1016#define GP_PIXEL_RGBA8888_TO_RGB666(p1, p2) \
1017 GP_PIXEL_RGBA8888_TO_RGB666_OFFSET(p1, 0, p2, 0)
1026#define GP_PIXEL_RGB666_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
1027 GP_SET_BITS(24+o2, 8, p2,\
1028 GP_SCALE_VAL_6_8(GP_GET_BITS(12+o1, 6, p1))); \
1029 GP_SET_BITS(16+o2, 8, p2,\
1030 GP_SCALE_VAL_6_8(GP_GET_BITS(6+o1, 6, p1))); \
1031 GP_SET_BITS(8+o2, 8, p2,\
1032 GP_SCALE_VAL_6_8(GP_GET_BITS(0+o1, 6, p1))); \
1033 GP_SET_BITS(0+o2, 8, p2, 0xff); \
1037#define GP_PIXEL_RGB666_TO_RGBA8888(p1, p2) \
1038 GP_PIXEL_RGB666_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
1047#define GP_PIXEL_RGBA8888_TO_RGB332_OFFSET(p1, o1, p2, o2) do { \
1048 GP_SET_BITS(5+o2, 3, p2,\
1049 GP_SCALE_VAL_8_3(GP_GET_BITS(24+o1, 8, p1))); \
1050 GP_SET_BITS(2+o2, 3, p2,\
1051 GP_SCALE_VAL_8_3(GP_GET_BITS(16+o1, 8, p1))); \
1052 GP_SET_BITS(0+o2, 2, p2,\
1053 GP_SCALE_VAL_8_2(GP_GET_BITS(8+o1, 8, p1))); \
1057#define GP_PIXEL_RGBA8888_TO_RGB332(p1, p2) \
1058 GP_PIXEL_RGBA8888_TO_RGB332_OFFSET(p1, 0, p2, 0)
1067#define GP_PIXEL_RGB332_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
1068 GP_SET_BITS(24+o2, 8, p2,\
1069 GP_SCALE_VAL_3_8(GP_GET_BITS(5+o1, 3, p1))); \
1070 GP_SET_BITS(16+o2, 8, p2,\
1071 GP_SCALE_VAL_3_8(GP_GET_BITS(2+o1, 3, p1))); \
1072 GP_SET_BITS(8+o2, 8, p2,\
1073 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
1074 GP_SET_BITS(0+o2, 8, p2, 0xff); \
1078#define GP_PIXEL_RGB332_TO_RGBA8888(p1, p2) \
1079 GP_PIXEL_RGB332_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
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)); \
1100#define GP_PIXEL_RGBA8888_TO_CMYK8888(p1, p2) \
1101 GP_PIXEL_RGBA8888_TO_CMYK8888_OFFSET(p1, 0, p2, 0)
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) \
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) \
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) \
1123 GP_SET_BITS(0+o2, 8, p2, 0xff); \
1127#define GP_PIXEL_CMYK8888_TO_RGBA8888(p1, p2) \
1128 GP_PIXEL_CMYK8888_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
1137#define GP_PIXEL_RGBA8888_TO_G1_DB_OFFSET(p1, o1, p2, o2) do { \
1138 GP_SET_BITS(0+o2, 1, p2, ( \
1139 GP_SCALE_VAL_8_1(GP_GET_BITS(24+o1, 8, p1)) + \
1140 GP_SCALE_VAL_8_1(GP_GET_BITS(16+o1, 8, p1)) + \
1141 GP_SCALE_VAL_8_1(GP_GET_BITS(8+o1, 8, p1)) + \
1146#define GP_PIXEL_RGBA8888_TO_G1_DB(p1, p2) \
1147 GP_PIXEL_RGBA8888_TO_G1_DB_OFFSET(p1, 0, p2, 0)
1156#define GP_PIXEL_G1_DB_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
1157 GP_SET_BITS(24+o2, 8, p2,\
1158 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
1159 GP_SET_BITS(16+o2, 8, p2,\
1160 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
1161 GP_SET_BITS(8+o2, 8, p2,\
1162 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
1163 GP_SET_BITS(0+o2, 8, p2, 0xff); \
1167#define GP_PIXEL_G1_DB_TO_RGBA8888(p1, p2) \
1168 GP_PIXEL_G1_DB_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
1177#define GP_PIXEL_RGBA8888_TO_G2_DB_OFFSET(p1, o1, p2, o2) do { \
1178 GP_SET_BITS(0+o2, 2, p2, ( \
1179 GP_SCALE_VAL_8_2(GP_GET_BITS(24+o1, 8, p1)) + \
1180 GP_SCALE_VAL_8_2(GP_GET_BITS(16+o1, 8, p1)) + \
1181 GP_SCALE_VAL_8_2(GP_GET_BITS(8+o1, 8, p1)) + \
1186#define GP_PIXEL_RGBA8888_TO_G2_DB(p1, p2) \
1187 GP_PIXEL_RGBA8888_TO_G2_DB_OFFSET(p1, 0, p2, 0)
1196#define GP_PIXEL_G2_DB_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
1197 GP_SET_BITS(24+o2, 8, p2,\
1198 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
1199 GP_SET_BITS(16+o2, 8, p2,\
1200 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
1201 GP_SET_BITS(8+o2, 8, p2,\
1202 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
1203 GP_SET_BITS(0+o2, 8, p2, 0xff); \
1207#define GP_PIXEL_G2_DB_TO_RGBA8888(p1, p2) \
1208 GP_PIXEL_G2_DB_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
1217#define GP_PIXEL_RGBA8888_TO_G4_DB_OFFSET(p1, o1, p2, o2) do { \
1218 GP_SET_BITS(0+o2, 4, p2, ( \
1219 GP_SCALE_VAL_8_4(GP_GET_BITS(24+o1, 8, p1)) + \
1220 GP_SCALE_VAL_8_4(GP_GET_BITS(16+o1, 8, p1)) + \
1221 GP_SCALE_VAL_8_4(GP_GET_BITS(8+o1, 8, p1)) + \
1226#define GP_PIXEL_RGBA8888_TO_G4_DB(p1, p2) \
1227 GP_PIXEL_RGBA8888_TO_G4_DB_OFFSET(p1, 0, p2, 0)
1236#define GP_PIXEL_G4_DB_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
1237 GP_SET_BITS(24+o2, 8, p2,\
1238 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
1239 GP_SET_BITS(16+o2, 8, p2,\
1240 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
1241 GP_SET_BITS(8+o2, 8, p2,\
1242 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
1243 GP_SET_BITS(0+o2, 8, p2, 0xff); \
1247#define GP_PIXEL_G4_DB_TO_RGBA8888(p1, p2) \
1248 GP_PIXEL_G4_DB_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
1257#define GP_PIXEL_RGBA8888_TO_G1_UB_OFFSET(p1, o1, p2, o2) do { \
1258 GP_SET_BITS(0+o2, 1, p2, ( \
1259 GP_SCALE_VAL_8_1(GP_GET_BITS(24+o1, 8, p1)) + \
1260 GP_SCALE_VAL_8_1(GP_GET_BITS(16+o1, 8, p1)) + \
1261 GP_SCALE_VAL_8_1(GP_GET_BITS(8+o1, 8, p1)) + \
1266#define GP_PIXEL_RGBA8888_TO_G1_UB(p1, p2) \
1267 GP_PIXEL_RGBA8888_TO_G1_UB_OFFSET(p1, 0, p2, 0)
1276#define GP_PIXEL_G1_UB_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
1277 GP_SET_BITS(24+o2, 8, p2,\
1278 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
1279 GP_SET_BITS(16+o2, 8, p2,\
1280 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
1281 GP_SET_BITS(8+o2, 8, p2,\
1282 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
1283 GP_SET_BITS(0+o2, 8, p2, 0xff); \
1287#define GP_PIXEL_G1_UB_TO_RGBA8888(p1, p2) \
1288 GP_PIXEL_G1_UB_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
1297#define GP_PIXEL_RGBA8888_TO_G2_UB_OFFSET(p1, o1, p2, o2) do { \
1298 GP_SET_BITS(0+o2, 2, p2, ( \
1299 GP_SCALE_VAL_8_2(GP_GET_BITS(24+o1, 8, p1)) + \
1300 GP_SCALE_VAL_8_2(GP_GET_BITS(16+o1, 8, p1)) + \
1301 GP_SCALE_VAL_8_2(GP_GET_BITS(8+o1, 8, p1)) + \
1306#define GP_PIXEL_RGBA8888_TO_G2_UB(p1, p2) \
1307 GP_PIXEL_RGBA8888_TO_G2_UB_OFFSET(p1, 0, p2, 0)
1316#define GP_PIXEL_G2_UB_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
1317 GP_SET_BITS(24+o2, 8, p2,\
1318 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
1319 GP_SET_BITS(16+o2, 8, p2,\
1320 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
1321 GP_SET_BITS(8+o2, 8, p2,\
1322 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
1323 GP_SET_BITS(0+o2, 8, p2, 0xff); \
1327#define GP_PIXEL_G2_UB_TO_RGBA8888(p1, p2) \
1328 GP_PIXEL_G2_UB_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
1337#define GP_PIXEL_RGBA8888_TO_G4_UB_OFFSET(p1, o1, p2, o2) do { \
1338 GP_SET_BITS(0+o2, 4, p2, ( \
1339 GP_SCALE_VAL_8_4(GP_GET_BITS(24+o1, 8, p1)) + \
1340 GP_SCALE_VAL_8_4(GP_GET_BITS(16+o1, 8, p1)) + \
1341 GP_SCALE_VAL_8_4(GP_GET_BITS(8+o1, 8, p1)) + \
1346#define GP_PIXEL_RGBA8888_TO_G4_UB(p1, p2) \
1347 GP_PIXEL_RGBA8888_TO_G4_UB_OFFSET(p1, 0, p2, 0)
1356#define GP_PIXEL_G4_UB_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
1357 GP_SET_BITS(24+o2, 8, p2,\
1358 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
1359 GP_SET_BITS(16+o2, 8, p2,\
1360 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
1361 GP_SET_BITS(8+o2, 8, p2,\
1362 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
1363 GP_SET_BITS(0+o2, 8, p2, 0xff); \
1367#define GP_PIXEL_G4_UB_TO_RGBA8888(p1, p2) \
1368 GP_PIXEL_G4_UB_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
1377#define GP_PIXEL_RGBA8888_TO_G8_OFFSET(p1, o1, p2, o2) do { \
1378 GP_SET_BITS(0+o2, 8, p2, ( \
1379 GP_SCALE_VAL_8_8(GP_GET_BITS(24+o1, 8, p1)) + \
1380 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1)) + \
1381 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1)) + \
1386#define GP_PIXEL_RGBA8888_TO_G8(p1, p2) \
1387 GP_PIXEL_RGBA8888_TO_G8_OFFSET(p1, 0, p2, 0)
1396#define GP_PIXEL_RGBA8888_TO_GA88_OFFSET(p1, o1, p2, o2) do { \
1397 GP_SET_BITS(0+o2, 8, p2, ( \
1398 GP_SCALE_VAL_8_8(GP_GET_BITS(24+o1, 8, p1)) + \
1399 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1)) + \
1400 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1)) + \
1402 GP_SET_BITS(8+o2, 8, p2,\
1403 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1407#define GP_PIXEL_RGBA8888_TO_GA88(p1, p2) \
1408 GP_PIXEL_RGBA8888_TO_GA88_OFFSET(p1, 0, p2, 0)
1417#define GP_PIXEL_GA88_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
1418 GP_SET_BITS(24+o2, 8, p2,\
1419 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1420 GP_SET_BITS(16+o2, 8, p2,\
1421 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1422 GP_SET_BITS(8+o2, 8, p2,\
1423 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1424 GP_SET_BITS(0+o2, 8, p2,\
1425 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1))); \
1429#define GP_PIXEL_GA88_TO_RGBA8888(p1, p2) \
1430 GP_PIXEL_GA88_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
1439#define GP_PIXEL_RGBA8888_TO_G16_OFFSET(p1, o1, p2, o2) do { \
1440 GP_SET_BITS(0+o2, 16, p2, ( \
1441 GP_SCALE_VAL_8_16(GP_GET_BITS(24+o1, 8, p1)) + \
1442 GP_SCALE_VAL_8_16(GP_GET_BITS(16+o1, 8, p1)) + \
1443 GP_SCALE_VAL_8_16(GP_GET_BITS(8+o1, 8, p1)) + \
1448#define GP_PIXEL_RGBA8888_TO_G16(p1, p2) \
1449 GP_PIXEL_RGBA8888_TO_G16_OFFSET(p1, 0, p2, 0)
1458#define GP_PIXEL_G16_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
1459 GP_SET_BITS(24+o2, 8, p2,\
1460 GP_SCALE_VAL_16_8(GP_GET_BITS(0+o1, 16, p1))); \
1461 GP_SET_BITS(16+o2, 8, p2,\
1462 GP_SCALE_VAL_16_8(GP_GET_BITS(0+o1, 16, p1))); \
1463 GP_SET_BITS(8+o2, 8, p2,\
1464 GP_SCALE_VAL_16_8(GP_GET_BITS(0+o1, 16, p1))); \
1465 GP_SET_BITS(0+o2, 8, p2, 0xff); \
1469#define GP_PIXEL_G16_TO_RGBA8888(p1, p2) \
1470 GP_PIXEL_G16_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
1504#define GP_PIXEL_G8_TO_RGB101010_OFFSET(p1, o1, p2, o2) do { \
1505 GP_SET_BITS(20+o2, 10, p2,\
1506 GP_SCALE_VAL_8_10(GP_GET_BITS(0+o1, 8, p1))); \
1507 GP_SET_BITS(10+o2, 10, p2,\
1508 GP_SCALE_VAL_8_10(GP_GET_BITS(0+o1, 8, p1))); \
1509 GP_SET_BITS(0+o2, 10, p2,\
1510 GP_SCALE_VAL_8_10(GP_GET_BITS(0+o1, 8, p1))); \
1514#define GP_PIXEL_G8_TO_RGB101010(p1, p2) \
1515 GP_PIXEL_G8_TO_RGB101010_OFFSET(p1, 0, p2, 0)
1524#define GP_PIXEL_RGB101010_TO_G8_OFFSET(p1, o1, p2, o2) do { \
1525 GP_SET_BITS(0+o2, 8, p2, ( \
1526 GP_SCALE_VAL_10_8(GP_GET_BITS(20+o1, 10, p1)) + \
1527 GP_SCALE_VAL_10_8(GP_GET_BITS(10+o1, 10, p1)) + \
1528 GP_SCALE_VAL_10_8(GP_GET_BITS(0+o1, 10, p1)) + \
1533#define GP_PIXEL_RGB101010_TO_G8(p1, p2) \
1534 GP_PIXEL_RGB101010_TO_G8_OFFSET(p1, 0, p2, 0)
1543#define GP_PIXEL_G8_TO_xRGB8888_OFFSET(p1, o1, p2, o2) do { \
1544 GP_SET_BITS(16+o2, 8, p2,\
1545 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1546 GP_SET_BITS(8+o2, 8, p2,\
1547 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1548 GP_SET_BITS(0+o2, 8, p2,\
1549 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1553#define GP_PIXEL_G8_TO_xRGB8888(p1, p2) \
1554 GP_PIXEL_G8_TO_xRGB8888_OFFSET(p1, 0, p2, 0)
1563#define GP_PIXEL_xRGB8888_TO_G8_OFFSET(p1, o1, p2, o2) do { \
1564 GP_SET_BITS(0+o2, 8, p2, ( \
1565 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1)) + \
1566 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1)) + \
1567 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1)) + \
1572#define GP_PIXEL_xRGB8888_TO_G8(p1, p2) \
1573 GP_PIXEL_xRGB8888_TO_G8_OFFSET(p1, 0, p2, 0)
1582#define GP_PIXEL_G8_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
1583 GP_SET_BITS(24+o2, 8, p2,\
1584 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1585 GP_SET_BITS(16+o2, 8, p2,\
1586 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1587 GP_SET_BITS(8+o2, 8, p2,\
1588 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1589 GP_SET_BITS(0+o2, 8, p2, 0xff); \
1593#define GP_PIXEL_G8_TO_RGBA8888(p1, p2) \
1594 GP_PIXEL_G8_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
1603#define GP_PIXEL_G8_TO_RGB888_OFFSET(p1, o1, p2, o2) do { \
1604 GP_SET_BITS(16+o2, 8, p2,\
1605 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1606 GP_SET_BITS(8+o2, 8, p2,\
1607 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1608 GP_SET_BITS(0+o2, 8, p2,\
1609 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1613#define GP_PIXEL_G8_TO_RGB888(p1, p2) \
1614 GP_PIXEL_G8_TO_RGB888_OFFSET(p1, 0, p2, 0)
1623#define GP_PIXEL_G8_TO_BGR888_OFFSET(p1, o1, p2, o2) do { \
1624 GP_SET_BITS(16+o2, 8, p2,\
1625 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1626 GP_SET_BITS(8+o2, 8, p2,\
1627 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1628 GP_SET_BITS(0+o2, 8, p2,\
1629 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
1633#define GP_PIXEL_G8_TO_BGR888(p1, p2) \
1634 GP_PIXEL_G8_TO_BGR888_OFFSET(p1, 0, p2, 0)
1643#define GP_PIXEL_BGR888_TO_G8_OFFSET(p1, o1, p2, o2) do { \
1644 GP_SET_BITS(0+o2, 8, p2, ( \
1645 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1)) + \
1646 GP_SCALE_VAL_8_8(GP_GET_BITS(8+o1, 8, p1)) + \
1647 GP_SCALE_VAL_8_8(GP_GET_BITS(16+o1, 8, p1)) + \
1652#define GP_PIXEL_BGR888_TO_G8(p1, p2) \
1653 GP_PIXEL_BGR888_TO_G8_OFFSET(p1, 0, p2, 0)
1662#define GP_PIXEL_G8_TO_RGB555_OFFSET(p1, o1, p2, o2) do { \
1663 GP_SET_BITS(10+o2, 5, p2,\
1664 GP_SCALE_VAL_8_5(GP_GET_BITS(0+o1, 8, p1))); \
1665 GP_SET_BITS(5+o2, 5, p2,\
1666 GP_SCALE_VAL_8_5(GP_GET_BITS(0+o1, 8, p1))); \
1667 GP_SET_BITS(0+o2, 5, p2,\
1668 GP_SCALE_VAL_8_5(GP_GET_BITS(0+o1, 8, p1))); \
1672#define GP_PIXEL_G8_TO_RGB555(p1, p2) \
1673 GP_PIXEL_G8_TO_RGB555_OFFSET(p1, 0, p2, 0)
1682#define GP_PIXEL_RGB555_TO_G8_OFFSET(p1, o1, p2, o2) do { \
1683 GP_SET_BITS(0+o2, 8, p2, ( \
1684 GP_SCALE_VAL_5_8(GP_GET_BITS(10+o1, 5, p1)) + \
1685 GP_SCALE_VAL_5_8(GP_GET_BITS(5+o1, 5, p1)) + \
1686 GP_SCALE_VAL_5_8(GP_GET_BITS(0+o1, 5, p1)) + \
1691#define GP_PIXEL_RGB555_TO_G8(p1, p2) \
1692 GP_PIXEL_RGB555_TO_G8_OFFSET(p1, 0, p2, 0)
1701#define GP_PIXEL_G8_TO_RGB565_OFFSET(p1, o1, p2, o2) do { \
1702 GP_SET_BITS(11+o2, 5, p2,\
1703 GP_SCALE_VAL_8_5(GP_GET_BITS(0+o1, 8, p1))); \
1704 GP_SET_BITS(5+o2, 6, p2,\
1705 GP_SCALE_VAL_8_6(GP_GET_BITS(0+o1, 8, p1))); \
1706 GP_SET_BITS(0+o2, 5, p2,\
1707 GP_SCALE_VAL_8_5(GP_GET_BITS(0+o1, 8, p1))); \
1711#define GP_PIXEL_G8_TO_RGB565(p1, p2) \
1712 GP_PIXEL_G8_TO_RGB565_OFFSET(p1, 0, p2, 0)
1721#define GP_PIXEL_RGB565_TO_G8_OFFSET(p1, o1, p2, o2) do { \
1722 GP_SET_BITS(0+o2, 8, p2, ( \
1723 GP_SCALE_VAL_5_8(GP_GET_BITS(11+o1, 5, p1)) + \
1724 GP_SCALE_VAL_6_8(GP_GET_BITS(5+o1, 6, p1)) + \
1725 GP_SCALE_VAL_5_8(GP_GET_BITS(0+o1, 5, p1)) + \
1730#define GP_PIXEL_RGB565_TO_G8(p1, p2) \
1731 GP_PIXEL_RGB565_TO_G8_OFFSET(p1, 0, p2, 0)
1740#define GP_PIXEL_G8_TO_RGB666_OFFSET(p1, o1, p2, o2) do { \
1741 GP_SET_BITS(12+o2, 6, p2,\
1742 GP_SCALE_VAL_8_6(GP_GET_BITS(0+o1, 8, p1))); \
1743 GP_SET_BITS(6+o2, 6, p2,\
1744 GP_SCALE_VAL_8_6(GP_GET_BITS(0+o1, 8, p1))); \
1745 GP_SET_BITS(0+o2, 6, p2,\
1746 GP_SCALE_VAL_8_6(GP_GET_BITS(0+o1, 8, p1))); \
1750#define GP_PIXEL_G8_TO_RGB666(p1, p2) \
1751 GP_PIXEL_G8_TO_RGB666_OFFSET(p1, 0, p2, 0)
1760#define GP_PIXEL_RGB666_TO_G8_OFFSET(p1, o1, p2, o2) do { \
1761 GP_SET_BITS(0+o2, 8, p2, ( \
1762 GP_SCALE_VAL_6_8(GP_GET_BITS(12+o1, 6, p1)) + \
1763 GP_SCALE_VAL_6_8(GP_GET_BITS(6+o1, 6, p1)) + \
1764 GP_SCALE_VAL_6_8(GP_GET_BITS(0+o1, 6, p1)) + \
1769#define GP_PIXEL_RGB666_TO_G8(p1, p2) \
1770 GP_PIXEL_RGB666_TO_G8_OFFSET(p1, 0, p2, 0)
1779#define GP_PIXEL_G8_TO_RGB332_OFFSET(p1, o1, p2, o2) do { \
1780 GP_SET_BITS(5+o2, 3, p2,\
1781 GP_SCALE_VAL_8_3(GP_GET_BITS(0+o1, 8, p1))); \
1782 GP_SET_BITS(2+o2, 3, p2,\
1783 GP_SCALE_VAL_8_3(GP_GET_BITS(0+o1, 8, p1))); \
1784 GP_SET_BITS(0+o2, 2, p2,\
1785 GP_SCALE_VAL_8_2(GP_GET_BITS(0+o1, 8, p1))); \
1789#define GP_PIXEL_G8_TO_RGB332(p1, p2) \
1790 GP_PIXEL_G8_TO_RGB332_OFFSET(p1, 0, p2, 0)
1799#define GP_PIXEL_RGB332_TO_G8_OFFSET(p1, o1, p2, o2) do { \
1800 GP_SET_BITS(0+o2, 8, p2, ( \
1801 GP_SCALE_VAL_3_8(GP_GET_BITS(5+o1, 3, p1)) + \
1802 GP_SCALE_VAL_3_8(GP_GET_BITS(2+o1, 3, p1)) + \
1803 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1)) + \
1808#define GP_PIXEL_RGB332_TO_G8(p1, p2) \
1809 GP_PIXEL_RGB332_TO_G8_OFFSET(p1, 0, p2, 0)
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."); \
1826#define GP_PIXEL_G8_TO_CMYK8888(p1, p2) \
1827 GP_PIXEL_G8_TO_CMYK8888_OFFSET(p1, 0, p2, 0)
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) \
1848#define GP_PIXEL_CMYK8888_TO_G8(p1, p2) \
1849 GP_PIXEL_CMYK8888_TO_G8_OFFSET(p1, 0, p2, 0)
1858#define GP_PIXEL_G8_TO_G1_DB_OFFSET(p1, o1, p2, o2) do { \
1859 GP_SET_BITS(0+o2, 1, p2,\
1860 GP_SCALE_VAL_8_1(GP_GET_BITS(0+o1, 8, p1))); \
1864#define GP_PIXEL_G8_TO_G1_DB(p1, p2) \
1865 GP_PIXEL_G8_TO_G1_DB_OFFSET(p1, 0, p2, 0)
1874#define GP_PIXEL_G1_DB_TO_G8_OFFSET(p1, o1, p2, o2) do { \
1875 GP_SET_BITS(0+o2, 8, p2,\
1876 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
1880#define GP_PIXEL_G1_DB_TO_G8(p1, p2) \
1881 GP_PIXEL_G1_DB_TO_G8_OFFSET(p1, 0, p2, 0)
1890#define GP_PIXEL_G8_TO_G2_DB_OFFSET(p1, o1, p2, o2) do { \
1891 GP_SET_BITS(0+o2, 2, p2,\
1892 GP_SCALE_VAL_8_2(GP_GET_BITS(0+o1, 8, p1))); \
1896#define GP_PIXEL_G8_TO_G2_DB(p1, p2) \
1897 GP_PIXEL_G8_TO_G2_DB_OFFSET(p1, 0, p2, 0)
1906#define GP_PIXEL_G2_DB_TO_G8_OFFSET(p1, o1, p2, o2) do { \
1907 GP_SET_BITS(0+o2, 8, p2,\
1908 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
1912#define GP_PIXEL_G2_DB_TO_G8(p1, p2) \
1913 GP_PIXEL_G2_DB_TO_G8_OFFSET(p1, 0, p2, 0)
1922#define GP_PIXEL_G8_TO_G4_DB_OFFSET(p1, o1, p2, o2) do { \
1923 GP_SET_BITS(0+o2, 4, p2,\
1924 GP_SCALE_VAL_8_4(GP_GET_BITS(0+o1, 8, p1))); \
1928#define GP_PIXEL_G8_TO_G4_DB(p1, p2) \
1929 GP_PIXEL_G8_TO_G4_DB_OFFSET(p1, 0, p2, 0)
1938#define GP_PIXEL_G4_DB_TO_G8_OFFSET(p1, o1, p2, o2) do { \
1939 GP_SET_BITS(0+o2, 8, p2,\
1940 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
1944#define GP_PIXEL_G4_DB_TO_G8(p1, p2) \
1945 GP_PIXEL_G4_DB_TO_G8_OFFSET(p1, 0, p2, 0)
1954#define GP_PIXEL_G8_TO_G1_UB_OFFSET(p1, o1, p2, o2) do { \
1955 GP_SET_BITS(0+o2, 1, p2,\
1956 GP_SCALE_VAL_8_1(GP_GET_BITS(0+o1, 8, p1))); \
1960#define GP_PIXEL_G8_TO_G1_UB(p1, p2) \
1961 GP_PIXEL_G8_TO_G1_UB_OFFSET(p1, 0, p2, 0)
1970#define GP_PIXEL_G1_UB_TO_G8_OFFSET(p1, o1, p2, o2) do { \
1971 GP_SET_BITS(0+o2, 8, p2,\
1972 GP_SCALE_VAL_1_8(GP_GET_BITS(0+o1, 1, p1))); \
1976#define GP_PIXEL_G1_UB_TO_G8(p1, p2) \
1977 GP_PIXEL_G1_UB_TO_G8_OFFSET(p1, 0, p2, 0)
1986#define GP_PIXEL_G8_TO_G2_UB_OFFSET(p1, o1, p2, o2) do { \
1987 GP_SET_BITS(0+o2, 2, p2,\
1988 GP_SCALE_VAL_8_2(GP_GET_BITS(0+o1, 8, p1))); \
1992#define GP_PIXEL_G8_TO_G2_UB(p1, p2) \
1993 GP_PIXEL_G8_TO_G2_UB_OFFSET(p1, 0, p2, 0)
2002#define GP_PIXEL_G2_UB_TO_G8_OFFSET(p1, o1, p2, o2) do { \
2003 GP_SET_BITS(0+o2, 8, p2,\
2004 GP_SCALE_VAL_2_8(GP_GET_BITS(0+o1, 2, p1))); \
2008#define GP_PIXEL_G2_UB_TO_G8(p1, p2) \
2009 GP_PIXEL_G2_UB_TO_G8_OFFSET(p1, 0, p2, 0)
2018#define GP_PIXEL_G8_TO_G4_UB_OFFSET(p1, o1, p2, o2) do { \
2019 GP_SET_BITS(0+o2, 4, p2,\
2020 GP_SCALE_VAL_8_4(GP_GET_BITS(0+o1, 8, p1))); \
2024#define GP_PIXEL_G8_TO_G4_UB(p1, p2) \
2025 GP_PIXEL_G8_TO_G4_UB_OFFSET(p1, 0, p2, 0)
2034#define GP_PIXEL_G4_UB_TO_G8_OFFSET(p1, o1, p2, o2) do { \
2035 GP_SET_BITS(0+o2, 8, p2,\
2036 GP_SCALE_VAL_4_8(GP_GET_BITS(0+o1, 4, p1))); \
2040#define GP_PIXEL_G4_UB_TO_G8(p1, p2) \
2041 GP_PIXEL_G4_UB_TO_G8_OFFSET(p1, 0, p2, 0)
2050#define GP_PIXEL_G8_TO_G8_OFFSET(p1, o1, p2, o2) do { \
2051 GP_SET_BITS(0+o2, 8, p2,\
2052 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
2056#define GP_PIXEL_G8_TO_G8(p1, p2) \
2057 GP_PIXEL_G8_TO_G8_OFFSET(p1, 0, p2, 0)
2066#define GP_PIXEL_G8_TO_GA88_OFFSET(p1, o1, p2, o2) do { \
2067 GP_SET_BITS(0+o2, 8, p2,\
2068 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
2069 GP_SET_BITS(8+o2, 8, p2, 0xff); \
2073#define GP_PIXEL_G8_TO_GA88(p1, p2) \
2074 GP_PIXEL_G8_TO_GA88_OFFSET(p1, 0, p2, 0)
2083#define GP_PIXEL_GA88_TO_G8_OFFSET(p1, o1, p2, o2) do { \
2084 GP_SET_BITS(0+o2, 8, p2,\
2085 GP_SCALE_VAL_8_8(GP_GET_BITS(0+o1, 8, p1))); \
2089#define GP_PIXEL_GA88_TO_G8(p1, p2) \
2090 GP_PIXEL_GA88_TO_G8_OFFSET(p1, 0, p2, 0)
2099#define GP_PIXEL_G8_TO_G16_OFFSET(p1, o1, p2, o2) do { \
2100 GP_SET_BITS(0+o2, 16, p2,\
2101 GP_SCALE_VAL_8_16(GP_GET_BITS(0+o1, 8, p1))); \
2105#define GP_PIXEL_G8_TO_G16(p1, p2) \
2106 GP_PIXEL_G8_TO_G16_OFFSET(p1, 0, p2, 0)
2115#define GP_PIXEL_G16_TO_G8_OFFSET(p1, o1, p2, o2) do { \
2116 GP_SET_BITS(0+o2, 8, p2,\
2117 GP_SCALE_VAL_16_8(GP_GET_BITS(0+o1, 16, p1))); \
2121#define GP_PIXEL_G16_TO_G8(p1, p2) \
2122 GP_PIXEL_G16_TO_G8_OFFSET(p1, 0, p2, 0)
2158#define GP_PIXEL_RGB565_TO_RGBA8888_OFFSET(p1, o1, p2, o2) do { \
2159 GP_SET_BITS(24+o2, 8, p2,\
2160 GP_SCALE_VAL_5_8(GP_GET_BITS(11+o1, 5, p1))); \
2161 GP_SET_BITS(16+o2, 8, p2,\
2162 GP_SCALE_VAL_6_8(GP_GET_BITS(5+o1, 6, p1))); \
2163 GP_SET_BITS(8+o2, 8, p2,\
2164 GP_SCALE_VAL_5_8(GP_GET_BITS(0+o1, 5, p1))); \
2165 GP_SET_BITS(0+o2, 8, p2, 0xff); \
2169#define GP_PIXEL_RGB565_TO_RGBA8888(p1, p2) \
2170 GP_PIXEL_RGB565_TO_RGBA8888_OFFSET(p1, 0, p2, 0)
2179#define GP_PIXEL_RGBA8888_TO_G2_UB_OFFSET(p1, o1, p2, o2) do { \
2180 GP_SET_BITS(0+o2, 2, p2, ( \
2181 GP_SCALE_VAL_8_2(GP_GET_BITS(24+o1, 8, p1)) + \
2182 GP_SCALE_VAL_8_2(GP_GET_BITS(16+o1, 8, p1)) + \
2183 GP_SCALE_VAL_8_2(GP_GET_BITS(8+o1, 8, p1)) + \
2188#define GP_PIXEL_RGBA8888_TO_G2_UB(p1, p2) \
2189 GP_PIXEL_RGBA8888_TO_G2_UB_OFFSET(p1, 0, p2, 0)
uint32_t gp_pixel
Pixel integer value.
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.