Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Image API

Images are like textures, but stored on the CPU. Images can be loaded and parsed from image files like .png and .jpg, and their contents can be manipulated by indexing into the buffer directly or using the many methods on the Image struct to draw shapes.

Unlike when GPU rendering, working with an Image requires you to use the ColorU8 type, which uses u8 values for (r,g,b,a), that range from 0 to 255, where white is (255,255,255,255). ColorU8 can be converted to Color and vice versa with .to_color and .to_color_u8.

An image can be uploaded to a GPU texture with SgeTexture::from_enginen_image and a GPU texture can be downloaded to an image with texture.download_to_image().


See: image module