15#ifndef CORE_GP_PIXMAP_H
16#define CORE_GP_PIXMAP_H
109#define GP_PIXEL_ADDR(pixmap, x, y) ((pixmap)->pixels \
110 + (y) * (pixmap)->bytes_per_row \
111 + ((x + (pixmap)->offset) * gp_pixel_size((pixmap)->pixel_type)) / 8)
113#define GP_CALC_ROW_SIZE(pixel_type, width) \
114 ((gp_pixel_size(pixel_type) * width) / 8 + \
115 !!((gp_pixel_size(pixel_type) * width) % 8))
118#define GP_CHECK_PIXMAP(pixmap) do { \
119 GP_CHECK(pixmap, "NULL passed as pixmap"); \
120 GP_CHECK(pixmap->pixels || pixmap->w == 0 || pixmap->h == 0, "invalid pixmap: pixels NULL on nonzero w h"); \
127#define GP_PIXEL_IS_CLIPPED(pixmap, x, y) \
128 ((x) < 0 || x >= (typeof(x)) pixmap->w \
129 || (y) < 0 || y >= (typeof(y)) pixmap->h) \
440 int x_swap,
int y_swap)
int gp_coord
Integer type for coordinates i.e. x, y, ...
unsigned int gp_size
Integer type for sizes i.e. w, h, ...
Gamma and sRGB corrections.
gp_pixel_type
List of all pixel types.
int gp_pixmap_resize(gp_pixmap *self, gp_size w, gp_size h)
Resizes 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.
void gp_pixmap_rotate_ccw(gp_pixmap *self)
Rotates pixmap flags counter clock wise.
static void gp_pixmap_rotation_copy(const gp_pixmap *src, gp_pixmap *dst)
Copies rotation flags from one pixmap to another.
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.
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.
gp_pixmap_copy_flags
A pixmap copy flags.
@ GP_PIXMAP_COPY_ROTATION
gp_pixmap_init_flags
A pixmap init flags.
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.
static gp_size gp_pixmap_w(const gp_pixmap *self)
Returns pixmap width taking axes swap into account.
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.
static gp_size gp_pixmap_h(const gp_pixmap *self)
Returns pixmap height taking axes swap into account.
gp_pixmap * gp_pixmap_copy(const gp_pixmap *src, enum gp_pixmap_copy_flags flags)
Copies a pixmap.
@ GP_CORRECTION_TYPE_GAMMA
Classical gamma correction.
@ GP_CORRECTION_TYPE_SRGB
Standard RGB.
static int gp_pixmap_srgb_set(gp_pixmap *self)
Sets a sRGB correction for the pixmap.
gp_pixmap * gp_pixmap_alloc(gp_size w, gp_size h, gp_pixel_type type)
Allocates a pixmap.
static int gp_pixmap_gamma_set(gp_pixmap *self, float gamma)
Sets a gamma correction for the pixmap.
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_correction_set(gp_pixmap *self, gp_correction_desc *corr_desc)
Sets a correction for the pixmap.
void gp_pixmap_free(gp_pixmap *self)
Frees a pixmap.
A correction description.
gp_correction_type corr_type
Correction type.
A correction tables for all pixel channels.
uint32_t h
Pixmap height in pixels.
uint8_t * pixels
A pointer to image pixels.
uint8_t x_swap
Mirrors image x axis for drawing.
uint8_t free_pixels
If set pixels are freed on gp_pixmap_free.
uint8_t y_swap
Mirrors image y axis for drawing.
enum gp_pixel_type pixel_type
A pixel format.
uint32_t bytes_per_row
Number of bytes per row.
gp_gamma * gamma
A pointer to a gamma correction table.
uint32_t w
Pixmap width in pixels.
uint8_t offset
An offset to apply before the start of the pixel row.
uint8_t axes_swap
Swaps image x and y axes for drawing.