TextureData
A TextureData stores raw 2D pixel info for Texture
s. It has a width, height, and format. The TextureData can be initialized with the contents of an image file or it can be created with uninitialized contents. The supported image formats are png
, jpg
, hdr
, dds
, ktx
, and astc
.
Usually you can just use Textures, but TextureData can be useful if you want to manipulate individual pixels, load Textures in a background thread, or use the FFI to efficiently access the raw image data.
Constructors
lovr.data.newTextureData | Create a new TextureData. |
Canvas:newTextureData | Create a new TextureData from a Canvas texture. |
Methods
TextureData:getBlob | Get the bytes backing this TextureData as a `Blob`. |
TextureData:getDimensions | Get the dimensions of the TextureData. |
TextureData:encode | Encode the TextureData as png and write it to a file. |
TextureData:getFormat | Get the pixel format of the TextureData. |
TextureData:getHeight | Get the height of the TextureData. |
TextureData:paste | Copy pixels from another TextureData to this one. |
TextureData:getPixel | Get the value of a pixel of the TextureData. |
TextureData:setPixel | Set the value of a pixel of the TextureData. |
TextureData:getWidth | Get the width of the TextureData. |
See also
lovr.data