GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
gp_pixel.gen.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.1-or-later
2/*
3 * gp_pixel.gen.h
4 *
5 * GENERATED on 2024 04 14 13:01:16 from gp_pixel.gen.h.t
6 *
7 * DO NOT MODIFY THIS FILE DIRECTLY!
8 */
9#ifndef GP_PIXEL_GEN_H
10#define GP_PIXEL_GEN_H
11
12/*
13 * Pixel type definitions and functions.
14 * Do not include directly, use gp_pixel.h
15 *
16 * Copyright (C) 2011 Tomas Gavenciak <gavento@ucw.cz>
17 * Copyright (C) 2013-2024 Cyril Hrubis <metan@ucw.cz>
18 */
19
29#include <core/gp_clamp.h>
30
64typedef enum gp_pixel_type {
71 GP_PIXEL_UNKNOWN,
77 GP_PIXEL_RGB101010,
83 GP_PIXEL_xRGB8888,
89 GP_PIXEL_RGBA8888,
95 GP_PIXEL_RGB888,
101 GP_PIXEL_BGR888,
107 GP_PIXEL_RGB555,
113 GP_PIXEL_RGB565,
119 GP_PIXEL_RGB666,
125 GP_PIXEL_RGB332,
131 GP_PIXEL_CMYK8888,
137 GP_PIXEL_P2,
143 GP_PIXEL_P4,
149 GP_PIXEL_P8,
155 GP_PIXEL_G1_DB,
161 GP_PIXEL_G2_DB,
167 GP_PIXEL_G4_DB,
173 GP_PIXEL_G1_UB,
179 GP_PIXEL_G2_UB,
185 GP_PIXEL_G4_UB,
191 GP_PIXEL_G8,
197 GP_PIXEL_GA88,
203 GP_PIXEL_G16,
207
208#define GP_PIXEL_UNKNOWN GP_PIXEL_UNKNOWN
209#define GP_PIXEL_RGB101010 GP_PIXEL_RGB101010
210#define GP_PIXEL_xRGB8888 GP_PIXEL_xRGB8888
211#define GP_PIXEL_RGBA8888 GP_PIXEL_RGBA8888
212#define GP_PIXEL_RGB888 GP_PIXEL_RGB888
213#define GP_PIXEL_BGR888 GP_PIXEL_BGR888
214#define GP_PIXEL_RGB555 GP_PIXEL_RGB555
215#define GP_PIXEL_RGB565 GP_PIXEL_RGB565
216#define GP_PIXEL_RGB666 GP_PIXEL_RGB666
217#define GP_PIXEL_RGB332 GP_PIXEL_RGB332
218#define GP_PIXEL_CMYK8888 GP_PIXEL_CMYK8888
219#define GP_PIXEL_P2 GP_PIXEL_P2
220#define GP_PIXEL_P4 GP_PIXEL_P4
221#define GP_PIXEL_P8 GP_PIXEL_P8
222#define GP_PIXEL_G1_DB GP_PIXEL_G1_DB
223#define GP_PIXEL_G2_DB GP_PIXEL_G2_DB
224#define GP_PIXEL_G4_DB GP_PIXEL_G4_DB
225#define GP_PIXEL_G1_UB GP_PIXEL_G1_UB
226#define GP_PIXEL_G2_UB GP_PIXEL_G2_UB
227#define GP_PIXEL_G4_UB GP_PIXEL_G4_UB
228#define GP_PIXEL_G8 GP_PIXEL_G8
229#define GP_PIXEL_GA88 GP_PIXEL_GA88
230#define GP_PIXEL_G16 GP_PIXEL_G16
231
237#define GP_PIXEL_CHANS_MAX 4
238
239/* Automatically generated code for pixel type RGB101010
240 *
241 * Size (bpp): 32 (32BPP)
242 * Pixel structure: BBBBBBBBBBGGGGGGGGGGRRRRRRRRRRxx
243 * Channels:
244 * R offset:20 size:10
245 * G offset:10 size:10
246 * B offset:0 size:10
247 */
248
249/*
250 * macros to get channels of pixel type RGB101010
251 */
252#define GP_PIXEL_GET_R_RGB101010(p) (GP_GET_BITS(20, 10, (p)))
253#define GP_PIXEL_GET_G_RGB101010(p) (GP_GET_BITS(10, 10, (p)))
254#define GP_PIXEL_GET_B_RGB101010(p) (GP_GET_BITS(0, 10, (p)))
255
256/*
257 * macros to get address and bit-offset of a pixel RGB101010 in a pixmap
258 */
259#define GP_PIXEL_ADDR_RGB101010(pixmap, x, y) GP_PIXEL_ADDR_32BPP(pixmap, x, y)
260#define GP_PIXEL_ADDR_OFFSET_RGB101010(x) GP_PIXEL_ADDR_OFFSET_32BPP(x)
261
262/*
263 * macros to create gp_pixel of pixel type RGB101010 directly from given values.
264 * The values MUST be already clipped/converted to relevant value ranges.
265 */
266#define GP_PIXEL_CREATE_RGB101010(R, G, B) (0\
267 + ((R) << 20) \
268 + ((G) << 10) \
269 + ((B) << 0) \
270 )
271
272/* Automatically generated code for pixel type xRGB8888
273 *
274 * Size (bpp): 32 (32BPP)
275 * Pixel structure: BBBBBBBBGGGGGGGGRRRRRRRRxxxxxxxx
276 * Channels:
277 * R offset:16 size:8
278 * G offset:8 size:8
279 * B offset:0 size:8
280 */
281
282/*
283 * macros to get channels of pixel type xRGB8888
284 */
285#define GP_PIXEL_GET_R_xRGB8888(p) (GP_GET_BITS(16, 8, (p)))
286#define GP_PIXEL_GET_G_xRGB8888(p) (GP_GET_BITS(8, 8, (p)))
287#define GP_PIXEL_GET_B_xRGB8888(p) (GP_GET_BITS(0, 8, (p)))
288
289/*
290 * macros to get address and bit-offset of a pixel xRGB8888 in a pixmap
291 */
292#define GP_PIXEL_ADDR_xRGB8888(pixmap, x, y) GP_PIXEL_ADDR_32BPP(pixmap, x, y)
293#define GP_PIXEL_ADDR_OFFSET_xRGB8888(x) GP_PIXEL_ADDR_OFFSET_32BPP(x)
294
295/*
296 * macros to create gp_pixel of pixel type xRGB8888 directly from given values.
297 * The values MUST be already clipped/converted to relevant value ranges.
298 */
299#define GP_PIXEL_CREATE_xRGB8888(R, G, B) (0\
300 + ((R) << 16) \
301 + ((G) << 8) \
302 + ((B) << 0) \
303 )
304
305/* Automatically generated code for pixel type RGBA8888
306 *
307 * Size (bpp): 32 (32BPP)
308 * Pixel structure: AAAAAAAABBBBBBBBGGGGGGGGRRRRRRRR
309 * Channels:
310 * R offset:24 size:8
311 * G offset:16 size:8
312 * B offset:8 size:8
313 * A offset:0 size:8
314 */
315
316/*
317 * macros to get channels of pixel type RGBA8888
318 */
319#define GP_PIXEL_GET_R_RGBA8888(p) (GP_GET_BITS(24, 8, (p)))
320#define GP_PIXEL_GET_G_RGBA8888(p) (GP_GET_BITS(16, 8, (p)))
321#define GP_PIXEL_GET_B_RGBA8888(p) (GP_GET_BITS(8, 8, (p)))
322#define GP_PIXEL_GET_A_RGBA8888(p) (GP_GET_BITS(0, 8, (p)))
323
324/*
325 * macros to get address and bit-offset of a pixel RGBA8888 in a pixmap
326 */
327#define GP_PIXEL_ADDR_RGBA8888(pixmap, x, y) GP_PIXEL_ADDR_32BPP(pixmap, x, y)
328#define GP_PIXEL_ADDR_OFFSET_RGBA8888(x) GP_PIXEL_ADDR_OFFSET_32BPP(x)
329
330/*
331 * macros to create gp_pixel of pixel type RGBA8888 directly from given values.
332 * The values MUST be already clipped/converted to relevant value ranges.
333 */
334#define GP_PIXEL_CREATE_RGBA8888(R, G, B, A) (0\
335 + ((R) << 24) \
336 + ((G) << 16) \
337 + ((B) << 8) \
338 + ((A) << 0) \
339 )
340
341/* Automatically generated code for pixel type RGB888
342 *
343 * Size (bpp): 24 (24BPP)
344 * Pixel structure: BBBBBBBBGGGGGGGGRRRRRRRR
345 * Channels:
346 * R offset:16 size:8
347 * G offset:8 size:8
348 * B offset:0 size:8
349 */
350
351/*
352 * macros to get channels of pixel type RGB888
353 */
354#define GP_PIXEL_GET_R_RGB888(p) (GP_GET_BITS(16, 8, (p)))
355#define GP_PIXEL_GET_G_RGB888(p) (GP_GET_BITS(8, 8, (p)))
356#define GP_PIXEL_GET_B_RGB888(p) (GP_GET_BITS(0, 8, (p)))
357
358/*
359 * macros to get address and bit-offset of a pixel RGB888 in a pixmap
360 */
361#define GP_PIXEL_ADDR_RGB888(pixmap, x, y) GP_PIXEL_ADDR_24BPP(pixmap, x, y)
362#define GP_PIXEL_ADDR_OFFSET_RGB888(x) GP_PIXEL_ADDR_OFFSET_24BPP(x)
363
364/*
365 * macros to create gp_pixel of pixel type RGB888 directly from given values.
366 * The values MUST be already clipped/converted to relevant value ranges.
367 */
368#define GP_PIXEL_CREATE_RGB888(R, G, B) (0\
369 + ((R) << 16) \
370 + ((G) << 8) \
371 + ((B) << 0) \
372 )
373
374/* Automatically generated code for pixel type BGR888
375 *
376 * Size (bpp): 24 (24BPP)
377 * Pixel structure: RRRRRRRRGGGGGGGGBBBBBBBB
378 * Channels:
379 * B offset:16 size:8
380 * G offset:8 size:8
381 * R offset:0 size:8
382 */
383
384/*
385 * macros to get channels of pixel type BGR888
386 */
387#define GP_PIXEL_GET_B_BGR888(p) (GP_GET_BITS(16, 8, (p)))
388#define GP_PIXEL_GET_G_BGR888(p) (GP_GET_BITS(8, 8, (p)))
389#define GP_PIXEL_GET_R_BGR888(p) (GP_GET_BITS(0, 8, (p)))
390
391/*
392 * macros to get address and bit-offset of a pixel BGR888 in a pixmap
393 */
394#define GP_PIXEL_ADDR_BGR888(pixmap, x, y) GP_PIXEL_ADDR_24BPP(pixmap, x, y)
395#define GP_PIXEL_ADDR_OFFSET_BGR888(x) GP_PIXEL_ADDR_OFFSET_24BPP(x)
396
397/*
398 * macros to create gp_pixel of pixel type BGR888 directly from given values.
399 * The values MUST be already clipped/converted to relevant value ranges.
400 */
401#define GP_PIXEL_CREATE_BGR888(B, G, R) (0\
402 + ((B) << 16) \
403 + ((G) << 8) \
404 + ((R) << 0) \
405 )
406
407/* Automatically generated code for pixel type RGB555
408 *
409 * Size (bpp): 16 (16BPP)
410 * Pixel structure: BBBBBGGGGGRRRRRx
411 * Channels:
412 * R offset:10 size:5
413 * G offset:5 size:5
414 * B offset:0 size:5
415 */
416
417/*
418 * macros to get channels of pixel type RGB555
419 */
420#define GP_PIXEL_GET_R_RGB555(p) (GP_GET_BITS(10, 5, (p)))
421#define GP_PIXEL_GET_G_RGB555(p) (GP_GET_BITS(5, 5, (p)))
422#define GP_PIXEL_GET_B_RGB555(p) (GP_GET_BITS(0, 5, (p)))
423
424/*
425 * macros to get address and bit-offset of a pixel RGB555 in a pixmap
426 */
427#define GP_PIXEL_ADDR_RGB555(pixmap, x, y) GP_PIXEL_ADDR_16BPP(pixmap, x, y)
428#define GP_PIXEL_ADDR_OFFSET_RGB555(x) GP_PIXEL_ADDR_OFFSET_16BPP(x)
429
430/*
431 * macros to create gp_pixel of pixel type RGB555 directly from given values.
432 * The values MUST be already clipped/converted to relevant value ranges.
433 */
434#define GP_PIXEL_CREATE_RGB555(R, G, B) (0\
435 + ((R) << 10) \
436 + ((G) << 5) \
437 + ((B) << 0) \
438 )
439
440/* Automatically generated code for pixel type RGB565
441 *
442 * Size (bpp): 16 (16BPP)
443 * Pixel structure: BBBBBGGGGGGRRRRR
444 * Channels:
445 * R offset:11 size:5
446 * G offset:5 size:6
447 * B offset:0 size:5
448 */
449
450/*
451 * macros to get channels of pixel type RGB565
452 */
453#define GP_PIXEL_GET_R_RGB565(p) (GP_GET_BITS(11, 5, (p)))
454#define GP_PIXEL_GET_G_RGB565(p) (GP_GET_BITS(5, 6, (p)))
455#define GP_PIXEL_GET_B_RGB565(p) (GP_GET_BITS(0, 5, (p)))
456
457/*
458 * macros to get address and bit-offset of a pixel RGB565 in a pixmap
459 */
460#define GP_PIXEL_ADDR_RGB565(pixmap, x, y) GP_PIXEL_ADDR_16BPP(pixmap, x, y)
461#define GP_PIXEL_ADDR_OFFSET_RGB565(x) GP_PIXEL_ADDR_OFFSET_16BPP(x)
462
463/*
464 * macros to create gp_pixel of pixel type RGB565 directly from given values.
465 * The values MUST be already clipped/converted to relevant value ranges.
466 */
467#define GP_PIXEL_CREATE_RGB565(R, G, B) (0\
468 + ((R) << 11) \
469 + ((G) << 5) \
470 + ((B) << 0) \
471 )
472
473/* Automatically generated code for pixel type RGB666
474 *
475 * Size (bpp): 18 (18BPP_DB)
476 * Pixel structure: BBBBBBGGGGGGRRRRRR
477 * Bit order: DB
478 * Channels:
479 * R offset:12 size:6
480 * G offset:6 size:6
481 * B offset:0 size:6
482 */
483
484/*
485 * macros to get channels of pixel type RGB666
486 */
487#define GP_PIXEL_GET_R_RGB666(p) (GP_GET_BITS(12, 6, (p)))
488#define GP_PIXEL_GET_G_RGB666(p) (GP_GET_BITS(6, 6, (p)))
489#define GP_PIXEL_GET_B_RGB666(p) (GP_GET_BITS(0, 6, (p)))
490
491/*
492 * macros to get address and bit-offset of a pixel RGB666 in a pixmap
493 */
494#define GP_PIXEL_ADDR_RGB666(pixmap, x, y) GP_PIXEL_ADDR_18BPP_DB(pixmap, x, y)
495#define GP_PIXEL_ADDR_OFFSET_RGB666(x) GP_PIXEL_ADDR_OFFSET_18BPP_DB(x)
496
497/*
498 * macros to create gp_pixel of pixel type RGB666 directly from given values.
499 * The values MUST be already clipped/converted to relevant value ranges.
500 */
501#define GP_PIXEL_CREATE_RGB666(R, G, B) (0\
502 + ((R) << 12) \
503 + ((G) << 6) \
504 + ((B) << 0) \
505 )
506
507/* Automatically generated code for pixel type RGB332
508 *
509 * Size (bpp): 8 (8BPP)
510 * Pixel structure: BBGGGRRR
511 * Channels:
512 * R offset:5 size:3
513 * G offset:2 size:3
514 * B offset:0 size:2
515 */
516
517/*
518 * macros to get channels of pixel type RGB332
519 */
520#define GP_PIXEL_GET_R_RGB332(p) (GP_GET_BITS(5, 3, (p)))
521#define GP_PIXEL_GET_G_RGB332(p) (GP_GET_BITS(2, 3, (p)))
522#define GP_PIXEL_GET_B_RGB332(p) (GP_GET_BITS(0, 2, (p)))
523
524/*
525 * macros to get address and bit-offset of a pixel RGB332 in a pixmap
526 */
527#define GP_PIXEL_ADDR_RGB332(pixmap, x, y) GP_PIXEL_ADDR_8BPP(pixmap, x, y)
528#define GP_PIXEL_ADDR_OFFSET_RGB332(x) GP_PIXEL_ADDR_OFFSET_8BPP(x)
529
530/*
531 * macros to create gp_pixel of pixel type RGB332 directly from given values.
532 * The values MUST be already clipped/converted to relevant value ranges.
533 */
534#define GP_PIXEL_CREATE_RGB332(R, G, B) (0\
535 + ((R) << 5) \
536 + ((G) << 2) \
537 + ((B) << 0) \
538 )
539
540/* Automatically generated code for pixel type CMYK8888
541 *
542 * Size (bpp): 32 (32BPP)
543 * Pixel structure: CCCCCCCCMMMMMMMMYYYYYYYYKKKKKKKK
544 * Channels:
545 * K offset:24 size:8
546 * Y offset:16 size:8
547 * M offset:8 size:8
548 * C offset:0 size:8
549 */
550
551/*
552 * macros to get channels of pixel type CMYK8888
553 */
554#define GP_PIXEL_GET_K_CMYK8888(p) (GP_GET_BITS(24, 8, (p)))
555#define GP_PIXEL_GET_Y_CMYK8888(p) (GP_GET_BITS(16, 8, (p)))
556#define GP_PIXEL_GET_M_CMYK8888(p) (GP_GET_BITS(8, 8, (p)))
557#define GP_PIXEL_GET_C_CMYK8888(p) (GP_GET_BITS(0, 8, (p)))
558
559/*
560 * macros to get address and bit-offset of a pixel CMYK8888 in a pixmap
561 */
562#define GP_PIXEL_ADDR_CMYK8888(pixmap, x, y) GP_PIXEL_ADDR_32BPP(pixmap, x, y)
563#define GP_PIXEL_ADDR_OFFSET_CMYK8888(x) GP_PIXEL_ADDR_OFFSET_32BPP(x)
564
565/*
566 * macros to create gp_pixel of pixel type CMYK8888 directly from given values.
567 * The values MUST be already clipped/converted to relevant value ranges.
568 */
569#define GP_PIXEL_CREATE_CMYK8888(K, Y, M, C) (0\
570 + ((K) << 24) \
571 + ((Y) << 16) \
572 + ((M) << 8) \
573 + ((C) << 0) \
574 )
575
576/* Automatically generated code for pixel type P2
577 *
578 * Size (bpp): 2 (2BPP_UB)
579 * Pixel structure: PP
580 * Bit order: UB
581 * Channels:
582 * P offset:0 size:2
583 */
584
585/*
586 * macros to get channels of pixel type P2
587 */
588#define GP_PIXEL_GET_P_P2(p) (GP_GET_BITS(0, 2, (p)))
589
590/*
591 * macros to get address and bit-offset of a pixel P2 in a pixmap
592 */
593#define GP_PIXEL_ADDR_P2(pixmap, x, y) GP_PIXEL_ADDR_2BPP_UB(pixmap, x, y)
594#define GP_PIXEL_ADDR_OFFSET_P2(x) GP_PIXEL_ADDR_OFFSET_2BPP_UB(x)
595
596/*
597 * macros to create gp_pixel of pixel type P2 directly from given values.
598 * The values MUST be already clipped/converted to relevant value ranges.
599 */
600#define GP_PIXEL_CREATE_P2(P) (0\
601 + ((P) << 0) \
602 )
603
604/* Automatically generated code for pixel type P4
605 *
606 * Size (bpp): 4 (4BPP_UB)
607 * Pixel structure: PPPP
608 * Bit order: UB
609 * Channels:
610 * P offset:0 size:4
611 */
612
613/*
614 * macros to get channels of pixel type P4
615 */
616#define GP_PIXEL_GET_P_P4(p) (GP_GET_BITS(0, 4, (p)))
617
618/*
619 * macros to get address and bit-offset of a pixel P4 in a pixmap
620 */
621#define GP_PIXEL_ADDR_P4(pixmap, x, y) GP_PIXEL_ADDR_4BPP_UB(pixmap, x, y)
622#define GP_PIXEL_ADDR_OFFSET_P4(x) GP_PIXEL_ADDR_OFFSET_4BPP_UB(x)
623
624/*
625 * macros to create gp_pixel of pixel type P4 directly from given values.
626 * The values MUST be already clipped/converted to relevant value ranges.
627 */
628#define GP_PIXEL_CREATE_P4(P) (0\
629 + ((P) << 0) \
630 )
631
632/* Automatically generated code for pixel type P8
633 *
634 * Size (bpp): 8 (8BPP)
635 * Pixel structure: PPPPPPPP
636 * Channels:
637 * P offset:0 size:8
638 */
639
640/*
641 * macros to get channels of pixel type P8
642 */
643#define GP_PIXEL_GET_P_P8(p) (GP_GET_BITS(0, 8, (p)))
644
645/*
646 * macros to get address and bit-offset of a pixel P8 in a pixmap
647 */
648#define GP_PIXEL_ADDR_P8(pixmap, x, y) GP_PIXEL_ADDR_8BPP(pixmap, x, y)
649#define GP_PIXEL_ADDR_OFFSET_P8(x) GP_PIXEL_ADDR_OFFSET_8BPP(x)
650
651/*
652 * macros to create gp_pixel of pixel type P8 directly from given values.
653 * The values MUST be already clipped/converted to relevant value ranges.
654 */
655#define GP_PIXEL_CREATE_P8(P) (0\
656 + ((P) << 0) \
657 )
658
659/* Automatically generated code for pixel type G1_DB
660 *
661 * Size (bpp): 1 (1BPP_DB)
662 * Pixel structure: V
663 * Bit order: DB
664 * Channels:
665 * V offset:0 size:1
666 */
667
668/*
669 * macros to get channels of pixel type G1_DB
670 */
671#define GP_PIXEL_GET_V_G1_DB(p) (GP_GET_BITS(0, 1, (p)))
672
673/*
674 * macros to get address and bit-offset of a pixel G1_DB in a pixmap
675 */
676#define GP_PIXEL_ADDR_G1_DB(pixmap, x, y) GP_PIXEL_ADDR_1BPP_DB(pixmap, x, y)
677#define GP_PIXEL_ADDR_OFFSET_G1_DB(x) GP_PIXEL_ADDR_OFFSET_1BPP_DB(x)
678
679/*
680 * macros to create gp_pixel of pixel type G1_DB directly from given values.
681 * The values MUST be already clipped/converted to relevant value ranges.
682 */
683#define GP_PIXEL_CREATE_G1_DB(V) (0\
684 + ((V) << 0) \
685 )
686
687/* Automatically generated code for pixel type G2_DB
688 *
689 * Size (bpp): 2 (2BPP_DB)
690 * Pixel structure: VV
691 * Bit order: DB
692 * Channels:
693 * V offset:0 size:2
694 */
695
696/*
697 * macros to get channels of pixel type G2_DB
698 */
699#define GP_PIXEL_GET_V_G2_DB(p) (GP_GET_BITS(0, 2, (p)))
700
701/*
702 * macros to get address and bit-offset of a pixel G2_DB in a pixmap
703 */
704#define GP_PIXEL_ADDR_G2_DB(pixmap, x, y) GP_PIXEL_ADDR_2BPP_DB(pixmap, x, y)
705#define GP_PIXEL_ADDR_OFFSET_G2_DB(x) GP_PIXEL_ADDR_OFFSET_2BPP_DB(x)
706
707/*
708 * macros to create gp_pixel of pixel type G2_DB directly from given values.
709 * The values MUST be already clipped/converted to relevant value ranges.
710 */
711#define GP_PIXEL_CREATE_G2_DB(V) (0\
712 + ((V) << 0) \
713 )
714
715/* Automatically generated code for pixel type G4_DB
716 *
717 * Size (bpp): 4 (4BPP_DB)
718 * Pixel structure: VVVV
719 * Bit order: DB
720 * Channels:
721 * V offset:0 size:4
722 */
723
724/*
725 * macros to get channels of pixel type G4_DB
726 */
727#define GP_PIXEL_GET_V_G4_DB(p) (GP_GET_BITS(0, 4, (p)))
728
729/*
730 * macros to get address and bit-offset of a pixel G4_DB in a pixmap
731 */
732#define GP_PIXEL_ADDR_G4_DB(pixmap, x, y) GP_PIXEL_ADDR_4BPP_DB(pixmap, x, y)
733#define GP_PIXEL_ADDR_OFFSET_G4_DB(x) GP_PIXEL_ADDR_OFFSET_4BPP_DB(x)
734
735/*
736 * macros to create gp_pixel of pixel type G4_DB directly from given values.
737 * The values MUST be already clipped/converted to relevant value ranges.
738 */
739#define GP_PIXEL_CREATE_G4_DB(V) (0\
740 + ((V) << 0) \
741 )
742
743/* Automatically generated code for pixel type G1_UB
744 *
745 * Size (bpp): 1 (1BPP_UB)
746 * Pixel structure: V
747 * Bit order: UB
748 * Channels:
749 * V offset:0 size:1
750 */
751
752/*
753 * macros to get channels of pixel type G1_UB
754 */
755#define GP_PIXEL_GET_V_G1_UB(p) (GP_GET_BITS(0, 1, (p)))
756
757/*
758 * macros to get address and bit-offset of a pixel G1_UB in a pixmap
759 */
760#define GP_PIXEL_ADDR_G1_UB(pixmap, x, y) GP_PIXEL_ADDR_1BPP_UB(pixmap, x, y)
761#define GP_PIXEL_ADDR_OFFSET_G1_UB(x) GP_PIXEL_ADDR_OFFSET_1BPP_UB(x)
762
763/*
764 * macros to create gp_pixel of pixel type G1_UB directly from given values.
765 * The values MUST be already clipped/converted to relevant value ranges.
766 */
767#define GP_PIXEL_CREATE_G1_UB(V) (0\
768 + ((V) << 0) \
769 )
770
771/* Automatically generated code for pixel type G2_UB
772 *
773 * Size (bpp): 2 (2BPP_UB)
774 * Pixel structure: VV
775 * Bit order: UB
776 * Channels:
777 * V offset:0 size:2
778 */
779
780/*
781 * macros to get channels of pixel type G2_UB
782 */
783#define GP_PIXEL_GET_V_G2_UB(p) (GP_GET_BITS(0, 2, (p)))
784
785/*
786 * macros to get address and bit-offset of a pixel G2_UB in a pixmap
787 */
788#define GP_PIXEL_ADDR_G2_UB(pixmap, x, y) GP_PIXEL_ADDR_2BPP_UB(pixmap, x, y)
789#define GP_PIXEL_ADDR_OFFSET_G2_UB(x) GP_PIXEL_ADDR_OFFSET_2BPP_UB(x)
790
791/*
792 * macros to create gp_pixel of pixel type G2_UB directly from given values.
793 * The values MUST be already clipped/converted to relevant value ranges.
794 */
795#define GP_PIXEL_CREATE_G2_UB(V) (0\
796 + ((V) << 0) \
797 )
798
799/* Automatically generated code for pixel type G4_UB
800 *
801 * Size (bpp): 4 (4BPP_UB)
802 * Pixel structure: VVVV
803 * Bit order: UB
804 * Channels:
805 * V offset:0 size:4
806 */
807
808/*
809 * macros to get channels of pixel type G4_UB
810 */
811#define GP_PIXEL_GET_V_G4_UB(p) (GP_GET_BITS(0, 4, (p)))
812
813/*
814 * macros to get address and bit-offset of a pixel G4_UB in a pixmap
815 */
816#define GP_PIXEL_ADDR_G4_UB(pixmap, x, y) GP_PIXEL_ADDR_4BPP_UB(pixmap, x, y)
817#define GP_PIXEL_ADDR_OFFSET_G4_UB(x) GP_PIXEL_ADDR_OFFSET_4BPP_UB(x)
818
819/*
820 * macros to create gp_pixel of pixel type G4_UB directly from given values.
821 * The values MUST be already clipped/converted to relevant value ranges.
822 */
823#define GP_PIXEL_CREATE_G4_UB(V) (0\
824 + ((V) << 0) \
825 )
826
827/* Automatically generated code for pixel type G8
828 *
829 * Size (bpp): 8 (8BPP)
830 * Pixel structure: VVVVVVVV
831 * Channels:
832 * V offset:0 size:8
833 */
834
835/*
836 * macros to get channels of pixel type G8
837 */
838#define GP_PIXEL_GET_V_G8(p) (GP_GET_BITS(0, 8, (p)))
839
840/*
841 * macros to get address and bit-offset of a pixel G8 in a pixmap
842 */
843#define GP_PIXEL_ADDR_G8(pixmap, x, y) GP_PIXEL_ADDR_8BPP(pixmap, x, y)
844#define GP_PIXEL_ADDR_OFFSET_G8(x) GP_PIXEL_ADDR_OFFSET_8BPP(x)
845
846/*
847 * macros to create gp_pixel of pixel type G8 directly from given values.
848 * The values MUST be already clipped/converted to relevant value ranges.
849 */
850#define GP_PIXEL_CREATE_G8(V) (0\
851 + ((V) << 0) \
852 )
853
854/* Automatically generated code for pixel type GA88
855 *
856 * Size (bpp): 16 (16BPP)
857 * Pixel structure: VVVVVVVVAAAAAAAA
858 * Channels:
859 * V offset:0 size:8
860 * A offset:8 size:8
861 */
862
863/*
864 * macros to get channels of pixel type GA88
865 */
866#define GP_PIXEL_GET_V_GA88(p) (GP_GET_BITS(0, 8, (p)))
867#define GP_PIXEL_GET_A_GA88(p) (GP_GET_BITS(8, 8, (p)))
868
869/*
870 * macros to get address and bit-offset of a pixel GA88 in a pixmap
871 */
872#define GP_PIXEL_ADDR_GA88(pixmap, x, y) GP_PIXEL_ADDR_16BPP(pixmap, x, y)
873#define GP_PIXEL_ADDR_OFFSET_GA88(x) GP_PIXEL_ADDR_OFFSET_16BPP(x)
874
875/*
876 * macros to create gp_pixel of pixel type GA88 directly from given values.
877 * The values MUST be already clipped/converted to relevant value ranges.
878 */
879#define GP_PIXEL_CREATE_GA88(V, A) (0\
880 + ((V) << 0) \
881 + ((A) << 8) \
882 )
883
884/* Automatically generated code for pixel type G16
885 *
886 * Size (bpp): 16 (16BPP)
887 * Pixel structure: VVVVVVVVVVVVVVVV
888 * Channels:
889 * V offset:0 size:16
890 */
891
892/*
893 * macros to get channels of pixel type G16
894 */
895#define GP_PIXEL_GET_V_G16(p) (GP_GET_BITS(0, 16, (p)))
896
897/*
898 * macros to get address and bit-offset of a pixel G16 in a pixmap
899 */
900#define GP_PIXEL_ADDR_G16(pixmap, x, y) GP_PIXEL_ADDR_16BPP(pixmap, x, y)
901#define GP_PIXEL_ADDR_OFFSET_G16(x) GP_PIXEL_ADDR_OFFSET_16BPP(x)
902
903/*
904 * macros to create gp_pixel of pixel type G16 directly from given values.
905 * The values MUST be already clipped/converted to relevant value ranges.
906 */
907#define GP_PIXEL_CREATE_G16(V) (0\
908 + ((V) << 0) \
909 )
910
911
912/*
913 * macros for branching on pixel_type
914 */
915
916#define GP_FN_PER_PIXELTYPE(FN_NAME, type, ...)\
917 switch (type) { \
918 case GP_PIXEL_RGB101010:\
919 FN_NAME##_RGB101010(__VA_ARGS__);\
920 break;\
921 case GP_PIXEL_xRGB8888:\
922 FN_NAME##_xRGB8888(__VA_ARGS__);\
923 break;\
924 case GP_PIXEL_RGBA8888:\
925 FN_NAME##_RGBA8888(__VA_ARGS__);\
926 break;\
927 case GP_PIXEL_RGB888:\
928 FN_NAME##_RGB888(__VA_ARGS__);\
929 break;\
930 case GP_PIXEL_BGR888:\
931 FN_NAME##_BGR888(__VA_ARGS__);\
932 break;\
933 case GP_PIXEL_RGB555:\
934 FN_NAME##_RGB555(__VA_ARGS__);\
935 break;\
936 case GP_PIXEL_RGB565:\
937 FN_NAME##_RGB565(__VA_ARGS__);\
938 break;\
939 case GP_PIXEL_RGB666:\
940 FN_NAME##_RGB666(__VA_ARGS__);\
941 break;\
942 case GP_PIXEL_RGB332:\
943 FN_NAME##_RGB332(__VA_ARGS__);\
944 break;\
945 case GP_PIXEL_CMYK8888:\
946 FN_NAME##_CMYK8888(__VA_ARGS__);\
947 break;\
948 case GP_PIXEL_P2:\
949 FN_NAME##_P2(__VA_ARGS__);\
950 break;\
951 case GP_PIXEL_P4:\
952 FN_NAME##_P4(__VA_ARGS__);\
953 break;\
954 case GP_PIXEL_P8:\
955 FN_NAME##_P8(__VA_ARGS__);\
956 break;\
957 case GP_PIXEL_G1_DB:\
958 FN_NAME##_G1_DB(__VA_ARGS__);\
959 break;\
960 case GP_PIXEL_G2_DB:\
961 FN_NAME##_G2_DB(__VA_ARGS__);\
962 break;\
963 case GP_PIXEL_G4_DB:\
964 FN_NAME##_G4_DB(__VA_ARGS__);\
965 break;\
966 case GP_PIXEL_G1_UB:\
967 FN_NAME##_G1_UB(__VA_ARGS__);\
968 break;\
969 case GP_PIXEL_G2_UB:\
970 FN_NAME##_G2_UB(__VA_ARGS__);\
971 break;\
972 case GP_PIXEL_G4_UB:\
973 FN_NAME##_G4_UB(__VA_ARGS__);\
974 break;\
975 case GP_PIXEL_G8:\
976 FN_NAME##_G8(__VA_ARGS__);\
977 break;\
978 case GP_PIXEL_GA88:\
979 FN_NAME##_GA88(__VA_ARGS__);\
980 break;\
981 case GP_PIXEL_G16:\
982 FN_NAME##_G16(__VA_ARGS__);\
983 break;\
984 default: GP_ABORT("Invalid PixelType %d", type);\
985 }
986
987#define GP_FN_RET_PER_PIXELTYPE(FN_NAME, type, ...)\
988 switch (type) { \
989 case GP_PIXEL_RGB101010:\
990 return FN_NAME##_RGB101010(__VA_ARGS__);\
991 case GP_PIXEL_xRGB8888:\
992 return FN_NAME##_xRGB8888(__VA_ARGS__);\
993 case GP_PIXEL_RGBA8888:\
994 return FN_NAME##_RGBA8888(__VA_ARGS__);\
995 case GP_PIXEL_RGB888:\
996 return FN_NAME##_RGB888(__VA_ARGS__);\
997 case GP_PIXEL_BGR888:\
998 return FN_NAME##_BGR888(__VA_ARGS__);\
999 case GP_PIXEL_RGB555:\
1000 return FN_NAME##_RGB555(__VA_ARGS__);\
1001 case GP_PIXEL_RGB565:\
1002 return FN_NAME##_RGB565(__VA_ARGS__);\
1003 case GP_PIXEL_RGB666:\
1004 return FN_NAME##_RGB666(__VA_ARGS__);\
1005 case GP_PIXEL_RGB332:\
1006 return FN_NAME##_RGB332(__VA_ARGS__);\
1007 case GP_PIXEL_CMYK8888:\
1008 return FN_NAME##_CMYK8888(__VA_ARGS__);\
1009 case GP_PIXEL_P2:\
1010 return FN_NAME##_P2(__VA_ARGS__);\
1011 case GP_PIXEL_P4:\
1012 return FN_NAME##_P4(__VA_ARGS__);\
1013 case GP_PIXEL_P8:\
1014 return FN_NAME##_P8(__VA_ARGS__);\
1015 case GP_PIXEL_G1_DB:\
1016 return FN_NAME##_G1_DB(__VA_ARGS__);\
1017 case GP_PIXEL_G2_DB:\
1018 return FN_NAME##_G2_DB(__VA_ARGS__);\
1019 case GP_PIXEL_G4_DB:\
1020 return FN_NAME##_G4_DB(__VA_ARGS__);\
1021 case GP_PIXEL_G1_UB:\
1022 return FN_NAME##_G1_UB(__VA_ARGS__);\
1023 case GP_PIXEL_G2_UB:\
1024 return FN_NAME##_G2_UB(__VA_ARGS__);\
1025 case GP_PIXEL_G4_UB:\
1026 return FN_NAME##_G4_UB(__VA_ARGS__);\
1027 case GP_PIXEL_G8:\
1028 return FN_NAME##_G8(__VA_ARGS__);\
1029 case GP_PIXEL_GA88:\
1030 return FN_NAME##_GA88(__VA_ARGS__);\
1031 case GP_PIXEL_G16:\
1032 return FN_NAME##_G16(__VA_ARGS__);\
1033 default: GP_ABORT("Invalid PixelType %d", type);\
1034 }
1035
1036
1037/*
1038 * macros to do per-channel operations on a pixel.
1039 */
1040#define GP_PIXEL_CHANS_ADD_RGB101010(pixel, perc) \
1041 GP_PIXEL_CREATE_RGB101010( \
1042 GP_SAT_ADD(GP_PIXEL_GET_R_RGB101010(pixel), 0x3ff * perc / 100, 0x3ff), \
1043 GP_SAT_ADD(GP_PIXEL_GET_G_RGB101010(pixel), 0x3ff * perc / 100, 0x3ff), \
1044 GP_SAT_ADD(GP_PIXEL_GET_B_RGB101010(pixel), 0x3ff * perc / 100, 0x3ff) \
1045 )
1046
1047#define GP_PIXEL_CHANS_ADD_xRGB8888(pixel, perc) \
1048 GP_PIXEL_CREATE_xRGB8888( \
1049 GP_SAT_ADD(GP_PIXEL_GET_R_xRGB8888(pixel), 0xff * perc / 100, 0xff), \
1050 GP_SAT_ADD(GP_PIXEL_GET_G_xRGB8888(pixel), 0xff * perc / 100, 0xff), \
1051 GP_SAT_ADD(GP_PIXEL_GET_B_xRGB8888(pixel), 0xff * perc / 100, 0xff) \
1052 )
1053
1054#define GP_PIXEL_CHANS_ADD_RGBA8888(pixel, perc) \
1055 GP_PIXEL_CREATE_RGBA8888( \
1056 GP_SAT_ADD(GP_PIXEL_GET_R_RGBA8888(pixel), 0xff * perc / 100, 0xff), \
1057 GP_SAT_ADD(GP_PIXEL_GET_G_RGBA8888(pixel), 0xff * perc / 100, 0xff), \
1058 GP_SAT_ADD(GP_PIXEL_GET_B_RGBA8888(pixel), 0xff * perc / 100, 0xff), \
1059 GP_PIXEL_GET_A_RGBA8888(pixel) \
1060 )
1061
1062#define GP_PIXEL_CHANS_ADD_RGB888(pixel, perc) \
1063 GP_PIXEL_CREATE_RGB888( \
1064 GP_SAT_ADD(GP_PIXEL_GET_R_RGB888(pixel), 0xff * perc / 100, 0xff), \
1065 GP_SAT_ADD(GP_PIXEL_GET_G_RGB888(pixel), 0xff * perc / 100, 0xff), \
1066 GP_SAT_ADD(GP_PIXEL_GET_B_RGB888(pixel), 0xff * perc / 100, 0xff) \
1067 )
1068
1069#define GP_PIXEL_CHANS_ADD_BGR888(pixel, perc) \
1070 GP_PIXEL_CREATE_BGR888( \
1071 GP_SAT_ADD(GP_PIXEL_GET_B_BGR888(pixel), 0xff * perc / 100, 0xff), \
1072 GP_SAT_ADD(GP_PIXEL_GET_G_BGR888(pixel), 0xff * perc / 100, 0xff), \
1073 GP_SAT_ADD(GP_PIXEL_GET_R_BGR888(pixel), 0xff * perc / 100, 0xff) \
1074 )
1075
1076#define GP_PIXEL_CHANS_ADD_RGB555(pixel, perc) \
1077 GP_PIXEL_CREATE_RGB555( \
1078 GP_SAT_ADD(GP_PIXEL_GET_R_RGB555(pixel), 0x1f * perc / 100, 0x1f), \
1079 GP_SAT_ADD(GP_PIXEL_GET_G_RGB555(pixel), 0x1f * perc / 100, 0x1f), \
1080 GP_SAT_ADD(GP_PIXEL_GET_B_RGB555(pixel), 0x1f * perc / 100, 0x1f) \
1081 )
1082
1083#define GP_PIXEL_CHANS_ADD_RGB565(pixel, perc) \
1084 GP_PIXEL_CREATE_RGB565( \
1085 GP_SAT_ADD(GP_PIXEL_GET_R_RGB565(pixel), 0x1f * perc / 100, 0x1f), \
1086 GP_SAT_ADD(GP_PIXEL_GET_G_RGB565(pixel), 0x3f * perc / 100, 0x3f), \
1087 GP_SAT_ADD(GP_PIXEL_GET_B_RGB565(pixel), 0x1f * perc / 100, 0x1f) \
1088 )
1089
1090#define GP_PIXEL_CHANS_ADD_RGB666(pixel, perc) \
1091 GP_PIXEL_CREATE_RGB666( \
1092 GP_SAT_ADD(GP_PIXEL_GET_R_RGB666(pixel), 0x3f * perc / 100, 0x3f), \
1093 GP_SAT_ADD(GP_PIXEL_GET_G_RGB666(pixel), 0x3f * perc / 100, 0x3f), \
1094 GP_SAT_ADD(GP_PIXEL_GET_B_RGB666(pixel), 0x3f * perc / 100, 0x3f) \
1095 )
1096
1097#define GP_PIXEL_CHANS_ADD_RGB332(pixel, perc) \
1098 GP_PIXEL_CREATE_RGB332( \
1099 GP_SAT_ADD(GP_PIXEL_GET_R_RGB332(pixel), 0x7 * perc / 100, 0x7), \
1100 GP_SAT_ADD(GP_PIXEL_GET_G_RGB332(pixel), 0x7 * perc / 100, 0x7), \
1101 GP_SAT_ADD(GP_PIXEL_GET_B_RGB332(pixel), 0x3 * perc / 100, 0x3) \
1102 )
1103
1104#define GP_PIXEL_CHANS_ADD_CMYK8888(pixel, perc) \
1105 GP_PIXEL_CREATE_CMYK8888( \
1106 GP_SAT_ADD(GP_PIXEL_GET_K_CMYK8888(pixel), 0xff * perc / 100, 0xff), \
1107 GP_SAT_ADD(GP_PIXEL_GET_Y_CMYK8888(pixel), 0xff * perc / 100, 0xff), \
1108 GP_SAT_ADD(GP_PIXEL_GET_M_CMYK8888(pixel), 0xff * perc / 100, 0xff), \
1109 GP_SAT_ADD(GP_PIXEL_GET_C_CMYK8888(pixel), 0xff * perc / 100, 0xff) \
1110 )
1111
1112#define GP_PIXEL_CHANS_ADD_P2(pixel, perc) \
1113 GP_PIXEL_CREATE_P2( \
1114 GP_SAT_ADD(GP_PIXEL_GET_P_P2(pixel), 0x3 * perc / 100, 0x3) \
1115 )
1116
1117#define GP_PIXEL_CHANS_ADD_P4(pixel, perc) \
1118 GP_PIXEL_CREATE_P4( \
1119 GP_SAT_ADD(GP_PIXEL_GET_P_P4(pixel), 0xf * perc / 100, 0xf) \
1120 )
1121
1122#define GP_PIXEL_CHANS_ADD_P8(pixel, perc) \
1123 GP_PIXEL_CREATE_P8( \
1124 GP_SAT_ADD(GP_PIXEL_GET_P_P8(pixel), 0xff * perc / 100, 0xff) \
1125 )
1126
1127#define GP_PIXEL_CHANS_ADD_G1_DB(pixel, perc) \
1128 GP_PIXEL_CREATE_G1_DB( \
1129 GP_SAT_ADD(GP_PIXEL_GET_V_G1_DB(pixel), 0x1 * perc / 100, 0x1) \
1130 )
1131
1132#define GP_PIXEL_CHANS_ADD_G2_DB(pixel, perc) \
1133 GP_PIXEL_CREATE_G2_DB( \
1134 GP_SAT_ADD(GP_PIXEL_GET_V_G2_DB(pixel), 0x3 * perc / 100, 0x3) \
1135 )
1136
1137#define GP_PIXEL_CHANS_ADD_G4_DB(pixel, perc) \
1138 GP_PIXEL_CREATE_G4_DB( \
1139 GP_SAT_ADD(GP_PIXEL_GET_V_G4_DB(pixel), 0xf * perc / 100, 0xf) \
1140 )
1141
1142#define GP_PIXEL_CHANS_ADD_G1_UB(pixel, perc) \
1143 GP_PIXEL_CREATE_G1_UB( \
1144 GP_SAT_ADD(GP_PIXEL_GET_V_G1_UB(pixel), 0x1 * perc / 100, 0x1) \
1145 )
1146
1147#define GP_PIXEL_CHANS_ADD_G2_UB(pixel, perc) \
1148 GP_PIXEL_CREATE_G2_UB( \
1149 GP_SAT_ADD(GP_PIXEL_GET_V_G2_UB(pixel), 0x3 * perc / 100, 0x3) \
1150 )
1151
1152#define GP_PIXEL_CHANS_ADD_G4_UB(pixel, perc) \
1153 GP_PIXEL_CREATE_G4_UB( \
1154 GP_SAT_ADD(GP_PIXEL_GET_V_G4_UB(pixel), 0xf * perc / 100, 0xf) \
1155 )
1156
1157#define GP_PIXEL_CHANS_ADD_G8(pixel, perc) \
1158 GP_PIXEL_CREATE_G8( \
1159 GP_SAT_ADD(GP_PIXEL_GET_V_G8(pixel), 0xff * perc / 100, 0xff) \
1160 )
1161
1162#define GP_PIXEL_CHANS_ADD_GA88(pixel, perc) \
1163 GP_PIXEL_CREATE_GA88( \
1164 GP_SAT_ADD(GP_PIXEL_GET_V_GA88(pixel), 0xff * perc / 100, 0xff), \
1165 GP_PIXEL_GET_A_GA88(pixel) \
1166 )
1167
1168#define GP_PIXEL_CHANS_ADD_G16(pixel, perc) \
1169 GP_PIXEL_CREATE_G16( \
1170 GP_SAT_ADD(GP_PIXEL_GET_V_G16(pixel), 0xffff * perc / 100, 0xffff) \
1171 )
1172
1173#endif /* GP_PIXEL_GEN_H */
Fast value clamping.
gp_pixel_type
List of all pixel types.
@ GP_PIXEL_MAX
Last valid pixel type has value GP_PIXEL_MAX-1.