Packed pixel format 2026-11-05
A packed pixel format stores the component fields or index for each pixel together in a single image plane, with successive pixels following one another in that plane. A planar pixel format instead separates component or bit planes. Packed does not necessarily mean one byte per pixel or the absence of row padding: the Linux frame-buffer API explicitly permits end-of-row padding in its packed storage type.[ref]
The Frame Buffer Device API in the Linux Kernel documentation. §2, FB_TYPE_PACKED_PIXELS, FB_TYPE_PLANES and line_length
Consider an original 16-bit encoding with 4-bit fields in the order red, green, blue, alpha from most significant to least significant:The bit fields for give . Extracting components by integer arithmetic givesThe same extraction can be implemented with bitwise operations. Declaring endianness is a separate step: this word occupies successive bytes
C5 A3 in little-endian storage, and A3 C5 in big-endian storage. A component order in a word does not by itself specify the byte sequence.If a row contains 100 of these two-byte pixels, its active data occupy 200 bytes. With framebuffer stride 208 bytes, the next row begins 208 bytes later, leaving eight padding bytes. A pixel-buffer consumer therefore needs the exact pixel format, dimensions and framebuffer stride, as well as any alpha channel convention and color space.
Pixel format 2026-11-05
A pixel format specifies how stored bits represent a pixel value: its components or table index, the allocation of bits to those components, and the applicable representation conventions. A complete image layout also needs dimensions and row organization, including framebuffer stride. The Linux frame-buffer API separates storage type from color interpretation and describes component offsets and lengths explicitly.[ref]
The Frame Buffer Device API in the Linux Kernel documentation. Sections2–4, types and visuals; bits_per_pixel and fb_bitfield offset/length
For an original packed pixel format, place red, green and blue codes in a 16-bit unsigned word , with widths 5, 6 and 5 bits respectively. Declare the red component to occupy bits15–11, green10–5 and blue4–0:These non-overlapping bit fields specify a particular encoding. Setting gives , or
0xF800 in hexadecimal. Knowing only “16 bits per pixel” would not identify those component positions.Endianness then controls how the word occupies byte-addressed computer memory. Little-endian storage of
0xF800 gives successive bytes 00 F8; big-endian storage gives F8 00. Reading the little-endian bytes as a big-endian word instead produces 0x00F8. Under the same declared component fields, that decodes to rather than . Bit significance in the word and byte order in memory are separate specifications.Bit allocation also limits representable component codes: the red and blue fields have 32 levels each, while green has 64. If normalized codes are defined as , and , their respective increments are , and . These are code increments, not a claim that emitted light varies linearly with the stored number. The RGB color model and an appropriate color space supply further interpretation.
Other formats can store an image lookup table index or include an alpha channel for transparency. The frame-buffer documentation likewise distinguishes pseudocolor indices from direct component fields.[ref]
The Frame Buffer Device API in the Linux Kernel documentation. Section2, FB_VISUAL_PSEUDOCOLOR and component-based visuals; section4, transparency and colorspace fields
Report the actual format alongside dimensions and stride when exchanging pixel buffers.