The home page of it is here: https://libspng.org/
Code: Select all
#pragma once
#include once "crt/stdlib.bi"
#include once "crt/stdint.bi"
#include once "crt/stdio.bi"
extern "C"
#define SPNG_CDECL
const SPNG_VERSION_MAJOR = 0
const SPNG_VERSION_MINOR = 7
const SPNG_VERSION_PATCH = 1
type spng_errno as long
enum
SPNG_IO_ERROR = -2
SPNG_IO_EOF = -1
SPNG_OK = 0
SPNG_EINVAL
SPNG_EMEM
SPNG_EOVERFLOW
SPNG_ESIGNATURE
SPNG_EWIDTH
SPNG_EHEIGHT
SPNG_EUSER_WIDTH
SPNG_EUSER_HEIGHT
SPNG_EBIT_DEPTH
SPNG_ECOLOR_TYPE
SPNG_ECOMPRESSION_METHOD
SPNG_EFILTER_METHOD
SPNG_EINTERLACE_METHOD
SPNG_EIHDR_SIZE
SPNG_ENOIHDR
SPNG_ECHUNK_POS
SPNG_ECHUNK_SIZE
SPNG_ECHUNK_CRC
SPNG_ECHUNK_TYPE
SPNG_ECHUNK_UNKNOWN_CRITICAL
SPNG_EDUP_PLTE
SPNG_EDUP_CHRM
SPNG_EDUP_GAMA
SPNG_EDUP_ICCP
SPNG_EDUP_SBIT
SPNG_EDUP_SRGB
SPNG_EDUP_BKGD
SPNG_EDUP_HIST
SPNG_EDUP_TRNS
SPNG_EDUP_PHYS
SPNG_EDUP_TIME
SPNG_EDUP_OFFS
SPNG_EDUP_EXIF
SPNG_ECHRM
SPNG_EPLTE_IDX
SPNG_ETRNS_COLOR_TYPE
SPNG_ETRNS_NO_PLTE
SPNG_EGAMA
SPNG_EICCP_NAME
SPNG_EICCP_COMPRESSION_METHOD
SPNG_ESBIT
SPNG_ESRGB
SPNG_ETEXT
SPNG_ETEXT_KEYWORD
SPNG_EZTXT
SPNG_EZTXT_COMPRESSION_METHOD
SPNG_EITXT
SPNG_EITXT_COMPRESSION_FLAG
SPNG_EITXT_COMPRESSION_METHOD
SPNG_EITXT_LANG_TAG
SPNG_EITXT_TRANSLATED_KEY
SPNG_EBKGD_NO_PLTE
SPNG_EBKGD_PLTE_IDX
SPNG_EHIST_NO_PLTE
SPNG_EPHYS
SPNG_ESPLT_NAME
SPNG_ESPLT_DUP_NAME
SPNG_ESPLT_DEPTH
SPNG_ETIME
SPNG_EOFFS
SPNG_EEXIF
SPNG_EIDAT_TOO_SHORT
SPNG_EIDAT_STREAM
SPNG_EZLIB
SPNG_EFILTER
SPNG_EBUFSIZ
SPNG_EIO
SPNG_EOF
SPNG_EBUF_SET
SPNG_EBADSTATE
SPNG_EFMT
SPNG_EFLAGS
SPNG_ECHUNKAVAIL
SPNG_ENCODE_ONLY
SPNG_EOI
SPNG_ENOPLTE
SPNG_ECHUNK_LIMITS
SPNG_EZLIB_INIT
SPNG_ECHUNK_STDLEN
SPNG_EINTERNAL
SPNG_ECTXTYPE
SPNG_ENOSRC
SPNG_ENODST
SPNG_EOPSTATE
SPNG_ENOTFINAL
end enum
type spng_text_type as long
enum
SPNG_TEXT = 1
SPNG_ZTXT = 2
SPNG_ITXT = 3
end enum
type spng_color_type as long
enum
SPNG_COLOR_TYPE_GRAYSCALE = 0
SPNG_COLOR_TYPE_TRUECOLOR = 2
SPNG_COLOR_TYPE_INDEXED = 3
SPNG_COLOR_TYPE_GRAYSCALE_ALPHA = 4
SPNG_COLOR_TYPE_TRUECOLOR_ALPHA = 6
end enum
type spng_filter as long
enum
SPNG_FILTER_NONE = 0
SPNG_FILTER_SUB = 1
SPNG_FILTER_UP = 2
SPNG_FILTER_AVERAGE = 3
SPNG_FILTER_PAETH = 4
end enum
type spng_filter_choice as long
enum
SPNG_DISABLE_FILTERING = 0
SPNG_FILTER_CHOICE_NONE = 8
SPNG_FILTER_CHOICE_SUB = 16
SPNG_FILTER_CHOICE_UP = 32
SPNG_FILTER_CHOICE_AVG = 64
SPNG_FILTER_CHOICE_PAETH = 128
SPNG_FILTER_CHOICE_ALL = (((8 or 16) or 32) or 64) or 128
end enum
type spng_interlace_method as long
enum
SPNG_INTERLACE_NONE = 0
SPNG_INTERLACE_ADAM7 = 1
end enum
type spng_format as long
enum
SPNG_FMT_RGBA8 = 1
SPNG_FMT_RGBA16 = 2
SPNG_FMT_RGB8 = 4
SPNG_FMT_GA8 = 16
SPNG_FMT_GA16 = 32
SPNG_FMT_G8 = 64
SPNG_FMT_PNG = 256
SPNG_FMT_RAW = 512
end enum
type spng_ctx_flags as long
enum
SPNG_CTX_IGNORE_ADLER32 = 1
SPNG_CTX_ENCODER = 2
end enum
type spng_decode_flags as long
enum
SPNG_DECODE_USE_TRNS = 1
SPNG_DECODE_USE_GAMA = 2
SPNG_DECODE_USE_SBIT = 8
SPNG_DECODE_TRNS = 1
SPNG_DECODE_GAMMA = 2
SPNG_DECODE_PROGRESSIVE = 256
end enum
type spng_crc_action as long
enum
SPNG_CRC_ERROR = 0
SPNG_CRC_DISCARD = 1
SPNG_CRC_USE = 2
end enum
type spng_encode_flags as long
enum
SPNG_ENCODE_PROGRESSIVE = 1
SPNG_ENCODE_FINALIZE = 2
end enum
type spng_ihdr
width as ulong
height as ulong
bit_depth as ubyte
color_type as ubyte
compression_method as ubyte
filter_method as ubyte
interlace_method as ubyte
end type
type spng_plte_entry
red as ubyte
green as ubyte
blue as ubyte
alpha as ubyte
end type
type spng_plte
n_entries as ulong
entries(0 to 255) as spng_plte_entry
end type
type spng_trns
gray as ushort
red as ushort
green as ushort
blue as ushort
n_type3_entries as ulong
type3_alpha(0 to 255) as ubyte
end type
type spng_chrm_int
white_point_x as ulong
white_point_y as ulong
red_x as ulong
red_y as ulong
green_x as ulong
green_y as ulong
blue_x as ulong
blue_y as ulong
end type
type spng_chrm
white_point_x as double
white_point_y as double
red_x as double
red_y as double
green_x as double
green_y as double
blue_x as double
blue_y as double
end type
type spng_iccp
profile_name as zstring * 80
profile_len as uinteger
profile as zstring ptr
end type
type spng_sbit
grayscale_bits as ubyte
red_bits as ubyte
green_bits as ubyte
blue_bits as ubyte
alpha_bits as ubyte
end type
type spng_text
keyword as zstring * 80
as long type
length as uinteger
text as zstring ptr
compression_flag as ubyte
compression_method as ubyte
language_tag as zstring ptr
translated_keyword as zstring ptr
end type
type spng_bkgd
gray as ushort
red as ushort
green as ushort
blue as ushort
plte_index as ushort
end type
type spng_hist
frequency(0 to 255) as ushort
end type
type spng_phys
ppu_x as ulong
ppu_y as ulong
unit_specifier as ubyte
end type
type spng_splt_entry
red as ushort
green as ushort
blue as ushort
alpha as ushort
frequency as ushort
end type
type spng_splt
name as zstring * 80
sample_depth as ubyte
n_entries as ulong
entries as spng_splt_entry ptr
end type
type spng_time
year as ushort
month as ubyte
day as ubyte
hour as ubyte
minute as ubyte
second as ubyte
end type
type spng_offs
x as long
y as long
unit_specifier as ubyte
end type
type spng_exif
length as uinteger
data as zstring ptr
end type
type spng_chunk
offset as uinteger
length as ulong
as ubyte type(0 to 3)
crc as ulong
end type
type spng_location as long
enum
SPNG_AFTER_IHDR = 1
SPNG_AFTER_PLTE = 2
SPNG_AFTER_IDAT = 8
end enum
type spng_unknown_chunk
as ubyte type(0 to 3)
length as uinteger
data as any ptr
location as spng_location
end type
type spng_option as long
enum
SPNG_KEEP_UNKNOWN_CHUNKS = 1
SPNG_IMG_COMPRESSION_LEVEL
SPNG_IMG_WINDOW_BITS
SPNG_IMG_MEM_LEVEL
SPNG_IMG_COMPRESSION_STRATEGY
SPNG_TEXT_COMPRESSION_LEVEL
SPNG_TEXT_WINDOW_BITS
SPNG_TEXT_MEM_LEVEL
SPNG_TEXT_COMPRESSION_STRATEGY
SPNG_FILTER_CHOICE
SPNG_CHUNK_COUNT_LIMIT
SPNG_ENCODE_TO_BUFFER
end enum
type spng_alloc
malloc_fn as function(byval size as uinteger) as any ptr
realloc_fn as function(byval ptr as any ptr, byval size as uinteger) as any ptr
calloc_fn as function(byval count as uinteger, byval size as uinteger) as any ptr
free_fn as sub(byval ptr as any ptr)
end type
type spng_row_info
scanline_idx as ulong
row_num as ulong
pass as long
filter as ubyte
end type
declare function spng_ctx_new(byval flags as long) as spng_ctx ptr
declare function spng_ctx_new2(byval alloc as spng_alloc ptr, byval flags as long) as spng_ctx ptr
declare sub spng_ctx_free(byval ctx as spng_ctx ptr)
declare function spng_set_png_buffer(byval ctx as spng_ctx ptr, byval buf as const any ptr, byval size as uinteger) as long
declare function spng_set_png_stream(byval ctx as spng_ctx ptr, byval rw_func as function(byval ctx as spng_ctx ptr, byval user as any ptr, byval dst_src as any ptr, byval length as uinteger) as long, byval user as any ptr) as long
declare function spng_set_png_file(byval ctx as spng_ctx ptr, byval file as FILE ptr) as long
declare function spng_get_png_buffer(byval ctx as spng_ctx ptr, byval len as uinteger ptr, byval error as long ptr) as any ptr
declare function spng_set_image_limits(byval ctx as spng_ctx ptr, byval width as ulong, byval height as ulong) as long
declare function spng_get_image_limits(byval ctx as spng_ctx ptr, byval width as ulong ptr, byval height as ulong ptr) as long
declare function spng_set_chunk_limits(byval ctx as spng_ctx ptr, byval chunk_size as uinteger, byval cache_size as uinteger) as long
declare function spng_get_chunk_limits(byval ctx as spng_ctx ptr, byval chunk_size as uinteger ptr, byval cache_size as uinteger ptr) as long
declare function spng_set_crc_action(byval ctx as spng_ctx ptr, byval critical as long, byval ancillary as long) as long
declare function spng_set_option(byval ctx as spng_ctx ptr, byval option as spng_option, byval value as long) as long
declare function spng_get_option(byval ctx as spng_ctx ptr, byval option as spng_option, byval value as long ptr) as long
declare function spng_decoded_image_size(byval ctx as spng_ctx ptr, byval fmt as long, byval len as uinteger ptr) as long
declare function spng_decode_image(byval ctx as spng_ctx ptr, byval out as any ptr, byval len as uinteger, byval fmt as long, byval flags as long) as long
declare function spng_decode_scanline(byval ctx as spng_ctx ptr, byval out as any ptr, byval len as uinteger) as long
declare function spng_decode_row(byval ctx as spng_ctx ptr, byval out as any ptr, byval len as uinteger) as long
declare function spng_decode_chunks(byval ctx as spng_ctx ptr) as long
declare function spng_get_row_info(byval ctx as spng_ctx ptr, byval row_info as spng_row_info ptr) as long
declare function spng_encode_image(byval ctx as spng_ctx ptr, byval img as const any ptr, byval len as uinteger, byval fmt as long, byval flags as long) as long
declare function spng_encode_scanline(byval ctx as spng_ctx ptr, byval scanline as const any ptr, byval len as uinteger) as long
declare function spng_encode_row(byval ctx as spng_ctx ptr, byval row as const any ptr, byval len as uinteger) as long
declare function spng_encode_chunks(byval ctx as spng_ctx ptr) as long
declare function spng_get_ihdr(byval ctx as spng_ctx ptr, byval ihdr as spng_ihdr ptr) as long
declare function spng_get_plte(byval ctx as spng_ctx ptr, byval plte as spng_plte ptr) as long
declare function spng_get_trns(byval ctx as spng_ctx ptr, byval trns as spng_trns ptr) as long
declare function spng_get_chrm(byval ctx as spng_ctx ptr, byval chrm as spng_chrm ptr) as long
declare function spng_get_chrm_int(byval ctx as spng_ctx ptr, byval chrm_int as spng_chrm_int ptr) as long
declare function spng_get_gama(byval ctx as spng_ctx ptr, byval gamma as double ptr) as long
declare function spng_get_gama_int(byval ctx as spng_ctx ptr, byval gama_int as ulong ptr) as long
declare function spng_get_iccp(byval ctx as spng_ctx ptr, byval iccp as spng_iccp ptr) as long
declare function spng_get_sbit(byval ctx as spng_ctx ptr, byval sbit as spng_sbit ptr) as long
declare function spng_get_srgb(byval ctx as spng_ctx ptr, byval rendering_intent as ubyte ptr) as long
declare function spng_get_text(byval ctx as spng_ctx ptr, byval text as spng_text ptr, byval n_text as ulong ptr) as long
declare function spng_get_bkgd(byval ctx as spng_ctx ptr, byval bkgd as spng_bkgd ptr) as long
declare function spng_get_hist(byval ctx as spng_ctx ptr, byval hist as spng_hist ptr) as long
declare function spng_get_phys(byval ctx as spng_ctx ptr, byval phys as spng_phys ptr) as long
declare function spng_get_splt(byval ctx as spng_ctx ptr, byval splt as spng_splt ptr, byval n_splt as ulong ptr) as long
declare function spng_get_time(byval ctx as spng_ctx ptr, byval time as spng_time ptr) as long
declare function spng_get_unknown_chunks(byval ctx as spng_ctx ptr, byval chunks as spng_unknown_chunk ptr, byval n_chunks as ulong ptr) as long
declare function spng_get_offs(byval ctx as spng_ctx ptr, byval offs as spng_offs ptr) as long
declare function spng_get_exif(byval ctx as spng_ctx ptr, byval exif as spng_exif ptr) as long
declare function spng_set_ihdr(byval ctx as spng_ctx ptr, byval ihdr as spng_ihdr ptr) as long
declare function spng_set_plte(byval ctx as spng_ctx ptr, byval plte as spng_plte ptr) as long
declare function spng_set_trns(byval ctx as spng_ctx ptr, byval trns as spng_trns ptr) as long
declare function spng_set_chrm(byval ctx as spng_ctx ptr, byval chrm as spng_chrm ptr) as long
declare function spng_set_chrm_int(byval ctx as spng_ctx ptr, byval chrm_int as spng_chrm_int ptr) as long
declare function spng_set_gama(byval ctx as spng_ctx ptr, byval gamma as double) as long
declare function spng_set_gama_int(byval ctx as spng_ctx ptr, byval gamma as ulong) as long
declare function spng_set_iccp(byval ctx as spng_ctx ptr, byval iccp as spng_iccp ptr) as long
declare function spng_set_sbit(byval ctx as spng_ctx ptr, byval sbit as spng_sbit ptr) as long
declare function spng_set_srgb(byval ctx as spng_ctx ptr, byval rendering_intent as ubyte) as long
declare function spng_set_text(byval ctx as spng_ctx ptr, byval text as spng_text ptr, byval n_text as ulong) as long
declare function spng_set_bkgd(byval ctx as spng_ctx ptr, byval bkgd as spng_bkgd ptr) as long
declare function spng_set_hist(byval ctx as spng_ctx ptr, byval hist as spng_hist ptr) as long
declare function spng_set_phys(byval ctx as spng_ctx ptr, byval phys as spng_phys ptr) as long
declare function spng_set_splt(byval ctx as spng_ctx ptr, byval splt as spng_splt ptr, byval n_splt as ulong) as long
declare function spng_set_time(byval ctx as spng_ctx ptr, byval time as spng_time ptr) as long
declare function spng_set_unknown_chunks(byval ctx as spng_ctx ptr, byval chunks as spng_unknown_chunk ptr, byval n_chunks as ulong) as long
declare function spng_set_offs(byval ctx as spng_ctx ptr, byval offs as spng_offs ptr) as long
declare function spng_set_exif(byval ctx as spng_ctx ptr, byval exif as spng_exif ptr) as long
declare function spng_strerror(byval err as long) as const zstring ptr
declare function spng_version_string() as const zstring ptr
end extern