PNG Images
PNG methods allow you to decode, scale, and render PNG images directly onto displays. Images are provided as Base64 encoded PNG data unless otherwise specified.
Methods
Section titled “Methods”decodeAndScalePNG
Section titled “decodeAndScalePNG”Decodes a Base64 PNG image and scales it to the requested size.
Useful when you need image data before drawing.
Requires: base64PngData : string, targetWidth : number, targetHeight : number
Returns: Image data table.
Example
Section titled “Example”local image = gpu.decodeAndScalePNG( base64PngData, 128, 128)decodePNG
Section titled “decodePNG”Decodes a Base64 PNG image and returns its pixel data.
Requires: base64PngData : string
Returns: Image data table.
Example
Section titled “Example”local image = gpu.decodePNG(base64PngData)getPNGDimensions
Section titled “getPNGDimensions”Gets the dimensions of a PNG without fully decoding or rendering it.
Requires: base64PngData : string
Returns:
{ width, height}Example
Section titled “Example”local dims = gpu.getPNGDimensions(base64PngData)
print(dims.width, dims.height)loadPNGFullscreen
Section titled “loadPNGFullscreen”Decodes a PNG image and fills the entire display with it.
Call updateDisplay afterwards to push the framebuffer.
Requires: DisplayID, base64PngData : string
Example
Section titled “Example”gpu.loadPNGFullscreen(displayId, base64PngData)gpu.updateDisplay(displayId)loadPNGRegion
Section titled “loadPNGRegion”Loads PNG binary data into a specific region of a display.
Useful for updating only part of the framebuffer.
Requires: DisplayID, pngBinaryData : string, x : number, y : number, w : number, h : number
Example
Section titled “Example”gpu.loadPNGRegion( displayId, pngBinaryData, 0, 0, 100, 100)loadPNGRegionBytes
Section titled “loadPNGRegionBytes”Loads a Base64 encoded PNG into a specific display region.
This is the Base64 version of loadPNGRegion.
Requires: DisplayID, base64PngData : string, x : number, y : number, w : number, h : number
Example
Section titled “Example”gpu.loadPNGRegionBytes( displayId, base64PngData, 50, 50, 128, 128)