dxGetTexturePixels
Client-side
Server-side
Shared
Pair: dxSetTexturePixels
Updated in 1.6.0-9.22188
Tip
By default the pixels from the whole texture is returned. To get only a portion of the texture, define a rectangular area using all four of these optional arguments: x, y, width, height.
Note
- This function is slow and not something you want to be doing once a frame.
- It is slower when reading pixels from a render target or screen source.
- Is very slow indeed if the texture format is not
argb(unless the nativeddsformat is used with correct options).
Important
If the user has not enabled screen uploading in the settings, the function will use a 32x32 empty texture as a basis.
OOP Syntax Help! I don't understand this!
- Method:texture:getPixels(...)
Syntax
string|false dxGetTexturePixels ( [ int surfaceIndex = 0 ], texture texture, [ string pixelsFormat = "plain", string textureFormat = "unknown" ], bool mipmaps, [ int x = 0, int y = 0, int width = 0, int height = 0 ] )Required Arguments
- texture: The texture element to get the pixels from.
- mipmaps: true to create a mip-map chain for
ddspixels so the texture looks good when drawn at various sizes.
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.
- surfaceIndex (default: 0): Desired slice to get if the texture is a volume texture, or desired face to get if the texture is a cube map. (Cube map faces: 0=+X 1=-X 2=+Y 3=-Y 4=+Z 5=-Z)
- pixelsFormat (default: "plain"): Pixels format.
- plain
- png
- jpeg
- dds
- textureFormat (default: "unknown"): A string representing the desired texture format. Use
unkownto determine automatically based on texture format.- argb: RGB uncompressed 32 bit color (default).
- rgb: RGB uncompressed 16-bit RGB color format. Uses 5 bits for red, 6 bits for green, and 5 bits for blue.
- xrgb: RGB Uncompressed 32-bit RGB color format without alpha. Each pixel uses 8 bits for red, green, and blue. The highest 8 bits are unused (padding) and should be ignored.
- dxt1: DXT1 compressed - Can take a fraction of a second longer to load (unless the file is already a DXT1 .dds). Uses 8 times less video memory than ARGB and can speed up drawing. Quality not as good as ARGB. It supports alpha blending, but it can only be on or off, that is: either 0 or 255.
- dxt3: DXT3 compressed - Can take a fraction of a second longer to load (unless the file is already a DXT3 .dds). Uses 4 times less video memory than ARGB and can speed up drawing. Quality slightly better than DXT1 and supports crisp alpha blending.
- dxt5: DXT5 compressed - Can take a fraction of a second longer to load (unless the file is already a DXT5 .dds). Uses 4 times less video memory than ARGB and can speed up drawing. Quality slightly better than DXT1 and supports smooth alpha blending.
- intz: Depth-stencil texture format used for sampling depth buffers in shaders.
- df24: 24-bit depth buffer format with optional stencil support, exposed as a texture.
- df16: 16-bit depth buffer format exposed as a texture.
- rawz: Raw depth texture format providing direct access to depth buffer values.
- x (default: 0): Rectangle left position.
- y (default: 0): Rectangle top position.
- width (default: 0): Rectangle width.
- height (default: 0): Rectangle height.
Returns
- string|false: pixels
Returns pixels string if successful, false if invalid arguments were passed to the function.
Code Examples
client
local mtaLogo = dxCreateTexture("mta-logo.png")outputChatBox("MTA logo pixels is: "..dxGetTexturePixels(mtaLogo))See Also
Drawing Functions
- dxConvertPixels
- dxCreateFont
- dxCreateRenderTargetUpdated
- dxCreateScreenSource
- dxCreateShader
- dxCreateTextureUpdated
- dxDrawCircle
- dxDrawImage
- dxDrawImageSection
- dxDrawLine
- dxDrawLine3D
- dxDrawMaterialLine3D
- dxDrawMaterialPrimitive
- dxDrawMaterialPrimitive3D
- dxDrawMaterialSectionLine3D
- dxDrawModel3DNew
- dxDrawPrimitive
- dxDrawPrimitive3D
- dxDrawRectangle
- dxDrawText
- dxDrawWiredSphere
- dxGetBlendMode
- dxGetFontHeight
- dxGetMaterialSize
- dxGetPixelColor
- dxGetPixelsFormat
- dxGetPixelsSize
- dxGetStatusUpdated
- dxGetTextSize
- dxGetTexturePixelsUpdated
- dxGetTextWidth
- dxIsAspectRatioAdjustmentEnabled
- dxSetAspectRatioAdjustmentEnabled
- dxSetBlendMode
- dxSetPixelColor
- dxSetRenderTarget
- dxSetShaderTessellation
- dxSetShaderTransform
- dxSetShaderValue
- dxSetTestMode
- dxSetTextureEdge
- dxSetTexturePixels
- dxUpdateScreenSource