pntr
Image manipulation library
|
Image manipulation library for C99 or C++, with a focus on ease-of-use. More...
Modules | |
Configuration | |
Colors | |
Memory | |
String Manipulation | |
Math | |
Data Structures | |
union | pntr_color |
struct | pntr_rectangle |
struct | pntr_image |
struct | pntr_vector |
struct | pntr_font |
Macros | |
#define | PNTR_API |
#define | PNTR_PIXELFORMAT PNTR_PIXELFORMAT_RGBA8888 |
#define | PNTR_PIXEL(image, x, y) image->data[(y) * (image->pitch >> 2) + (x)] |
Typedefs | |
typedef union pntr_color | pntr_color |
typedef struct pntr_rectangle | pntr_rectangle |
typedef struct pntr_image | pntr_image |
typedef struct pntr_vector | pntr_vector |
typedef struct pntr_font | pntr_font |
typedef enum pntr_pixelformat | pntr_pixelformat |
typedef enum pntr_filter | pntr_filter |
typedef enum pntr_error | pntr_error |
typedef enum pntr_image_type | pntr_image_type |
Enumerations | |
enum | pntr_pixelformat { PNTR_PIXELFORMAT_RGBA8888 = 0 , PNTR_PIXELFORMAT_ARGB8888 , PNTR_PIXELFORMAT_GRAYSCALE } |
enum | pntr_filter { PNTR_FILTER_NEARESTNEIGHBOR = 0 , PNTR_FILTER_BILINEAR } |
enum | pntr_error { PNTR_ERROR_NONE = 0 , PNTR_ERROR_INVALID_ARGS = -1 , PNTR_ERROR_NO_MEMORY = -2 , PNTR_ERROR_NOT_SUPPORTED = -3 , PNTR_ERROR_FAILED_TO_OPEN = -4 , PNTR_ERROR_FAILED_TO_WRITE = -5 , PNTR_ERROR_UNKNOWN = -6 } |
enum | pntr_image_type { PNTR_IMAGE_TYPE_UNKNOWN = 0 , PNTR_IMAGE_TYPE_PNG , PNTR_IMAGE_TYPE_JPG , PNTR_IMAGE_TYPE_BMP } |
Functions | |
PNTR_API pntr_image * | pntr_new_image (int width, int height) |
PNTR_API pntr_image * | pntr_gen_image_color (int width, int height, pntr_color color) |
PNTR_API pntr_image * | pntr_image_copy (pntr_image *image) |
PNTR_API pntr_image * | pntr_image_from_image (pntr_image *image, int x, int y, int width, int height) |
PNTR_API pntr_image * | pntr_image_subimage (pntr_image *image, int x, int y, int width, int height) |
PNTR_API pntr_rectangle | pntr_image_get_clip (pntr_image *image) |
PNTR_API void | pntr_image_set_clip (pntr_image *image, int x, int y, int width, int height) |
PNTR_API void | pntr_image_set_clip_rec (pntr_image *image, pntr_rectangle clip) |
PNTR_API void | pntr_image_reset_clip (pntr_image *image) |
PNTR_API void | pntr_unload_image (pntr_image *image) |
PNTR_API void | pntr_clear_background (pntr_image *image, pntr_color color) |
PNTR_API void | pntr_draw_point (pntr_image *dst, int x, int y, pntr_color color) |
PNTR_API void | pntr_draw_point_vec (pntr_image *dst, pntr_vector *point, pntr_color color) |
PNTR_API void | pntr_draw_points (pntr_image *dst, pntr_vector *points, int pointsCount, pntr_color color) |
PNTR_API void | pntr_draw_line (pntr_image *dst, int startPosX, int startPosY, int endPosX, int endPosY, pntr_color color) |
PNTR_API void | pntr_draw_line_vec (pntr_image *dst, pntr_vector start, pntr_vector end, pntr_color color) |
PNTR_API void | pntr_draw_line_vertical (pntr_image *dst, int posX, int posY, int height, pntr_color color) |
PNTR_API void | pntr_draw_line_horizontal (pntr_image *dst, int posX, int posY, int width, pntr_color color) |
PNTR_API void | pntr_draw_rectangle (pntr_image *dst, int posX, int posY, int width, int height, pntr_color color) |
PNTR_API void | pntr_draw_rectangle_rec (pntr_image *dst, pntr_rectangle rec, pntr_color color) |
PNTR_API void | pntr_draw_rectangle_thick (pntr_image *dst, int posX, int posY, int width, int height, int thickness, pntr_color color) |
PNTR_API void | pntr_draw_rectangle_thick_rec (pntr_image *dst, pntr_rectangle rect, int thickness, pntr_color color) |
PNTR_API void | pntr_draw_rectangle_fill (pntr_image *dst, int posX, int posY, int width, int height, pntr_color color) |
PNTR_API void | pntr_draw_rectangle_fill_rec (pntr_image *dst, pntr_rectangle rect, pntr_color color) |
PNTR_API void | pntr_draw_rectangle_gradient (pntr_image *dst, int x, int y, int width, int height, pntr_color topLeft, pntr_color topRight, pntr_color bottomLeft, pntr_color bottomRight) |
PNTR_API void | pntr_draw_rectangle_gradient_rec (pntr_image *dst, pntr_rectangle rect, pntr_color topLeft, pntr_color topRight, pntr_color bottomLeft, pntr_color bottomRight) |
PNTR_API void | pntr_draw_triangle (pntr_image *dst, int x1, int y1, int x2, int y2, int x3, int y3, pntr_color color) |
PNTR_API void | pntr_draw_triangle_vec (pntr_image *dst, pntr_vector point1, pntr_vector point2, pntr_vector point3, pntr_color color) |
PNTR_API void | pntr_draw_triangle_fill (pntr_image *dst, int x1, int y1, int x2, int y2, int x3, int y3, pntr_color color) |
PNTR_API void | pntr_draw_triangle_fill_vec (pntr_image *dst, pntr_vector point1, pntr_vector point2, pntr_vector point3, pntr_color color) |
PNTR_API void | pntr_draw_ellipse (pntr_image *dst, int centerX, int centerY, int radiusX, int radiusY, pntr_color color) |
PNTR_API void | pntr_draw_ellipse_fill (pntr_image *dst, int centerX, int centerY, int radiusX, int radiusY, pntr_color color) |
PNTR_API void | pntr_draw_circle (pntr_image *dst, int centerX, int centerY, int radius, pntr_color color) |
PNTR_API void | pntr_draw_circle_fill (pntr_image *dst, int centerX, int centerY, int radius, pntr_color color) |
PNTR_API void | pntr_draw_polygon (pntr_image *dst, pntr_vector *points, int numPoints, pntr_color color) |
PNTR_API void | pntr_draw_polygon_fill (pntr_image *dst, pntr_vector *points, int numPoints, pntr_color color) |
PNTR_API void | pntr_draw_polyline (pntr_image *dst, pntr_vector *points, int numPoints, pntr_color color) |
PNTR_API void | pntr_draw_arc (pntr_image *dst, int centerX, int centerY, float radius, float startAngle, float endAngle, int segments, pntr_color color) |
PNTR_API void | pntr_draw_arc_fill (pntr_image *dst, int centerX, int centerY, float radius, float startAngle, float endAngle, int segments, pntr_color color) |
PNTR_API void | pntr_draw_rectangle_rounded (pntr_image *dst, int x, int y, int width, int height, int topLeftRadius, int topRightRadius, int bottomLeftRadius, int bottomRightRadius, pntr_color color) |
PNTR_API void | pntr_draw_rectangle_rounded_fill (pntr_image *dst, int x, int y, int width, int height, int cornerRadius, pntr_color color) |
PNTR_API void | pntr_draw_image (pntr_image *dst, pntr_image *src, int posX, int posY) |
PNTR_API void | pntr_draw_image_rec (pntr_image *dst, pntr_image *src, pntr_rectangle srcRect, int posX, int posY) |
PNTR_API void | pntr_draw_image_tint (pntr_image *dst, pntr_image *src, int posX, int posY, pntr_color tint) |
PNTR_API void | pntr_draw_image_tint_rec (pntr_image *dst, pntr_image *src, pntr_rectangle srcRect, int posX, int posY, pntr_color tint) |
PNTR_API void | pntr_draw_image_rotated (pntr_image *dst, pntr_image *src, int posX, int posY, float degrees, float offsetX, float offsetY, pntr_filter filter) |
PNTR_API void | pntr_draw_image_rotated_rec (pntr_image *dst, pntr_image *src, pntr_rectangle srcRect, int posX, int posY, float degrees, float offsetX, float offsetY, pntr_filter filter) |
PNTR_API void | pntr_draw_image_flipped (pntr_image *dst, pntr_image *src, int posX, int posY, bool flipHorizontal, bool flipVertical, bool flipDiagonal) |
PNTR_API void | pntr_draw_image_flipped_rec (pntr_image *dst, pntr_image *src, pntr_rectangle srcRec, int posX, int posY, bool flipHorizontal, bool flipVertical, bool flipDiagonal) |
PNTR_API void | pntr_draw_image_scaled (pntr_image *dst, pntr_image *src, int posX, int posY, float scaleX, float scaleY, float offsetX, float offsetY, pntr_filter filter) |
PNTR_API void | pntr_draw_image_scaled_rec (pntr_image *dst, pntr_image *src, pntr_rectangle srcRect, int posX, int posY, float scaleX, float scaleY, float offsetX, float offsetY, pntr_filter filter) |
PNTR_API void | pntr_draw_text (pntr_image *dst, pntr_font *font, const char *text, int posX, int posY, pntr_color color) |
PNTR_API void | pntr_draw_text_wrapped (pntr_image *dst, pntr_font *font, const char *text, int posX, int posY, int maxWidth, pntr_color tint) |
PNTR_API pntr_color | pntr_new_color (unsigned char r, unsigned char g, unsigned char b, unsigned char a) |
PNTR_API pntr_color | pntr_get_color (unsigned int hexValue) |
PNTR_API unsigned char | pntr_color_r (pntr_color color) |
PNTR_API unsigned char | pntr_color_g (pntr_color color) |
PNTR_API unsigned char | pntr_color_b (pntr_color color) |
PNTR_API unsigned char | pntr_color_a (pntr_color color) |
PNTR_API void | pntr_color_set_r (pntr_color *color, unsigned char r) |
PNTR_API void | pntr_color_set_g (pntr_color *color, unsigned char g) |
PNTR_API void | pntr_color_set_b (pntr_color *color, unsigned char b) |
PNTR_API void | pntr_color_set_a (pntr_color *color, unsigned char a) |
PNTR_API pntr_color | pntr_image_get_color (pntr_image *image, int x, int y) |
PNTR_API bool | pntr_save_file (const char *fileName, const void *data, unsigned int bytesToWrite) |
PNTR_API void * | pntr_image_to_pixelformat (pntr_image *image, unsigned int *dataSize, pntr_pixelformat pixelFormat) |
PNTR_API bool | pntr_save_image (pntr_image *image, const char *fileName) |
PNTR_API unsigned char * | pntr_save_image_to_memory (pntr_image *image, pntr_image_type type, unsigned int *dataSize) |
PNTR_API int | pntr_get_pixel_data_size (int width, int height, pntr_pixelformat pixelFormat) |
PNTR_API pntr_image * | pntr_load_image (const char *fileName) |
PNTR_API pntr_image * | pntr_load_image_from_memory (pntr_image_type type, const unsigned char *fileData, unsigned int dataSize) |
PNTR_API pntr_image * | pntr_image_from_pixelformat (const void *data, int width, int height, pntr_pixelformat pixelFormat) |
PNTR_API void * | pntr_set_error (pntr_error error) |
PNTR_API const char * | pntr_get_error (void) |
PNTR_API pntr_error | pntr_get_error_code (void) |
PNTR_API pntr_image * | pntr_image_resize (pntr_image *image, int newWidth, int newHeight, pntr_filter filter) |
PNTR_API pntr_image * | pntr_image_scale (pntr_image *image, float scaleX, float scaleY, pntr_filter filter) |
PNTR_API void | pntr_image_color_replace (pntr_image *image, pntr_color color, pntr_color replace) |
PNTR_API pntr_color | pntr_color_tint (pntr_color color, pntr_color tint) |
PNTR_API void | pntr_image_color_tint (pntr_image *image, pntr_color color) |
PNTR_API pntr_color | pntr_color_fade (pntr_color color, float alpha) |
PNTR_API void | pntr_image_color_fade (pntr_image *image, float alpha) |
PNTR_API pntr_color | pntr_color_brightness (pntr_color color, float factor) |
PNTR_API pntr_color | pntr_get_pixel_color (void *srcPtr, pntr_pixelformat srcPixelFormat) |
PNTR_API void | pntr_set_pixel_color (void *dstPtr, pntr_pixelformat dstPixelFormat, pntr_color color) |
PNTR_API pntr_font * | pntr_load_font_default (void) |
PNTR_API void | pntr_unload_font (pntr_font *font) |
PNTR_API pntr_font * | pntr_font_copy (pntr_font *font) |
PNTR_API pntr_font * | pntr_font_scale (pntr_font *font, float scaleX, float scaleY, pntr_filter filter) |
PNTR_API pntr_font * | pntr_load_font_bmf (const char *fileName, const char *characters) |
PNTR_API pntr_font * | pntr_load_font_bmf_from_image (pntr_image *image, const char *characters) |
PNTR_API pntr_font * | pntr_load_font_bmf_from_memory (const unsigned char *fileData, unsigned int dataSize, const char *characters) |
PNTR_API int | pntr_measure_text (pntr_font *font, const char *text) |
PNTR_API pntr_vector | pntr_measure_text_ex (pntr_font *font, const char *text, int textLength) |
PNTR_API pntr_image * | pntr_gen_image_text (pntr_font *font, const char *text, pntr_color tint) |
PNTR_API pntr_font * | pntr_load_font_tty (const char *fileName, int glyphWidth, int glyphHeight, const char *characters) |
PNTR_API pntr_font * | pntr_load_font_tty_from_memory (const unsigned char *fileData, unsigned int dataSize, int glyphWidth, int glyphHeight, const char *characters) |
PNTR_API pntr_font * | pntr_load_font_tty_from_image (pntr_image *image, int glyphWidth, int glyphHeight, const char *characters) |
PNTR_API unsigned char * | pntr_load_file (const char *fileName, unsigned int *bytesRead) |
PNTR_API void | pntr_unload_file (unsigned char *fileData) |
PNTR_API const char * | pntr_load_file_text (const char *fileName) |
PNTR_API void | pntr_unload_file_text (const char *text) |
PNTR_API pntr_font * | pntr_load_font_ttf (const char *fileName, int fontSize) |
PNTR_API pntr_font * | pntr_load_font_ttf_from_memory (const unsigned char *fileData, unsigned int dataSize, int fontSize) |
PNTR_API pntr_color | pntr_color_invert (pntr_color color) |
PNTR_API void | pntr_image_color_invert (pntr_image *image) |
PNTR_API pntr_color | pntr_color_alpha_blend (pntr_color dst, pntr_color src) |
PNTR_API pntr_rectangle | pntr_image_alpha_border (pntr_image *image, float threshold) |
PNTR_API bool | pntr_image_crop (pntr_image *image, int x, int y, int width, int height) |
PNTR_API void | pntr_image_alpha_crop (pntr_image *image, float threshold) |
PNTR_API void | pntr_image_color_brightness (pntr_image *image, float factor) |
PNTR_API void | pntr_image_flip (pntr_image *image, bool horizontal, bool vertical) |
PNTR_API pntr_color | pntr_color_contrast (pntr_color color, float contrast) |
PNTR_API void | pntr_image_color_contrast (pntr_image *image, float contrast) |
PNTR_API void | pntr_image_alpha_mask (pntr_image *image, pntr_image *alphaMask, int posX, int posY) |
PNTR_API bool | pntr_image_resize_canvas (pntr_image *image, int newWidth, int newHeight, int offsetX, int offsetY, pntr_color fill) |
PNTR_API pntr_image * | pntr_image_rotate (pntr_image *image, float degrees, pntr_filter filter) |
PNTR_API pntr_image * | pntr_gen_image_gradient (int width, int height, pntr_color topLeft, pntr_color topRight, pntr_color bottomLeft, pntr_color bottomRight) |
PNTR_API pntr_color | pntr_color_bilinear_interpolate (pntr_color color00, pntr_color color01, pntr_color color10, pntr_color color11, float coordinateX, float coordinateY) |
PNTR_API void * | pntr_load_memory (size_t size) |
PNTR_API void | pntr_unload_memory (void *pointer) |
PNTR_API void * | pntr_memory_copy (void *destination, void *source, size_t size) |
PNTR_API pntr_image_type | pntr_get_file_image_type (const char *filePath) |
PNTR_API void | pntr_put_horizontal_line_unsafe (pntr_image *dst, int posX, int posY, int width, pntr_color color) |
PNTR_API void | pntr_draw_point_unsafe (pntr_image *dst, int x, int y, pntr_color color) |
PNTR_API void | pntr_blend_color (pntr_color *dst, pntr_color src) |
Image manipulation library for C99 or C++, with a focus on ease-of-use.
Make sure to define PNTR_IMPLEMENTATION
before including in one of your .c
files.
#define PNTR_API |
Prefix applied to all pntr methods.
If you're using Emscripten, for instance, you could use the following to export all pntr methods:
#define PNTR_API EMSCRIPTEN_KEEPALIVE
#define PNTR_PIXEL | ( | image, | |
x, | |||
y | |||
) | image->data[(y) * (image->pitch >> 2) + (x)] |
Retrieve the pixel at the given x,y coordinate of the image.
image | The image to check against. |
x | The x coordinate. |
y | The y coordinate. |
#define PNTR_PIXELFORMAT PNTR_PIXELFORMAT_RGBA8888 |
The set pixel format for the application.
Will become either PNTR_PIXELFORMAT_ARGB8888
or PNTR_PIXELFORMAT_RGBA8888
, with the default being PNTR_PIXELFORMAT_RGBA8888
.
typedef union pntr_color pntr_color |
Color, represented by an unsigned 32-bit integer.
Has four components: Red, Green, Blue, and Alpha. Depending on the pixel format, will shift the order in which the components are defines.
typedef enum pntr_error pntr_error |
Error states definitions.
typedef enum pntr_filter pntr_filter |
Possible image filters to apply.
Font used to render text.
If PNTR_ENABLE_UTF8
is enabled, will allow loading fonts with UTF-8 support.
typedef struct pntr_image pntr_image |
An image, represented by pixel data.
typedef enum pntr_image_type pntr_image_type |
The associated image format.
typedef enum pntr_pixelformat pntr_pixelformat |
Pixel format.
typedef struct pntr_rectangle pntr_rectangle |
A rectangle.
typedef struct pntr_vector pntr_vector |
A vector, represented by x and y coordinates.
enum pntr_error |
Error states definitions.
enum pntr_filter |
Possible image filters to apply.
enum pntr_image_type |
enum pntr_pixelformat |
|
inline |
Alpha blend the source color into the destination color.
dst | The destination color. |
src | The source color. |
PNTR_API void pntr_clear_background | ( | pntr_image * | image, |
pntr_color | color | ||
) |
Clears an image with the given color.
Clearing the background ignores clipping.
image | The image to clear. |
color | The color to fill the image with. |
|
inline |
Get source alpha-blended into destination color.
dst | The destination color. |
src | The source color. |
|
inline |
Bilinear interpolate the given colors, in the sequence below, based on their given 0-1 coordinates.
The colors appear in the following order:
00 10 01 11
color00 | The top left color. |
color01 | The bottom left color. |
color10 | The top right color. |
color11 | The bottom right color. |
coordinateX | A 0.0f to 1.0f fraction between color00 and color 10. |
coordinateY | A 0.0f to 1.0f fraction between color00 and color 01. |
PNTR_API pntr_color pntr_color_brightness | ( | pntr_color | color, |
float | factor | ||
) |
Change brightness of the given color by a factor from -1.0f to 1.0f.
color | The color to change the brightness of. |
factor | The factor in which to change the brightness from -1.0f to 1.0f. |
PNTR_API pntr_color pntr_color_contrast | ( | pntr_color | color, |
float | contrast | ||
) |
Apply contrast to the given color.
color | The color to apply constrast to. |
contrast | The amount of constrast to apply, from -1.0f to 1.0f. |
PNTR_API pntr_color pntr_color_fade | ( | pntr_color | color, |
float | factor | ||
) |
Fades the given color by a factor from -1.0f to 1.0f.
color | The color that you would like to fade. |
factor | The factor of which to fade the color, from -1.0f to 1.0f. |
|
inline |
Inverts the given color.
color | The color to invert. |
|
inline |
Tints the given color by another color.
color | The source color to apply the tint to. |
tint | The tint color. |
|
inline |
Draws a circle from the given center, with the given radius.
This uses the Midpoint Circle Algorithm: https://en.wikipedia.org/wiki/Midpoint_circle_algorithm
TODO: pntr_draw_circle: Add anti-aliased, and thickness.
dst | The image to draw the circle onto. |
centerX | The center of the circle at the X coordinate. |
centerX | The center of the circle at the Y coordinate. |
radius | The radius of the circle. |
color | The desired color of the circle. |
PNTR_API void pntr_draw_circle_fill | ( | pntr_image * | dst, |
int | centerX, | ||
int | centerY, | ||
int | radius, | ||
pntr_color | color | ||
) |
Draws a filled circle on the given image.
TODO: pntr_draw_circle_fill: Add anti-aliased.
dst | The image to draw the filled circle onto. |
centerX | The center of the circle at the X coordinate. |
centerX | The center of the circle at the Y coordinate. |
radius | The radius of the circle. |
color | The desired fill color of the circle. |
PNTR_API void pntr_draw_ellipse | ( | pntr_image * | dst, |
int | centerX, | ||
int | centerY, | ||
int | radiusX, | ||
int | radiusY, | ||
pntr_color | color | ||
) |
Draws an ellipse on the given image.
dst | The image to draw the filled circle onto. |
centerX | The center of the circle at the X coordinate. |
centerX | The center of the circle at the Y coordinate. |
radiusX | The horizontal radius of the circle. |
radiusY | The vertical radius of the circle. |
color | The desired color of the circle. |
PNTR_API void pntr_draw_ellipse_fill | ( | pntr_image * | dst, |
int | centerX, | ||
int | centerY, | ||
int | radiusX, | ||
int | radiusY, | ||
pntr_color | color | ||
) |
Draws a filled ellipse on the given image.
TODO: pntr_draw_ellipse_fill: Add anti-aliased
dst | The image to draw the filled circle onto. |
centerX | The center of the circle at the X coordinate. |
centerX | The center of the circle at the Y coordinate. |
radiusX | The horizontal radius of the circle. |
radiusY | The vertical radius of the circle. |
color | The desired fill color of the circle. |
|
inline |
Draw an image onto the destination image.
|
inline |
Draw a source image within a destination image.
dst | The destination image. |
src | The source image. |
srcRect | The source rectangle of what to draw from the source image. |
posX | Where to draw the image on the x coordinate. |
posY | Where to draw the image on the y coordinate. |
|
inline |
Draw a rotated image onto another image.
dst | Pointer to the destination image where the output will be stored. |
src | Pointer to the source image that will be drawn onto the destination image. |
posX | Where to draw the rotated image, at the X coordinate. |
posY | Where to draw the rotated image, at the Y coordinate. |
degrees | The degrees of rotation. |
offsetX | Offset in the X direction after rotation. |
offsetY | Offset in the Y direction after rotation. |
filter | Filter to be applied during the rotation. PNTR_FILTER_BILINEAR and PNTR_FILTER_NEARESTNEIGHBOR are supported. |
PNTR_API void pntr_draw_image_rotated_rec | ( | pntr_image * | dst, |
pntr_image * | src, | ||
pntr_rectangle | srcRect, | ||
int | posX, | ||
int | posY, | ||
float | degrees, | ||
float | offsetX, | ||
float | offsetY, | ||
pntr_filter | filter | ||
) |
Draw a rotated portion of an image onto another image.
dst | Pointer to the destination image where the output will be stored. |
src | Pointer to the source image that will be drawn onto the destination image. |
srcRect | The portion of the source image to draw. |
posX | Where to draw the rotated image, at the X coordinate. |
posY | Where to draw the rotated image, at the Y coordinate. |
degrees | The degrees of rotation. |
offsetX | Offset in the X direction after rotation. |
offsetY | Offset in the Y direction after rotation. |
filter | Filter to be applied during the rotation. PNTR_FILTER_BILINEAR and PNTR_FILTER_NEARESTNEIGHBOR are supported. |
|
inline |
Draw a scaled image.
dst | Pointer to the destination image where the output will be stored. |
src | Pointer to the source image that will be drawn onto the destination image. |
posX | Where to draw the scaled image, at the X coordinate. |
posY | Where to draw the scaled image, at the Y coordinate. |
scaleX | The scale of which to apply to the width of the image. |
scaleY | The scale of which to apply to the height of the image. |
offsetX | How much to offset the X drawing of the image, relative from its original source size. |
offsetX | How much to offset the Y drawing of the image, relative from its original source size. |
filter | Filter to be applied during the rotation. |
|
inline |
Draw an image onto the destination image, with tint.
PNTR_API void pntr_draw_image_tint_rec | ( | pntr_image * | dst, |
pntr_image * | src, | ||
pntr_rectangle | srcRect, | ||
int | posX, | ||
int | posY, | ||
pntr_color | tint | ||
) |
Draw a source image within a destination image, with tint.
dst | The destination image. |
src | The source image. |
srcRect | The source rectangle of what to draw from the source image. |
posX | Where to draw the image on the x coordinate. |
posY | Where to draw the image on the y coordinate. |
tint | The color to tint the image when drawing. |
PNTR_API void pntr_draw_line | ( | pntr_image * | dst, |
int | startPosX, | ||
int | startPosY, | ||
int | endPosX, | ||
int | endPosY, | ||
pntr_color | color | ||
) |
Draws a line on the given image.
TODO: pntr_draw_line: Add anti-aliased, and thickness to the lines.
PNTR_API void pntr_draw_line_horizontal | ( | pntr_image * | dst, |
int | posX, | ||
int | posY, | ||
int | width, | ||
pntr_color | color | ||
) |
Draw a horizontal line at the given x, y coordinates.
dst | The destination image. |
posX | The X position. |
posY | The Y position. |
width | How long the line should be. |
color | The color of the line. |
TODO: pntr_draw_line_horizontal: Support negative width.
PNTR_API void pntr_draw_line_vertical | ( | pntr_image * | dst, |
int | posX, | ||
int | posY, | ||
int | height, | ||
pntr_color | color | ||
) |
Draw a vertical line at the given x, y coordinates.
dst | The destination image. |
posX | The X position. |
posY | The Y position. |
height | How tall the line should be. |
color | The color of the line. |
TODO: pntr_draw_line_vertical: Support negative height.
PNTR_API void pntr_draw_point | ( | pntr_image * | dst, |
int | x, | ||
int | y, | ||
pntr_color | color | ||
) |
Draws a pixel on the given image.
|
inline |
Draws a point on the given image, without safety checks.
PNTR_API void pntr_draw_rectangle | ( | pntr_image * | dst, |
int | posX, | ||
int | posY, | ||
int | width, | ||
int | height, | ||
pntr_color | color | ||
) |
Draw a rectangle on the given image.
dst | The destination image. |
posX | The X position. |
posY | The Y position. |
width | How wide the rectangle should be. |
height | How tall the rectangle should be. |
color | The color of the line. |
|
inline |
Draws a filled rectangle on the given image.
dst | The destination image. |
posX | The X position. |
posY | The Y position. |
width | How wide the rectangle should be. |
height | How tall the rectangle should be. |
color | The color of the rectangle. |
PNTR_API void pntr_draw_rectangle_fill_rec | ( | pntr_image * | dst, |
pntr_rectangle | rect, | ||
pntr_color | color | ||
) |
Draws a filled rectangle on the given image, using a rectangle as input data.
dst | The destination image. |
rect | The rectangle of which to draw. |
color | The color of the rectangle. |
|
inline |
Draws a rectangle using a rectangle.
dst | Where to draw the rectangle. |
rec | The rectangle of which to draw. |
color | The color of the lines for the rectangle. |
PNTR_API void pntr_draw_text | ( | pntr_image * | dst, |
pntr_font * | font, | ||
const char * | text, | ||
int | posX, | ||
int | posY, | ||
pntr_color | tint | ||
) |
Prints text on the given image.
dst | The image of which to print the text on. |
font | The font to use when rendering the text. |
text | The text to write. Must be NULL terminated. |
posX | The position to print the text, starting from the top left on the X axis. |
posY | The position to print the text, starting from the top left on the Y axis. |
tint | What color to tint the font when drawing. Use PNTR_WHITE if you don't want to change the source color. |
PNTR_API void pntr_draw_text_wrapped | ( | pntr_image * | dst, |
pntr_font * | font, | ||
const char * | text, | ||
int | posX, | ||
int | posY, | ||
int | maxWidth, | ||
pntr_color | tint | ||
) |
Draws word-wrapped text on the given image.
dst | The image of which to print the text on. |
font | The font to use when rendering the text. |
text | The text to write. Must be NULL terminated. |
posX | The position to print the text, starting from the top left on the X axis. |
posY | The position to print the text, starting from the top left on the Y axis. |
maxWidth | The maximum width for each line. |
tint | What color to tint the font when drawing. Use PNTR_WHITE if you don't want to change the source color. |
PNTR_API void pntr_draw_triangle | ( | pntr_image * | dst, |
int | x1, | ||
int | y1, | ||
int | x2, | ||
int | y2, | ||
int | x3, | ||
int | y3, | ||
pntr_color | color | ||
) |
Draw a triangle on an image.
dst | The image of which to draw the triangle. |
x1 | The x coordinate of the first point. |
y1 | The y coordinate of the first point. |
x2 | The x coordinate of the second point. |
y2 | The y coordinate of the second point. |
x3 | The x coordinate of the third point. |
y3 | The y coordinate of the third point. |
color | The line color for the triangle. |
|
inline |
Draw a filled triangle on an image.
dst | The image of which to draw the triangle. |
x1 | The x coordinate of the first point. |
y1 | The y coordinate of the first point. |
x2 | The x coordinate of the second point. |
y2 | The y coordinate of the second point. |
x3 | The x coordinate of the third point. |
y3 | The y coordinate of the third point. |
color | The fill color of the triangle. |
PNTR_API void pntr_draw_triangle_fill_vec | ( | pntr_image * | dst, |
pntr_vector | point1, | ||
pntr_vector | point2, | ||
pntr_vector | point3, | ||
pntr_color | color | ||
) |
Draw a filled triangle using vectors.
dst | Where to draw the triangle. |
point1 | The first point in the triangle. |
point2 | The second point in the triangle. |
point3 | The third point in the triangle. |
color | What color to draw the triangle. |
|
inline |
Draw a triangle using vectors.
dst | Where to draw the triangle. |
point1 | The first point in the triangle. |
point2 | The second point in the triangle. |
point3 | The third point in the triangle. |
color | What color to draw the triangle. |
Creates a copy of the given font.
font | The font to copy. |
PNTR_API pntr_font * pntr_font_scale | ( | pntr_font * | font, |
float | scaleX, | ||
float | scaleY, | ||
pntr_filter | filter | ||
) |
Resize a font by a given scales.
font | The font that you would like to scale. |
scaleX | The scale of which to resize the width of the font by. |
scaleY | The scale of which to resize the height of the font by. |
filter | The filter to apply when resizing the font. PNTR_FILTER_NEARESTNEIGHBOR is good for pixel fonts. |
PNTR_API pntr_image * pntr_gen_image_color | ( | int | width, |
int | height, | ||
pntr_color | color | ||
) |
Generate a new image with the given color.
width | The width of the new image. |
height | The height of the given image. |
color | The desired color that will fill the new image. |
PNTR_API pntr_image * pntr_gen_image_gradient | ( | int | width, |
int | height, | ||
pntr_color | topLeft, | ||
pntr_color | topRight, | ||
pntr_color | bottomLeft, | ||
pntr_color | bottomRight | ||
) |
Generate image: vertical and horizontal gradient.
width | The width of the new image. |
height | The height of the new image. |
topLeft | The color at the top left of the image. |
topRight | The color at the top right of the image. |
bottomLeft | The color at the bottom left of the image. |
bottomRight | The color at the bottom right of the image. |
PNTR_API pntr_image * pntr_gen_image_text | ( | pntr_font * | font, |
const char * | text, | ||
pntr_color | tint | ||
) |
Generate an image with rendered text on it.
font | The font to use when rendering the text. |
text | The text to render. |
tint | The color to tint the text by. Use PNTR_WHITE if you don't want to change the color. |
|
inline |
Get a pntr_color from a RGBA hexadecimal value
hexValue | The RGBA hexadecimal value representing the color. For example: 0x052c46ff. |
PNTR_API pntr_image_type pntr_get_file_image_type | ( | const char * | filePath | ) |
Get the file type of the given image, based on its filename.
filePath | The file path to the image. |
PNTR_API pntr_color pntr_get_pixel_color | ( | void * | srcPtr, |
pntr_pixelformat | srcPixelFormat | ||
) |
Gets the pixel color of the given pointer.
srcPtr | A pointer to the given source data. |
srcPixelFormat | The pixel format of the given source color. |
PNTR_API int pntr_get_pixel_data_size | ( | int | width, |
int | height, | ||
pntr_pixelformat | pixelFormat | ||
) |
Retrieve the size of the image data in memory in bytes, depending on the given pixel format.
width | The width of the image data. |
height | The height of the image data. |
pixelFormat | The pixel format of the image data. |
PNTR_API pntr_rectangle pntr_image_alpha_border | ( | pntr_image * | image, |
float | threshold | ||
) |
Calculates a rectangle representing the available alpha border.
image | The image to calculate the alpha border on. |
threshold | A threshold factor from 0.0f to 1.0f to consider alpha. |
PNTR_API void pntr_image_alpha_crop | ( | pntr_image * | image, |
float | threshold | ||
) |
Crop an image based on the alpha border.
image | The image to crop. |
threshold | The alpha threshold to crop by, from 0.0f to 1.0f. |
PNTR_API void pntr_image_alpha_mask | ( | pntr_image * | image, |
pntr_image * | alphaMask, | ||
int | posX, | ||
int | posY | ||
) |
Apply an alpha mask to an image.
image | The image to apply the alpha mask to. |
alphaMask | An image that has the alphaMask data. |
posX | Where to position the alpha mask on the image. |
posY | Where to position the alpha mask on the image. |
PNTR_API void pntr_image_color_brightness | ( | pntr_image * | image, |
float | factor | ||
) |
Changes the brightness of the given image by a factor.
image | The image to change brightness of. |
factor | The factor in which to affect the brightness from -1.0f to 1.0f. |
PNTR_API void pntr_image_color_contrast | ( | pntr_image * | image, |
float | contrast | ||
) |
Apply contrast to the given image.
image | The image you would like to apply contrast to. |
contrast | The factor of contrast to apply, from -1.0f to 1.0f. |
PNTR_API void pntr_image_color_fade | ( | pntr_image * | image, |
float | factor | ||
) |
Fade an image by the given factor.
image | The image to fade. |
factor | The factor of which to fade the image, from -1.0f to 1.0f. |
PNTR_API void pntr_image_color_invert | ( | pntr_image * | image | ) |
PNTR_API void pntr_image_color_replace | ( | pntr_image * | image, |
pntr_color | color, | ||
pntr_color | replace | ||
) |
Replace the given color with another color on an image.
image | The image to process. |
color | The color to search for. |
replace | The color that will replace the original color. |
PNTR_API void pntr_image_color_tint | ( | pntr_image * | image, |
pntr_color | tint | ||
) |
Tints the given image by the provided color.
image | The image to tint. |
tint | The color of which to tint the image by. |
PNTR_API pntr_image * pntr_image_copy | ( | pntr_image * | image | ) |
Create an image duplicate.
image | The image that you want to copy. |
PNTR_API bool pntr_image_crop | ( | pntr_image * | image, |
int | x, | ||
int | y, | ||
int | width, | ||
int | height | ||
) |
Crops an image by the given coordinates.
image | The image to crop. |
x | The x coordinate to crop from. |
y | The y coordinate to crop from. |
width | The width of the desired crop. |
height | The height of the desired crop. |
PNTR_API void pntr_image_flip | ( | pntr_image * | image, |
bool | horizontal, | ||
bool | vertical | ||
) |
Flip an image, vertically, or horizontally, or both.
image | The image to flip. |
horizontal | Whether or not to flip the image horizontally. |
vertical | Whether or not to flip the image vertically. |
PNTR_API pntr_image * pntr_image_from_image | ( | pntr_image * | image, |
int | x, | ||
int | y, | ||
int | width, | ||
int | height | ||
) |
Creates a new image from a section of the original image.
The new image must be cleared with pntr_unload_image().
image | The original image to build the new image from. |
x | The x coordinate to build the new image from. |
y | The y coordinate to build the new image from. |
width | The width of the new image. |
height | The height of the new image. |
PNTR_API pntr_image * pntr_image_from_pixelformat | ( | const void * | imageData, |
int | width, | ||
int | height, | ||
pntr_pixelformat | pixelFormat | ||
) |
Creates a new image based on the given image data, from the given original pixel format.
This will not clear the original imageData.
imageData | The data of the image in memory. |
width | The width of the image. |
height | The height of the image. |
pixelFormat | The pixel format of the image in memory. |
PNTR_API pntr_rectangle pntr_image_get_clip | ( | pntr_image * | image | ) |
Get the clip rectangle from the given image. Anything outside of the clip cannot be changed.
image | The image of which to get the clip rectangle for. |
PNTR_API pntr_color pntr_image_get_color | ( | pntr_image * | image, |
int | x, | ||
int | y | ||
) |
Get image pixel color at (x, y) position.
image | The image to get the color from. |
x | The x position of the pixel. |
y | The y position of the pixel. |
PNTR_API void pntr_image_reset_clip | ( | pntr_image * | image | ) |
Reset the clipping rectangle for the given image.
image | The image to reset the clipping image for. |
PNTR_API pntr_image * pntr_image_resize | ( | pntr_image * | image, |
int | newWidth, | ||
int | newHeight, | ||
pntr_filter | filter | ||
) |
Resize an image.
image | The image to resize. |
newWidth | The desired width of the new image. |
newHeight | THe desired height of the new image. |
filter | Which filter to apply when resizing. |
PNTR_API bool pntr_image_resize_canvas | ( | pntr_image * | image, |
int | newWidth, | ||
int | newHeight, | ||
int | offsetX, | ||
int | offsetY, | ||
pntr_color | fill | ||
) |
Resize the canvas of the given image.
image | The image you would like to resize. |
newWidth | The desired width of the new canvas. |
newHeight | The desired height of the new canvas. |
offsetX | How to offset the image once its canvas is resized. Use 0 if you like to keep the original image on the left. |
offsetY | How to offset the image once its canvas is resized. Use 0 if you like to keep the original image at the top. |
fill | The color to use for the background of the new image. |
PNTR_API pntr_image * pntr_image_rotate | ( | pntr_image * | image, |
float | degrees, | ||
pntr_filter | filter | ||
) |
Creates a new image based off the given image, that's rotated by the given degrees.
image | The image to rotate. |
degrees | The desired amount to rotate the image in degrees. |
PNTR_API pntr_image * pntr_image_scale | ( | pntr_image * | image, |
float | scaleX, | ||
float | scaleY, | ||
pntr_filter | filter | ||
) |
Scales an image either up or down.
image | The image to scale up or down. |
scaleX | The scale of which to apply to the width of the image. |
scaleY | The scale of which to apply to the height of the image. |
filter | The filter to apply when resizing. |
PNTR_API void pntr_image_set_clip | ( | pntr_image * | image, |
int | x, | ||
int | y, | ||
int | width, | ||
int | height | ||
) |
Set the clipping rectangle for the given image to restrict drawing within.
image | The image to set the clipping rectangle. |
x | The X coordinate for the clipping rectangle. |
y | The Y coordinate for the clipping rectangle. |
width | The width of the desired clipping rectangle. |
height | The height of the desired clipping rectangle. |
PNTR_API void pntr_image_set_clip_rec | ( | pntr_image * | image, |
pntr_rectangle | clip | ||
) |
Set the clipping rectangle for the given image to restrict drawing within, using a rectangle.
image | The image to set the clipping rectangle. |
clip | The rectangle to set the new clip boundries. |
PNTR_API pntr_image * pntr_image_subimage | ( | pntr_image * | image, |
int | x, | ||
int | y, | ||
int | width, | ||
int | height | ||
) |
Creates an image that references a section of another image.
This is useful to have images reference a sprite in a tileset. Sub-images still need to be cleared with pntr_unload_image().
image | The original image to reference for the new portion of the image. |
x | The X coorindate of the subimage. |
y | The Y coordinate of the subimage. |
width | The width of the subimage. |
height | The height of the subimage. |
PNTR_API void * pntr_image_to_pixelformat | ( | pntr_image * | image, |
unsigned int * | dataSize, | ||
pntr_pixelformat | pixelFormat | ||
) |
Convert the given image to a new image using the provided pixel format.
image | The image to convert. |
dataSize | Where to put the resulting size of the image data. Use NULL if you have no need for the resulting data size. |
pixelFormat | The desired pixel format of the resulting image. |
PNTR_API unsigned char * pntr_load_file | ( | const char * | fileName, |
unsigned int * | bytesRead | ||
) |
Loads a file from the file system.
This data must be cleared with pntr_unload_file() when finished.
You can define your own callback for this by defining PNTR_LOAD_FILE.
fileName | The name of the file to load. |
bytesRead | Where to stick the amount of bytes that were read. Use NULL if you don't need the file size. |
PNTR_API const char * pntr_load_file_text | ( | const char * | fileName | ) |
Load text from a file. Must be cleared with pntr_unload_file().
fileName | The file to load. |
Load a BMFont from the file system.
fileName | The name of the image file to load as the bmfont. |
characters | A string representing the characters to load from the atlas. |
Load the default font.
This must be unloaded manually afterwards with pntr_unload_font().
Define PNTR_ENABLE_DEFAULT_FONT
to allow using the default 8x8 font.
You can change this by defining your own PNTR_DEFAULT_FONT. It must match the definition of pntr_load_font_default()
Loads a truetype font from the file system.
This needs to be compiled with PNTR_ENABLE_TTF
to be supported.
fileName | The name of the .ttf file. |
fontSize | The size of the font, in pixels. |
PNTR_API pntr_font * pntr_load_font_ttf_from_memory | ( | const unsigned char * | fileData, |
unsigned int | dataSize, | ||
int | fontSize | ||
) |
Load a truetype font from memory.
This needs to be compiled with PNTR_ENABLE_TTF
to be supported.
fileData | The data of the TTF file. |
dataSize | The size of the data in memory. |
fontSize | The desired size of the font, in pixels. |
PNTR_API pntr_font * pntr_load_font_tty | ( | const char * | fileName, |
int | glyphWidth, | ||
int | glyphHeight, | ||
const char * | characters | ||
) |
Loads a TTY Font from the file system.
fileName | The name of the image file to load as the font. |
glyphWidth | The width of each character on the font atlas. |
glyphHeight | The height of each character on the font atlas. |
characters | A string of characters that appear in the image. |
PNTR_API pntr_image * pntr_load_image | ( | const char * | fileName | ) |
Load an image from file.
fileName | The name of the file to load from the file system. |
PNTR_API pntr_image * pntr_load_image_from_memory | ( | pntr_image_type | type, |
const unsigned char * | fileData, | ||
unsigned int | dataSize | ||
) |
Load an image from memory buffer.
PNTR_LOAD_IMAGE_FROM_MEMORY
.type | The type of image to load. |
fileData | The data of the file to be loaded. |
dataSize | The size of the file data. |
|
inline |
Allocates the given amount of bytes in size.
size | The amount of bytes to allocate to memory. |
Measures the horizontal length of the text when rendered with the given font.
font | The font to use when rendering the text. |
text | The text to measure the length of. |
PNTR_API pntr_vector pntr_measure_text_ex | ( | pntr_font * | font, |
const char * | text, | ||
int | textLength | ||
) |
Measures the width and height of the given text when rendered with the font.
font | The font to use when rendering the text. |
text | The text to measure the length of. |
textLength | (Optional) How long the string to measure is from text. Provide 0 to determine the string length with a null character. |
|
inline |
Copy a memory address from the source to the destination.
destination | Where to copy the memory to. |
source | The source data. |
size | The size of the data to copy. |
|
inline |
Creates a new color, provided the given red, green, blue, and alpha colors.
red | The red channel. |
green | The green channel. |
blue | The blue channel. |
alpha | The alpha channel. |
PNTR_API pntr_image * pntr_new_image | ( | int | width, |
int | height | ||
) |
Create a new image at the given width and height.
This method will not clear the image upon instantiation.
width | The width of the new image. |
height | The height of the new image. |
|
inline |
Draws a line on the destination image.
PNTR_API bool pntr_save_file | ( | const char * | fileName, |
const void * | data, | ||
unsigned int | bytesToWrite | ||
) |
Saves a file to the file system.
You can define your own callback for this by defining PNTR_SAVE_FILE.
fileName | The name of the file to save. |
data | A pointer to the memory data in memory. |
bytesToWrite | The size of the data in memory. |
PNTR_API bool pntr_save_image | ( | pntr_image * | image, |
const char * | fileName | ||
) |
Saves an image to the file system.
image | The image to save to the file system. |
fileName | The name of the file to save. |
PNTR_API unsigned char * pntr_save_image_to_memory | ( | pntr_image * | image, |
pntr_image_type | type, | ||
unsigned int * | dataSize | ||
) |
Gets a PNG representation of the given image in memory.
PNTR_SAVE_IMAGE_TO_MEMORY
.image | The image to save to memory. |
type | The type of the image. Use PNTR_IMAGE_TYPE_UNKNOWN if unknown. PNTR_IMAGE_TYPE_PNG, PNTR_IMAGE_TYPE_JPG, etc. |
dataSize | Where to put the resulting size of the image. Use NULL if you do not care about getting the file size. |
PNTR_API void * pntr_set_error | ( | pntr_error | error | ) |
Sets an error.
error | A string representing the error that had just occured. |
PNTR_API void pntr_set_pixel_color | ( | void * | dstPtr, |
pntr_pixelformat | dstPixelFormat, | ||
pntr_color | color | ||
) |
Set the pixel color of the given pixel color pointer.
dstPtr | A pointer to the pixel in memory. |
dstPixelFormat | The desired destination pixel format. |
color | The color to apply. |
|
inline |
Unloads the given file data.
fileData | The data of the file to unload from memory. |
|
inline |
Unload the file text data from memory.
text | The text to unload. |
Unloads the given font from memory.
font | The font to unload from memory. |
PNTR_API void pntr_unload_image | ( | pntr_image * | image | ) |
Unloads the given image from memory.
image | The image to unload from memory. |