3 * Pixel type definitions and functions.
4 * Do not include directly, use GP_Pixel.h
6 * Copyright (C) 2011 Tomas Gavenciak <gavento@ucw.cz>
7 * Copyright (C) 2013-2014 Cyril Hrubis <metan@ucw.cz>
11 * List of all known pixel types
13 typedef enum GP_PixelType {
14 @ for pt in pixeltypes:
15 GP_PIXEL_{{ pt.name }},
20 @ for pt in pixeltypes:
21 #define GP_PIXEL_{{ pt.name }} GP_PIXEL_{{ pt.name }}
24 @ for pt in pixeltypes:
25 @ if not pt.is_unknown():
26 /* Automatically generated code for pixel type {{ pt.name }}
28 * Size (bpp): {{ pt.pixelsize.size }} ({{ pt.pixelsize.suffix }})
29 * Bit endian: {{ pt.pixelsize.bit_endian_const }}
30 * Pixel structure: {{ "".join(pt.bits) }}
32 @ for c in pt.chanslist:
33 * {{ c[0] }} offset:{{ c[1] }} size:{{ c[2] }}
38 * macros to get channels of pixel type {{ pt.name }}
40 @ for c in pt.chanslist:
41 #define GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(p) (GP_GET_BITS({{ c[1] }}, {{ c[2] }}, (p)))
45 * macros to get address and bit-offset of a pixel {{ pt.name }} in a pixmap
47 #define GP_PIXEL_ADDR_{{ pt.name }}(pixmap, x, y) GP_PIXEL_ADDR_{{ pt.pixelsize.suffix }}(pixmap, x, y)
48 #define GP_PIXEL_ADDR_OFFSET_{{ pt.name }}(x) GP_PIXEL_ADDR_OFFSET_{{ pt.pixelsize.suffix }}(x)
51 * macros to create GP_Pixel of pixel type {{ pt.name }} directly from given values.
52 * The values MUST be already clipped/converted to relevant value ranges.
54 #define GP_Pixel_CREATE_{{ pt.name }}({{ ', '.join(pt.chan_names) }}) (0\
55 @ for c in pt.chanslist:
56 + (({{ c[0] }}) << {{ c[1] }}) \
63 * macros for branching on PixelType (similar to GP_FnPerBpp macros)
66 @ for r in [('', ''), ('return ', 'RET_')]:
67 #define GP_FN_{{ r[1] }}PER_PIXELTYPE(FN_NAME, type, ...)\
69 @ for pt in pixeltypes:
70 @ if not pt.is_unknown():
71 case GP_PIXEL_{{ pt.name }}:\
72 {{ r[0] }}FN_NAME{{'##'}}_{{ pt.name }}(__VA_ARGS__);\
77 default: GP_ABORT("Invalid PixelType %d", type);\