Skip to content

MK_api.imgΒΆ

The img container class can be used to manipulate image files. e.g., to re-encode video frames or composite A/B images.

load( filename )
Fills the container with the contents of the given image file.
save( filename )
Saves the container to the given image file. The output format is selected by the filename extension.
get_w()
Returns the width in pixels of the current image.
get_h()
Returns the height in pixels of the current image.
get_num_channels()
Returns the channel count (1, 2, 3 or 4) of the current image.
create( w, h )
Allocates an empty rgb8 canvas of the given dimensions.
create_rgba( w, h )
Allocates an empty rgba8 canvas of the given dimensions.
to_rgb8()
Coerces the in-memory pixel format to plain rgb8. Use this after load() before put_image() when the source file is png16, tiff16, exr32f or any other non-rgb8 / rgba8 format.
to_rgba8()
Coerces the in-memory pixel format to plain rgba8.
clone( src )
Replaces the contents of this image with a copy of src.
crop( x, y, w, h )
Crops the image to the given rectangle.
resize( w, h )
Resamples the image to the given dimensions.
put_image( x, y, src )
Pastes src into this image at the given top-left coordinate.
fill( r, g, b )
Fills the image with the given 8-bit color.