dxConvertPixels | Multi Theft Auto: Wiki Skip to content

dxConvertPixels

Client-side
Server-side
Shared

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function converts pixels from one format to another.

Syntax

string dxConvertPixels ( string pixels, string newFormat, [ int quality = 80 ] )
Required Arguments
  • pixels: MISSING_PARAM_DESC
  • newFormat: MISSING_PARAM_DESC
Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.

  • quality (default: 80): MISSING_PARAM_DESC

Returns

  • string: value

Returns a copy of the pixels in the new format, or false if invalid arguments were passed to the function.

Code Examples

shared

The code opens an image, read its pixels, convert the pixels to PNG, and then save it. (You can usethisimage to test.)

addEventHandler('onClientResourceStart', resourceRoot, function()
local img = fileOpen('img.jpg')
local pixels = fileRead(img, fileGetSize(img))
local pngPixels = dxConvertPixels(pixels, 'png')
local newImg = fileCreate('img.png')
fileWrite(newImg, pngPixels)
fileClose(newImg)
fileClose(img)
end)