libui
A portable GUI library for C
Loading...
Searching...
No Matches
uiImage Struct Reference

Description

A container for an image to be displayed on screen.

The container can hold multiple representations of the same image with the same aspect ratio but in different resolutions to support high-density displays.

Common image dimension scale factors are 1x and 2x. Providing higher density representations is entirely optional.

The system will automatically determine the correct image to render depending on the screen's pixel density.

uiImage only supports premultiplied 32-bit RGBA images.

No image file loading or image format conversion utilities are provided.

#include <ui.h>

Public Member Functions

void uiFreeImage (uiImage *i)
 Frees the image container and all associated resources.
 
void uiImageAppend (uiImage *i, void *pixels, int pixelWidth, int pixelHeight, int byteStride)
 Appends a new image representation.
 

Static Public Member Functions

uiImageuiNewImage (double width, double height)
 Creates a new image container.
 

Member Function Documentation

◆ uiFreeImage()

void uiFreeImage ( uiImage * i)

Frees the image container and all associated resources.

Parameters
iuiImage instance.

◆ uiImageAppend()

void uiImageAppend ( uiImage * i,
void * pixels,
int pixelWidth,
int pixelHeight,
int byteStride )

Appends a new image representation.

Parameters
iuiImage instance.
pixelsByte array of premultiplied pixels in [R G B A] order.
((uint8_t *) pixels)[0] equals the R of the first pixel, [3] the A of the first pixel.
pixels must be at least byteStride * pixelHeight bytes long.
Data is copied internally. Ownership is not transferred.
pixelWidthWidth in pixels.
pixelHeightHeight in pixels.
byteStrideNumber of bytes per row of the pixel array.
Todo

see if we either need the stride or can provide a way to get the OS-preferred stride (in cairo we do)

use const void * for const correctness

◆ uiNewImage()

uiImage * uiNewImage ( double width,
double height )
static

Creates a new image container.

Dimensions are measured in points. This is most commonly the pixel size of the 1x scaled image.

Parameters
widthWidth in points.
heightHeight in points.
Returns
A new uiImage instance.

The documentation for this struct was generated from the following file: