[][src]Module stb::image

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_callbacks with a generic reader (anything that implements io::Read and io::Seek). So look for stbi_xyz_from_reader APIs instead of stbi_xyz_from_callbacks.
  • There is no Stdio version of the API since it is convenient enough to use stbi_xyz_from_reader API from Rust and there is no need to pay C string conversion overhead.
  • You can use stbi_no_FORMAT feature toggles to disable not needed image formats.

Structs

Data

Holds image memory allocated by stb and responsible for calling stbi_image_free once dropped.

Info

Enums

Channels

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).