GFXprim
2D bitmap graphics library with emphasis on speed and correctness
|
A pixel description. More...
#include <stdint.h>
#include <core/gp_types.h>
#include <core/gp_common.h>
#include <core/gp_pixel.gen.h>
#include <core/gp_pixel_channel.gen.h>
#include <core/gp_pixel_alias.h>
#include <core/gp_get_set_bits.h>
Go to the source code of this file.
Data Structures | |
struct | gp_pixel_channel |
Description of one pixel channel. More... | |
struct | gp_pixel_type_desc |
A description of a gp_pixel_type Assumes name with at most 15 chars. More... | |
Typedefs | |
typedef struct gp_pixel_channel | gp_pixel_channel |
Description of one pixel channel. | |
typedef enum gp_pixel_flags | gp_pixel_flags |
Pixel type flags for various pixel properties. | |
Enumerations | |
enum | gp_pixel_flags { GP_PIXEL_HAS_ALPHA = 0x01 , GP_PIXEL_IS_RGB = 0x02 , GP_PIXEL_IS_PALETTE = 0x04 , GP_PIXEL_IS_CMYK = 0x08 , GP_PIXEL_IS_GRAYSCALE = 0x10 } |
Pixel type flags for various pixel properties. More... | |
Functions | |
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. | |
static uint8_t | gp_pixel_channel_bits (gp_pixel_type type, uint8_t channel) |
Returns number of bits for a pixel channel. | |
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 char * | gp_pixel_channel_name (gp_pixel_type type, uint8_t channel) |
Returns number of bits for a pixel channel. | |
static int | gp_pixel_channel_is_alpha (gp_pixel_type type, uint8_t channel) |
Returns true if pixel channel is alpha 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. | |
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. | |
int | gp_pixel_has_flags (gp_pixel_type pixel_type, gp_pixel_flags flags) |
Function to determine pixel attributes. | |
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. | |
gp_pixel | gp_pixel_chans_add (gp_pixel_type pixel_type, gp_pixel pixel, int add) |
Does per-channel saturated addition. | |
Variables | |
const gp_pixel_type_desc | gp_pixel_types [GP_PIXEL_MAX] |
Array with description for all pixel types. | |
A pixel description.
Definition in file gp_pixel.h.
typedef struct gp_pixel_channel gp_pixel_channel |
Description of one pixel channel.
Assumes all the channel names to be at most 7 chars long
The common channel names are:
R, G, B - RGB as usual C, M, Y, K - CMYK V - value, for grayscale A - opacity (0=transparent) P - palette (index)
enum gp_pixel_flags |
Pixel type flags for various pixel properties.
Definition at line 62 of file gp_pixel.h.
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.
pixel_type | A pixel type. |
chan_name | A channel name, e.g. "R" or "A". |
|
inlinestatic |
Returns number of bits for a pixel channel.
type | A pixel type. |
channel | A channel index. |
Definition at line 157 of file gp_pixel.h.
References gp_pixel_type_desc::channels, gp_pixel_types, and gp_pixel_channel::size.
|
inlinestatic |
Returns a numbers of pixel channels.
type | A pixel type. |
Definition at line 144 of file gp_pixel.h.
References gp_pixel_types, and gp_pixel_type_desc::numchannels.
|
inlinestatic |
Returns true if pixel channel is alpha channel.
type | A pixel type. |
channel | A channel index. |
Definition at line 197 of file gp_pixel.h.
References gp_pixel_type_desc::channels, gp_pixel_types, and gp_pixel_channel::name.
|
inlinestatic |
Returns number of bits for a linearized pixel channel.
type | A pixel type. |
channel | A channel index. |
Definition at line 170 of file gp_pixel.h.
References gp_pixel_type_desc::channels, gp_pixel_types, and gp_pixel_channel::lin_size.
|
inlinestatic |
Returns number of bits for a pixel channel.
type | A pixel type. |
channel | A channel index. |
Definition at line 183 of file gp_pixel.h.
References gp_pixel_type_desc::channels, gp_pixel_types, and gp_pixel_channel::name.
gp_pixel gp_pixel_chans_add | ( | gp_pixel_type | pixel_type, |
gp_pixel | pixel, | ||
int | add | ||
) |
Does per-channel saturated addition.
The alpha channel is left untouched.
pixel_type | A pixel type. |
pixel | A pixel value. |
add | An addition in percets of the maximal channel value. |
|
inlinestatic |
Returns a pixel type description for a pixel type enum.
type | A pixel type. |
Definition at line 132 of file gp_pixel.h.
References gp_pixel_types.
int gp_pixel_has_flags | ( | gp_pixel_type | pixel_type, |
gp_pixel_flags | flags | ||
) |
Function to determine pixel attributes.
pixel_type | A pixel type to check. |
flags | Bitwise or of attributes to check. |
Example use:
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.
This is the same as gp_pixel_rgb_match() but with sizes and offsets instead of masks.
rsize | A size of the red channel. |
roff | An offset for the red channel. |
gsize | A size of the green channel. |
goff | An offset for the green channel. |
bsize | A size of the blue channel. |
boff | An offset for the blue channel. |
asize | A size of the alpha channel, if set to zero the pixel does not have alpha channel. |
aoff | An offset for the alpha channel. |
bits_per_pixel | The size of the pixel in bits. |
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.
This is the same as gp_pixel_rgb_lookup() but with masks instead of sizes and offsets.
rmask | A mask for the red channel. |
gmask | A mask for the green channel. |
bmask | A mask for the blue channel. |
amask | A mask for the alpha channel, if set to zero the pixel does not have alpha channel. |
bits_per_pixel | The size of the pixel in bits. |
Referenced by gp_pixmap_from_sdl_surface().