pntr
Image manipulation library
pntr

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_imagepntr_new_image (int width, int height)
 
PNTR_API pntr_imagepntr_gen_image_color (int width, int height, pntr_color color)
 
PNTR_API pntr_imagepntr_image_copy (pntr_image *image)
 
PNTR_API pntr_imagepntr_image_from_image (pntr_image *image, int x, int y, int width, int height)
 
PNTR_API pntr_imagepntr_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_imagepntr_load_image (const char *fileName)
 
PNTR_API pntr_imagepntr_load_image_from_memory (pntr_image_type type, const unsigned char *fileData, unsigned int dataSize)
 
PNTR_API pntr_imagepntr_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_imagepntr_image_resize (pntr_image *image, int newWidth, int newHeight, pntr_filter filter)
 
PNTR_API pntr_imagepntr_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_fontpntr_load_font_default (void)
 
PNTR_API void pntr_unload_font (pntr_font *font)
 
PNTR_API pntr_fontpntr_font_copy (pntr_font *font)
 
PNTR_API pntr_fontpntr_font_scale (pntr_font *font, float scaleX, float scaleY, pntr_filter filter)
 
PNTR_API pntr_fontpntr_load_font_bmf (const char *fileName, const char *characters)
 
PNTR_API pntr_fontpntr_load_font_bmf_from_image (pntr_image *image, const char *characters)
 
PNTR_API pntr_fontpntr_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_imagepntr_gen_image_text (pntr_font *font, const char *text, pntr_color tint)
 
PNTR_API pntr_fontpntr_load_font_tty (const char *fileName, int glyphWidth, int glyphHeight, const char *characters)
 
PNTR_API pntr_fontpntr_load_font_tty_from_memory (const unsigned char *fileData, unsigned int dataSize, int glyphWidth, int glyphHeight, const char *characters)
 
PNTR_API pntr_fontpntr_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_fontpntr_load_font_ttf (const char *fileName, int fontSize)
 
PNTR_API pntr_fontpntr_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_imagepntr_image_rotate (pntr_image *image, float degrees, pntr_filter filter)
 
PNTR_API pntr_imagepntr_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)
 

Detailed Description

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_IMPLEMENTATION
#include "pntr.h"
int main() {
pntr_image* image = pntr_new_image(200, 200);
pntr_draw_circle_fill(image, 100, 100, 80, PNTR_RED);
pntr_save_image(image, "output.png");
return 0;
}
#define PNTR_RED
Definition: pntr.h:788
PNTR_API void pntr_unload_image(pntr_image *image)
Definition: pntr.h:1744
PNTR_API pntr_image * pntr_new_image(int width, int height)
Definition: pntr.h:1516
PNTR_API bool pntr_save_image(pntr_image *image, const char *fileName)
Definition: pntr.h:4426
PNTR_API void pntr_draw_circle_fill(pntr_image *dst, int centerX, int centerY, int radius, pntr_color color)
Definition: pntr.h:2289
Definition: pntr.h:404
See also
PNTR_IMPLEMENTATION

Macro Definition Documentation

◆ PNTR_API

#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

◆ PNTR_PIXEL

#define PNTR_PIXEL (   image,
  x,
 
)    image->data[(y) * (image->pitch >> 2) + (x)]

Retrieve the pixel at the given x,y coordinate of the image.

Parameters
imageThe image to check against.
xThe x coordinate.
yThe y coordinate.
Returns
The pixel color at the given coordinate.

◆ PNTR_PIXELFORMAT

#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.

See also
PNTR_PIXELFORMAT_RGBA8888
PNTR_PIXELFORMAT_ARGB8888

Typedef Documentation

◆ pntr_color

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.

See also
pntr_new_color()
pntr_get_color()
PNTR_PIXELFORMAT_RGBA
PNTR_PIXELFORMAT_ARGB

◆ pntr_error

typedef enum pntr_error pntr_error

Error states definitions.

See also
pntr_set_error()
pntr_get_error()

◆ pntr_filter

typedef enum pntr_filter pntr_filter

Possible image filters to apply.

◆ pntr_font

typedef struct pntr_font pntr_font

Font used to render text.

If PNTR_ENABLE_UTF8 is enabled, will allow loading fonts with UTF-8 support.

See also
pntr_load_font_tty()
pntr_load_font_ttf()
pntr_load_font_bmf()
PNTR_ENABLE_UTF8

◆ pntr_image

typedef struct pntr_image pntr_image

An image, represented by pixel data.

See also
pntr_new_image()
pntr_gen_image_color()

◆ pntr_image_type

The associated image format.

◆ pntr_pixelformat

Pixel format.

◆ pntr_rectangle

A rectangle.

◆ pntr_vector

typedef struct pntr_vector pntr_vector

A vector, represented by x and y coordinates.

Enumeration Type Documentation

◆ pntr_error

enum pntr_error

Error states definitions.

See also
pntr_set_error()
pntr_get_error()
Enumerator
PNTR_ERROR_NONE 

No error

PNTR_ERROR_INVALID_ARGS 

Invalid arguments

PNTR_ERROR_NO_MEMORY 

Not enough memory

PNTR_ERROR_NOT_SUPPORTED 

Not supported

PNTR_ERROR_FAILED_TO_OPEN 

Failed to open

PNTR_ERROR_FAILED_TO_WRITE 

Failed to write

PNTR_ERROR_UNKNOWN 

Unknown error occurred

◆ pntr_filter

Possible image filters to apply.

Enumerator
PNTR_FILTER_NEARESTNEIGHBOR 

Nearest-neighbor interpolation for fast processing.

This is good for scaling up pixel art when you want to keep the pixel art look.

PNTR_FILTER_BILINEAR 

Bilinear interpolation will combine multiple pixels together when processing for smoother scaling.

See also
pntr_color_bilinear_interpolate()

◆ pntr_image_type

The associated image format.

Enumerator
PNTR_IMAGE_TYPE_UNKNOWN 

Image type: Unknown.

PNTR_IMAGE_TYPE_PNG 

Image type: PNG.

PNTR_IMAGE_TYPE_JPG 

Image type: JPEG.

PNTR_IMAGE_TYPE_BMP 

Image type: BMP.

◆ pntr_pixelformat

Pixel format.

Enumerator
PNTR_PIXELFORMAT_RGBA8888 

RGBA, with 8 bytes for each component.

PNTR_PIXELFORMAT_ARGB8888 

ARGB, with 8 bytes for each component.

PNTR_PIXELFORMAT_GRAYSCALE 

Grayscale, with one byte for each pixel, 0 - 255. 0 being disabled, 255 being enabled.

Function Documentation

◆ pntr_blend_color()

PNTR_API void pntr_blend_color ( pntr_color dst,
pntr_color  src 
)
inline

Alpha blend the source color into the destination color.

Parameters
dstThe destination color.
srcThe source color.
See also
PNTR_NO_ALPHABLEND
pntr_color_alpha_blend()

◆ pntr_clear_background()

PNTR_API void pntr_clear_background ( pntr_image image,
pntr_color  color 
)

Clears an image with the given color.

Clearing the background ignores clipping.

Parameters
imageThe image to clear.
colorThe color to fill the image with.

◆ pntr_color_alpha_blend()

PNTR_API pntr_color pntr_color_alpha_blend ( pntr_color  dst,
pntr_color  src 
)
inline

Get source alpha-blended into destination color.

Parameters
dstThe destination color.
srcThe source color.
Returns
The new alpha-blended color.
See also
PNTR_NO_ALPHABLEND

◆ pntr_color_bilinear_interpolate()

PNTR_API pntr_color pntr_color_bilinear_interpolate ( pntr_color  color00,
pntr_color  color01,
pntr_color  color10,
pntr_color  color11,
float  coordinateX,
float  coordinateY 
)
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
Parameters
color00The top left color.
color01The bottom left color.
color10The top right color.
color11The bottom right color.
coordinateXA 0.0f to 1.0f fraction between color00 and color 10.
coordinateYA 0.0f to 1.0f fraction between color00 and color 01.
Returns
The bilinear interpolated color.

◆ pntr_color_brightness()

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.

Parameters
colorThe color to change the brightness of.
factorThe factor in which to change the brightness from -1.0f to 1.0f.
See also
pntr_image_color_brightness()

◆ pntr_color_contrast()

PNTR_API pntr_color pntr_color_contrast ( pntr_color  color,
float  contrast 
)

Apply contrast to the given color.

Parameters
colorThe color to apply constrast to.
contrastThe amount of constrast to apply, from -1.0f to 1.0f.
Returns
The new color with the contrast applied.

◆ pntr_color_fade()

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.

Parameters
colorThe color that you would like to fade.
factorThe factor of which to fade the color, from -1.0f to 1.0f.
Returns
The faded new color.
See also
pntr_image_color_fade()

◆ pntr_color_invert()

PNTR_API pntr_color pntr_color_invert ( pntr_color  color)
inline

Inverts the given color.

Parameters
colorThe color to invert.
Returns
The new inverted color.
See also
pntr_image_color_invert()

◆ pntr_color_tint()

PNTR_API pntr_color pntr_color_tint ( pntr_color  color,
pntr_color  tint 
)
inline

Tints the given color by another color.

Parameters
colorThe source color to apply the tint to.
tintThe tint color.
Returns
The newly tinted color.
See also
pntr_image_color_tint()

◆ pntr_draw_circle()

PNTR_API void pntr_draw_circle ( pntr_image dst,
int  centerX,
int  centerY,
int  radius,
pntr_color  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.

Parameters
dstThe image to draw the circle onto.
centerXThe center of the circle at the X coordinate.
centerXThe center of the circle at the Y coordinate.
radiusThe radius of the circle.
colorThe desired color of the circle.
See also
pntr_draw_circle_fill()

◆ pntr_draw_circle_fill()

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.

Parameters
dstThe image to draw the filled circle onto.
centerXThe center of the circle at the X coordinate.
centerXThe center of the circle at the Y coordinate.
radiusThe radius of the circle.
colorThe desired fill color of the circle.
See also
pntr_draw_circle()

◆ pntr_draw_ellipse()

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.

Parameters
dstThe image to draw the filled circle onto.
centerXThe center of the circle at the X coordinate.
centerXThe center of the circle at the Y coordinate.
radiusXThe horizontal radius of the circle.
radiusYThe vertical radius of the circle.
colorThe desired color of the circle.
See also
pntr_draw_ellipse_fill()

◆ pntr_draw_ellipse_fill()

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

Parameters
dstThe image to draw the filled circle onto.
centerXThe center of the circle at the X coordinate.
centerXThe center of the circle at the Y coordinate.
radiusXThe horizontal radius of the circle.
radiusYThe vertical radius of the circle.
colorThe desired fill color of the circle.
See also
pntr_draw_circle_fill()

◆ pntr_draw_image()

PNTR_API void pntr_draw_image ( pntr_image dst,
pntr_image src,
int  posX,
int  posY 
)
inline

Draw an image onto the destination image.

◆ pntr_draw_image_rec()

PNTR_API void pntr_draw_image_rec ( pntr_image dst,
pntr_image src,
pntr_rectangle  srcRect,
int  posX,
int  posY 
)
inline

Draw a source image within a destination image.

Parameters
dstThe destination image.
srcThe source image.
srcRectThe source rectangle of what to draw from the source image.
posXWhere to draw the image on the x coordinate.
posYWhere to draw the image on the y coordinate.
See also
pntr_draw_image()

◆ pntr_draw_image_rotated()

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 
)
inline

Draw a rotated image onto another image.

Parameters
dstPointer to the destination image where the output will be stored.
srcPointer to the source image that will be drawn onto the destination image.
posXWhere to draw the rotated image, at the X coordinate.
posYWhere to draw the rotated image, at the Y coordinate.
degreesThe degrees of rotation.
offsetXOffset in the X direction after rotation.
offsetYOffset in the Y direction after rotation.
filterFilter to be applied during the rotation. PNTR_FILTER_BILINEAR and PNTR_FILTER_NEARESTNEIGHBOR are supported.
See also
pntr_draw_image_rec_rotated()
pntr_image_rotate()

◆ pntr_draw_image_rotated_rec()

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.

Parameters
dstPointer to the destination image where the output will be stored.
srcPointer to the source image that will be drawn onto the destination image.
srcRectThe portion of the source image to draw.
posXWhere to draw the rotated image, at the X coordinate.
posYWhere to draw the rotated image, at the Y coordinate.
degreesThe degrees of rotation.
offsetXOffset in the X direction after rotation.
offsetYOffset in the Y direction after rotation.
filterFilter to be applied during the rotation. PNTR_FILTER_BILINEAR and PNTR_FILTER_NEARESTNEIGHBOR are supported.
See also
pntr_draw_image_rotated()

◆ pntr_draw_image_scaled()

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 
)
inline

Draw a scaled image.

Parameters
dstPointer to the destination image where the output will be stored.
srcPointer to the source image that will be drawn onto the destination image.
posXWhere to draw the scaled image, at the X coordinate.
posYWhere to draw the scaled image, at the Y coordinate.
scaleXThe scale of which to apply to the width of the image.
scaleYThe scale of which to apply to the height of the image.
offsetXHow much to offset the X drawing of the image, relative from its original source size.
offsetXHow much to offset the Y drawing of the image, relative from its original source size.
filterFilter to be applied during the rotation.

◆ pntr_draw_image_tint()

PNTR_API void pntr_draw_image_tint ( pntr_image dst,
pntr_image src,
int  posX,
int  posY,
pntr_color  tint 
)
inline

Draw an image onto the destination image, with tint.

◆ pntr_draw_image_tint_rec()

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.

Parameters
dstThe destination image.
srcThe source image.
srcRectThe source rectangle of what to draw from the source image.
posXWhere to draw the image on the x coordinate.
posYWhere to draw the image on the y coordinate.
tintThe color to tint the image when drawing.
See also
pntr_draw_image()

◆ pntr_draw_line()

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.

See also
pntr_draw_line_horizontal()
pntr_draw_line_vertical()

◆ pntr_draw_line_horizontal()

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.

Parameters
dstThe destination image.
posXThe X position.
posYThe Y position.
widthHow long the line should be.
colorThe color of the line.

TODO: pntr_draw_line_horizontal: Support negative width.

◆ pntr_draw_line_vertical()

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.

Parameters
dstThe destination image.
posXThe X position.
posYThe Y position.
heightHow tall the line should be.
colorThe color of the line.

TODO: pntr_draw_line_vertical: Support negative height.

◆ pntr_draw_point()

PNTR_API void pntr_draw_point ( pntr_image dst,
int  x,
int  y,
pntr_color  color 
)

Draws a pixel on the given image.

◆ pntr_draw_point_unsafe()

PNTR_API void pntr_draw_point_unsafe ( pntr_image dst,
int  x,
int  y,
pntr_color  color 
)
inline

Draws a point on the given image, without safety checks.

◆ pntr_draw_rectangle()

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.

Parameters
dstThe destination image.
posXThe X position.
posYThe Y position.
widthHow wide the rectangle should be.
heightHow tall the rectangle should be.
colorThe color of the line.
See also
pntr_draw_rectangle_rec()
pntr_draw_rectangle_fill()

◆ pntr_draw_rectangle_fill()

PNTR_API void pntr_draw_rectangle_fill ( pntr_image dst,
int  posX,
int  posY,
int  width,
int  height,
pntr_color  color 
)
inline

Draws a filled rectangle on the given image.

Parameters
dstThe destination image.
posXThe X position.
posYThe Y position.
widthHow wide the rectangle should be.
heightHow tall the rectangle should be.
colorThe color of the rectangle.
See also
pntr_draw_rectangle()

◆ pntr_draw_rectangle_fill_rec()

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.

Parameters
dstThe destination image.
rectThe rectangle of which to draw.
colorThe color of the rectangle.
See also
pntr_draw_rectangle_fill()

◆ pntr_draw_rectangle_rec()

PNTR_API void pntr_draw_rectangle_rec ( pntr_image dst,
pntr_rectangle  rec,
pntr_color  color 
)
inline

Draws a rectangle using a rectangle.

Parameters
dstWhere to draw the rectangle.
recThe rectangle of which to draw.
colorThe color of the lines for the rectangle.

◆ pntr_draw_text()

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.

Parameters
dstThe image of which to print the text on.
fontThe font to use when rendering the text.
textThe text to write. Must be NULL terminated.
posXThe position to print the text, starting from the top left on the X axis.
posYThe position to print the text, starting from the top left on the Y axis.
tintWhat color to tint the font when drawing. Use PNTR_WHITE if you don't want to change the source color.
See also
pntr_draw_text_wrapped()

◆ pntr_draw_text_wrapped()

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.

Parameters
dstThe image of which to print the text on.
fontThe font to use when rendering the text.
textThe text to write. Must be NULL terminated.
posXThe position to print the text, starting from the top left on the X axis.
posYThe position to print the text, starting from the top left on the Y axis.
maxWidthThe maximum width for each line.
tintWhat color to tint the font when drawing. Use PNTR_WHITE if you don't want to change the source color.
See also
pntr_draw_text()

◆ pntr_draw_triangle()

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.

Parameters
dstThe image of which to draw the triangle.
x1The x coordinate of the first point.
y1The y coordinate of the first point.
x2The x coordinate of the second point.
y2The y coordinate of the second point.
x3The x coordinate of the third point.
y3The y coordinate of the third point.
colorThe line color for the triangle.

◆ pntr_draw_triangle_fill()

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 
)
inline

Draw a filled triangle on an image.

Parameters
dstThe image of which to draw the triangle.
x1The x coordinate of the first point.
y1The y coordinate of the first point.
x2The x coordinate of the second point.
y2The y coordinate of the second point.
x3The x coordinate of the third point.
y3The y coordinate of the third point.
colorThe fill color of the triangle.

◆ pntr_draw_triangle_fill_vec()

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.

Parameters
dstWhere to draw the triangle.
point1The first point in the triangle.
point2The second point in the triangle.
point3The third point in the triangle.
colorWhat color to draw the triangle.

◆ pntr_draw_triangle_vec()

PNTR_API void pntr_draw_triangle_vec ( pntr_image dst,
pntr_vector  point1,
pntr_vector  point2,
pntr_vector  point3,
pntr_color  color 
)
inline

Draw a triangle using vectors.

Parameters
dstWhere to draw the triangle.
point1The first point in the triangle.
point2The second point in the triangle.
point3The third point in the triangle.
colorWhat color to draw the triangle.

◆ pntr_font_copy()

PNTR_API pntr_font * pntr_font_copy ( pntr_font font)

Creates a copy of the given font.

Parameters
fontThe font to copy.
Returns
A new font that is a copy of the given font.

◆ pntr_font_scale()

PNTR_API pntr_font * pntr_font_scale ( pntr_font font,
float  scaleX,
float  scaleY,
pntr_filter  filter 
)

Resize a font by a given scales.

Parameters
fontThe font that you would like to scale.
scaleXThe scale of which to resize the width of the font by.
scaleYThe scale of which to resize the height of the font by.
filterThe filter to apply when resizing the font. PNTR_FILTER_NEARESTNEIGHBOR is good for pixel fonts.
Returns
The new font that has been resized.

◆ pntr_gen_image_color()

PNTR_API pntr_image * pntr_gen_image_color ( int  width,
int  height,
pntr_color  color 
)

Generate a new image with the given color.

Parameters
widthThe width of the new image.
heightThe height of the given image.
colorThe desired color that will fill the new image.
Returns
A pointer to the new image in memory.

◆ pntr_gen_image_gradient()

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.

Parameters
widthThe width of the new image.
heightThe height of the new image.
topLeftThe color at the top left of the image.
topRightThe color at the top right of the image.
bottomLeftThe color at the bottom left of the image.
bottomRightThe color at the bottom right of the image.
Returns
A pointer to the new image.

◆ pntr_gen_image_text()

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.

Parameters
fontThe font to use when rendering the text.
textThe text to render.
tintThe color to tint the text by. Use PNTR_WHITE if you don't want to change the color.
Returns
A new image with text on it, using the given font.

◆ pntr_get_color()

PNTR_API pntr_color pntr_get_color ( unsigned int  hexValue)
inline

Get a pntr_color from a RGBA hexadecimal value

Parameters
hexValueThe RGBA hexadecimal value representing the color. For example: 0x052c46ff.
Returns
The color representing the given hex value.

◆ pntr_get_file_image_type()

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.

Parameters
filePathThe file path to the image.
Returns
The type of the image, based on its file extension, or PNTR_IMAGE_TYPE_UNKNOWN if it's unknown.
See also
PNTR_IMAGE_TYPE_UNKNOWN
PNTR_IMAGE_TYPE_PNG
PNTR_IMAGE_TYPE_BMP
PNTR_IMAGE_TYPE_JPG

◆ pntr_get_pixel_color()

PNTR_API pntr_color pntr_get_pixel_color ( void *  srcPtr,
pntr_pixelformat  srcPixelFormat 
)

Gets the pixel color of the given pointer.

Parameters
srcPtrA pointer to the given source data.
srcPixelFormatThe pixel format of the given source color.
Returns
The color of the pixel in memory.

◆ pntr_get_pixel_data_size()

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.

Parameters
widthThe width of the image data.
heightThe height of the image data.
pixelFormatThe pixel format of the image data.
Returns
The size of the image data, in bytes.

◆ pntr_image_alpha_border()

PNTR_API pntr_rectangle pntr_image_alpha_border ( pntr_image image,
float  threshold 
)

Calculates a rectangle representing the available alpha border.

Parameters
imageThe image to calculate the alpha border on.
thresholdA threshold factor from 0.0f to 1.0f to consider alpha.
Returns
The rectangle representing the alpha border of the image.

◆ pntr_image_alpha_crop()

PNTR_API void pntr_image_alpha_crop ( pntr_image image,
float  threshold 
)

Crop an image based on the alpha border.

Parameters
imageThe image to crop.
thresholdThe alpha threshold to crop by, from 0.0f to 1.0f.
See also
pntr_image_alpha_border()
pntr_image_crop()

◆ pntr_image_alpha_mask()

PNTR_API void pntr_image_alpha_mask ( pntr_image image,
pntr_image alphaMask,
int  posX,
int  posY 
)

Apply an alpha mask to an image.

Parameters
imageThe image to apply the alpha mask to.
alphaMaskAn image that has the alphaMask data.
posXWhere to position the alpha mask on the image.
posYWhere to position the alpha mask on the image.

◆ pntr_image_color_brightness()

PNTR_API void pntr_image_color_brightness ( pntr_image image,
float  factor 
)

Changes the brightness of the given image by a factor.

Parameters
imageThe image to change brightness of.
factorThe factor in which to affect the brightness from -1.0f to 1.0f.
See also
pntr_color_brightness()

◆ pntr_image_color_contrast()

PNTR_API void pntr_image_color_contrast ( pntr_image image,
float  contrast 
)

Apply contrast to the given image.

Parameters
imageThe image you would like to apply contrast to.
contrastThe factor of contrast to apply, from -1.0f to 1.0f.
See also
pntr_color_contrast()

◆ pntr_image_color_fade()

PNTR_API void pntr_image_color_fade ( pntr_image image,
float  factor 
)

Fade an image by the given factor.

Parameters
imageThe image to fade.
factorThe factor of which to fade the image, from -1.0f to 1.0f.
See also
pntr_color_fade()

◆ pntr_image_color_invert()

PNTR_API void pntr_image_color_invert ( pntr_image image)

Inverts the given image.

Parameters
imageThe image to invert.
See also
pntr_color_invert()

◆ pntr_image_color_replace()

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.

Parameters
imageThe image to process.
colorThe color to search for.
replaceThe color that will replace the original color.

◆ pntr_image_color_tint()

PNTR_API void pntr_image_color_tint ( pntr_image image,
pntr_color  tint 
)

Tints the given image by the provided color.

Parameters
imageThe image to tint.
tintThe color of which to tint the image by.
See also
pntr_color_tint()

◆ pntr_image_copy()

PNTR_API pntr_image * pntr_image_copy ( pntr_image image)

Create an image duplicate.

Parameters
imageThe image that you want to copy.
Returns
A pointer to the new image that is a copy of the original image.

◆ pntr_image_crop()

PNTR_API bool pntr_image_crop ( pntr_image image,
int  x,
int  y,
int  width,
int  height 
)

Crops an image by the given coordinates.

Parameters
imageThe image to crop.
xThe x coordinate to crop from.
yThe y coordinate to crop from.
widthThe width of the desired crop.
heightThe height of the desired crop.
See also
pntr_image_from_image()

◆ pntr_image_flip()

PNTR_API void pntr_image_flip ( pntr_image image,
bool  horizontal,
bool  vertical 
)

Flip an image, vertically, or horizontally, or both.

Parameters
imageThe image to flip.
horizontalWhether or not to flip the image horizontally.
verticalWhether or not to flip the image vertically.
See also
pntr_image_flip()

◆ pntr_image_from_image()

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().

Parameters
imageThe original image to build the new image from.
xThe x coordinate to build the new image from.
yThe y coordinate to build the new image from.
widthThe width of the new image.
heightThe height of the new image.
Returns
A new image that is based off of the section of the original image.
See also
pntr_image_subimage()
pntr_unload_image()

◆ pntr_image_from_pixelformat()

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.

Parameters
imageDataThe data of the image in memory.
widthThe width of the image.
heightThe height of the image.
pixelFormatThe pixel format of the image in memory.
Returns
A new image built from the given image data.

◆ pntr_image_get_clip()

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.

Parameters
imageThe image of which to get the clip rectangle for.
Returns
The clip rectangle associated with the given image.

◆ pntr_image_get_color()

PNTR_API pntr_color pntr_image_get_color ( pntr_image image,
int  x,
int  y 
)

Get image pixel color at (x, y) position.

Parameters
imageThe image to get the color from.
xThe x position of the pixel.
yThe y position of the pixel.
Returns
The color at (x, y) position from the image.

◆ pntr_image_reset_clip()

PNTR_API void pntr_image_reset_clip ( pntr_image image)

Reset the clipping rectangle for the given image.

Parameters
imageThe image to reset the clipping image for.
See also
pntr_image_set_clip()

◆ pntr_image_resize()

PNTR_API pntr_image * pntr_image_resize ( pntr_image image,
int  newWidth,
int  newHeight,
pntr_filter  filter 
)

Resize an image.

Parameters
imageThe image to resize.
newWidthThe desired width of the new image.
newHeightTHe desired height of the new image.
filterWhich filter to apply when resizing.
Returns
The newly resized image.
See also
pntr_image_scale()

◆ pntr_image_resize_canvas()

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.

Parameters
imageThe image you would like to resize.
newWidthThe desired width of the new canvas.
newHeightThe desired height of the new canvas.
offsetXHow to offset the image once its canvas is resized. Use 0 if you like to keep the original image on the left.
offsetYHow to offset the image once its canvas is resized. Use 0 if you like to keep the original image at the top.
fillThe color to use for the background of the new image.
Returns
True or false depending on if the image was resized correctly.

◆ pntr_image_rotate()

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.

Parameters
imageThe image to rotate.
degreesThe desired amount to rotate the image in degrees.
Returns
The new rotated image.
See also
pntr_draw_image_rotated()
pntr_draw_image_rotated_rec()

◆ pntr_image_scale()

PNTR_API pntr_image * pntr_image_scale ( pntr_image image,
float  scaleX,
float  scaleY,
pntr_filter  filter 
)

Scales an image either up or down.

Parameters
imageThe image to scale up or down.
scaleXThe scale of which to apply to the width of the image.
scaleYThe scale of which to apply to the height of the image.
filterThe filter to apply when resizing.
Returns
The newly scaled image.
See also
pntr_image_resize()

◆ pntr_image_set_clip()

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.

Parameters
imageThe image to set the clipping rectangle.
xThe X coordinate for the clipping rectangle.
yThe Y coordinate for the clipping rectangle.
widthThe width of the desired clipping rectangle.
heightThe height of the desired clipping rectangle.
See also
pntr_image_set_clip_rec()
pntr_image_reset_clip()

◆ pntr_image_set_clip_rec()

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.

Parameters
imageThe image to set the clipping rectangle.
clipThe rectangle to set the new clip boundries.
See also
pntr_image_set_clip()
pntr_image_reset_clip()

◆ pntr_image_subimage()

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().

Parameters
imageThe original image to reference for the new portion of the image.
xThe X coorindate of the subimage.
yThe Y coordinate of the subimage.
widthThe width of the subimage.
heightThe height of the subimage.
Returns
The pntr_image referencing the section of the given image.
See also
pntr_image_from_image()
pntr_unload_image()

◆ pntr_image_to_pixelformat()

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.

Parameters
imageThe image to convert.
dataSizeWhere to put the resulting size of the image data. Use NULL if you have no need for the resulting data size.
pixelFormatThe desired pixel format of the resulting image.
Returns
A pointer to the resulting image data in memory.

◆ pntr_load_file()

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.

Parameters
fileNameThe name of the file to load.
bytesReadWhere to stick the amount of bytes that were read. Use NULL if you don't need the file size.
Returns
A pointer to the file data in memory.
See also
pntr_unload_file()
PNTR_LOAD_FILE

◆ pntr_load_file_text()

PNTR_API const char * pntr_load_file_text ( const char *  fileName)

Load text from a file. Must be cleared with pntr_unload_file().

Parameters
fileNameThe file to load.
See also
pntr_load_file()
pntr_unload_file_text()

◆ pntr_load_font_bmf()

PNTR_API pntr_font * pntr_load_font_bmf ( const char *  fileName,
const char *  characters 
)

Load a BMFont from the file system.

Parameters
fileNameThe name of the image file to load as the bmfont.
charactersA string representing the characters to load from the atlas.
Returns
The newly loaded font.
See also
examples/resources/bmfont.png

◆ pntr_load_font_default()

PNTR_API pntr_font * pntr_load_font_default ( void  )

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()

#define PNTR_DEFAULT_FONT load_my_font
Returns
The default font, which must be unloaded when finished using.
See also
pntr_unload_font()
PNTR_ENABLE_DEFAULT_FONT
PNTR_DEFAULT_FONT

◆ pntr_load_font_ttf()

PNTR_API pntr_font * pntr_load_font_ttf ( const char *  fileName,
int  fontSize 
)

Loads a truetype font from the file system.

This needs to be compiled with PNTR_ENABLE_TTF to be supported.

Parameters
fileNameThe name of the .ttf file.
fontSizeThe size of the font, in pixels.
Returns
The newly loaded truetype font.
See also
examples/resources/tuffy.ttf
PNTR_ENABLE_TTF

◆ pntr_load_font_ttf_from_memory()

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.

Parameters
fileDataThe data of the TTF file.
dataSizeThe size of the data in memory.
fontSizeThe desired size of the font, in pixels.
Returns
The newly loaded truetype font.
See also
examples/resources/tuffy.ttf
PNTR_ENABLE_TTF

◆ pntr_load_font_tty()

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.

Parameters
fileNameThe name of the image file to load as the font.
glyphWidthThe width of each character on the font atlas.
glyphHeightThe height of each character on the font atlas.
charactersA string of characters that appear in the image.
Returns
The newly loaded TTY font.
See also
examples/resources/ttyfont-16x16.png

◆ pntr_load_image()

PNTR_API pntr_image * pntr_load_image ( const char *  fileName)

Load an image from file.

Parameters
fileNameThe name of the file to load from the file system.
Returns
The newly loaded file.

◆ pntr_load_image_from_memory()

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.

Note
This can be overloaded by defining PNTR_LOAD_IMAGE_FROM_MEMORY .
Parameters
typeThe type of image to load.
fileDataThe data of the file to be loaded.
dataSizeThe size of the file data.
Returns
A newly loaded image, or NULL on failure.
See also
PNTR_LOAD_IMAGE_FROM_MEMORY

◆ pntr_load_memory()

PNTR_API void * pntr_load_memory ( size_t  size)
inline

Allocates the given amount of bytes in size.

Parameters
sizeThe amount of bytes to allocate to memory.
Returns
A pointer to the new memory address.
See also
PNTR_MALLOC

◆ pntr_measure_text()

PNTR_API int pntr_measure_text ( pntr_font font,
const char *  text 
)
inline

Measures the horizontal length of the text when rendered with the given font.

Parameters
fontThe font to use when rendering the text.
textThe text to measure the length of.
Returns
The amount of pixels the text is when rendered with the font.

◆ pntr_measure_text_ex()

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.

Parameters
fontThe font to use when rendering the text.
textThe 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.
Returns
A vector containing the width and height of the text when rendered by the font.

◆ pntr_memory_copy()

PNTR_API void * pntr_memory_copy ( void *  destination,
void *  source,
size_t  size 
)
inline

Copy a memory address from the source to the destination.

Parameters
destinationWhere to copy the memory to.
sourceThe source data.
sizeThe size of the data to copy.
Returns
The destination.
See also
PNTR_MEMCPY

◆ pntr_new_color()

PNTR_API pntr_color pntr_new_color ( unsigned char  red,
unsigned char  green,
unsigned char  blue,
unsigned char  alpha 
)
inline

Creates a new color, provided the given red, green, blue, and alpha colors.

Parameters
redThe red channel.
greenThe green channel.
blueThe blue channel.
alphaThe alpha channel.
Returns
The color with the given red, green, blue, and alpha components.

◆ pntr_new_image()

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.

Parameters
widthThe width of the new image.
heightThe height of the new image.
Returns
The new image that is the size of the given width/height.
See also
pntr_gen_image_color()

◆ pntr_put_horizontal_line_unsafe()

PNTR_API void pntr_put_horizontal_line_unsafe ( pntr_image dst,
int  posX,
int  posY,
int  width,
pntr_color  color 
)
inline

Draws a line on the destination image.

◆ pntr_save_file()

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.

Parameters
fileNameThe name of the file to save.
dataA pointer to the memory data in memory.
bytesToWriteThe size of the data in memory.
Returns
True if the file saved properly, false otherwise.
See also
PNTR_SAVE_FILE

◆ pntr_save_image()

PNTR_API bool pntr_save_image ( pntr_image image,
const char *  fileName 
)

Saves an image to the file system.

Parameters
imageThe image to save to the file system.
fileNameThe name of the file to save.
Returns
True when the file was saved successfully, false otherwise.
See also
pntr_save_image_to_memory()
pntr_save_file()

◆ pntr_save_image_to_memory()

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.

Note
This method can be overloaded by defining PNTR_SAVE_IMAGE_TO_MEMORY .
Parameters
imageThe image to save to memory.
typeThe type of the image. Use PNTR_IMAGE_TYPE_UNKNOWN if unknown. PNTR_IMAGE_TYPE_PNG, PNTR_IMAGE_TYPE_JPG, etc.
dataSizeWhere to put the resulting size of the image. Use NULL if you do not care about getting the file size.
Returns
The image data in memory. This data must be freed when finished using. NULL on failure.
See also
PNTR_SAVE_IMAGE_TO_MEMORY
PNTR_IMAGE_TYPE_PNG
PNTR_IMAGE_TYPE_JPG
PNTR_IMAGE_TYPE_UNKNOWN

◆ pntr_set_error()

PNTR_API void * pntr_set_error ( pntr_error  error)

Sets an error.

Parameters
errorA string representing the error that had just occured.
Returns
Always returns NULL.

◆ pntr_set_pixel_color()

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.

Parameters
dstPtrA pointer to the pixel in memory.
dstPixelFormatThe desired destination pixel format.
colorThe color to apply.

◆ pntr_unload_file()

PNTR_API void pntr_unload_file ( unsigned char *  fileData)
inline

Unloads the given file data.

Parameters
fileDataThe data of the file to unload from memory.
See also
pntr_load_file()

◆ pntr_unload_file_text()

PNTR_API void pntr_unload_file_text ( const char *  text)
inline

Unload the file text data from memory.

Parameters
textThe text to unload.
See also
pntr_load_file_text()

◆ pntr_unload_font()

PNTR_API void pntr_unload_font ( pntr_font font)

Unloads the given font from memory.

Parameters
fontThe font to unload from memory.

◆ pntr_unload_image()

PNTR_API void pntr_unload_image ( pntr_image image)

Unloads the given image from memory.

Parameters
imageThe image to unload from memory.

◆ pntr_unload_memory()

PNTR_API void pntr_unload_memory ( void *  pointer)

Unloads the given memory.

Parameters
pointerA pointer to the memory of which to unload.
See also
PNTR_FREE