RGBA color model

Last updated

Example of an RGBA image composited over a checkerboard background. alpha is 0% at the top and 100% at the bottom. RGBA comp.png
Example of an RGBA image composited over a checkerboard background. alpha is 0% at the top and 100% at the bottom.

RGBA stands for red green blue alpha. While it is sometimes described as a color space, it is actually a three-channel RGB color model 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, with transparent areas and anti-aliasing of the edges of opaque regions.

Contents

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 (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) 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 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. 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.

RGBA representation converter
Little-endianBig-endian
RGBA8888ABGR32RGBA32
ARGB32BGRA8888ARGB8888
RGBA32ABGR8888RGBA8888

RGBA8888

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. On a little endian architecture this is equivalent to ABGR32. [1]

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:

Sample layout in a typical 32bpp pixel PixelSamples32bppRGBA.png
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 (#) [2] 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, 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.

HexRGBAbits.png

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

See also

Related Research Articles

<span class="mw-page-title-main">Alpha compositing</span> Operation in computer graphics

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 passes or layers and then combine the resulting 2D images into a single, final image called the composite. Compositing is used extensively in film when combining computer-rendered image elements with live footage. Alpha blending is also used in 2D computer graphics to put rasterized foreground elements over a background.

<span class="mw-page-title-main">GIF</span> Bitmap image file format family

The Graphics Interchange Format is a bitmap image format that was developed by a team at the online services provider CompuServe led by American computer scientist Steve Wilhite and released on June 15, 1987.

<span class="mw-page-title-main">PNG</span> Family of lossless compression file formats for image files

Portable Network Graphics is a raster-graphics file format that supports lossless data compression. PNG was developed as an improved, non-patented replacement for Graphics Interchange Format (GIF)—unofficially, the initials PNG stood for the recursive acronym "PNG's not GIF".

PCX, standing for PiCture eXchange, was an image file format developed by the now-defunct ZSoft Corporation of Marietta, Georgia, United States. It was the native file format for PC Paintbrush and became one of the first widely accepted DOS imaging standards, although it has since been succeeded by more sophisticated image formats, such as BMP, JPEG, and PNG. PCX files commonly stored palette-indexed images ranging from 2 or 4 colors to 16 and 256 colors, although the format has been extended to record true-color (24-bit) images as well.

In computing, endianness is the order or sequence of bytes of a word of digital data in computer memory or data communication which is identified by describing the impact of the "first" bytes, meaning at the smallest address or sent first. Endianness is primarily expressed as big-endian (BE) or little-endian (LE). A big-endian system stores the most significant byte of a word at the smallest memory address and the least significant byte at the largest. A little-endian system, in contrast, stores the least-significant byte at the smallest address. Bi-endianness is a feature supported by numerous computer architectures that feature switchable endianness in data fetches and stores or for instruction fetches. Other orderings are generically called middle-endian or mixed-endian.

The BMP file format or bitmap, is a raster graphics image file format used to store bitmap digital images, independently of the display device, especially on Microsoft Windows and OS/2 operating systems.

Truevision TGA, often referred to as TARGA, is a raster graphics file format created by Truevision Inc.. It was the native format of TARGA and VISTA boards, which were the first graphic cards for IBM-compatible PCs to support Highcolor/truecolor display. This family of graphic cards was intended for professional computer image synthesis and video editing with PCs; for this reason, usual resolutions of TGA image files match those of the NTSC and PAL video formats.

Web colors are colors used in displaying web pages on the World Wide Web; they can be described by way of three methods: a color may be specified as an RGB triplet, in hexadecimal format or according to its common English name in some cases. A color tool or other graphics software is often used to generate color values. In some uses, hexadecimal color codes are specified with notation using a leading number sign (#). A color is specified according to the intensity of its red, green and blue components, each represented by eight bits. Thus, there are 24 bits used to specify a web color within the sRGB gamut, and 16,777,216 colors that may be so specified.

Color depth or colour depth, also known as bit depth, is either the number of bits used to indicate the color of a single pixel, or the number of bits used for each color component of a single pixel. When referring to a pixel, the concept can be defined as bits per pixel (bpp). When referring to a color component, the concept can be defined as bits per component, bits per channel, bits per color, and also bits per pixel component, bits per color channel or bits per sample (bps). Modern standards tend to use bits per component, but historical lower-depth systems used bits per pixel more often.

S3 Texture Compression (S3TC) is a group of related lossy texture compression algorithms originally developed by Iourcha et al. of S3 Graphics, Ltd. for use in their Savage 3D computer graphics accelerator. The method of compression is strikingly similar to the previously published Color Cell Compression, which is in turn an adaptation of Block Truncation Coding published in the late 1970s. Unlike some image compression algorithms, S3TC's fixed-rate data compression coupled with the single memory access made it well-suited for use in compressing textures in hardware-accelerated 3D computer graphics. Its subsequent inclusion in Microsoft's DirectX 6.0 and OpenGL 1.3 led to widespread adoption of the technology among hardware and software makers. While S3 Graphics is no longer a competitor in the graphics accelerator market, license fees have been levied and collected for the use of S3TC technology until October 2017, for example in game consoles and graphics cards. The wide use of S3TC has led to a de facto requirement for OpenGL drivers to support it, but the patent-encumbered status of S3TC presented a major obstacle to open source implementations, while implementation approaches which tried to avoid the patented parts existed.

Netpbm is an open-source package of graphics programs and a programming library. It is used mainly in the Unix world, where one can find it included in all major open-source operating system distributions, but also works on Microsoft Windows, macOS, and other operating systems.

The ICO file format is an image file format for computer icons in Microsoft Windows. ICO files contain one or more small images at multiple sizes and color depths, such that they may be scaled appropriately. In Windows, all executables that display an icon to the user, on the desktop, in the Start Menu, or in file Explorer, must carry the icon in ICO format.

<span class="mw-page-title-main">STL (file format)</span> File format for stereolithography applications

STL is a file format native to the stereolithography CAD software created by 3D Systems. Chuck Hull, the inventor of stereolithography and 3D Systems’ founder, reports that the file extension is an abbreviation for stereolithography.

An image file format is a file format for a digital image. There are many formats that can be used, such as JPEG, PNG, and GIF. Most formats up until 2022 were for storing 2D images, not 3D ones. The data stored in an image file format may be compressed or uncompressed. If the data is compressed, it may be done so using lossy compression or lossless compression. For graphic design applications, vector formats are often used. Some image file formats support transparency.

In the X Window System, the program xwd captures the content of a screen or of a window and optionally saves it into a file.

In computing, indexed color is a technique to manage digital images' colors in a limited fashion, in order to save computer memory and file storage, while speeding up display refresh and file transfers. It is a form of vector quantization compression.

The Apple Icon Image format is an icon format used in Apple Inc.'s macOS. It supports icons of 16 × 16, 32 × 32, 48 × 48, 128 × 128, 256 × 256, 512 × 512 points at 1x and 2x scale, with both 1- and 8-bit alpha channels and multiple image states. The fixed-size icons can be scaled by the operating system and displayed at any intermediate size.

Silicon Graphics Image (SGI) or the RGB file format is the native raster graphics file format for Silicon Graphics workstations. The format was invented by Paul Haeberli. It can be run-length encoded (RLE). FFmpeg and ImageMagick, among others, support this format.

PVRTC and PVRTC2 are a family of lossy, fixed-rate texture compression formats used in PowerVR's MBX, SGX and Rogue technologies. The PVRTC algorithm is documented in Simon Fenney's paper "Texture Compression using Low-Frequency Signal Modulation" that was presented at Graphics Hardware 2003.

The Quite OK Image Format (QOI) is a specification for lossless image compression of 24-bit or 32-bit color raster (bitmapped) images, invented by Dominic Szablewski and first announced on 24 November 2021.

References

  1. "Portable Network Graphics (PNG) Specification (Second Edition)". www.w3.org. Retrieved 25 November 2021.
  2. Microsoft MSDN XAML Color Structure reference (XAML/WPF/Silverlight), including #aarrggbb and sc# scA,scR,scG,scB