16#ifndef CORE_GP_PIXEL_H
17#define CORE_GP_PIXEL_H
24#define GP_PIXEL_BITS (sizeof(gp_pixel) * 8)
93 const char bitmap[GP_PIXEL_BITS + 1];
103#define GP_VALID_PIXELTYPE(type) (((type) > 0) && ((type) < GP_PIXEL_MAX))
105#define GP_CHECK_VALID_PIXELTYPE(type) \
106 GP_CHECK(GP_VALID_PIXELTYPE(type), "Invalid PixelType %d", (type))
111static inline const char *gp_pixel_type_name(
gp_pixel_type type)
113 GP_CHECK_VALID_PIXELTYPE(type);
122 GP_CHECK_VALID_PIXELTYPE(type);
134 GP_CHECK_VALID_PIXELTYPE(type);
146 GP_CHECK_VALID_PIXELTYPE(type);
159 GP_CHECK_VALID_PIXELTYPE(type);
172 GP_CHECK_VALID_PIXELTYPE(type);
186 GP_CHECK_VALID_PIXELTYPE(type);
200 GP_CHECK_VALID_PIXELTYPE(type);
237 uint8_t bits_per_pixel);
260 uint32_t gsize, uint32_t goff,
261 uint32_t bsize, uint32_t boff,
262 uint32_t asize, uint32_t aoff,
263 uint8_t bits_per_pixel);
uint32_t gp_pixel
Pixel integer value.
Helper macros to get and set bits given offset and length.
A pixel defintions generated from gen/include/gfxprim_config.py.
#define GP_PIXEL_CHANS_MAX
Maximal number of channels per all defined pixel types.
gp_pixel_type
List of all pixel types.
@ GP_PIXEL_MAX
Last valid pixel type has value GP_PIXEL_MAX-1.
int gp_pixel_has_flags(gp_pixel_type pixel_type, gp_pixel_flags flags)
Function to determine pixel attributes.
static int gp_pixel_channel_is_alpha(gp_pixel_type type, uint8_t channel)
Returns true if pixel channel is alpha channel.
gp_pixel gp_pixel_chan_mask(gp_pixel_type pixel_type, const char *chan_name)
Returns channel mask for a given pixel type and channel name.
const gp_pixel_type_desc gp_pixel_types[GP_PIXEL_MAX]
Array with description for all pixel types.
gp_pixel gp_pixel_chans_add(gp_pixel_type pixel_type, gp_pixel pixel, int add)
Does per-channel saturated addition.
static uint8_t gp_pixel_channel_bits(gp_pixel_type type, uint8_t channel)
Returns number of bits for a pixel channel.
gp_pixel_type gp_pixel_rgb_match(gp_pixel rmask, gp_pixel gmask, gp_pixel bmask, gp_pixel amask, uint8_t bits_per_pixel)
Matches a RGB pixel type againts known pixel types.
static uint8_t gp_pixel_channel_lin_bits(gp_pixel_type type, uint8_t channel)
Returns number of bits for a linearized pixel channel.
static const gp_pixel_type_desc * gp_pixel_desc(gp_pixel_type type)
Returns a pixel type description for a pixel type enum.
static unsigned int gp_pixel_channel_count(gp_pixel_type type)
Returns a numbers of pixel channels.
gp_pixel_type gp_pixel_rgb_lookup(uint32_t rsize, uint32_t roff, uint32_t gsize, uint32_t goff, uint32_t bsize, uint32_t boff, uint32_t asize, uint32_t aoff, uint8_t bits_per_pixel)
Looks up a RGB pixel type against know pixel types.
gp_pixel_flags
Pixel type flags for various pixel properties.
@ GP_PIXEL_IS_PALETTE
Pixel is palette.
@ GP_PIXEL_HAS_ALPHA
Pixel has an alpha channel.
@ GP_PIXEL_IS_CMYK
Pixel has CMYK channels.
@ GP_PIXEL_IS_GRAYSCALE
Pixel is grayscale.
@ GP_PIXEL_IS_RGB
Pixel has RGB channels.
static const char * gp_pixel_channel_name(gp_pixel_type type, uint8_t channel)
Returns number of bits for a pixel channel.
A pixel channel manipulations generated from gen/include/gfxprim_config.py.
Description of one pixel channel.
A description of a gp_pixel_type Assumes name with at most 15 chars.
const gp_pixel_channel channels[4]
An individual channel descriptions.
uint8_t pack
A pixel packing.
const char bitmap[(sizeof(gp_pixel) *8)+1]
String describing the bit-representaton (as in "RRRRRGGGGGGBBBBB")
gp_pixel_flags flags
Bitwise or of gp_pixel_flags.
uint8_t size
A pixel size in bits.
const char name[16]
A name e.g. xRGB8888.
gp_pixel_type type
An id of the pixel type.
uint8_t numchannels
A number of channels.