Overview
Provides JPEG encoding/decoding capabilities and utilities for image format conversion, masking, and border manipulation. Built on top of TurboJPEG for high-performance compression.Types
Image
Represents an 8-bit unsigned char image.Pixel data buffer (row-major order)
Image width in pixels
Image height in pixels
Number of color channels (1 for grayscale, 3 for RGB)
ImageF
Represents a floating-point image.Floating-point pixel data buffer
Image width in pixels
Image height in pixels
Number of color channels
ImageS
Represents a short integer image.Short integer pixel data buffer
Image width in pixels
Image height in pixels
Number of color channels
BorderType
Enumeration for border handling modes.Fill border with constant value (typically 0)
Reflect image pixels at boundaries
Constants
Functions
decompress_jpeg
Decompresses a JPEG file into an Image structure.Path to JPEG file to decompress
Decompressed image with allocated data buffer
Returns an RGB image (3 channels) regardless of source format. Check
img.data != NULL to verify successful loading.Example
compress_jpeg
Compresses an RGB image to JPEG format.Output JPEG file path
Pointer to RGB image to compress (must have 3 channels)
JPEG quality (1-100, where 100 is best quality)
1 on success, 0 on failure
The image must have exactly 3 channels (RGB). For grayscale images, use
compress_grayscale_jpeg instead.Example
compress_grayscale_jpeg
Compresses a grayscale image to JPEG format.Output JPEG file path
Pointer to grayscale image (must have 1 channel)
JPEG quality (1-100)
1 on success, 0 on failure
Example
convert_RGB_to_gray
Converts an RGB image to grayscale.Pointer to source RGB image (3 channels)
Newly allocated grayscale image (1 channel)
Uses standard luminance conversion: Y = 0.299R + 0.587G + 0.114B
Example
create_mask
Creates a horizontal gradient mask for image blending.Mask width in pixels
Mask height in pixels
Gradient transition range as fraction of width (0.0-1.0)
Value for left edge (0 or 1, scaled to 0 or 255)
Value for right edge (0 or 1, scaled to 0 or 255)
Grayscale mask image with smooth horizontal gradient
The
range parameter controls the transition zone width. For example, 0.1 creates a gradient over 10% of the image width.Example
create_vertical_mask
Creates a vertical gradient mask for image blending.Mask width in pixels
Mask height in pixels
Gradient transition range as fraction of height (0.0-1.0)
Value for top edge (0 or 1)
Value for bottom edge (0 or 1)
Grayscale mask image with smooth vertical gradient
Example
add_border_to_image
Adds border padding to an image.Pointer to image (modified in-place)
Pixels to add on top
Pixels to add on bottom
Pixels to add on left
Pixels to add on right
Number of channels in the image
Border fill method (BORDER_CONSTANT or BORDER_REFLECT)
Modifies the image structure in-place by reallocating the data buffer with expanded dimensions.
Example
convert_image_to_image_f
Converts unsigned char image to floating-point format.Source image (unsigned char)
Destination image (must be pre-allocated with same dimensions)
The
out image must already be allocated with matching dimensions. Values are converted from [0, 255] to [0.0, 255.0].Example
convert_image_to_image_s
Converts unsigned char image to short integer format.Source image (unsigned char)
Destination image (must be pre-allocated)
convert_imagef_to_image
Converts floating-point image to unsigned char format.Source float image
Destination image (must be pre-allocated)
Values are clamped to [0, 255] range during conversion.
convert_images_to_image
Converts short integer image to unsigned char format.Source short image
Destination image (must be pre-allocated)
crop_image_buf
Crops an image buffer by removing borders.Pointer to image to crop (modified in-place)
Pixels to remove from top
Pixels to remove from bottom
Pixels to remove from left
Pixels to remove from right
Number of channels