GFXprim
2D bitmap graphics library with emphasis on speed and correctness
|
A pixel buffer. More...
#include <stdint.h>
#include <unistd.h>
#include <core/gp_common.h>
#include <core/gp_types.h>
#include <core/gp_pixel.h>
#include <core/gp_gamma_correction.h>
Go to the source code of this file.
Data Structures | |
struct | gp_pixmap |
A pixmap buffer. More... | |
Macros | |
#define | GP_PIXEL_ADDR(pixmap, x, y) |
Returns pixel addres in an image. | |
#define | GP_PIXEL_IS_CLIPPED(pixmap, x, y) |
Returns true when pixel is clipped out of pixmap. | |
Enumerations | |
enum | gp_pixmap_init_flags { GP_PIXMAP_FREE_PIXELS = 0x01 } |
A pixmap init flags. More... | |
enum | gp_pixmap_copy_flags { GP_PIXMAP_COPY_PIXELS = 0x01 , GP_PIXMAP_COPY_ROTATION = 0x02 , GP_PIXMAP_COPY_GAMMA = 0x04 } |
A pixmap copy flags. More... | |
Functions | |
gp_pixmap * | gp_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. | |
gp_pixmap * | gp_pixmap_init (gp_pixmap *pixmap, gp_size w, gp_size h, gp_pixel_type type, void *pixels, enum gp_pixmap_init_flags flags) |
Initializes allocated pixmap structure. | |
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) |
Creates a pixmap from a buffer allocated by malloc(). | |
int | gp_pixmap_resize (gp_pixmap *self, gp_size w, gp_size h) |
Resizes pixmap. | |
gp_pixmap * | gp_pixmap_copy (const gp_pixmap *src, enum gp_pixmap_copy_flags flags) |
Copies a pixmap. | |
gp_pixmap * | gp_sub_pixmap (const gp_pixmap *src, gp_pixmap *subpixmap, gp_coord x, gp_coord y, gp_size w, gp_size h) |
Initializes a subpixmap. | |
gp_pixmap * | gp_sub_pixmap_alloc (const gp_pixmap *src, gp_coord x, gp_coord y, gp_size w, gp_size h) |
Allocate and initalize a subpixmap. | |
void | gp_pixmap_print_info (const gp_pixmap *self) |
Prints pixmap information into stdout. | |
void | gp_pixmap_rotate_cw (gp_pixmap *self) |
Rotates pixmap flags clockwise. | |
void | gp_pixmap_rotate_ccw (gp_pixmap *self) |
Rotates pixmap flags counter clock wise. | |
static int | gp_pixmap_rotation_equal (const gp_pixmap *c1, const gp_pixmap *c2) |
Compares rotation flags for two pixmaps. | |
static void | gp_pixmap_rotation_set (gp_pixmap *self, int axes_swap, int x_swap, int y_swap) |
Sets pixmap rotation flags. | |
static void | gp_pixmap_rotation_copy (const gp_pixmap *src, gp_pixmap *dst) |
Copies rotation flags from one pixmap to another. | |
static gp_size | gp_pixmap_w (const gp_pixmap *self) |
Returns pixmap width taking axes swap into account. | |
static gp_size | gp_pixmap_h (const gp_pixmap *self) |
Returns pixmap height taking axes swap into account. | |
A pixel buffer.
Definition in file gp_pixmap.h.
#define GP_PIXEL_ADDR | ( | pixmap, | |
x, | |||
y | |||
) |
Returns pixel addres in an image.
Determines the address of a pixel within the pixmap's buffer.
Rows and columns are specified in the image origiinal orientation i.e. this macro ignores the rotation flags.
Definition at line 109 of file gp_pixmap.h.
enum gp_pixmap_copy_flags |
A pixmap copy flags.
Definition at line 309 of file gp_pixmap.h.
enum gp_pixmap_init_flags |
A pixmap init flags.
Enumerator | |
---|---|
GP_PIXMAP_FREE_PIXELS | If set the pixmap->pixels is freed on gp_pixmap_free() |
Definition at line 231 of file gp_pixmap.h.
gp_pixmap * gp_pixmap_copy | ( | const gp_pixmap * | src, |
enum gp_pixmap_copy_flags | flags | ||
) |
Copies a pixmap.
Allocates a pixmap with exactly same data as source pixmap.
src | An input pixmap. |
flags | An enum gp_pixmap_copy_flags. |
Returns pixmap height taking axes swap into account.
self | A pixmap. |
Definition at line 481 of file gp_pixmap.h.
References gp_pixmap::axes_swap, gp_pixmap::h, and gp_pixmap::w.
gp_pixmap * gp_pixmap_init | ( | gp_pixmap * | pixmap, |
gp_size | w, | ||
gp_size | h, | ||
gp_pixel_type | type, | ||
void * | pixels, | ||
enum gp_pixmap_init_flags | flags | ||
) |
Initializes allocated pixmap structure.
Initalize pixmap structure, pixels pointer is not dereferenced so it's safe to pass NULL there and allocate it later with size pixmap->bpr * pixmap->h.
BEWARE: The user has to make sure that the pixels array has correct size and format.
pixmap | A pointer to a pixmap structure to be initialized with a data. |
w | Pixmap width |
h | Pixmap height |
type | A pixel type, describes how pixels are organized in the data buffer. |
pixels | A pointer to a buffer with the pixel data. |
flags | A bitmask or of the enum gp_pixmap_init_flags |
Referenced by gp_pixmap_from_data().
void gp_pixmap_print_info | ( | const gp_pixmap * | self | ) |
Prints pixmap information into stdout.
self | A pixmap to print an info about. |
Resizes pixmap.
This only resizes the buffer, the pixel values are uninitialized after the operation!
If you are looking for functions to resize an image you are looking for resampling filters.
self | A pixmap. |
w | A new width. |
h | A new height. |
void gp_pixmap_rotate_ccw | ( | gp_pixmap * | self | ) |
Rotates pixmap flags counter clock wise.
self | A pixmap. |
The underlying pixmap buffer is not changed, only the rotation flags are affected.
void gp_pixmap_rotate_cw | ( | gp_pixmap * | self | ) |
Rotates pixmap flags clockwise.
self | A pixmap. |
The underlying pixmap buffer is not changed, only the rotation flags are affected.
Copies rotation flags from one pixmap to another.
src | A source pixmap for rotation flags. |
dst | A destination pixmap for rotation flags. |
Definition at line 453 of file gp_pixmap.h.
References gp_pixmap::axes_swap, gp_pixmap::x_swap, and gp_pixmap::y_swap.
Compares rotation flags for two pixmaps.
c1 | A pixmap. |
c2 | A pixmap. |
Definition at line 423 of file gp_pixmap.h.
References gp_pixmap::axes_swap, gp_pixmap::x_swap, and gp_pixmap::y_swap.
|
inlinestatic |
Sets pixmap rotation flags.
self | A pixmap. |
axes_swap | Set to 1 if axes should be swapped. |
x_swap | Set to 1 if x axis should be mirrored. |
y_swap | Set to 1 if y axis should be mirrored. |
Definition at line 439 of file gp_pixmap.h.
References gp_pixmap::axes_swap, gp_pixmap::x_swap, and gp_pixmap::y_swap.
Returns pixmap width taking axes swap into account.
self | A pixmap. |
Definition at line 467 of file gp_pixmap.h.
References gp_pixmap::axes_swap, gp_pixmap::h, and gp_pixmap::w.
gp_pixmap * gp_sub_pixmap | ( | const gp_pixmap * | src, |
gp_pixmap * | subpixmap, | ||
gp_coord | x, | ||
gp_coord | y, | ||
gp_size | w, | ||
gp_size | h | ||
) |
Initializes a subpixmap.
The subpixmap has to fit into the source pixmap!
The original image must not be freed including its gamma tables until the resulting subpixmap is being in use.
src | An input pixmap. |
subpixmap | A pointer to a pixmap to initialize. |
x | A starting coordinate of the subpixmap. |
y | A starting coordinate of the subpixmap. |
w | A subpixmap width. |
h | A subpixmap height. |
gp_pixmap * gp_sub_pixmap_alloc | ( | const gp_pixmap * | src, |
gp_coord | x, | ||
gp_coord | y, | ||
gp_size | w, | ||
gp_size | h | ||
) |
Allocate and initalize a subpixmap.
The subpixmap has to fit into the source pixmap!
The original image must not be freed including its gamma tables until the resulting subpixmap is being in use.
src | An input pixmap. |
x | A starting coordinate of the subpixmap. |
y | A starting coordinate of the subpixmap. |
w | A subpixmap width. |
h | A subpixmap height. |