M MY Multiplayer: Wiki
Side
Kind

dxSetTexturePixels

Client

Writes pixels into a texture made by a script or into a render target.

bool dxSetTexturePixels(texture texture, string pixels [, int x, y = 0, 0, int width, height = 0, 0])

Parameters

NameTypeDescription
texturetextureA texture from engineCreateTexture or a render target.
pixelsstringThe pixels in plain.
x, yintTop-left corner of the area written, in pixels. A vec2 also works.default 0, 0
width, heightintSize of the area written. With a height of 0, the whole image is written. A vec2 also works.default 0, 0

Returns

true when the write was done or scheduled, false when the image holds no pixels (a screen source, dui or txd texture) or the pixels are not plain.

A leading number (MTA's surface index) is accepted and ignored. If the image is still loading, the write happens once it is ready. plain pixels are 4 bytes per pixel (blue, green, red, alpha), row by row, followed by the width and the height in 2 bytes each.

Example

local tex = engineCreateTexture(64, 64)

dxGetTexturePixels(tex, function(pixels)
    if not pixels then return end
    for x = 0, 63 do
        dxSetPixelColor(pixels, x, 32, 255, 0, 0)
    end
    dxSetTexturePixels(tex, pixels)
end)

See also