Skip to content

GIF Images

GIF methods allow you to decode, scale, and render GIF images (including animated GIFs) directly onto displays. Images are provided as Base64 encoded GIF data unless otherwise specified.

Method
decodeAndScaleGIF(base64GifData : string, targetWidth : number, targetHeight : number) : table
decodeGIF(base64GifData : string) : table
getGIFDimensions(base64GifData : string) : table
getGIFFrameInfo(base64GifData : string) : table
loadGIFFullscreen(displayId : DisplayID, gifData : string) : ()
loadGIFFrame(displayId : DisplayID, gifData : string, frameIndex : number, x : number, y : number, w : number, h : number) : ()
loadGIFRegion(displayId : DisplayID, gifBinaryData : string, x : number, y : number, w : number, h : number) : ()
loadGIFRegionBytes(displayId : DisplayID, base64GifData : string, x : number, y : number, w : number, h : number) : ()
stopGIF(displayId : DisplayID) : ()

Decodes a Base64 GIF image and scales it to the requested size.

Useful when you need image data before drawing.

Requires: base64GifData : string, targetWidth : number, targetHeight : number

Returns: Image data table.

local image = gpu.decodeAndScaleGIF(
base64GifData,
128,
128
)

Decodes a Base64 GIF image and returns its pixel data.

Requires: base64GifData : string

Returns: Image data table.

local image = gpu.decodeGIF(base64GifData)

Gets the dimensions of a GIF without fully decoding or rendering it.

Requires: base64GifData : string

Returns:

{
width,
height
}
local dims = gpu.getGIFDimensions(base64GifData)
print(dims.width, dims.height)

Gets information about the frames of an animated GIF.

Requires: base64GifData : string

Returns: Table containing frame information (such as frame count and per-frame data).

local info = gpu.getGIFFrameInfo(base64GifData)
print(info.frameCount)

Decodes a GIF image and fills the entire display with it.

Call updateDisplay afterwards to push the framebuffer.

Requires: DisplayID, gifData : string

gpu.loadGIFFullscreen(displayId, gifData)
gpu.updateDisplay(displayId)

Loads a single frame of an animated GIF into a specific region of a display.

Requires: DisplayID, gifData : string, frameIndex : number, x : number, y : number, w : number, h : number

gpu.loadGIFFrame(
displayId,
gifData,
1,
0,
0,
128,
128
)

Loads GIF binary data into a specific region of a display.

Useful for updating only part of the framebuffer.

Requires: DisplayID, gifBinaryData : string, x : number, y : number, w : number, h : number

gpu.loadGIFRegion(
displayId,
gifBinaryData,
0,
0,
100,
100
)

Loads a Base64 encoded GIF into a specific display region.

This is the Base64 version of loadGIFRegion.

Requires: DisplayID, base64GifData : string, x : number, y : number, w : number, h : number

gpu.loadGIFRegionBytes(
displayId,
base64GifData,
50,
50,
128,
128
)

Stops GIF playback on a display.

Requires: DisplayID

gpu.stopGIF(displayId)