An image element is a general-purpose pixel canvas that lives in the LWXGL element list. Each image is backed by a flat array of palette indices (one byte per pixel, values 0–15) and a correspondingDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/DRESSedAlarm184/LWXGL/llms.txt
Use this file to discover all available pages before exploring further.
XPixmap. You write pixel data by modifying the array returned by GetImageData, then call UpdateImage to push changes to the GPU-side pixmap. Only pixels that differ from the previous uploaded frame are retransferred, keeping updates efficient even for large canvases.
Image elements also support an optional bitmap font engine — install a font with SetImageFont and draw multi-line text directly into the pixel buffer with DrawString, independent of the global X11 font.
CreateImage
XImage, a pixel data buffer, a previous-frame shadow buffer (used for dirty-region detection), and an XPixmap of the same dimensions. All buffers are zero-initialized (palette index 0, i.e. black).
Unique element ID.
X coordinate of the image’s top-left corner within the window, in pixels.
Y coordinate of the image’s top-left corner within the window, in pixels.
Width in pixels. If
w <= 0, the actual width is computed as (back_buffer_width - x + w), which lets you express “fill to the right edge minus an optional margin”. For example, w = 0 fills exactly to the right edge of the back-buffer.Height in pixels. The same edge-relative rule applies: if
h <= 0, the height is (back_buffer_height - y + h).GetImageData
width × height bytes stored in row-major order: pixel at (px, py) is at data[py * width + px]. Each byte is a palette index in the range 0–15.
ID of an existing image element.
UpdateImage to commit the changes.
UpdateImage
XImage, then calls XPutImage to upload the updated XImage to the element’s XPixmap. If no pixels changed, no Xlib calls are made.
ID of the image element to synchronize.
ClearImage
c using memset. Does not call UpdateImage — you must call UpdateImage afterwards to make the clear visible on screen.
ID of the image element to clear.
Palette index (0–15) to fill every pixel with. Use
CLR_BLACK (0) to zero out the buffer.SetImageFont
DrawString. The font data is copied internally, so the font pointer can be freed after this call returns.
ID of the image element.
Pointer to the font bitmap data. The buffer must be exactly
256 * h bytes. The layout is one entry per ASCII character code (0–255), each entry being h bytes. Each byte represents one horizontal row of 8 pixels: bit 7 (MSB) is the leftmost pixel and bit 0 (LSB) is the rightmost pixel.Height of a single character in pixels (number of rows per glyph). Each character is implicitly 8 pixels wide (one byte per row), but
DrawString advances the cursor by 9 pixels horizontally to add one pixel of spacing between characters.DrawString
SetImageFont. Pixels that fall outside the image bounds are clipped silently. The background is not cleared — only set pixels are written.
ID of the image element. Must have a font installed via
SetImageFont.X coordinate (in image-local pixels) of the top-left of the first character.
Y coordinate (in image-local pixels) of the top of the first character row.
Null-terminated string to render. Newline characters (
'\n', ASCII 10) advance y by font_height and reset x to the original starting column.Palette index (0–15) used for every set pixel of the rendered glyphs.
ApplyPixelFunc
f(px, py, current_index) % 16. The function is called in row-major order. After this call you must call UpdateImage to push the results to the pixmap.
ID of the image element.
Transform function. Receives the pixel’s column (
x), row (y), and current palette index (color). The return value modulo 16 becomes the new palette index.RedrawAllImages
UpdateImage call by resetting all shadow (previous-frame) buffer bytes to 255 (an invalid palette index), ensuring the dirty-detection logic marks every pixel as changed. This is necessary after calling PaletteModify to make color changes visible in already-uploaded image content.
RedrawAllImages is called automatically by PaletteModify when its redraw parameter is non-zero.