![RGBA comp](https://upload.wikimedia.org/wikipedia/commons/0/0b/RGBA_comp.png)
RGBA stands for red green blue alpha. While it is sometimes described as a
color space
A color space is a specific organization of colors. In combination with color profiling supported by various physical devices, it supports reproducible representations of colorwhether such representation entails an analog or a digital represent ...
, it is actually a three-channel
RGB color model
The RGB color model is an additive color model in which the red, green and blue primary colors of light are added together in various ways to reproduce a broad array of colors. The name of the model comes from the initials of the three additiv ...
supplemented with a fourth ''alpha channel''. Alpha indicates how opaque each pixel is and allows an image to be combined over others using
alpha compositing
In computer graphics, alpha compositing or alpha blending is the process of combining one image with a background to create the appearance of partial or full transparency. It is often useful to render picture elements (pixels) in separate pas ...
, with
transparent
Transparency, transparence or transparent most often refer to:
* Transparency (optics), the physical property of allowing the transmission of light through a material
They may also refer to:
Literal uses
* Transparency (photography), a still, ...
areas and
anti-aliasing Anti-aliasing may refer to any of a number of techniques to combat the problems of aliasing in a sampled signal such as a digital image or digital audio recording.
Specific topics in anti-aliasing include:
* Anti-aliasing filter, a filter used be ...
of the edges of opaque regions.
The term does ''not'' define what RGB color space is being used. It also does not state whether or not the colors are
premultiplied by the alpha value, and if they are it does not state what color space that premultiplication was done in. This means more information than just "RGBA" is needed to determine how to handle an image.
In some contexts the abbreviation "RGBA" means a specific memory layout (called
RGBA8888 below), with other terms such as "BGRA" used for alternatives. In other contexts "RGBA" means any layout.
Representation
In computer graphics, pixels encoding the RGBA color space information must be stored in
computer memory
In computing, memory is a device or system that is used to store information for immediate use in a computer or related computer hardware and digital electronic devices. The term ''memory'' is often synonymous with the term ''primary storage ...
(or in files on disk). In most cases four equal-sized pieces of adjacent memory are used, one for each channel, and a 0 in a channel indicates black color or transparent alpha, while all-1 bits indicates white or fully opaque alpha. By far the most common format is to store 8 bits (one
byte
The byte is a unit of digital information that most commonly consists of eight bits. Historically, the byte was the number of bits used to encode a single character of text in a computer and for this reason it is the smallest addressable unit ...
) for each channel, which is 32 bits for each pixel.
The ''order'' of these four bytes in memory can differ, 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.). The interpretation of these 4-letter mnemonics is not well established. 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.
In a
big-endian
In computing, endianness, also known as byte sex, is the order or sequence of bytes of a word of digital data in computer memory. Endianness is primarily expressed as big-endian (BE) or little-endian (LE). A big-endian system stores the most sig ...
system, the two schemes are equivalent. This is not the case for a
little-endian
In computing, endianness, also known as byte sex, is the order or sequence of bytes of a word of digital data in computer memory. Endianness is primarily expressed as big-endian (BE) or little-endian (LE). A big-endian system stores the most si ...
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. This article will use a scheme that has some popularity, which is to add the suffix "8888" to indicate if 4 8-bit units or "32" if one 32-bit unit are being discussed.
RGBA8888
In
OpenGL
OpenGL (Open Graphics Library) is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics. The API is typically used to interact with a graphics processing unit (GPU), to achieve hardwa ...
and
Portable Network Graphics
Portable Network Graphics (PNG, officially pronounced , colloquially pronounced ) is a raster-graphics file format that supports lossless data compression. PNG was developed as an improved, non-patented replacement for Graphics Interchange F ...
(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. On a little endian architecture this is equivalent to ABGR32.
In many systems when there are more than 8 bits per channel (such as 16 bits or floating-point), the channels are stored in RGBA order, even if 8-bit channels are stored in some other order.
ARGB32
The channels 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:
![PixelSamples32bppRGBA](https://upload.wikimedia.org/wikipedia/commons/0/0e/PixelSamples32bppRGBA.png)
ARGB values are typically expressed using 8
hexadecimal
In mathematics and computing, the hexadecimal (also base-16 or simply hex) numeral system is a positional numeral system that represents numbers using a radix (base) of 16. Unlike the decimal system representing numbers using 10 symbols, hexa ...
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 (#)
Microsoft MSDN XAML Color Structure reference
(XAML/WPF/Silverlight), including #aarrggbb
and sc# scA,scR,scG,scB
is put before the hex digits.
This layout became popular when 24-bit color (and 32-bit RGBA) was introduced on personal computers. At the time it was much faster and easier for programs to manipulate one 32-bit unit than four 8-bit units.
On little-endian systems, this is equivalent to BGRA byte order. On big-endian systems, this is equivalent to ARGB byte order.
RGBA32
In some software originating on big-endian machines such as Silicon Graphics
Silicon Graphics, Inc. (stylized as SiliconGraphics before 1999, later rebranded SGI, historically known as Silicon Graphics Computer Systems or SGCS) was an American high-performance computing manufacturer, producing computer hardware and soft ...
, colors were stored in 32 bits similar to ARGB32, 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 what you would get if RGBA8888 data was read as words on these machines. It is used in Portable Arbitrary Map and in FLTK, but in general it is rare.
The bytes are stored in memory on a little-endian machine in the order ABGR.
See also
* Portable Network Graphics
Portable Network Graphics (PNG, officially pronounced , colloquially pronounced ) is a raster-graphics file format that supports lossless data compression. PNG was developed as an improved, non-patented replacement for Graphics Interchange F ...
References
External links
Alpha transparency
on W3C
The World Wide Web Consortium (W3C) is the main international standards organization for the World Wide Web. Founded in 1994 and led by Tim Berners-Lee, the consortium is made up of member organizations that maintain full-time staff working to ...
PNG specification
RGBA Colors
– Preview page with implementation info on CSS3.info
{{DEFAULTSORT:Rgba Color Space
Color space