Ifĭesired_channels is non-zero, *channels_in_file has the number of components that would have been output otherwise. The number of components N is 'desired_channels' if desired_channels is non-zero, or *channels_in_file otherwise. There is no padding between image scanlines or between pixels, regardless ofįormat. The pixel data consists of *y scanlines of *x pixels, with each pixel consisting of N interleaved 8-bitĬomponents the first pixel pointed to is top-left-most in the image. The return value from an image loader is an 'unsigned char *' which points to the pixel data, or NULL on an allocation failure or if the image
There's premultiplied data (currently only happens in iPhone images, and only if iPhone convert-to-rgb processing is on). To enable this conversion, call convert_iphone_png_to_rgb(1).Ĭall set_unpremultiply_on_load(1) as well to force a divide per pixel to remove any premultiplied alpha *only* if the image file explicitly says We optionally support converting iPhone-formatted PNGs (which store premultiplied BGRA) back to RGB, even though they're internally encodedĭifferently. Stbi_is_hdr(char *filename) iPhone PNG support If you load LDR images through this interface, those images will be promoted to floating point values, run through the inverse of constantsįinally, given a filename (or an open file or memory block) containing image data, you can query for the "most appropriate" interface to use (that is,
(note, do not use inverse constants stbi_image will invert them appropriately).Īdditionally, there is a new, parallel interface for loading files as (linear) floats to preserve the full dynamic range:įloat *data = stbi_loadf(filename, &x, &y, &n, 0) You can still load any file through theĮxisting interface if you attempt to load an HDR file, it will be automatically remapped to LDR, assuming gamma 2.2 and an arbitrary scale factorĭefaulting to 1 both of these constants can be reconfigured through this interface:
Stb_image supports loading HDR images in general, and currently the Radiance. but 'n' will always be the number that it would have been if you said 0 replace '0' with '1'.'4' to force that many components per pixel x = width, y = height, n = # 8-bit components per pixel. Unsigned char *data = stbi_load(filename, &x, &y, &n, 0) SIMD acceleration on x86/圆4 (SSE2) and ARM (NEON)īasic usage (see HDR discussion below for HDR usage):.GIF (*desired_channels always reports as 4-channel)Īnimated GIF still needs a proper API, but here's one way to do it.PSD (composited view only, no extra channels, 8/16 bit-per-channel).TGA (not sure what subset, if a subset).JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib.Primarily of interest to game developers and other people who can avoid problematic images and only need the trivial interface. Native bindings to stb_image.h from the stb library.