Palette (computing): Difference between revisions

Content deleted Content added
→‎Microsoft Windows: Grammar fixes
no sentences
 
(19 intermediate revisions by 16 users not shown)
Line 1:
{{More citations needed|date=September 2021}}
{{about|color lookup tables|color schemes used in design software|color scheme|the UI element also known as utility window|Palette window}}
{{short description|In computer graphics, a finite set of available colors}}
{{Color depth}}
 
{{multiple image
| align = right
| image1 = RGB 24bits palette sample image.jpg
| width1 = 150
| caption1 = Sample image
| image2 = Sample Image RGB Cube.gif
| width2 = 200
| caption2 = The palette used in the image, shown rotating about the [[RGB color space]].
}}
 
In [[computer graphics]], a '''palette''' is the set of available colors from which an image can be made. In some systems, alsothe calledpalette is fixed by the hardware design, and in others it is dynamic, typically implemented via a '''color lookup table''' (CLUT), is a correspondence table in which selected colors from a certain [[color space]]'s color reproduction range are assigned an index, by which they can be referenced. By referencing the colors via an index, which takes less information than the one needed to describe the actual colors in saidthe color space, this technique aims to reduce data usage, be it asincluding processing payload, transfer bandwidth, RAM usage, or persistentand storage. Images in which colors are indicated by references to a CLUT are called [[indexed color]] images.
 
==Description==
As of 2019, the most common image colorspace in computing[[graphics card]]s is the [[RGB color model]] with 8 bits per pixel [[color depth]]. Using this technique, 8 bits per pixel are used to describe the [[luminance]] level in each of the [[RGB channel]]s, therefore 24 bits of storage are necessary to fully describe the color of each pixel. The full system palette for such hardware therefore has 2<sup>24</sup> colors. The objective of the usage of smaller palettes via CLUTs is to lower thisthe storagenumber requirementof bits per pixel by reducing the set of possible colors that are to be handled at once (often using adaptive methods),. assigning eachEach possible color is assigned an index, which allows each color to be referenced using less information than needed to fully describe the color. A commonAn example is the 256-color palette commonly used in the [[GIF]] file format, in which 256 colors to be used to represent an image are selected from the whole 24 bppbit color space, each being assigned an 8 bit index. This way, while the system can potentially reproduce any color in the RGB color space (as long as the 256 color restriction allows), the storage requirement per pixel is lowered from 24 to 8 bits per pixel.
 
==Master palette==
[[File:Palette sizes.ogv|right|thumb|300px|An adaptive color palette expanding from 2 colors to 256 colors, demonstrating how the image changes (click to see animation).]]
In an application showing many different [[thumbnail|image thumbnail]]s in a mosaic on screen, the program may not be able to load all the adaptive palettes of every displayed image thumbnail at the same time in the hardware color registers. A solution is to use a unique, common ''[[List of software palettes#RGB arrangements|master palette]]'' or ''universal palette'', which can be used to display with reasonable accuracy any kind of image.
 
This is done by selecting colors in such way that the master palette comprises a full [[RGB color space]] "in miniature", limiting the possible levels that the red, green, and blue components may have. This kind of arrangement is sometimes referred to as a ''uniform palette''.<ref>[http://tex.imm.uran.ru/alchemy.pdf Handmade Software's ''Image Alchemy'' User's Manual.]</ref> The normal [[human eye]] has sensibility to the three primary colors in different degrees: the more to the green, the less to the blue. So RGB arrangements can take advantage of this by assigning more levels for the green component and lessfewer to the blue.
 
A master palette built this way can be filled with up to {{nowrap|[[List of software palettes#8-8-4 levels RGB|8R×8G×4B {{=}} 256 colors]]}}, but this does not leave space in the palette for reserved colors, color indices that the program could use for special purposes. It is more general to use only {{nowrap|[[List of software palettes#6 level RGB|6R×6G×6B {{=}} 216]]}} (as in the [[Web colors]] case), {{nowrap|[[List of software palettes#6-8-5 levels RGB|6R×8G×5B {{=}} 240]]}} or {{nowrap|[[List of software palettes#6-7-6 levels RGB|6R×7G×6B {{=}} 252]]}}, which leaves room for some reserved colors.
Line 34 ⟶ 35:
 
==Adaptive palette==
When using [[indexed color]] techniques, real life images are represented with better fidelity to the [[24-bit color|truecolor]] original one by using [[List of software palettes#Adaptive palettes|adaptive palette]]s (sometimes spelledtermed ''adaptative palettes''), in which the colors are selected or [[color quantization|quantized]] through some algorithm directly from the original image (by picking the most frequent colors). This way, and with further [[dithering]], the indexed color image can nearly match the original.
 
But this creates a heavy dependence between the image [[pixel]]s and its adaptive palette. Assuming a limited 8-bit depth graphic display, it is necessary to load a given image's adaptive palette into the color hardware registers prior to loading the image surface itself into the [[Framebuffer|frame buffer]]. To display different images with different adaptive palettes, they must be loaded one by one, as in a [[slideshow]]. Here are samples of four different indexed color images with color patches to show their respective (and largely incompatible) adaptive palettes:
Line 72 ⟶ 73:
[[2D computer graphics|2-D painting programs]], like [[Microsoft Paint]] and [[Deluxe Paint]], can employ the user designated ''background color'' as the transparent color when performing [[cut, copy, and paste]] operations.
 
Although related (due to they are used for the same purposes), [[Image mask|image bit masks]] and [[alpha channel]]s are techniques which do not involve the use of palettes nor transparent color at all, but off-image added extra binary data layers.
 
==Software palettes==
Line 79 ⟶ 80:
[[Microsoft Windows]] applications manage the palette of 4-bit or 8-bit indexed color display devices through specialized functions of the [[Win32 API]]. The applicability of palettes in [[Highcolor]] and [[24-bit color|Truecolor]] display modes becomes questionable. These APIs deals with the so-called "system palette" and with many "logical palettes".
 
The "system palette" is a copy in [[Random-access memory|RAM]] of the color display's hardware registers, primarily a physical palette, and it is a unique, shared common resource of the system. At boot, it is loaded with the [[List of software palettes#Microsoft Windows and IBM OS/2 default 16-color palettecolor_palette|default system palette]] (mainly a "master palette" which works well enough with most programs).
 
When a given application intends to output colorized graphics and/or images, it can set their own "logical palette", that is, its own private selection of colors (up to 256). It is supposed that every graphic element that the application tries to show on screen employs the colors of its logical palette. Every program can manage freely one or more logical palettes without further expected interference (in advance).
Line 96 ⟶ 97:
 
==References==
* Julio Sanchez and Maria P. Canton (2003). ''[https://books.google.com/books?id=gZ5SDTpMR-MC&pg=PA756&dq=palette+intitle:%22The+PC+Graphics+Handbook%22&lrpg=&as_brr=0&ei=uaPHR7aKHqbutAOohely&sig=4UrkgNS_n3TkvwC1DQ5x91wzcv4PA756 The PC Graphics Handbook.]'' CRC Press. {{ISBN|0-8493-1678-2}}.
* [http://msdn.microsoft.com/en-us/library/dd183459(VS.85).aspx Color palettes at Microsoft Developer Network (MSDN)]
* [http://msdn.microsoft.com/en-us/library/dd162938%28VS.85%29.aspx The RGBQUAD color table entry in BITMAPINFO structure at Microsoft Developer Network (MSDN)]
Line 105 ⟶ 106:
[[Category:Computer graphics data structures]]
[[Category:Color depths]]
[[Category:ComputingComputer output devices]]
[[Category:Articles containing video clips]]