GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
gp_get_put_pixel.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later
2/*
3 * Copyright (C) 2011 Tomas Gavenciak <gavento@ucw.cz>
4 * Copyright (C) 2011-2024 Cyril Hrubis <metan@ucw.cz>
5 */
6
11#ifndef CORE_GP_GETPUTPIXEL_H
12#define CORE_GP_GETPUTPIXEL_H
13
14#include <core/gp_types.h>
15#include <core/gp_pixel.h>
18
34
52static inline gp_pixel gp_getpixel_raw(const gp_pixmap *pixmap,
53 gp_coord x, gp_coord y)
54{
55 GP_FN_RET_PER_PACK_PIXMAP(gp_getpixel_raw, pixmap, pixmap, x, y);
56
57 GP_ABORT("Invalid pixmap pixel type");
58}
59
60/*
61 * Version of GetPixel without transformations and with border checking.
62 */
63static inline gp_pixel gp_getpixel_raw_clipped(const gp_pixmap *pixmap,
64 gp_coord x, gp_coord y)
65{
66 if (GP_PIXEL_IS_CLIPPED(pixmap, x, y))
67 return 0;
68
69 return gp_getpixel_raw(pixmap, x, y);
70}
71
89
107static inline void gp_putpixel_raw(gp_pixmap *pixmap,
108 gp_coord x, gp_coord y, gp_pixel p)
109{
110 GP_FN_PER_PACK_PIXMAP(gp_putpixel_raw, pixmap, pixmap, x, y, p);
111}
112
113/*
114 * Version of PutPixel without transformation and with border checking.
115 */
116static inline void gp_putpixel_raw_clipped(gp_pixmap *pixmap,
117 gp_coord x, gp_coord y, gp_pixel p)
118{
119 GP_FN_PER_PACK_PIXMAP(gp_putpixel_raw_clipped, pixmap, pixmap, x, y, p);
120}
121
134uint8_t gp_pixel_addr_offset(const gp_pixmap *pixmap, gp_coord x);
135
136#endif /* CORE_GP_GETPUTPIXEL_H */
A common types.
uint32_t gp_pixel
Pixel integer value.
Definition gp_types.h:33
int gp_coord
Integer type for coordinates i.e. x, y, ...
Definition gp_types.h:19
Generated macros and function to access pixels.
uint8_t gp_pixel_addr_offset(const gp_pixmap *pixmap, gp_coord x)
Returns a pixel offset in a byte (in pixels).
A pixel description.
Defines how are pixels packed in a buffer.
static void gp_putpixel_raw(gp_pixmap *pixmap, gp_coord x, gp_coord y, gp_pixel p)
Puts a pixel value.
static gp_pixel gp_getpixel_raw(const gp_pixmap *pixmap, gp_coord x, gp_coord y)
Gets a pixel value.
void gp_putpixel(gp_pixmap *pixmap, gp_coord x, gp_coord y, gp_pixel p)
Puts a pixel value.
gp_pixel gp_getpixel(const gp_pixmap *pixmap, gp_coord x, gp_coord y)
Gets a pixel value.
#define GP_PIXEL_IS_CLIPPED(pixmap, x, y)
Returns true when pixel is clipped out of pixmap.
Definition gp_pixmap.h:127
A pixmap buffer.
Definition gp_pixmap.h:33