.. _stdlib_stbimage: ================================================ Image loading, writing, and resizing (stb_image) ================================================ .. das:module:: stbimage Low-level image I/O and resizing bindings for stb_image, stb_image_write, and stb_image_resize2. ++++++++++++ Enumerations ++++++++++++ .. _enum-stbimage-stbir_datatype: .. das:attribute:: stbir_datatype Pixel data type for resize operations. :Values: * **STBIR_TYPE_UINT8** = 0 - 8-bit unsigned integer. * **STBIR_TYPE_UINT8_SRGB** = 1 - 8-bit unsigned integer with sRGB gamma. * **STBIR_TYPE_UINT8_SRGB_ALPHA** = 2 - 8-bit unsigned integer with sRGB gamma and linear alpha. * **STBIR_TYPE_UINT16** = 3 - 16-bit unsigned integer. * **STBIR_TYPE_FLOAT** = 4 - 32-bit float. * **STBIR_TYPE_HALF_FLOAT** = 5 - 16-bit float (half precision). .. _enum-stbimage-stbir_edge: .. das:attribute:: stbir_edge Edge handling mode for resize operations. :Values: * **STBIR_EDGE_CLAMP** = 0 - Clamp to edge pixels. * **STBIR_EDGE_REFLECT** = 1 - Reflect at edges. * **STBIR_EDGE_WRAP** = 2 - Wrap around (tile). * **STBIR_EDGE_ZERO** = 3 - Use zero for out-of-bounds pixels. .. _enum-stbimage-stbir_filter: .. das:attribute:: stbir_filter Resampling filter for resize operations. :Values: * **STBIR_FILTER_DEFAULT** = 0 - Default filter (Catmull-Rom for downscale, cubic B-spline for upscale). * **STBIR_FILTER_BOX** = 1 - Box filter (nearest-neighbor averaging). * **STBIR_FILTER_TRIANGLE** = 2 - Triangle (bilinear) filter. * **STBIR_FILTER_CUBICBSPLINE** = 3 - Cubic B-spline filter. * **STBIR_FILTER_CATMULLROM** = 4 - Catmull-Rom filter. * **STBIR_FILTER_MITCHELL** = 5 - Mitchell-Netravali filter. * **STBIR_FILTER_POINT_SAMPLE** = 6 - Point sampling (nearest neighbor, no filtering). * **STBIR_FILTER_OTHER** = 7 - Reserved for custom filters. .. _enum-stbimage-stbir_pixel_layout: .. das:attribute:: stbir_pixel_layout Pixel channel layout for resize operations. :Values: * **STBIR_1CHANNEL** = 1 - Single channel. * **STBIR_2CHANNEL** = 2 - Two channels. * **STBIR_RGB** = 3 - RGB layout. * **STBIR_BGR** = 0 - BGR layout. * **STBIR_4CHANNEL** = 5 - Four channels. * **STBIR_RGBA** = 4 - RGBA layout. * **STBIR_BGRA** = 6 - BGRA layout. * **STBIR_ARGB** = 7 - ARGB layout. * **STBIR_ABGR** = 8 - ABGR layout. * **STBIR_RA** = 9 - Red-Alpha layout. * **STBIR_AR** = 10 - Alpha-Red layout. * **STBIR_RGBA_PM** = 11 - RGBA with premultiplied alpha. * **STBIR_BGRA_PM** = 12 - BGRA with premultiplied alpha. * **STBIR_ARGB_PM** = 13 - ARGB with premultiplied alpha. * **STBIR_ABGR_PM** = 14 - ABGR with premultiplied alpha. * **STBIR_RA_PM** = 15 - Red-Alpha with premultiplied alpha. * **STBIR_AR_PM** = 16 - Alpha-Red with premultiplied alpha. +++++++++++++ Image loading +++++++++++++ * :ref:`stbi_load (filename: string; x: int?; y: int?; comp: int?; req_comp: int) : uint8? ` * :ref:`stbi_load_16 (filename: string; x: int?; y: int?; comp: int?; req_comp: int) : uint16? ` * :ref:`stbi_load_16_from_memory (buffer: uint8 const?; len: int; x: int?; y: int?; comp: int?; req_comp: int) : uint16? ` * :ref:`stbi_load_from_memory (buffer: uint8 const?; len: int; x: int?; y: int?; comp: int?; req_comp: int) : uint8? ` * :ref:`stbi_load_gif_from_memory (buffer: uint8 const?; len: int; delays: int??; x: int?; y: int?; z: int?; comp: int?; req_comp: int) : uint8? ` * :ref:`stbi_loadf (filename: string; x: int?; y: int?; comp: int?; req_comp: int) : float? ` * :ref:`stbi_loadf_from_memory (buffer: uint8 const?; len: int; x: int?; y: int?; comp: int?; req_comp: int) : float? ` .. _function-stbimage_stbi_load_string_int_q__int_q__int_q__int: .. das:function:: stbi_load(filename: string; x: int?; y: int?; comp: int?; req_comp: int) : uint8? Load an image from file, returning pixel data as uint8. :Arguments: * **filename** : string implicit * **x** : int? implicit * **y** : int? implicit * **comp** : int? implicit * **req_comp** : int .. _function-stbimage_stbi_load_16_string_int_q__int_q__int_q__int: .. das:function:: stbi_load_16(filename: string; x: int?; y: int?; comp: int?; req_comp: int) : uint16? Load an image from file as 16-bit unsigned integer data. :Arguments: * **filename** : string implicit * **x** : int? implicit * **y** : int? implicit * **comp** : int? implicit * **req_comp** : int .. _function-stbimage_stbi_load_16_from_memory_uint8_const_q__int_int_q__int_q__int_q__int: .. das:function:: stbi_load_16_from_memory(buffer: uint8 const?; len: int; x: int?; y: int?; comp: int?; req_comp: int) : uint16? Load an image from a memory buffer as 16-bit unsigned integer data. :Arguments: * **buffer** : uint8? implicit * **len** : int * **x** : int? implicit * **y** : int? implicit * **comp** : int? implicit * **req_comp** : int .. _function-stbimage_stbi_load_from_memory_uint8_const_q__int_int_q__int_q__int_q__int: .. das:function:: stbi_load_from_memory(buffer: uint8 const?; len: int; x: int?; y: int?; comp: int?; req_comp: int) : uint8? Load an image from a memory buffer as uint8. :Arguments: * **buffer** : uint8? implicit * **len** : int * **x** : int? implicit * **y** : int? implicit * **comp** : int? implicit * **req_comp** : int .. _function-stbimage_stbi_load_gif_from_memory_uint8_const_q__int_int_q__q__int_q__int_q__int_q__int_q__int: .. das:function:: stbi_load_gif_from_memory(buffer: uint8 const?; len: int; delays: int??; x: int?; y: int?; z: int?; comp: int?; req_comp: int) : uint8? Load all frames of an animated GIF from a memory buffer. :Arguments: * **buffer** : uint8? implicit * **len** : int * **delays** : int?? implicit * **x** : int? implicit * **y** : int? implicit * **z** : int? implicit * **comp** : int? implicit * **req_comp** : int .. _function-stbimage_stbi_loadf_string_int_q__int_q__int_q__int: .. das:function:: stbi_loadf(filename: string; x: int?; y: int?; comp: int?; req_comp: int) : float? Load an image from file as HDR float data. :Arguments: * **filename** : string implicit * **x** : int? implicit * **y** : int? implicit * **comp** : int? implicit * **req_comp** : int .. _function-stbimage_stbi_loadf_from_memory_uint8_const_q__int_int_q__int_q__int_q__int: .. das:function:: stbi_loadf_from_memory(buffer: uint8 const?; len: int; x: int?; y: int?; comp: int?; req_comp: int) : float? Load an image from a memory buffer as HDR float data. :Arguments: * **buffer** : uint8? implicit * **len** : int * **x** : int? implicit * **y** : int? implicit * **comp** : int? implicit * **req_comp** : int ++++++++++ Image info ++++++++++ * :ref:`stbi_info (filename: string; x: int?; y: int?; comp: int?) : int ` * :ref:`stbi_info_from_memory (buffer: uint8 const?; len: int; x: int?; y: int?; comp: int?) : int ` * :ref:`stbi_is_16_bit (filename: string) : int ` * :ref:`stbi_is_16_bit_from_memory (buffer: uint8 const?; len: int) : int ` * :ref:`stbi_is_hdr (filename: string) : int ` * :ref:`stbi_is_hdr_from_memory (buffer: uint8 const?; len: int) : int ` .. _function-stbimage_stbi_info_string_int_q__int_q__int_q_: .. das:function:: stbi_info(filename: string; x: int?; y: int?; comp: int?) : int Query image dimensions and channel count from a file without loading pixel data. :Arguments: * **filename** : string implicit * **x** : int? implicit * **y** : int? implicit * **comp** : int? implicit .. _function-stbimage_stbi_info_from_memory_uint8_const_q__int_int_q__int_q__int_q_: .. das:function:: stbi_info_from_memory(buffer: uint8 const?; len: int; x: int?; y: int?; comp: int?) : int Query image dimensions and channel count from a memory buffer without decoding. :Arguments: * **buffer** : uint8? implicit * **len** : int * **x** : int? implicit * **y** : int? implicit * **comp** : int? implicit .. _function-stbimage_stbi_is_16_bit_string: .. das:function:: stbi_is_16_bit(filename: string) : int Check if a file contains 16-bit image data. :Arguments: * **filename** : string implicit .. _function-stbimage_stbi_is_16_bit_from_memory_uint8_const_q__int: .. das:function:: stbi_is_16_bit_from_memory(buffer: uint8 const?; len: int) : int Check if a memory buffer contains 16-bit image data. :Arguments: * **buffer** : uint8? implicit * **len** : int .. _function-stbimage_stbi_is_hdr_string: .. das:function:: stbi_is_hdr(filename: string) : int Check if a file contains HDR image data. :Arguments: * **filename** : string implicit .. _function-stbimage_stbi_is_hdr_from_memory_uint8_const_q__int: .. das:function:: stbi_is_hdr_from_memory(buffer: uint8 const?; len: int) : int Check if a memory buffer contains HDR image data. :Arguments: * **buffer** : uint8? implicit * **len** : int +++++++++++++++++ Memory management +++++++++++++++++ * :ref:`stbi_failure_reason () : string ` * :ref:`stbi_image_free (retval_from_stbi_load: void?) ` .. _function-stbimage_stbi_failure_reason: .. das:function:: stbi_failure_reason() : string Return a description of the last load failure. .. _function-stbimage_stbi_image_free_void_q_: .. das:function:: stbi_image_free(retval_from_stbi_load: void?) Free pixel data allocated by stbi_load and related functions. :Arguments: * **retval_from_stbi_load** : void? implicit +++++++++++++ Load settings +++++++++++++ * :ref:`stbi_convert_iphone_png_to_rgb (flag: int) ` * :ref:`stbi_set_flip_vertically_on_load (flag: int) ` * :ref:`stbi_set_unpremultiply_on_load (flag: int) ` .. _function-stbimage_stbi_convert_iphone_png_to_rgb_int: .. das:function:: stbi_convert_iphone_png_to_rgb(flag: int) Set whether to convert iPhone PNG format to standard RGB. :Arguments: * **flag** : int .. _function-stbimage_stbi_set_flip_vertically_on_load_int: .. das:function:: stbi_set_flip_vertically_on_load(flag: int) Set whether loaded images should be flipped vertically. :Arguments: * **flag** : int .. _function-stbimage_stbi_set_unpremultiply_on_load_int: .. das:function:: stbi_set_unpremultiply_on_load(flag: int) Set whether to unpremultiply alpha on load (iPhone PNG). :Arguments: * **flag** : int +++++++++++++++++++ HDR gamma and scale +++++++++++++++++++ * :ref:`stbi_hdr_to_ldr_gamma (gamma: float) ` * :ref:`stbi_hdr_to_ldr_scale (scale: float) ` * :ref:`stbi_ldr_to_hdr_gamma (gamma: float) ` * :ref:`stbi_ldr_to_hdr_scale (scale: float) ` .. _function-stbimage_stbi_hdr_to_ldr_gamma_float: .. das:function:: stbi_hdr_to_ldr_gamma(gamma: float) Set gamma value for HDR to LDR conversion. :Arguments: * **gamma** : float .. _function-stbimage_stbi_hdr_to_ldr_scale_float: .. das:function:: stbi_hdr_to_ldr_scale(scale: float) Set scale factor for HDR to LDR conversion. :Arguments: * **scale** : float .. _function-stbimage_stbi_ldr_to_hdr_gamma_float: .. das:function:: stbi_ldr_to_hdr_gamma(gamma: float) Set gamma value for LDR to HDR conversion. :Arguments: * **gamma** : float .. _function-stbimage_stbi_ldr_to_hdr_scale_float: .. das:function:: stbi_ldr_to_hdr_scale(scale: float) Set scale factor for LDR to HDR conversion. :Arguments: * **scale** : float ++++++++++++ File writing ++++++++++++ * :ref:`stbi_write_bmp (filename: string; x: int; y: int; comp: int; data: void?) : int ` * :ref:`stbi_write_hdr (filename: string; x: int; y: int; comp: int; data: float const?) : int ` * :ref:`stbi_write_jpg (filename: string; x: int; y: int; comp: int; data: void?; quality: int) : int ` * :ref:`stbi_write_png (filename: string; x: int; y: int; comp: int; data: void?; stride_bytes: int) : int ` * :ref:`stbi_write_tga (filename: string; x: int; y: int; comp: int; data: void?) : int ` .. _function-stbimage_stbi_write_bmp_string_int_int_int_void_q_: .. das:function:: stbi_write_bmp(filename: string; x: int; y: int; comp: int; data: void?) : int Write image data to a BMP file. :Arguments: * **filename** : string implicit * **x** : int * **y** : int * **comp** : int * **data** : void? implicit .. _function-stbimage_stbi_write_hdr_string_int_int_int_float_const_q_: .. das:function:: stbi_write_hdr(filename: string; x: int; y: int; comp: int; data: float const?) : int Write HDR float image data to an HDR file. :Arguments: * **filename** : string implicit * **x** : int * **y** : int * **comp** : int * **data** : float? implicit .. _function-stbimage_stbi_write_jpg_string_int_int_int_void_q__int: .. das:function:: stbi_write_jpg(filename: string; x: int; y: int; comp: int; data: void?; quality: int) : int Write image data to a JPEG file with specified quality. :Arguments: * **filename** : string implicit * **x** : int * **y** : int * **comp** : int * **data** : void? implicit * **quality** : int .. _function-stbimage_stbi_write_png_string_int_int_int_void_q__int: .. das:function:: stbi_write_png(filename: string; x: int; y: int; comp: int; data: void?; stride_bytes: int) : int Write image data to a PNG file. :Arguments: * **filename** : string implicit * **x** : int * **y** : int * **comp** : int * **data** : void? implicit * **stride_bytes** : int .. _function-stbimage_stbi_write_tga_string_int_int_int_void_q_: .. das:function:: stbi_write_tga(filename: string; x: int; y: int; comp: int; data: void?) : int Write image data to a TGA file. :Arguments: * **filename** : string implicit * **x** : int * **y** : int * **comp** : int * **data** : void? implicit +++++++++++++++ Write to memory +++++++++++++++ * :ref:`stbi_write_bmp_to_memory (x: int; y: int; comp: int; data: void?; block: block\<(array\#):void\>) ` * :ref:`stbi_write_jpg_to_memory (x: int; y: int; comp: int; data: void?; quality: int; block: block\<(array\#):void\>) ` * :ref:`stbi_write_png_to_memory (x: int; y: int; comp: int; data: void?; stride_bytes: int; block: block\<(array\#):void\>) ` * :ref:`stbi_write_tga_to_memory (x: int; y: int; comp: int; data: void?; block: block\<(array\#):void\>) ` .. _function-stbimage_stbi_write_bmp_to_memory_int_int_int_void_q__block_ls_array_ls_uint8_gr__hh__c_void_gr_: .. das:function:: stbi_write_bmp_to_memory(x: int; y: int; comp: int; data: void?; block: block<(array#):void>) Encode image data as BMP to a memory buffer. :Arguments: * **x** : int * **y** : int * **comp** : int * **data** : void? implicit * **block** : block<(array\ #):void> implicit .. _function-stbimage_stbi_write_jpg_to_memory_int_int_int_void_q__int_block_ls_array_ls_uint8_gr__hh__c_void_gr_: .. das:function:: stbi_write_jpg_to_memory(x: int; y: int; comp: int; data: void?; quality: int; block: block<(array#):void>) Encode image data as JPEG to a memory buffer. :Arguments: * **x** : int * **y** : int * **comp** : int * **data** : void? implicit * **quality** : int * **block** : block<(array\ #):void> implicit .. _function-stbimage_stbi_write_png_to_memory_int_int_int_void_q__int_block_ls_array_ls_uint8_gr__hh__c_void_gr_: .. das:function:: stbi_write_png_to_memory(x: int; y: int; comp: int; data: void?; stride_bytes: int; block: block<(array#):void>) Encode image data as PNG to a memory buffer. :Arguments: * **x** : int * **y** : int * **comp** : int * **data** : void? implicit * **stride_bytes** : int * **block** : block<(array\ #):void> implicit .. _function-stbimage_stbi_write_tga_to_memory_int_int_int_void_q__block_ls_array_ls_uint8_gr__hh__c_void_gr_: .. das:function:: stbi_write_tga_to_memory(x: int; y: int; comp: int; data: void?; block: block<(array#):void>) Encode image data as TGA to a memory buffer. :Arguments: * **x** : int * **y** : int * **comp** : int * **data** : void? implicit * **block** : block<(array\ #):void> implicit ++++++++++++++ Write settings ++++++++++++++ * :ref:`stbi_flip_vertically_on_write (flag: int) ` * :ref:`stbi_write_get_force_png_filter () : int ` * :ref:`stbi_write_get_png_compression_level () : int ` * :ref:`stbi_write_get_tga_with_rle () : int ` * :ref:`stbi_write_set_force_png_filter (filter: int) ` * :ref:`stbi_write_set_png_compression_level (level: int) ` * :ref:`stbi_write_set_tga_with_rle (rle: int) ` .. _function-stbimage_stbi_flip_vertically_on_write_int: .. das:function:: stbi_flip_vertically_on_write(flag: int) Set whether to flip images vertically when writing. :Arguments: * **flag** : int .. _function-stbimage_stbi_write_get_force_png_filter: .. das:function:: stbi_write_get_force_png_filter() : int Get current PNG filter mode setting. .. _function-stbimage_stbi_write_get_png_compression_level: .. das:function:: stbi_write_get_png_compression_level() : int Get current PNG compression level. .. _function-stbimage_stbi_write_get_tga_with_rle: .. das:function:: stbi_write_get_tga_with_rle() : int Get current TGA RLE compression setting. .. _function-stbimage_stbi_write_set_force_png_filter_int: .. das:function:: stbi_write_set_force_png_filter(filter: int) Force a specific PNG filter mode (-1 for auto). :Arguments: * **filter** : int .. _function-stbimage_stbi_write_set_png_compression_level_int: .. das:function:: stbi_write_set_png_compression_level(level: int) Set PNG compression level (default 8). :Arguments: * **level** : int .. _function-stbimage_stbi_write_set_tga_with_rle_int: .. das:function:: stbi_write_set_tga_with_rle(rle: int) Set whether TGA files use RLE compression. :Arguments: * **rle** : int ++++++++++++++ Image resizing ++++++++++++++ * :ref:`stbir_resize (input_pixels: void?; input_w: int; input_h: int; input_stride_in_bytes: int; output_pixels: void?; output_w: int; output_h: int; output_stride_in_bytes: int; pixel_layout: stbir_pixel_layout; data_type: stbir_datatype; edge: stbir_edge; filter: stbir_filter) : void? ` * :ref:`stbir_resize_float_linear (input_pixels: float const?; input_w: int; input_h: int; input_stride_in_bytes: int; output_pixels: float?; output_w: int; output_h: int; output_stride_in_bytes: int; pixel_type: stbir_pixel_layout) : float? ` * :ref:`stbir_resize_uint8_linear (input_pixels: uint8 const?; input_w: int; input_h: int; input_stride_in_bytes: int; output_pixels: uint8?; output_w: int; output_h: int; output_stride_in_bytes: int; pixel_type: stbir_pixel_layout) : uint8? ` * :ref:`stbir_resize_uint8_srgb (input_pixels: uint8 const?; input_w: int; input_h: int; input_stride_in_bytes: int; output_pixels: uint8?; output_w: int; output_h: int; output_stride_in_bytes: int; pixel_type: stbir_pixel_layout) : uint8? ` .. _function-stbimage_stbir_resize_void_q__int_int_int_void_q__int_int_int_stbir_pixel_layout_stbir_datatype_stbir_edge_stbir_filter: .. das:function:: stbir_resize(input_pixels: void?; input_w: int; input_h: int; input_stride_in_bytes: int; output_pixels: void?; output_w: int; output_h: int; output_stride_in_bytes: int; pixel_layout: stbir_pixel_layout; data_type: stbir_datatype; edge: stbir_edge; filter: stbir_filter) : void? Resize image with full control over data type, layout, edge mode, and filter. :Arguments: * **input_pixels** : void? implicit * **input_w** : int * **input_h** : int * **input_stride_in_bytes** : int * **output_pixels** : void? implicit * **output_w** : int * **output_h** : int * **output_stride_in_bytes** : int * **pixel_layout** : :ref:`stbir_pixel_layout ` * **data_type** : :ref:`stbir_datatype ` * **edge** : :ref:`stbir_edge ` * **filter** : :ref:`stbir_filter ` .. _function-stbimage_stbir_resize_float_linear_float_const_q__int_int_int_float_q__int_int_int_stbir_pixel_layout: .. das:function:: stbir_resize_float_linear(input_pixels: float const?; input_w: int; input_h: int; input_stride_in_bytes: int; output_pixels: float?; output_w: int; output_h: int; output_stride_in_bytes: int; pixel_type: stbir_pixel_layout) : float? Resize a float image in linear color space. :Arguments: * **input_pixels** : float? implicit * **input_w** : int * **input_h** : int * **input_stride_in_bytes** : int * **output_pixels** : float? implicit * **output_w** : int * **output_h** : int * **output_stride_in_bytes** : int * **pixel_type** : :ref:`stbir_pixel_layout ` .. _function-stbimage_stbir_resize_uint8_linear_uint8_const_q__int_int_int_uint8_q__int_int_int_stbir_pixel_layout: .. das:function:: stbir_resize_uint8_linear(input_pixels: uint8 const?; input_w: int; input_h: int; input_stride_in_bytes: int; output_pixels: uint8?; output_w: int; output_h: int; output_stride_in_bytes: int; pixel_type: stbir_pixel_layout) : uint8? Resize a uint8 image in linear color space. :Arguments: * **input_pixels** : uint8? implicit * **input_w** : int * **input_h** : int * **input_stride_in_bytes** : int * **output_pixels** : uint8? implicit * **output_w** : int * **output_h** : int * **output_stride_in_bytes** : int * **pixel_type** : :ref:`stbir_pixel_layout ` .. _function-stbimage_stbir_resize_uint8_srgb_uint8_const_q__int_int_int_uint8_q__int_int_int_stbir_pixel_layout: .. das:function:: stbir_resize_uint8_srgb(input_pixels: uint8 const?; input_w: int; input_h: int; input_stride_in_bytes: int; output_pixels: uint8?; output_w: int; output_h: int; output_stride_in_bytes: int; pixel_type: stbir_pixel_layout) : uint8? Resize a uint8 image with sRGB gamma correction. :Arguments: * **input_pixels** : uint8? implicit * **input_w** : int * **input_h** : int * **input_stride_in_bytes** : int * **output_pixels** : uint8? implicit * **output_w** : int * **output_h** : int * **output_stride_in_bytes** : int * **pixel_type** : :ref:`stbir_pixel_layout `