lovr.data.newImage

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.

image = lovr.data.newImage(filename, flip)

Arguments

NameTypeDefaultDescription
filenamestringThe filename of the image to load.
flipbooleantrueWhether to vertically flip the image on load. This should be true for normal textures, and false for textures that are going to be used in a cubemap.

Returns

NameTypeDescription
imageImageThe new Image.

Create an Image with a given size and pixel format.

image = lovr.data.newImage(width, height, format, data)

Arguments

NameTypeDefaultDescription
widthnumberThe width of the texture.
heightnumberThe height of the texture.
formatTextureFormatrgbaThe format of the texture's pixels.
dataBlobnilRaw pixel values to use as the contents. If nil, the data will all be zero.

Returns

NameTypeDescription
imageImageThe new Image.

Clone an existing Image.

image = lovr.data.newImage(source)

Arguments

NameTypeDescription
sourceImageThe Image to clone.

Returns

NameTypeDescription
imageImageThe new Image.

Decode image data from a Blob.

image = lovr.data.newImage(blob, flip)

Arguments

NameTypeDefaultDescription
blobBlobThe Blob containing image data to decode.
flipbooleantrueWhether to vertically flip the image on load. This should be true for normal textures, and false for textures that are going to be used in a cubemap.

Returns

NameTypeDescription
imageImageThe new Image.

Notes

The supported image file formats are png, jpg, hdr, dds (DXT1, DXT3, DXT5), ktx, and astc.

Only 2D textures are supported for DXT/ASTC.

Currently textures loaded as KTX need to be in DXT/ASTC formats.

See also