GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
Data Structures | Typedefs | Enumerations | Functions | Variables
gp_pixel.h File Reference

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_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

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.
 

Detailed Description

A pixel description.

Definition in file gp_pixel.h.

Typedef Documentation

◆ 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)

Enumeration Type Documentation

◆ gp_pixel_flags

Pixel type flags for various pixel properties.

Enumerator
GP_PIXEL_HAS_ALPHA 

Pixel has an alpha channel.

GP_PIXEL_IS_RGB 

Pixel has RGB channels.

GP_PIXEL_IS_PALETTE 

Pixel is palette.

GP_PIXEL_IS_CMYK 

Pixel has CMYK channels.

GP_PIXEL_IS_GRAYSCALE 

Pixel is grayscale.

Definition at line 55 of file gp_pixel.h.

Function Documentation

◆ gp_pixel_chan_mask()

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.

Parameters
pixel_typeA pixel type.
chan_nameA channel name, e.g. "R" or "A".
Returns
A channel mask or zero if channel is not present.

◆ gp_pixel_chans_add()

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.

Parameters
pixel_typeA pixel type.
pixelA pixel value.
addAn addition in percets of the maximal channel value.
Returns
A pixel value after addition.

◆ gp_pixel_has_flags()

int gp_pixel_has_flags ( gp_pixel_type  pixel_type,
gp_pixel_flags  flags 
)

Function to determine pixel attributes.

Parameters
pixel_typeA pixel type to check.
flagsBitwise or of attributes to check.
Returns
True if all flags are present.

Example use:

...
int gp_pixel_has_flags(gp_pixel_type pixel_type, gp_pixel_flags flags)
Function to determine pixel attributes.
@ GP_PIXEL_HAS_ALPHA
Pixel has an alpha channel.
Definition gp_pixel.h:57
@ GP_PIXEL_IS_RGB
Pixel has RGB channels.
Definition gp_pixel.h:59

◆ gp_pixel_rgb_lookup()

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.

Parameters
rsizeA size of the red channel.
roffAn offset for the red channel.
gsizeA size of the green channel.
goffAn offset for the green channel.
bsizeA size of the blue channel.
boffAn offset for the blue channel.
asizeA size of the alpha channel, if set to zero the pixel does not have alpha channel.
aoffAn offset for the alpha channel.
bits_per_pixelThe size of the pixel in bits.
Returns
Either valid gp_pixel_type or GP_PIXEL_UNKNOWN.

◆ gp_pixel_rgb_match()

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.

Parameters
rmaskA mask for the red channel.
gmaskA mask for the green channel.
bmaskA mask for the blue channel.
amaskA mask for the alpha channel, if set to zero the pixel does not have alpha channel.
bits_per_pixelThe size of the pixel in bits.
Returns
Either valid gp_pixel_type or GP_PIXEL_UNKNOWN.