4:2:2 chroma subsampling 2026-11-05
4:2:2 chroma subsampling keeps the full luma sample count while sampling each colour-difference component at half the horizontal rate and the full vertical rate. Thus a horizontal group with four Y samples has two Cb and two Cr samples.[ref]
For an original sample-count example, let the grid be six positions wide and three rows high. It contains 18 Y samples and nine samples of each colour-difference component. At eight bits per sample, its active payload is
The corresponding 4:4:4 chroma sampling payload is 54 bytes. The reduction is one third, or from 24 to 16 bits per original pixel. These counts omit padding and any alpha channel; they describe a sampling grid rather than every storage API's alignment constraints.
Horizontal fine colour detail can be lost even though the vertical sample count is unchanged. If a colour-difference row alternates between codes 40 and 160 at every luma position, pair averaging gives three samples of 100 on the stipulated six-position row. Interpolating from those averages cannot identify the original alternation. A low-pass filter and an explicit chroma sample location describe how the reduction is performed; the ratio alone does not specify either.
For a grid whose colour samples share the luma row coordinates, chroma reconstruction needs to estimate missing horizontal positions without inventing a missing vertical row. A later conversion to 4:2:0 chroma subsampling additionally reduces the colour sampling vertically. Rearranging the same 4:2:2 samples between packed pixel formats and planar pixel formats changes layout without making that further sampling reduction.
Alpha channel 2026-11-05
An alpha channel stores an additional value for each pixel that controls its contribution when images are combined by alpha compositing. In a common normalized convention, makes the source pixel fully transparent and makes it fully opaque. An alpha channel can describe partial coverage as well as transparency; its meaning includes the compositing rule, rather than merely a fourth color component. PNG represents its explicit alpha channel with 8-bit or 16-bit values, with zero fully transparent and the maximum value fully opaque.[ref]
For source color and an opaque background color , the source-over rule in Linear-light RGB is
For an original example, a red source at over a blue background produces . These are linear color components; applying the same arithmetic directly to nonlinear display codes generally gives a different physical mixture.[ref]
Storage conventions matter too. With straight alpha the stored color remains ; with premultiplied alpha it is . The red source in the example is therefore stored as either or . Using the first formula on an already premultiplied color would multiply its source contribution by alpha twice. PNG explicitly uses non-premultiplied color samples.[ref]
Alpha compositing 2026-11-05
Alpha compositing combines image contributions using their colour values and alpha channels. The source-over compositing rule places a source layer over a destination while retaining the destination's contribution where the source is partly transparent. Other compositing rules select different contributions; the alpha values alone do not identify the chosen rule.[ref]
Write for source and background colour triples, with alpha values . In premultiplied alpha form, and . Then source-over compositing gives
When , the corresponding straight alpha colour is . The output can remain partly transparent, ready to be combined with another background.
For an original Linear-light RGB example, place red with over blue with . The result is
Reversing the layers instead gives and , with the same output alpha. Layer order changes the colour even when it leaves the output alpha unchanged.
If the background is opaque, and , so the rule reduces to . For a physical light-mixture interpretation, carry out that arithmetic in Linear-light RGB; encoded sRGB values first need their appropriate conversion.[ref] Separately specify whether stored colour samples already contain their alpha multiplier, so that the source contribution is not multiplied twice.
Color component 2026-11-05
A color component is one numerical coordinate used by a color model to describe a colour. An RGB representation has red, green and blue components, while YCbCr has luma and two colour-difference components. Their meanings depend on the model and encoding: a component need not represent a separately emitted primary light. The Microsoft technical guide explicitly separates RGB signals from Y, Cb and Cr and gives their conversion equations.[ref]
For an original normalized Linear-light RGB example, the triple contains three component values for one colour sample. Its blue component is ; that scalar alone does not specify the complete colour. A second triple shares that blue component while differing in red and green. Likewise, the same numerical triple interpreted in different color spaces need not describe the same physical colour.
A component is also distinct from a storage plane. An eight-bit packed pixel format can place three RGB component codes in three successive bytes for each pixel, all in one image memory plane. NV12M instead uses a luma plane and an interleaved colour-difference plane: two memory planes carry three color components. Chroma subsampling can additionally give the components different spatial sample counts.
An alpha channel describes transparency or coverage rather than another coordinate of the colour itself. PNG consequently distinguishes truecolour samples with red, green and blue components from truecolour-with-alpha samples that carry an additional alpha value.[ref] Component identity, sample location, numerical encoding and storage layout together determine how an image is interpreted.
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.
Premultiplied alpha 2026-11-05
With premultiplied alpha, a stored colour triple already includes its alpha channel multiplier: , where is the corresponding straight alpha colour. The alpha value itself is retained. This is also called associated alpha. For , recover ; at zero alpha the multiplication loses the original colour. PNG uses unassociated samples rather than this convention.[ref]
For an original Linear-light RGB example, red with becomes the stored quadruple . The source-over compositing contribution of this sample is already . Multiplying its first three entries by alpha again would make the red contribution instead of .
Premultiplied alpha also makes a useful linear interpolation example transparent. Let sample A be opaque red, , and sample B be fully transparent blue, . Their premultiplied quadruples are and . Averaging them gives
Placed over black, this contributes . Averaging the straight colour triples and alphas separately would instead give , , contributing over black. That blue contribution came from colour attached to a fully transparent sample. The calculation explains how an interpolation convention can create a coloured fringe.
The multiplication convention and the color space are separate choices. The example uses Linear-light RGB throughout. A file decoder, texture sampler and alpha compositing stage must agree on both the colour encoding and whether the samples use straight alpha or premultiplied alpha.
Source-over compositing 2026-11-05
Source-over compositing combines a source layer with a background by retaining the source contribution and the fraction of the background left by the source's alpha channel. For premultiplied alpha colour triples and , the rule is
The W3C compositing specification states this operator explicitly.[ref] The output is another colour-and-alpha pair, so it can be combined with another layer.
For an original Linear-light RGB example, take red layer A with alpha , green layer B with alpha , and blue layer C with alpha . Place A over B over C. Expanding source-over compositing gives
with . Its straight alpha colour is therefore . The colour triple alone does not describe the partly transparent output; the alpha must accompany it.
The expansion also proves associativity in exact arithmetic: grouping A over B first or grouping B over C first produces those same three terms. Reordering the layers changes the coefficients, so associativity does not permit exchanging front and back. Intermediate rounding can introduce small numerical differences even when the mathematical grouping is equivalent.
For fully transparent source alpha zero, source-over compositing retains the background; for opaque source alpha one, it retains only the source. To interpret the colour arithmetic as a mixture of light contributions, use a common Linear-light RGB space. Stored sRGB codes generally need decoding first.[ref] Apply the equation for the actual storage convention: treating premultiplied alpha samples as straight alpha samples multiplies the source contribution twice.
Straight alpha 2026-11-05
With straight alpha, colour samples are stored independently of their alpha channel value. The same convention is called unassociated alpha. For a normalized colour triple and alpha , the stored pair is ; premultiplied alpha instead stores . The PNG specification requires the unassociated convention.[ref]
For an original Linear-light RGB colour and alpha , the straight-alpha quadruple is . The corresponding premultiplied quadruple is . Both describe the same source contribution when interpreted correctly. Raising alpha to can leave the straight colour triple unchanged, while its premultiplied counterpart must become .
For source-over compositing against an opaque black background, the first sample contributes . The stored straight colour is therefore not already its final contribution. At zero alpha, a straight-alpha representation can retain arbitrary colour components while the source contributes no colour to this operation. Multiplying by zero discards those components.
Unpremultiplication recovers the straight colour by dividing premultiplied colour by alpha when alpha is nonzero. It cannot recover a colour erased at zero alpha, and finite-precision errors become significant near zero. If a premultiplied component has absolute rounding error at most , exact division by a fixed alpha magnifies that bound to . At , a component error can therefore become . These are original error bounds, rather than a measured decoder defect.
The alpha convention and the color space remain separate specifications. For light-linear arithmetic, decode nonlinear colour samples before forming their light contributions. PNG documents both compositing and conversion from associated data, including handling zero alpha.[ref]
Unpremultiplication 2026-11-05
Unpremultiplication converts premultiplied alpha colour samples back to straight alpha by dividing out a nonzero alpha channel. If is the stored premultiplied colour triple, then
The alpha value is retained. PNG's encoder guidance specifies this division when converting associated input samples to its unassociated representation, followed by scaling to the output sample range and rounding.[ref]
For an original exact-arithmetic example in Linear-light RGB, let and . The recovered colour is . Multiplying that triple by the retained alpha restores . Dividing the alpha itself would instead destroy the transparency information.
At , all exact premultiplied colour triples arising from finite equal zero. The original colour cannot be recovered from that result: many inputs mapped to the same stored value. PNG's conversion guidance chooses black for this case; that is a defined output convention, not recovered hidden colour.[ref]
Finite precision adds another limitation. Suppose , , and the premultiplied channels are rounded to eight-bit normalized codes. Their integer codes become , while the alpha code is one. Unpremultiplication then yields normalized straight colour , far from the original triple. For fixed exact alpha, a stored component error becomes after division. Near-zero alpha can therefore magnify rounding error even when the conversion formula is correct.