dxConvertPixels
Client-side
Server-side
Shared
This function converts pixels from one format to another.
Syntax
string|false dxConvertPixels ( string pixels, string newFormat, [ int quality = 80 ] )Required arguments
- pixels: The pixels to convert the format of.
- newFormat: The new format required.
- plain
- png
- jpeg
Optional arguments
Note: when using optional arguments, you might need to supply all arguments before the one you wish to use.
- quality (default: 80): The quality of the returned pixels if the new format is
jpeg.
Returns
Returns a copy of the pixels in the new format, or false if invalid arguments were passed to the function.
- string|false: pixels
Code Examples
client
The code opens an image, read its pixels, convert the pixels to PNG, and then save it.
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)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