Expand description
Image loading/decoding Rust API for image loading/decoding from file/memory: JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC. See https://github.com/nothings/stb/blob/master/stb_image.h
Primarily of interest to game developers and other people who can avoid problematic images and only need the trivial interface.
- JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib)
- PNG 1/2/4/8/16-bit-per-channel
- TGA (not sure what subset, if a subset)
- BMP non-1bpp, non-RLE
- PSD (composited view only, no extra channels, 8/16 bit-per-channel)
- GIF (*comp always reports as 4-channel)
- HDR (radiance rgbE format)
- PIC (Softimage PIC)
- PNM (PPM and PGM binary only)
Current limitations:
- No 12-bit-per-channel JPEG
- No JPEGs with arithmetic coding
- GIF always returns *comp=4
Rust implementation notes:
- The crate wraps
stbi_io_callbackswith a generic reader (anything that implementsio::Readandio::Seek). So look forstbi_xyz_from_readerAPIs instead ofstbi_xyz_from_callbacks. - There is no
Stdioversion of the API since it is convenient enough to usestbi_xyz_from_readerAPI from Rust and there is no need to pay C string conversion overhead. - You can use
stbi_no_FORMATfeature toggles to disable not needed image formats.
Structs§
- Data
- Holds image memory allocated by stb and responsible for calling
stbi_image_freeonce dropped. - Info
Enums§
Functions§
- stbi_
convert_ iphone_ png_ to_ rgb - By default we convert iphone-formatted PNGs back to RGB, even though they are internally
encoded differently. You can disable this conversion by calling
stbi_convert_iphone_png_to_rgb(false), in which case you will always just get the native iphone “format” through (which is BGR stored in RGB). - stbi_
hdr_ to_ ldr_ gamma - stbi_
hdr_ to_ ldr_ scale - stbi_
info_ from_ memory - Get image dimensions & components from a slice without fully decoding
- stbi_
info_ from_ reader - Get image dimensions & components from reader without fully decoding
- stbi_
is_ 16_ bit_ from_ memory - stbi_
is_ 16_ bit_ from_ reader - stbi_
ldr_ to_ hdr_ gamma - stbi_
ldr_ to_ hdr_ scale - stbi_
load_ 16_ from_ memory - 16-bits-per-channel interface, load image from memory
- stbi_
load_ 16_ from_ reader - stbi_
load_ from_ memory - stbi_
load_ from_ reader - 8-bits-per-channel interface, load image from reader
- stbi_
loadf_ from_ memory - stbi_
loadf_ from_ reader - stbi_
set_ flip_ vertically_ on_ load - Flip the image vertically, so the first pixel in the output array is the bottom left
- stbi_
set_ unpremultiply_ on_ load - Call
stbi_set_unpremultiply_on_load(true)to force a divide per pixel to remove any premultiplied alpha only if the image file explicitly says there’s premultiplied data (currently only happens in iPhone images, and only if iPhone convert-to-rgb processing is on).