lovr.data.newImage

Edit

Creates a new Image. Image data can be loaded and decoded from an image file, or a raw block of pixels with a specified width, height, and format can be created.





Load image data from a file.

Arguments

NameTypeDescription
filenamestring The filename of the image to load.

Returns

NameTypeDescription
imageImage The new Image.

Create an Image with a given size and pixel format.

Arguments

NameTypeDefaultDescription
widthnumber The width of the texture.
heightnumber The height of the texture.
formatTextureFormatrgba8 The format of the texture's pixels.
dataBlobnil Raw pixel values to use as the contents. If nil, the data will all be zero.

Returns

NameTypeDescription
imageImage The new Image.

Clone an existing Image.

Arguments

NameTypeDescription
sourceImage The Image to clone.

Returns

NameTypeDescription
imageImage The new Image.

Decode image data from a Blob.

Arguments

NameTypeDescription
blobBlob The Blob containing image data to decode.

Returns

NameTypeDescription
imageImage The new Image.

Notes

The supported image file formats are png, jpg, hdr, dds, ktx1, ktx2, and astc.

DDS and KTX files can contain cubemaps and array textures, in any of the texture formats LÖVR supports.

See also