RGB

From MultimediaWiki
Jump to navigation Jump to search

RGB is a common colorspace when dealing with computer graphics. An RGB pixel consists of a red component, a green component, and a blue component. RGB colorspaces come in a number of flavors which allocate different amounts of bits to each component and arrange the components in various orders.

Palettized RGB

In a palettized RGB scheme, the pixels that comprise an image are actually individual indices into a table that stores the full color information. The simplest example of this is a 1-bit palette scheme, or monochrome. Either the pixel is on or off. This type of scheme can represent 8 pixels in a byte. There are also 2-, 4-, and commonly, 8-bit palette schemes.

IBM VGA

A common palettized scheme used in FMV is the IBM VGA's video mode 0x13 which allowed for 256 simultaneous on-screen colors. Each pixel is a byte in video memory which is where the 256-entry limit comes from. The palette table allocates 6 bits to each components. To simplify storage, programs that are designed around the VGA usually store palette components with 6 bits each, and in red-green-blue order (as the digital to analog converter, or DAC, unit expects them). This is an important bit of information for understanding many FMV formats that were designed to work efficiently with VGA.

15-/16-bit RGB

In 15- and 16-bit RGB schemes, a 16-bit unit of memory holds the RGB information for a single pixel. A 15-bit pixel allocates 5 bits for each of the 3 components, usually in the lower 15 bits of the unit. The upper bit can either be a don't-care value, an alpha channel bit, or carry other scheme-specific information.

In 16-bit RGB, all 16 bits are allocated towards RGB data, typically with the green component receiving an extra bit of precision. This is due to the empirical evidence that human vision is more perceptive of green variations.

An essential consideration for dealing with 15- or 16-bit pixels is byte ordering. Understand whether the scheme stores the values as little or big endian before operating on the pixel values.

Common identifiers for these formats include RGB15 and RGB16.

24-bit RGB

In 24-bit RGB schemes, a single pixel is represented by 3 bytes. Each byte represents 8 bits of either red, green, or blue component information.

Common identifiers for this scheme include RGB24 or BGR24, depending on the component ordering.

32-bit RGB

32-bit RGB is similar to 24-bit except that an extra byte is added, usually to make more sense for memory alignment. Sometimes the extra byte is a don't-care value. Sometimes it denotes alpha channel transparency information.

Common identifiers for this scheme include ARGB, RGBA, BGRA, ABGR, RGB32, and BGR32. These denote the left to right component ordering of the respective scheme.