GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
Pixmap

Data Structures

struct  gp_pixmap
 A pixmap buffer. More...
 

Macros

#define GP_PIXEL_IS_CLIPPED(pixmap, x, y)
 Returns true when pixel is clipped out of pixmap.
 

Functions

gp_pixmapgp_pixmap_alloc (gp_size w, gp_size h, gp_pixel_type type)
 Allocates a pixmap.
 
int gp_pixmap_correction_set (gp_pixmap *self, gp_correction_desc *corr_desc)
 Sets a correction for the pixmap.
 
static int gp_pixmap_gamma_set (gp_pixmap *self, float gamma)
 Sets a gamma correction for the pixmap.
 
static int gp_pixmap_srgb_set (gp_pixmap *self)
 Sets a sRGB correction for the pixmap.
 
void gp_pixmap_free (gp_pixmap *self)
 Frees a pixmap.
 
static gp_pixmapgp_pixmap_from_data (gp_size w, gp_size h, gp_pixel_type type, void *pixels, enum gp_pixmap_init_flags flags)
 Creates a pixmap from a buffer allocated by malloc().
 

Detailed Description

Function Documentation

◆ gp_pixmap_alloc()

gp_pixmap * gp_pixmap_alloc ( gp_size  w,
gp_size  h,
gp_pixel_type  type 
)

Allocates a pixmap.

The pixmap consists of two parts, the gp_pixmap structure and pixels array.

The rotation flags are set to (0, 0, 0).

Parameters
wA pixmap width.
hA pixmap height.
typeA pixel type.
Returns
A newly allocated pixmap or NULL in a case of malloc() failure.

◆ gp_pixmap_correction_set()

int gp_pixmap_correction_set ( gp_pixmap self,
gp_correction_desc corr_desc 
)

Sets a correction for the pixmap.

If there was a gamma correction allready set for the pixmap the original correction reference counters are decremented and the correction is replaced with a new table.

Parameters
selfA pixmap.
corr_descA correction description.
Returns
Zero on success. May fail if underlying malloc() has failed.

Referenced by gp_pixmap_gamma_set(), and gp_pixmap_srgb_set().

◆ gp_pixmap_free()

void gp_pixmap_free ( gp_pixmap self)

Frees a pixmap.

If pixmap->free_pixels is set also free pixel data, this flag is set automatically by gp_pixmap_alloc().

Parameters
selfA pixmap to free.

◆ gp_pixmap_from_data()

static gp_pixmap * gp_pixmap_from_data ( gp_size  w,
gp_size  h,
gp_pixel_type  type,
void *  pixels,
enum gp_pixmap_init_flags  flags 
)
inlinestatic

Creates a pixmap from a buffer allocated by malloc().

This is actually shorthand for allocating the gp_pixmap structure and calling gp_pixmap_init() on the resulting pointer.

Attention
The user has to make sure that the pixels array has correct size and format.
Parameters
wPixmap width
hPixmap height
typeA pixel type, describes how pixels are organized in the data buffer.
pixelsA pointer to a buffer with the pixel data.
flagsA bitmask or of the enum gp_pixmap_init_flags
Returns
A newly allocated and initialized pixmap or NULL in a case of a failure.

Definition at line 276 of file gp_pixmap.h.

References gp_pixmap_init().

◆ gp_pixmap_gamma_set()

static int gp_pixmap_gamma_set ( gp_pixmap self,
float  gamma 
)
inlinestatic

Sets a gamma correction for the pixmap.

This is a shorthand for:

.gamma = gamma;
};
@ GP_CORRECTION_TYPE_GAMMA
Classical gamma correction.
int gp_pixmap_correction_set(gp_pixmap *self, gp_correction_desc *corr_desc)
Sets a correction for the pixmap.
A correction description.
gp_correction_type corr_type
Correction type.
Parameters
selfA pixmap.
gammaA gamma value.
Returns
Zero on success. May fail if underlying malloc() has failed.

Definition at line 181 of file gp_pixmap.h.

References gp_correction_desc::corr_type, GP_CORRECTION_TYPE_GAMMA, and gp_pixmap_correction_set().

◆ gp_pixmap_srgb_set()

static int gp_pixmap_srgb_set ( gp_pixmap self)
inlinestatic

Sets a sRGB correction for the pixmap.

This is a shorthand for:

};
@ GP_CORRECTION_TYPE_SRGB
Standard RGB.
Parameters
selfA pixmap.
Returns
Zero on success. May fail if underlying malloc() has failed.

Definition at line 208 of file gp_pixmap.h.

References gp_correction_desc::corr_type, GP_CORRECTION_TYPE_SRGB, and gp_pixmap_correction_set().