dxConvertPixels
Client
Converts an image held in a string to another format, in the background, and hands the result to a function.
bool dxConvertPixels(string pixels, string format, function callback [, int quality = 80])
Parameters
| Name | Type | Description |
|---|---|---|
| pixels | string | The pixels. |
| format | string | Target format: plain, png or jpeg. |
| quality | int | jpeg quality, from 0 to 100.default 80 |
| callback | function | Receives the converted pixels, or false when the conversion failed. |
Returns
true when the conversion started. false when the source format was not recognised or the conversion is to or from dds.
Example
local target = dxCreateRenderTarget(256, 256)
dxGetTexturePixels(target, function(pixels)
if not pixels then return end
dxConvertPixels(pixels, "jpeg", 90, function(jpeg)
if jpeg then
local file = fileCreate("snapshot.jpg")
fileWrite(file, jpeg)
fileClose(file)
end
end)
end)Coming from MTAMTA returns the result right away. MYMP hands it to a function, since the conversion runs on a worker thread.