RGBA color space

From Infogalactic: the planetary knowledge core
(Redirected from RGBAX)
Jump to: navigation, search

Lua error in package.lua at line 80: module 'strict' not found.

Example of an RGBA image with translucent and transparent portions, displayed on a white background

RGBA stands for red green blue alpha. While it is sometimes described as a color space, it is actually simply a use of the RGB color model, with extra information. The color is RGB, and may belong to any RGB color space, but an integral alpha value as invented by Catmull and Smith between 1971 and 1972 enables alpha compositing. The inventors named alpha after the Greek letter in the classic linear interpolation formula α A + (1 − α) B.

The alpha channel is normally used as an opacity channel. If a pixel has a value of 0% in its alpha channel, it is fully transparent (and, thus, invisible), whereas a value of 100% in the alpha channel gives a fully opaque pixel (traditional digital images). Values between 0% and 100% make it possible for pixels to show through a background like a glass, an effect not possible with simple binary (transparent or opaque) transparency. It allows easy image compositing.

Representation

In computer graphics, pixels encoding the RGBA color space information must be stored in computer memory (or in files on disk), in well defined formats. There are several ways to encode RGBA colors, which can lead to confusion when image data is exchanged. These encodings are often denoted by the four letters in some order (e.g. RGBA, ARGB, etc). Unfortunately, the interpretation of the these 4-letter mnemonics is not well established, leading to further confusion. There are two typical ways to understand a mnemonic such as "RGBA":

  • In the byte-order scheme, "RGBA" is understood to mean a byte R, followed by a byte G, followed by a byte B, and followed by a byte A. This scheme is commonly used for describing file formats or network protocols, which are both byte-oriented.
  • In the word-order scheme, "RGBA" is understood to represent a complete 32-bit word, where R is more significant than G, which is more significant than B, which is more significant than A. This scheme can be used to describe the memory layout on a particular system. Its meaning varies depending on the endianness of the system.

In a [big-endian] system, the two schemes are equivalent. This is not the case for a [little-endian] system, where the two mnemonics are reverses of each other. Therefore, to be unambiguous, it is important to state which ordering is used when referring to the encoding.

RGBA (byte-order)

In OpenGL and Portable Network Graphics (PNG), the RGBA (byte-order) is used, where the colors are stored in memory such that R is at the lowest address, G after it, B after that, and A last.

Even when there are more than 8 bits per channel (such as 16 bits or floating-point), the channels are still stored in RGBA order. In PNG, the channels are stored as 16-bit integers in network order (big-endian).

ARGB (word-order)

In the ARGB (word-order) encoding the intensity of each channel sample is defined by 8 bits, and are arranged in memory in such manner that a single 32-bit unsigned integer has the alpha sample in the highest 8 bits, followed by the red sample, green sample and finally the blue sample in the lowest 8 bits:

Sample layout in a typical 32bpp pixel

ARGB values are typically expressed using 8 hexadecimal digits, with each pair of the hexadecimal digits representing the values of the Alpha, Red, Green and Blue channel, respectively. For example 80FFFF00 represents 50.2% opaque (non-premultiplied) yellow. The 80 hex value, which is 128 in decimal, represents a 50.2% alpha value because 128 is approximately 50.2% of the maximum value of 255 (FF hex); to continue to decipher the 80FFFF00 value, the first FF represents the maximum value red can have; the second FF is like the previous but for green; the final 00 represents the minimum value blue can have (effectively – no blue). Consequently red + green yields yellow. In cases where the alpha is not used this can be shortened to 6 digits RRGGBB, this is why it was chosen to put the alpha in the top bits. Depending on the context a 0x or a number sign (#)[1] is put before the hex digits.

On little-endian systems, this is equivalent to BGRA (byte-order). On big-endian systems, this is equivalent to ARGB (byte-order).

RGBA hexadecimal (word-order)

Lua error in package.lua at line 80: module 'strict' not found.

In some software originating on big-endian machines such as Silicon Graphics, RGBA (word-order) means color is specified similar to ARGB (word-order) but with the alpha in the bottom 8 bits rather than the top. For example 808000FF would be Red and Green:50.2%, Blue:0% and Alpha:100%, a brown. This is used in, e.g. Portable Arbitrary Map (PAM).

RGBA pixel layout

The bytes are stored in memory on a little-endian machine in the order ABGR (byte-order).

See also

References

  1. Microsoft MSDN XAML Color Structure reference (XAML/WPF/Silverlight), including #aarrggbb and sc# scA,scR,scG,scB

External links