package vendor:stb/image
Overview
Bindings for stb_image.h.
Index
Variables (0)
This section is empty.
Procedures (76)
- build_samplers
- build_samplers_with_splits
- convert_iphone_png_to_rgb
- convert_iphone_png_to_rgb_thread
- failure_reason
- flip_vertically_on_write
- free_samplers
- hdr_to_ldr_gamma
- hdr_to_ldr_scale
- image_free
- info
info_… (3)
- ldr_to_hdr_gamma
- ldr_to_hdr_scale
- load
- loadf
loadf_… (3)
- resize
set_… (17)
- set_buffer_ptrs
- set_datatypes
- set_edgemodes
- set_filter_callbacks
- set_filter_callbacks_new
- set_filters
- set_flip_vertically_on_load
- set_flip_vertically_on_load_thread
- set_input_subrect
- set_non_pm_alpha_speed_over_quality
- set_output_pixel_subrect
- set_pixel_callbacks
- set_pixel_layouts
- set_pixel_subrect
- set_unpremultiply_on_load
- set_unpremultiply_on_load_thread
- set_user_data
Procedure Groups (0)
This section is empty.
Types
Io_Callbacks ¶
Io_Callbacks :: struct { read: proc "c" (user: rawptr, data: [^]u8, size: i32) -> i32, // fill 'data' with 'size' u8s. return number of u8s actually read skip: proc "c" (user: rawptr, n: i32), // skip the next 'n' u8s, or 'unget' the last -n u8s if negative eof: proc "c" (user: rawptr) -> i32, }
load image by filename, open file, or memory buffer
Related Procedures With Parameters
datatype ¶
datatype :: enum i32 { UINT8 = 0, UINT8_SRGB = 1, UINT8_SRGB_ALPHA = 2, // alpha channel, when present, should also be SRGB (this is very unusual) UINT16 = 3, FLOAT = 4, HALF_FLOAT = 5, }
Related Procedures With Parameters
edge ¶
edge :: enum i32 { CLAMP = 0, REFLECT = 1, WRAP = 2, // this edge mode is slower and uses more memory ZERO = 3, }
What to do when sampling off the edge of the image.
Related Procedures With Parameters
filter ¶
filter :: enum i32 { DEFAULT = 0, // use same filter type that the easy-to-use API chooses BOX = 1, // A trapezoid w/1-pixel wide ramps, same result as box for integer scale ratios TRIANGLE = 2, // On upsampling, produces same results as bilinear texture filtering CUBICBSPLINE = 3, // The cubic b-spline (aka Mitchell-Netrevalli with B=1,C=0), gaussian-esque CATMULLROM = 4, // An interpolating cubic spline (the default when upsampling) MITCHELL = 5, // Mitchell-Netrevalli filter with B=1/3, C=1/3 (the default when downsampling) POINT_SAMPLE = 6, // Simple point sampling MITCHELL_QUARTER = 7, // Mitchell-Netrevalli with B=1/4, C=3/8 (Robidoux), a little sharper than Mitchell MITCHELL_SIXTH = 8, // Mitchell-Netrevalli with B=1/6, C=5/12, sharper still MITCHELL_NEG_SIXTH = 9, // Mitchell-Netrevalli with B=-1/6, C=7/12, over-sharpening MITCHELL_NEG_THIRD = 10, // Mitchell-Netrevalli with B=-1/3, C=2/3, more over-sharpening LANCZOS4 = 11, // Lanczos with 2 lobes (4 taps at 1:1), sharp, some ringing on hard edges LANCZOS5 = 12, // Lanczos with 2.5 lobes (5 taps at 1:1), very sharp, often ringy MURATORI6 = 13, // Casey Muratori's Bink 2 kernel (1 -4 19 19 -4 1)/32, stable under repeated half pixel shifts with 8-bit pixels OTHER = 14, // User callback specified (keep last: the built-ins are everything below it) }
Related Procedures With Parameters
input_callback ¶
input_callback :: proc "c" (optional_output: rawptr, input_ptr: rawptr, num_pixels: i32, x, y: i32, ctx: rawptr) -> rawptr
Called for input scanlines. optional_output is a buffer you may fill and return; or return a pointer into
your own data. input_ptr is the start of the row based on the stride and base pointer, and x and
num_pixels say which part of the row is needed.
kernel_callback ¶
Callbacks for your own filters. The "new" ones work in f64; the old float forms exist for compatibility only.
output_callback ¶
Called for output scanlines, or pieces of them: the resizer may deliver column slices, out of order, always in the full output image's pixel space.
pixel_layout ¶
pixel_layout :: enum i32 { BGR = 0, // 3 channels, with the order specified (for channel flipping) CHANNEL_1 = 1, CHANNEL_2 = 2, RGB = 3, // 3 channels, with the order specified (for channel flipping) RGBA = 4, // alpha formats, where alpha is NOT premultiplied into the color channels CHANNEL_4 = 5, BGRA = 6, ARGB = 7, ABGR = 8, RA = 9, AR = 10, RGBA_PM = 11, // alpha formats, where alpha IS premultiplied into the color channels BGRA_PM = 12, ARGB_PM = 13, ABGR_PM = 14, RA_PM = 15, AR_PM = 16, }
Specifies the number of channels, their order, and whether color is premultiplied by alpha.
For compatibility with the old API, a channel count can be cast to a pixel_layout:
pixel_layout(3) is .RGB and pixel_layout(4) is .RGBA.
Related Procedures With Parameters
Related Constants
resizer ¶
resizer :: struct { user_data: rawptr, input_pixels: rawptr, input_w: i32, input_h: i32, input_s0: f64, input_t0: f64, input_s1: f64, input_t1: f64, input_s_n0: i32, input_s_n1: i32, input_s_d: i32, input_t_n0: i32, input_t_n1: i32, input_t_d: i32, input_cb: input_callback, output_pixels: rawptr, output_w: i32, output_h: i32, output_subx: i32, output_suby: i32, output_subw: i32, output_subh: i32, output_cb: output_callback, input_stride_in_bytes: i64, output_stride_in_bytes: i64, splits: i32, fast_alpha: i32, needs_rebuild: i32, called_alloc: i32, input_pixel_layout_public: pixel_layout, output_pixel_layout_public: pixel_layout, input_data_type: datatype, output_data_type: datatype, horizontal_filter: filter, vertical_filter: filter, horizontal_edge: edge, vertical_edge: edge, horizontal_filter_kernel: kernel_callback, horizontal_filter_support: support_callback, vertical_filter_kernel: kernel_callback, vertical_filter_support: support_callback, horizontal_filter_kernel_new: kernel_callback_new, horizontal_filter_support_new: support_callback_new, horizontal_filter_radius: radius_callback_new, vertical_filter_kernel_new: kernel_callback_new, vertical_filter_support_new: support_callback_new, vertical_filter_radius: radius_callback_new, samplers: rawptr, }
Mirrors STBIR_RESIZE. Initialize it with resize_init and change it with the set_* procedures rather than by
writing to the fields, so that it keeps working with future versions.
Related Procedures With Parameters
- build_samplers
- build_samplers_with_splits
- free_samplers
- resize_extended
- resize_extended_split
- resize_init
- set_buffer_ptrs
- set_datatypes
- set_edgemodes
- set_filter_callbacks
- set_filter_callbacks_new
- set_filters
- set_input_subrect
- set_non_pm_alpha_speed_over_quality
- set_output_pixel_subrect
- set_pixel_callbacks
- set_pixel_layouts
- set_pixel_subrect
- set_user_data
write_func ¶
Related Procedures With Parameters
Constants
NO_STDIO ¶
NO_STDIO :: ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64p32
PIXEL_LAYOUT_ABGR_NO_AW ¶
PIXEL_LAYOUT_ABGR_NO_AW :: pixel_layout.ABGR_PM
PIXEL_LAYOUT_ARGB_NO_AW ¶
PIXEL_LAYOUT_ARGB_NO_AW :: pixel_layout.ARGB_PM
PIXEL_LAYOUT_AR_NO_AW ¶
PIXEL_LAYOUT_AR_NO_AW :: pixel_layout.AR_PM
PIXEL_LAYOUT_BGRA_NO_AW ¶
PIXEL_LAYOUT_BGRA_NO_AW :: pixel_layout.BGRA_PM
PIXEL_LAYOUT_RA_NO_AW ¶
PIXEL_LAYOUT_RA_NO_AW :: pixel_layout.RA_PM
PIXEL_LAYOUT_RGBA_NO_AW ¶
PIXEL_LAYOUT_RGBA_NO_AW :: pixel_layout.RGBA_PM
Alpha formats where NO alpha weighting is applied at all. Synonyms of the _PM layouts, under a name
that makes the intent clearer to some.
Variables
This section is empty.
Procedures
build_samplers ¶C · stbir_build_samplersSource · stb_image_resize2.odin:264
Prebuilds the internal data needed to resample, with one allocation. If you call this you MUST eventually call free_samplers.
build_samplers_with_splits ¶C · stbir_build_samplers_with_splitsSource · stb_image_resize2.odin:274
Multithreading. build_samplers_with_splits builds the samplers for up to try_splits threads and returns how
many splits (threads) you may actually use; it may be fewer. Then call resize_extended_split once per split
(usually with split_start as the thread index and a split_count of 1). A split is a piece of the output
pixel space. You MUST call build_samplers_with_splits before resize_extended_split.
convert_iphone_png_to_rgb ¶C · stbi_convert_iphone_png_to_rgbSource · stb_image.odin:130
convert_iphone_png_to_rgb :: proc "c" (flag_true_if_should_convert: i32) ---
indicate whether we should process iphone images back to canonical format, or just pass them through "as-is"
convert_iphone_png_to_rgb_thread ¶C · stbi_convert_iphone_png_to_rgb_threadSource · stb_image.odin:139
convert_iphone_png_to_rgb_thread :: proc "c" (flag_true_if_should_convert: b32) ---
failure_reason ¶C · stbi_failure_reasonSource · stb_image.odin:112
failure_reason :: proc "c" () -> cstring ---
get a VERY brief reason for failure NOT THREADSAFE
flip_vertically_on_write ¶C · stbi_flip_vertically_on_writeSource · stb_image_write.odin:35
flip_vertically_on_write :: proc "c" (flip_boolean: b32) ---
free_samplers ¶C · stbir_free_samplersSource · stb_image_resize2.odin:265
free_samplers :: proc "c" (resize: ^resizer) ---
hdr_to_ldr_gamma ¶C · stbi_hdr_to_ldr_gammaSource · stb_image.odin:101
hdr_to_ldr_gamma :: proc "c" (gamma: f32) ---
hdr_to_ldr_scale ¶C · stbi_hdr_to_ldr_scaleSource · stb_image.odin:102
hdr_to_ldr_scale :: proc "c" (scale: f32) ---
image_free ¶C · stbi_image_freeSource · stb_image.odin:115
image_free :: proc "c" (retval_from_load: rawptr) ---
free the loaded image -- this is just free()
info ¶C · stbi_infoSource · stb_image.odin:68
get image dimensions & components without fully decoding
info_from_callbacks ¶C · stbi_info_from_callbacksSource · stb_image.odin:119
info_from_callbacks :: proc "c" (clbk: ^Io_Callbacks, user: rawptr, x, y, comp: ^i32) -> i32 ---
info_from_file ¶C · stbi_info_from_fileSource · stb_image.odin:69
info_from_memory ¶C · stbi_info_from_memorySource · stb_image.odin:118
get image dimensions & components without fully decoding
is_16_bit ¶C · stbi_is_16_bitSource · stb_image.odin:71
is_16_bit_from_file ¶C · stbi_is_16_bit_from_fileSource · stb_image.odin:72
is_16_bit_from_memory ¶C · stbi_is_16_bit_from_memorySource · stb_image.odin:121
is_hdr ¶C · stbi_is_hdrSource · stb_image.odin:64
is_hdr_from_callbacks ¶C · stbi_is_hdr_from_callbacksSource · stb_image.odin:107
is_hdr_from_callbacks :: proc "c" (clbk: ^Io_Callbacks, user: rawptr) -> i32 ---
is_hdr_from_file ¶C · stbi_is_hdr_from_fileSource · stb_image.odin:65
is_hdr_from_memory ¶C · stbi_is_hdr_from_memorySource · stb_image.odin:108
ldr_to_hdr_gamma ¶C · stbi_ldr_to_hdr_gammaSource · stb_image.odin:104
ldr_to_hdr_gamma :: proc "c" (gamma: f32) ---
ldr_to_hdr_scale ¶C · stbi_ldr_to_hdr_scaleSource · stb_image.odin:105
ldr_to_hdr_scale :: proc "c" (scale: f32) ---
load ¶C · stbi_loadSource · stb_image.odin:47
load :: proc "c" ( filename: cstring, x, y, channels_in_file: ^i32, desired_channels: i32, ) -> [^]u8 ---
//////////////////////////////////
8-bits-per-channel interface
load_16 ¶C · stbi_load_16Source · stb_image.odin:54
load_16 :: proc "c" ( filename: cstring, x, y, channels_in_file: ^i32, desired_channels: i32, ) -> [^]u16 ---
//////////////////////////////////
16-bits-per-channel interface
load_16_from_callbacks ¶C · stbi_load_16_from_callbacksSource · stb_image.odin:92
load_16_from_callbacks :: proc "c" ( clbk: ^Io_Callbacks, x, y, channels_in_file: ^i32, desired_channels: i32, ) -> [^]u16 ---
load_16_from_file ¶C · stbi_load_16_from_fileSource · stb_image.odin:55
load_16_from_memory ¶C · stbi_load_16_from_memorySource · stb_image.odin:91
load_16_from_memory :: proc "c" ( buffer: [^]u8, len: i32, x, y, channels_in_file: ^i32, desired_channels: i32, ) -> [^]u16 ---
//////////////////////////////////
16-bits-per-channel interface
load_from_callbacks ¶C · stbi_load_from_callbacksSource · stb_image.odin:83
load_from_callbacks :: proc "c" ( clbk: ^Io_Callbacks, user: rawptr, x, y, channels_in_file: ^i32, desired_channels: i32, ) -> [^]u8 ---
load_from_file ¶C · stbi_load_from_fileSource · stb_image.odin:48
load_from_memory ¶C · stbi_load_from_memorySource · stb_image.odin:82
load_from_memory :: proc "c" ( buffer: [^]u8, len: i32, x, y, channels_in_file: ^i32, desired_channels: i32, ) -> [^]u8 ---
//////////////////////////////////
8-bits-per-channel interface
load_gif_from_memory ¶C · stbi_load_gif_from_memorySource · stb_image.odin:85
loadf ¶C · stbi_loadfSource · stb_image.odin:61
loadf :: proc "c" ( filename: cstring, x, y, channels_in_file: ^i32, desired_channels: i32, ) -> [^]f32 ---
//////////////////////////////////
float-per-channel interface
loadf_from_callbacks ¶C · stbi_loadf_from_callbacksSource · stb_image.odin:99
loadf_from_callbacks :: proc "c" ( clbk: ^Io_Callbacks, user: rawptr, x, y, channels_in_file: ^i32, desired_channels: i32, ) -> [^]f32 ---
loadf_from_file ¶C · stbi_loadf_from_fileSource · stb_image.odin:62
loadf_from_memory ¶C · stbi_loadf_from_memorySource · stb_image.odin:98
loadf_from_memory :: proc "c" ( buffer: [^]u8, len: i32, x, y, channels_in_file: ^i32, desired_channels: i32, ) -> [^]f32 ---
//////////////////////////////////
float-per-channel interface
resize ¶C · stbir_resizeSource · stb_image_resize2.odin:130
resize_extended ¶C · stbir_resize_extendedSource · stb_image_resize2.odin:268
Performs the resize synchronously on one thread. Returns 1 on success and 0 on failure.
resize_extended_split ¶C · stbir_resize_extended_splitSource · stb_image_resize2.odin:275
resize_float_linear ¶C · stbir_resize_float_linearSource · stb_image_resize2.odin:126
resize_init ¶C · stbir_resize_initSource · stb_image_resize2.odin:224
resize_init :: proc "c" ( resize: ^resizer, input_pixels: rawptr, input_w, input_h, input_stride_in_bytes: i64, output_pixels: rawptr, output_w, output_h, output_stride_in_bytes: i64, pixel_layout: pixel_layout, data_type: datatype, ) ---
You must ALWAYS call this on your resizer before any of the other calls. Strides may be 0.
resize_uint8_linear ¶C · stbir_resize_uint8_linearSource · stb_image_resize2.odin:122
resize_uint8_srgb ¶C · stbir_resize_uint8_srgbSource · stb_image_resize2.odin:118
set_buffer_ptrs ¶C · stbir_set_buffer_ptrsSource · stb_image_resize2.odin:233
set_datatypes ¶C · stbir_set_datatypesSource · stb_image_resize2.odin:230
These can be changed at any time after resize_init at no cost.
set_edgemodes ¶C · stbir_set_edgemodesSource · stb_image_resize2.odin:237
CLAMP by default
set_filter_callbacks ¶C · stbir_set_filter_callbacksSource · stb_image_resize2.odin:250
set_filter_callbacks :: proc "c" ( resize: ^resizer, horizontal_filter: kernel_callback, horizontal_support: support_callback, vertical_filter: kernel_callback, vertical_support: support_callback, ) -> i32 ---
The old float version of the above, for compatibility only.
set_filter_callbacks_new ¶C · stbir_set_filter_callbacks_newSource · stb_image_resize2.odin:245
set_filter_callbacks_new :: proc "c" ( resize: ^resizer, horizontal_filter: kernel_callback_new, horizontal_support: support_callback_new, horizontal_radius: radius_callback_new, vertical_filter: kernel_callback_new, vertical_support: support_callback_new, vertical_radius: radius_callback_new, ) -> i32 ---
Your own filters, per axis: a kernel callback and one of two ways to give its extent, a support or a radius
(giving both on one axis fails with 0; all nil keeps the built-in filter).
The kernel returns the weight at x in the filter's own pixels, centered on zero. The support returns the
radius in those same pixels. The radius callback is the alternative for kernels whose extent depends on the
scale; it returns the radius in input pixels.
set_filters ¶C · stbir_set_filtersSource · stb_image_resize2.odin:238
the default up/downsample filters otherwise
set_flip_vertically_on_load ¶C · stbi_set_flip_vertically_on_loadSource · stb_image.odin:133
set_flip_vertically_on_load :: proc "c" (flag_true_if_should_flip: i32) ---
flip the image vertically, so the first pixel in the output array is the bottom left
set_flip_vertically_on_load_thread ¶C · stbi_set_flip_vertically_on_load_threadSource · stb_image.odin:140
set_flip_vertically_on_load_thread :: proc "c" (flag_true_if_should_flip: b32) ---
set_input_subrect ¶C · stbir_set_input_subrectSource · stb_image_resize2.odin:255
sets the input sub-region; a region past the image is clipped to it
set_non_pm_alpha_speed_over_quality ¶C · stbir_set_non_pm_alpha_speed_over_qualitySource · stb_image_resize2.odin:261
set_non_pm_alpha_speed_over_quality :: proc "c" ( resize: ^resizer, non_pma_alpha_speed_over_quality: i32, ) -> i32 ---
When both input and output are non-premultiplied alpha, a slower but higher quality technique fills the RGB of zero-alpha pixels with something plausible. If you don't care about those areas, enabling this gives about a 25% speed-up for RGBA to RGBA resizes.
set_output_pixel_subrect ¶C · stbir_set_output_pixel_subrectSource · stb_image_resize2.odin:256
sets the output sub-region
set_pixel_callbacks ¶C · stbir_set_pixel_callbacksSource · stb_image_resize2.odin:231
set_pixel_callbacks :: proc "c" ( resize: ^resizer, input_cb: input_callback, output_cb: output_callback, ) ---
none by default
set_pixel_layouts ¶C · stbir_set_pixel_layoutsSource · stb_image_resize2.odin:236
set_pixel_layouts :: proc "c" ( resize: ^resizer, input_pixel_layout, output_pixel_layout: pixel_layout, ) -> i32 ---
Calling any of these triggers a sampler rebuild. They return 1 on success and 0 on failure.
set_pixel_subrect ¶C · stbir_set_pixel_subrectSource · stb_image_resize2.odin:254
sets both sub-regions (full regions by default)
set_unpremultiply_on_load ¶C · stbi_set_unpremultiply_on_loadSource · stb_image.odin:126
set_unpremultiply_on_load :: proc "c" (flag_true_if_should_unpremultiply: i32) ---
for image formats that explicitly notate that they have premultiplied alpha, we just return the colors as stored in the file. set this flag to force unpremultiplication. results are undefined if the unpremultiply overflow.
set_unpremultiply_on_load_thread ¶C · stbi_set_unpremultiply_on_load_threadSource · stb_image.odin:138
set_unpremultiply_on_load_thread :: proc "c" (flag_true_if_should_unpremultiply: b32) ---
as above, but only applies to images loaded on the thread that calls the function this function is only available if your compiler supports thread-local variables; calling it will fail to link if your compiler doesn't
set_user_data ¶C · stbir_set_user_dataSource · stb_image_resize2.odin:232
the resizer itself by default
write_bmp ¶C · stbi_write_bmpSource · stb_image_write.odin:42
write_bmp_to_func ¶C · stbi_write_bmp_to_funcSource · stb_image_write.odin:30
write_bmp_to_func :: proc "c" ( func: write_func, ctx: rawptr, w, h, comp: i32, data: rawptr, ) -> i32 ---
write_hdr ¶C · stbi_write_hdrSource · stb_image_write.odin:44
write_hdr_to_func ¶C · stbi_write_hdr_to_funcSource · stb_image_write.odin:32
write_hdr_to_func :: proc "c" ( func: write_func, ctx: rawptr, w, h, comp: i32, data: [^]f32, ) -> i32 ---
write_jpg ¶C · stbi_write_jpgSource · stb_image_write.odin:45
write_jpg_to_func ¶C · stbi_write_jpg_to_funcSource · stb_image_write.odin:33
write_png ¶C · stbi_write_pngSource · stb_image_write.odin:41
write_png_to_func ¶C · stbi_write_png_to_funcSource · stb_image_write.odin:29
write_tga ¶C · stbi_write_tgaSource · stb_image_write.odin:43
write_tga_to_func ¶C · stbi_write_tga_to_funcSource · stb_image_write.odin:31
write_tga_to_func :: proc "c" ( func: write_func, ctx: rawptr, w, h, comp: i32, data: rawptr, ) -> i32 ---
zlib_decode_buffer ¶C · stbi_zlib_decode_bufferSource · stb_image.odin:146
zlib_decode_malloc ¶C · stbi_zlib_decode_mallocSource · stb_image.odin:145
zlib_decode_malloc_guesssize ¶C · stbi_zlib_decode_malloc_guesssizeSource · stb_image.odin:143
zlib_decode_malloc_guesssize :: proc "c" ( buffer: [^]u8, len: i32, initial_size: i32, outlen: ^i32, ) -> [^]u8 ---
ZLIB client - used by PNG, available for other purposes
zlib_decode_malloc_guesssize_headerflag ¶C · stbi_zlib_decode_malloc_guesssize_headerflagSource · stb_image.odin:144
zlib_decode_noheader_buffer ¶C · stbi_zlib_decode_noheader_bufferSource · stb_image.odin:149
zlib_decode_noheader_malloc ¶C · stbi_zlib_decode_noheader_mallocSource · stb_image.odin:148
Procedure Groups
This section is empty.
Source Files
Generation Information
Generated with odin version dev-2026-11 (vendor "odin") Windows_amd64 @ 2026-11-02 00:06:06.977463700 +0000 UTC