Simple Graphics Library 1.0.0.0
Runtime-independent image processing primitives
Loading...
Searching...
No Matches
Rotate

Nearest-neighbor rotation into a caller-owned bounding-box buffer. More...

Functions

sgl_result_t sgl_get_rotated_dimensions (sgl_int32_t src_width, sgl_int32_t src_height, sgl_float64_t angle, sgl_int32_t *dst_width, sgl_int32_t *dst_height)
 Calculates the destination bounding-box dimensions for a rotation.
 
sgl_int32_t sgl_get_rotated_size (sgl_int32_t src_width, sgl_int32_t src_height, sgl_int32_t bpp, sgl_float64_t angle)
 Calculates the required destination buffer size for a rotation.
 
sgl_rotate_lookup_t * sgl_generic_create_rotate_lut (sgl_int32_t src_width, sgl_int32_t src_height, sgl_float64_t angle)
 Creates a reusable rotation mapping table.
 
void sgl_generic_destroy_rotate_lut (sgl_rotate_lookup_t *lut)
 Destroys a rotation LUT.
 
sgl_result_t sgl_generic_rotate (sgl_threadpool_t *pool, sgl_rotate_lookup_t *ext_lut, const sgl_uint8_t *src, sgl_int32_t src_width, sgl_int32_t src_height, sgl_uint8_t *dst, sgl_int32_t bpp, sgl_float64_t angle)
 Rotates a tightly packed image using nearest-neighbor sampling.
 
sgl_result_t sgl_simd_rotate (sgl_threadpool_t *pool, sgl_rotate_lookup_t *ext_lut, const sgl_uint8_t *src, sgl_int32_t src_width, sgl_int32_t src_height, sgl_uint8_t *dst, sgl_int32_t bpp, sgl_float64_t angle)
 SIMD rotation implementation.
 

Detailed Description

Nearest-neighbor rotation into a caller-owned bounding-box buffer.

Angles are clockwise degrees and are normalized modulo 360. Pixels in the destination bounding box that map outside the source are filled with zero.

Function Documentation

◆ sgl_generic_create_rotate_lut()

sgl_rotate_lookup_t * sgl_generic_create_rotate_lut ( sgl_int32_t  src_width,
sgl_int32_t  src_height,
sgl_float64_t  angle 
)

Creates a reusable rotation mapping table.

Parameters
[in]src_widthPositive source width in pixels.
[in]src_heightPositive source height in pixels.
[in]angleClockwise rotation angle in degrees.
Returns
New LUT, or SGL_NULL for invalid geometry or allocation failure.
Note
A LUT is independent of bpp and is valid only for the exact source dimensions and normalized angle used during creation.

◆ sgl_generic_destroy_rotate_lut()

void sgl_generic_destroy_rotate_lut ( sgl_rotate_lookup_t *  lut)

Destroys a rotation LUT.

Parameters
[in]lutLUT or SGL_NULL.

◆ sgl_generic_rotate()

sgl_result_t sgl_generic_rotate ( sgl_threadpool_t *  pool,
sgl_rotate_lookup_t *  ext_lut,
const sgl_uint8_t *  src,
sgl_int32_t  src_width,
sgl_int32_t  src_height,
sgl_uint8_t *  dst,
sgl_int32_t  bpp,
sgl_float64_t  angle 
)

Rotates a tightly packed image using nearest-neighbor sampling.

Parameters
[in]poolWorker pool, or SGL_NULL for single-thread execution.
[in]ext_lutMatching reusable rotation LUT, or SGL_NULL.
[in]srcBuffer of at least src_width * src_height * bpp bytes.
[in]src_widthPositive source width in pixels.
[in]src_heightPositive source height in pixels.
[out]dstCaller-owned buffer sized by sgl_get_rotated_size().
[in]bppPositive number of bytes per packed pixel.
[in]angleClockwise rotation angle in degrees.
Return values
SGL_SUCCESSRotation completed.
SGL_ERROR_INVALID_ARGUMENTSInvalid input or a LUT created for different geometry.
SGL_ERROR_MEMORY_ALLOCATIONParallel work storage was unavailable.
Precondition
Source and destination buffers do not overlap.

◆ sgl_get_rotated_dimensions()

sgl_result_t sgl_get_rotated_dimensions ( sgl_int32_t  src_width,
sgl_int32_t  src_height,
sgl_float64_t  angle,
sgl_int32_t *  dst_width,
sgl_int32_t *  dst_height 
)

Calculates the destination bounding-box dimensions for a rotation.

Parameters
[in]src_widthPositive source width in pixels.
[in]src_heightPositive source height in pixels.
[in]angleClockwise rotation angle in degrees.
[out]dst_widthCalculated destination width.
[out]dst_heightCalculated destination height.
Return values
SGL_SUCCESSDimensions calculated successfully.
SGL_ERROR_INVALID_ARGUMENTSInvalid dimensions, output pointer, NaN, unsupported angle magnitude, or overflowing result.

◆ sgl_get_rotated_size()

sgl_int32_t sgl_get_rotated_size ( sgl_int32_t  src_width,
sgl_int32_t  src_height,
sgl_int32_t  bpp,
sgl_float64_t  angle 
)

Calculates the required destination buffer size for a rotation.

Parameters
[in]src_widthPositive source width in pixels.
[in]src_heightPositive source height in pixels.
[in]bppPositive number of bytes per packed pixel.
[in]angleClockwise rotation angle in degrees.
Returns
Required byte count, or 0 for invalid or overflowing input.

◆ sgl_simd_rotate()

sgl_result_t sgl_simd_rotate ( sgl_threadpool_t *  pool,
sgl_rotate_lookup_t *  ext_lut,
const sgl_uint8_t *  src,
sgl_int32_t  src_width,
sgl_int32_t  src_height,
sgl_uint8_t *  dst,
sgl_int32_t  bpp,
sgl_float64_t  angle 
)

SIMD rotation implementation.

Parameters
[in]poolWorker pool, or SGL_NULL for single-thread execution.
[in]ext_lutMatching reusable rotation LUT, or SGL_NULL.
[in]srcBuffer of at least src_width * src_height * bpp bytes.
[in]src_widthPositive source width in pixels.
[in]src_heightPositive source height in pixels.
[out]dstCaller-owned buffer sized by sgl_get_rotated_size().
[in]bppPositive number of bytes per packed pixel.
[in]angleClockwise rotation angle in degrees.
Return values
SGL_SUCCESSRotation completed.
SGL_ERROR_INVALID_ARGUMENTSInvalid input or a LUT created for different geometry.
SGL_ERROR_MEMORY_ALLOCATIONParallel work storage was unavailable.
Precondition
Source and destination buffers do not overlap.