Bit Depth, Channels, and Alpha
Under every color you have read about in this library is a far less glamorous truth: in a file, a color is just a handful of numbers. How many numbers, how many bits each, and what they mean - that is what decides whether a gradient is smooth or striped, whether an edge composites cleanly or fringes, and how big the file is. This is the interactive guide to how color actually lives in memory.
Color is just numbers
A digital image is a grid of pixels, and each pixel is a small set of numbers - typically red, green, blue, and often a fourth, alpha. The colorful physics and perception elsewhere in this library all collapse, at storage time, into integers like (220, 40, 40, 255). Everything practical about digital color - smoothness, transparency, file size, fidelity - comes down to three questions about those numbers: how many channels, how many bits each, and how they are interpreted.
Get those right and color "just works." Get them wrong and you meet the classic bugs: striped skies, muddy edges, posterized exports, and files ten times bigger than they need to be.
Bit depth and levels
Bit depth is how many bits store each channel, which fixes how many distinct levels that channel can take: 2bits. Eight bits give 256 levels per channel and 2563 ≈ 16.7 million RGB colors. Drop the bit depth and the steps between levels grow until they become visible as banding across a smooth gradient.
Crush the levels and watch a gradient band
The same smooth gradient quantized to the chosen bits per channel. At 8 bits it is smooth; lower it and the steps appear as bands. The readout shows the levels per channel and the total representable colors - the numbers behind the picture.
Channels: splitting a pixel
A color image is really three (or four) grayscale images stacked together - one per channel. Each channel records how much of that primary is present at each pixel. Editors expose this directly: you can view, adjust, or swap a single channel, and "grayscale" is just the channels collapsed into one luminance image.
See a scene one channel at a time
The full-color scene, then each channel shown alone as the intensity of that primary, and finally the luminance (perceptual grayscale). Notice how the red apple is bright in the red channel and dark in the others - a channel is a map of one primary.
Alpha and compositing
The fourth channel, alpha, does not store color at all - it stores opacity, how much of the pixel is "there." On its own it does nothing; it tells the compositor how to blend this layer over what is behind it, using the "over" operator. Alpha is what makes transparency, anti-aliased edges, and layered UI possible.
Blend a layer over a background
A foreground color at the chosen opacity, composited over a background (the checkerboard shows true transparency). Drag alpha from 0 to 1 and watch the foreground fade in. The readout gives the exact composited color from the formula above.
Premultiplied vs straight
There are two ways to store an RGBA pixel, and mixing them up is a classic source of ugly edges. With straight (unassociated) alpha, the RGB values are the true color and alpha is kept separate. With premultiplied (associated) alpha, the RGB values are already multiplied by alpha, so a 50%-opaque red is stored as half-strength red. Premultiplied is what compositors use internally because it makes filtering correct: when you scale, blur, or anti-alias an edge, premultiplied values interpolate without pulling in the color of fully transparent pixels.
Indexed color and quantization
Not every image stores full RGB per pixel. Indexed color (as in GIF and PNG-8) keeps a small palette of colors and stores, per pixel, just an index into it - a few bits instead of 24. The trade-off is quantization: every original color must snap to the nearest palette entry, so gradients posterize and detail is lost. Shrink the palette and watch the image collapse onto fewer and fewer colors.
Map an image onto a small palette
The colorful source is reduced to a palette of the chosen size; every pixel snaps to its nearest palette color. The swatches below are the palette. Small palettes mean tiny files and heavy posterization - the GIF trade-off in one slider.
Bit budgets: 8, 10, 16, float
How many bits you spend per channel is a budget against banding, editing headroom, and HDR. Eight bits is the web baseline and fine for final, gamma-encoded display images. But edit aggressively - big curves or exposure moves - and 8-bit steps get stretched into visible bands, which is why editing and HDR want more.
| Depth | Levels / channel | Use for |
|---|---|---|
| 8-bit | 256 | Final web/display images; SDR delivery. Bands under heavy edits. |
| 10-bit | 1,024 | HDR video and smooth gradients; banding-free SDR on capable displays. |
| 12-16-bit | 4,096-65,536 | RAW capture and editing masters - huge headroom for adjustments. |
| 16/32-bit float | continuous | Linear-light compositing and HDR rendering; values can exceed 1.0. |
Practical guide
| If you need… | Use… |
|---|---|
| Transparency / soft edges | An alpha channel (RGBA) - PNG or WebP, not JPEG. |
| Smooth gradients without banding | 10-bit+ where possible, or add dithering at 8-bit. |
| Tiny files for flat graphics | Indexed color (PNG-8 / GIF) with a tuned palette. |
| Editing headroom | 16-bit (or RAW) masters; export to 8-bit only at the end. |
| Correct compositing | Premultiplied alpha, blended in linear light. |
| HDR delivery | 10-bit with a PQ/HLG transfer function (see the HDR article). |
Pitfalls and gotchas
Test your understanding
Six questions on bit depth, channels, alpha, and indexed color. Instant feedback, no scores recorded - a wrong answer comes with a short explanation.
Quick check
Continue your journey
Storage sits beneath encoding, gradients, and HDR. The numbers reflect each article's position in the editorial roadmap.
Camera Color: From Photons to Pixels
Why raw's high bit depth gives the headroom to recover and edit.
Digital · 17Gamma, Linear Light, and Transfer Functions
How the stored numbers map to light - and why compositing needs linear.
Digital · 27Color Gradients and Interpolation
The other half of banding - and how dithering hides limited bit depth.
Digital · 19HDR, Wide Gamut, PQ, HLG, and Modern Displays
Why HDR needs 10-bit and float, and how transfer functions spend bits.
Digital · 18RGB, sRGB, Adobe RGB, ProPhoto, Display P3, Rec.2020
Wide gamuts need more bits to avoid banding - the working-space side.
Digital · 16ICC Profiles and How Color Management Works
What those stored numbers actually mean as color, across devices.
Foundations · 01What Color Is and How Humans See It
The perception those few stored numbers are standing in for.