Texture:getPixels

Edit

Creates and returns a new Image object with the current pixels of the Texture. This function is very very slow because it stalls the CPU until the download is complete. It should only be used for debugging, non-interactive scripts, etc. For an asynchronous version that doesn't stall the CPU, see Texture:newReadback.

image = Texture:getPixels(x, y, layer, mipmap, width, height)

Arguments

NameTypeDefaultDescription
xnumber0 The x offset of the region to download.
ynumber0 The y offset of the region to download.
layernumber1 The index of the layer to download.
mipmapnumber1 The index of the mipmap level to download.
widthnumbernil The width of the pixel rectangle to download. If nil, the "rest" of the width will be used, based on the texture width and x offset.
heightnumbernil The height of the pixel rectangle to download. If nil, the "rest" of the height will be used, based on the texture height and y offset.

Returns

NameTypeDescription
imageImage The new image with the pixels.

Notes

The texture must have been created with the transfer usage.

Multisampled textures can not be read back.

It is not currently possible to read back a texture view.

See also