lovr.data.newImage
EditCreates 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
Name | Type | Default | Description |
filename | string | The filename of the image to load. | |
flip | boolean | true | Whether 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
Name | Type | Description |
image | Image | The new Image. |
Create an Image with a given size and pixel format.
Arguments
Name | Type | Default | Description |
width | number | The width of the texture. | |
height | number | The height of the texture. | |
format | TextureFormat | rgba8 | The format of the texture's pixels. |
data | Blob | nil |
Raw pixel values to use as the contents. If nil , the data will all be zero.
|
Returns
Name | Type | Description |
image | Image | The new Image. |
Clone an existing Image.
Arguments
Name | Type | Description |
source | Image | The Image to clone. |
Returns
Name | Type | Description |
image | Image | The new Image. |
Decode image data from a Blob.
Arguments
Name | Type | Default | Description |
blob | Blob | The Blob containing image data to decode. | |
flip | boolean | true | Whether 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
Name | Type | Description |
image | Image | The 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
lovr.data