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]
The Frame Buffer Device API in the Linux Kernel documentation. §2, Types and visuals; related Frame Buffer Device introduction, §§0–1
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 isThus 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]The Frame Buffer Device API in the Linux Kernel documentation. §3, Screen information, fixed line_length and variable resolution/depth fields
Articles by others on the same topic
There are currently no matching articles.