Stb_imageSourcetype 'kind buffer = ('a, 'b, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Array1.t constraint 'kind = ('a, 'b) Stdlib.Bigarray.kindbuffer simply is an alias to a bigarray with c_layout. The buffer type serves two purposes:
Two kind of pixel buffers are manipulated:
type 'kind t = private {width : int;height : int;channels : int;offset : int;stride : int;data : 'kind buffer;}A record describing an image. The buffer contains channels * width * height items, in this order:
channels itemswidth pixelsheight linesstride items between two lines.The pixel at coordinates (x, y) and in channel c is thus stored at index y * stride + x * channels + c in the buffer.
Load an 8-bit per channel image from a filename. If channels is specified, it has to be between 1 and 4 and the decoded image will be processed to have the requested number of channels.
Load a floating point channel image from a filename. See load for channels parameter.
Decode an 8-bit per channel image from a buffer. See load for channels parameter.
Decode a floating point channel image from a buffer. See load for channels parameter.
Functions are similar to the above one, except memory is not managed by OCaml GC. It has to be released explicitly with free_unmanaged function.
You get slightly faster load times, more deterministic memory use and more responsibility. Use at your own risk!
Generate one level of mipmap: downsample image half in each dimension. In mipmap imgin imgout: