Context

Data types

spng_ctx

Context handle.

Note

The context handle has no public members.

spng_crc_action
enum spng_crc_action
{
    SPNG_CRC_ERROR = 0, /* Default */
    SPNG_CRC_DISCARD = 1, /* Discard chunk, invalid for critical chunks */
    SPNG_CRC_USE = 2 /* Ignore and don't calculate checksum */
};

API

spng_ctx *spng_ctx_new(int flags)

Creates a new context.

spng_ctx *spng_ctx_new2(struct spng_alloc *alloc, int flags)

Creates a new context with a custom memory allocator, alloc must be non-NULL.

void spng_ctx_free(spng_ctx *ctx)

Releases context resources.

int spng_set_image_limits(spng_ctx *ctx, uint32_t width, uint32_t height)

Set image width and height limits, these may not be larger than 231-1.

int spng_get_image_limits(spng_ctx *ctx, uint32_t *width, uint32_t *height)

Get image width and height limits.

*width and *height must be non-NULL.

int spng_set_crc_action(spng_ctx *ctx, int critical, int ancillary)

Set how chunk CRC errors should be handled for critical and ancillary chunks.

Note

Partially implemented, SPNG_CRC_DISCARD has no effect.

int spng_set_chunk_limits(spng_ctx *ctx, size_t chunk_size, size_t cache_limit)

Set chunk size and chunk cache limits.

Warning

Unreleased function, do not use.

int spng_get_chunk_limits(spng_ctx *ctx, size_t *chunk_size, size_t *cache_limit)

Get chunk size and chunk cache limits.

Warning

Unreleased function, do not use.