Jump to content

RGBA color model

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 83.119.136.130 (talk) at 23:37, 28 February 2012 (RGBA pixel formats). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Example of a RGBA image with translucent and transparent portions, displayed on a checker 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 blending and 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 (translucency), an effect not possible with simple binary (transparent or opaque) transparency. It allows easy image compositing. Alpha channel values can be expressed as a percentage, integer, or real number between 0 and 1 like RGB parameters.

PNG is an image format that uses RGBA. The terms ARGB, ARGB32, or ARGB8888 are often used, for example, in Macromedia products terminology or the Silverlight framework. The term BGRA may also be seen. This represents the order that the bytes for each channel are actually in memory when ARGB32 data is stored by a little-endian CPU (such as Intel processors).

RGBA pixel formats

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.
In most 32-bit per pixel formats (32bpp), the intensity of each channel sample is defined by 8 bits, and the samples 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 the Blue sample in the lowest 8 bits.
See the diagram below:

Sample layout in a typical 32bpp pixel
Sample layout in a typical 32bpp pixel

Fig.1 – An example of the most common 32bpp pixel layout

ARGB values are typically expressed using 8 hexadecimal digits, with each pair of the hexadecimal digits representing the sample values of the Alpha, Red, Green and Blue channel, respectively. For example, 0x80FFFF00 represents 50.2% opaque (non-premultiplied) yellow. The "0x" prefix is used to identify a number as hexadecimal in C notation. 0x80 represents a 50.2% alpha value, because it is 50.2% of 0xFF (in decimal 128 is 50.2% of 255), the first 0xFF represents the maximum value a red sample can have; the second 0xFF is like the previous but for green; 0x00 represents the minimum value a blue sample can have (effectively – no blue). Consequently red + green yields yellow.

RGBAX notation

Sometimes the RGBAX notation is used for denoting the amount of samples used. As RGBA usually uses all channels to the maximum, none are left open. When a channel isn't fully filled and no extra bits are used in other (RGBA) channels, the remaining bits are assigned to the X-channel. The X-channel thus represents the unused bits of the total sampling space and denotes extra space left by not fully utilised channels. A typical RGBA image usually uses all channels to the fullest, so it would be noted as having used 8.8.8.8.0 as RGBAX channels. However, when only 6 of the normal 8 bits are used the sample length would be 6.6.6.6.8 in RGBAX notation. Similarly, when an image uses only half the number of bits of the alpha channel and 10 bits of the blue channel, one would write the sample length as 8.8.10.4.2 in RGBAX notation. Note however that the notation doesn't say anything about way the bits are stored in the file. Usually bitmap files are saved with X-channel first, then the alpha channel and so on (XABGR), but this can differ between implementations. [1]

See also

References