Skip to content

API‐Drawing

ZangoTech edited this page Jun 20, 2026 · 1 revision

Drawing

← Back to API Reference · Home

Namespace: acl::draw

Draw lines / rectangles / circles / text on an image. All entry points are non-templated, uint8_t only, supporting 1ch / 3ch / 4ch.

Tier: Starter+
Channels: 1 / 3 / 4
Inplace: drawn directly on the source image (img is both input and output)


drawLine

Draw a line segment using the Bresenham algorithm. Tier: Starter+
Channels: 1ch / 3ch / 4ch
Inplace: supported (writes onto the provided image buffer)
Types:

Template parameter Allowed types Constraint
T uint8_t
int drawLine(
    uint8_t* img,
    int width, int height, int cn, int stride,
    int x0, int y0, int x1, int y1,
    const uint8_t* color,
    int thickness = 1);
Parameter Type Meaning Default
img uint8_t* Destination image (drawn in place) non-null
width, height int Image size > 0
cn int Channel count 1 / 3 / 4
stride int Bytes per row 0 = width * cn
x0, y0, x1, y1 int Line segment start / end points
color const uint8_t* Color-value array of length cn non-null
thickness int Line width (pixels) 1

drawRect

Draw a rectangle (outline or filled). Tier: Starter+
Channels: 1ch / 3ch / 4ch
Inplace: supported (writes onto the provided image buffer)
Types:

Template parameter Allowed types Constraint
T uint8_t
int drawRect(
    uint8_t* img,
    int imgW, int imgH, int cn, int stride,
    int x, int y, int w, int h,
    const uint8_t* color,
    int thickness = 1);
Parameter Type Meaning Default
x, y int Rectangle top-left
w, h int Rectangle width / height
thickness int Line width; -1 = filled rectangle 1

Other parameters are the same as drawLine.


drawCircle

Draw a circle using the midpoint circle algorithm (outline or filled). Tier: Starter+
Channels: 1ch / 3ch / 4ch
Inplace: supported (writes onto the provided image buffer)
Types:

Template parameter Allowed types Constraint
T uint8_t
int drawCircle(
    uint8_t* img,
    int width, int height, int cn, int stride,
    int cx, int cy, int radius,
    const uint8_t* color,
    int thickness = 1);
Parameter Type Meaning Default
cx, cy int Circle center
radius int Radius ≥ 0
thickness int Line width; -1 = filled circle 1

putText

Render ASCII text using the built-in 8×16 bitmap font. Supports newlines \n; the font size scales linearly via scale. Tier: Starter+
Channels: 1ch / 3ch / 4ch
Inplace: supported (writes onto the provided image buffer)
Types:

Template parameter Allowed types Constraint
T uint8_t
int putText(
    uint8_t* img,
    int width, int height, int cn, int stride,
    const char* text,
    int x, int y,
    const uint8_t* color,
    int scale = 1);
Parameter Type Meaning Default
text const char* \0-terminated ASCII string non-null
x, y int Text top-left coordinates
scale int Font-size multiplier (1 = 8×16, 2 = 16×32 …) 1

Example

uint8_t img[1920*1080*3] = {};
uint8_t red[3]  = { 255, 0, 0 };
uint8_t blue[3] = { 0, 0, 255 };

acl::draw::drawLine(img, 1920, 1080, 3, 0, 100, 100, 500, 500, red, 2);
acl::draw::drawRect(img, 1920, 1080, 3, 0, 200, 200, 300, 150, blue, -1);
acl::draw::drawCircle(img, 1920, 1080, 3, 0, 960, 540, 80, red, 3);
acl::draw::putText(img, 1920, 1080, 3, 0, "Hello\nWorld", 50, 50, blue, 2);

Clone this wiki locally