Bit field 2026-11-05
A bit field assigns a selected group of bits within a stored value to a particular component or meaning. For a contiguous field, specify its width , starting position counted from the least significant bit, and interpretation. In a pixel format, separate bit fields can hold red, green and blue component codes. The Linux frame-buffer interface describes such fields with explicit offset and length members.[ref]
For a nonnegative integer word , the unsigned value of the field is
In a language with the usual unsigned bitwise operations, this corresponds to shifting right by and applying bitwise AND with .
For an original eight-bit example, let , written 0xB5 or binary 10110101. Select three bits beginning at position 4, so the field consists of bits 6–4. Extraction gives
The field's bits are 011. To replace them by value 6, clear the field with mask 0x70, then insert 6 << 4. Restricted to eight-bit words, the calculation is
The other five bits are unchanged. The range specifies what fits in an unsigned field.
A language-level bit-field declaration is a related abstraction, but its physical placement follows that language and implementation. In the C programming language, unsigned int code : 3; declares a three-bit field; C11 leaves allocation order within a storage unit implementation-defined and the storage unit's alignment unspecified.[ref] Such a declaration alone therefore does not specify a portable external byte sequence. An explicit layout must also state the relevant endianness and storage rules.
Bit plane 2026-11-05
A bit plane collects one fixed bit position from every integer sample of a digital image. For an unsigned -bit sample , define its plane- entry by
Each bit plane contains binary entries, while the powers of two determine their contribution to reconstruction. The Linux frame-buffer API uses this organization for FB_TYPE_PLANES, where plane stores bit of the pixel samples.[ref]
For an original four-pixel row stored as four-bit unsigned samples, the bit planes from most significant to least significant are
The third pixel reconstructs as . The same operation applies independently to every location in an image; bit-plane slicing extracts those binary images for inspection or processing.
If only the two most significant bit planes are retained, this row reconstructs as . In general that truncation gives , so the discarded remainder lies between zero and three. This is a statement about integer code values; a nonlinear color space can make equal code changes correspond to unequal light changes.
A bit plane differs from a component plane. One eight-bit red component plane can itself be decomposed into eight bit planes. State the component encoding, bit significance and layout before combining planes; the visible binary pattern alone does not identify its significance. Bit planes need not form a progression from smooth shapes to noise for arbitrary images.
Bit-plane slicing 2026-11-05
Bit-plane slicing extracts the same bit position from every integer sample of a digital image, producing one binary image per bit plane. For an unsigned -bit sample and ,
Equivalently, bitwise AND with the mask isolates that position, and a bit shift or nonzero test converts it to zero or one. Linux's frame-buffer API describes the underlying bit-plane storage convention as plane carrying bit of every sample.[ref]
For an original four-bit sample , the binary digits are : the planes have . Their contributions reconstruct . Displaying each plane as a black-and-white image makes its pattern visible, but does not give every plane equal numerical significance.
Figure 1.
An original four-bit image, two extracted bit planes and reconstruction from the two most significant planes
. Every grid entry shows its integer value. The binary panels map zero to black and one to white; the input and reconstruction use the common zero-to15 grayscale. The alternating row pattern is visible in the least significant plane. Details.
Keeping only planes three and two gives . The discarded remainder satisfies , by integer division. A one-unit change from seven to eight nevertheless flips every one of the four bits, so the binary patterns need not vary smoothly as intensity codes change. Nor is a low bit plane automatically noise: it can encode a deliberately structured pattern, as the example shows.
Slicing is an operation on the stated integer encoding. Applying it to a floating-point number's stored bit pattern examines sign, exponent and fraction fields rather than the same unsigned intensity significance. The sample type and pixel format therefore belong in the definition of the operation.
Framebuffer 2026-11-05
A framebuffer is computer memory holding an image's pixel values in a representation usable by graphics hardware or software. A pixel format specifies how stored bits encode those values. The image's dimensions alone do not determine its complete memory layout: rows can include padding, and different layouts can organize components differently.[ref]
For a concrete packed-row model, let the image be three pixels wide and two rows high, using four bytes per pixel. A row's actual pixel data occupies bytes. If each row starts 16 bytes after the previous one, the framebuffer stride is 16 bytes and four padding bytes separate consecutive pixel rows. Reserving two complete row slots takes bytes, although the pixel values themselves occupy only 24 bytes.
With zero-based coordinates, base memory address , stride and bytes per pixel, the start of a pixel in this stipulated layout is
Thus starts at . Replacing by the packed width12 would instead address the wrong location. This formula assumes packed, byte-addressable rows; it is not a formula for every possible pixel format.
The Linux interface makes the distinction explicit: line_length reports row length in bytes, separately from resolution and bits_per_pixel. A program should use the layout supplied by the interface when interpreting a framebuffer, rather than infer it from the visible dimensions alone.[ref]
Framebuffer stride 2026-11-05
A framebuffer stride is the memory address increment between the starts of consecutive image rows in a specified framebuffer layout. For a row-based packed pixel format, it is commonly measured in bytes. It includes any padding between rows, so the image width and pixel format alone do not determine it. The Linux frame-buffer interface reports this byte count as fb_fix_screeninfo.line_length.[ref]
Assume each pixel occupies complete bytes, rows advance by a positive stride , and coordinates are zero-based. With base address ,
This formula describes the stated packed-row layout. Formats with a different organization need their own addressing rule.
For an original example, choose an image width , height and per pixel. The pixel data in each row occupies 15 bytes. If the chosen allocator aligns each row to a multiple of eight bytes, it uses
There is one padding byte per row slot. The last pixel, at , starts at and occupies offsets 44, 45 and 46. Three complete row slots occupy 48 bytes, whereas the span through the last pixel ends at exclusive offset47:
The allocation rule and the bytes actually containing pixels are distinct parts of the layout.
A cropped view need not become tightly packed. Starting a three-pixel-wide crop at original coordinate gives new base . Its next row still begins at , although each cropped row contains only nine pixel bytes. Substituting nine for the stride would instead start that row at .
Query the actual layout supplied by the interface before traversing memory. In the documented Linux interface, a successful format change can also update line_length, so the stride belongs to the selected layout rather than being an immutable consequence of visible width.[ref]
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]
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 gives
The 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]
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] Report the actual format alongside dimensions and stride when exchanging pixel buffers.
Planar pixel format 2026-11-05
A planar pixel format distributes a pixel's information among separate planes of stored samples, instead of putting all its components together as in a packed pixel format. A component plane may contain all red samples, another all green samples and another all blue samples. Intel's image-format documentation distinguishes these arrangements explicitly.[ref]
For an original one-row, two-pixel RGB color model image, suppose the component triples are and , each component occupying one byte. A packed order can be 10 20 30 40 50 60. A declared planar layout can instead store red bytes 10 40, green bytes 20 50 and blue bytes 30 60. Reinterpreting one sequence as the other changes the reconstructed colours; it is not an image compression method.
For a chosen planar layout with one byte per sample, plane has base address and framebuffer stride bytes. The sample at row and column then has address
For example, with , , row and column , the red sample is at address . Width, height, plane order, sample size and each plane's stride belong in the layout specification. Separate planes need not be adjacent allocations.
A bit plane is another arrangement: one plane stores the same bit position from many pixels. The Linux frame-buffer API's FB_TYPE_PLANES uses this bit-plane meaning, rather than one entire colour component per plane.[ref] Thus the word planar alone is insufficient to decode a buffer. Processing one component across many pixels can use a contiguous component plane, while processing whole pixels must gather their components according to the declared pixel format.