MemoryFormat


Description:

[ CCode ( cprefix = "GDK_MEMORY_" , type_id = "gdk_memory_format_get_type ()" ) ]
public enum MemoryFormat

Describes formats that image data can have in memory.

It describes formats by listing the contents of the memory passed to it. So `GDK_MEMORY_A8R8G8B8` will be 1 byte (8 bits) of alpha, followed by a byte each of red, green and blue. It is not endian-dependent, so `CAIRO_FORMAT_ARGB32` is represented by different `GdkMemoryFormats` on architectures with different endiannesses.

A note on naming

The format names are roughly modelled after VkFormat. A name follows `GDK_MEMORY_<CHANNELS>_<DATA_TYPE>_<SUBSAMPLING> <PREMULTIPLIED>` where CHANNELS describe how the RGBA channels are layed out in memory, with an X denoting padding. DATA_TYPE is unsigned normalized integer if not present, or otherwise FLOAT. The optional SUBSAMPLING defines the subsampling method used. The optional ENDIAN term describes the endianness if it is not host-endian. Finally, an optional PREMULTIPLIED term indicates that the color channels are premultiplied with the alpha value, if it is omitted, the data is not premultiplied or there is no alpha channel.

The CHANNELS are given as a list of planes seperated by underscores where each plane is split into multiple elements describing one or more bytes of memory. Each element is given as the list of channels folowed by the amount of bits taken up.

So the fictional format `RGB565_A8_PREMULTIPLIED` would describe a format with 2 planes where the first plane is an unsigned 16 bit integer containing the RGB channels with 5, 6, and 5 bits respectively while the 2nd plane contains the alpha channel as an unisnged 8bit integer.


Namespace: Gdk
Package: gtk4

Content:

Enum values: