<s>
In	O
computer	O
graphics	O
,	O
a	O
palette	B-Data_Structure
is	O
the	O
set	O
of	O
available	O
colors	O
from	O
which	O
an	O
image	O
can	O
be	O
made	O
.	O
</s>
<s>
In	O
some	O
systems	O
,	O
the	O
palette	B-Data_Structure
is	O
fixed	O
by	O
the	O
hardware	O
design	O
,	O
and	O
in	O
others	O
it	O
is	O
dynamic	O
,	O
typically	O
implemented	O
via	O
a	O
color	B-Data_Structure
lookup	I-Data_Structure
table	I-Data_Structure
(	O
CLUT	B-Data_Structure
)	O
,	O
a	O
correspondence	O
table	O
in	O
which	O
selected	O
colors	O
from	O
a	O
certain	O
color	B-Algorithm
space	I-Algorithm
's	O
color	O
reproduction	O
range	O
are	O
assigned	O
an	O
index	O
,	O
by	O
which	O
they	O
can	O
be	O
referenced	O
.	O
</s>
<s>
By	O
referencing	O
the	O
colors	O
via	O
an	O
index	O
,	O
which	O
takes	O
less	O
information	O
than	O
needed	O
to	O
describe	O
the	O
actual	O
colors	O
in	O
the	O
color	B-Algorithm
space	I-Algorithm
,	O
this	O
technique	O
aims	O
to	O
reduce	O
data	O
usage	O
,	O
including	O
processing	O
,	O
transfer	O
bandwidth	O
,	O
RAM	B-Architecture
usage	O
,	O
and	O
storage	O
.	O
</s>
<s>
Images	O
in	O
which	O
colors	O
are	O
indicated	O
by	O
references	O
to	O
a	O
CLUT	B-Data_Structure
are	O
called	O
indexed	B-Data_Structure
color	I-Data_Structure
images	O
.	O
</s>
<s>
As	O
of	O
2019	O
,	O
the	O
most	O
common	O
image	O
colorspace	B-Algorithm
in	O
graphics	B-Device
cards	I-Device
is	O
the	O
RGB	O
color	O
model	O
with	O
8	O
bits	O
per	O
pixel	B-Algorithm
color	O
depth	O
.	O
</s>
<s>
Using	O
this	O
technique	O
,	O
8	O
bits	O
per	O
pixel	B-Algorithm
are	O
used	O
to	O
describe	O
the	O
luminance	O
level	O
in	O
each	O
of	O
the	O
RGB	O
channels	O
,	O
therefore	O
24	O
bits	O
fully	O
describe	O
the	O
color	O
of	O
each	O
pixel	B-Algorithm
.	O
</s>
<s>
The	O
full	O
system	O
palette	B-Data_Structure
for	O
such	O
hardware	O
therefore	O
has	O
224	O
colors	O
.	O
</s>
<s>
The	O
objective	O
of	O
the	O
usage	O
of	O
smaller	O
palettes	B-Data_Structure
via	O
CLUTs	B-Data_Structure
is	O
to	O
lower	O
the	O
number	O
of	O
bits	O
per	O
pixel	B-Algorithm
by	O
reducing	O
the	O
set	O
of	O
possible	O
colors	O
that	O
are	O
to	O
be	O
handled	O
at	O
once	O
(	O
often	O
using	O
adaptive	O
methods	O
)	O
.	O
</s>
<s>
An	O
example	O
is	O
the	O
256-color	O
palette	B-Data_Structure
commonly	O
used	O
in	O
the	O
GIF	O
file	O
format	O
,	O
in	O
which	O
256	O
colors	O
to	O
be	O
used	O
to	O
represent	O
an	O
image	O
are	O
selected	O
from	O
the	O
whole	O
24	O
bit	O
color	B-Algorithm
space	I-Algorithm
,	O
each	O
being	O
assigned	O
an	O
8	O
bit	O
index	O
.	O
</s>
<s>
This	O
way	O
,	O
while	O
the	O
system	O
can	O
potentially	O
reproduce	O
any	O
color	O
in	O
the	O
RGB	O
color	B-Algorithm
space	I-Algorithm
(	O
as	O
long	O
as	O
the	O
256	O
color	O
restriction	O
allows	O
)	O
,	O
the	O
storage	O
requirement	O
per	O
pixel	B-Algorithm
is	O
lowered	O
from	O
24	O
to	O
8	O
bits	O
per	O
pixel	B-Algorithm
.	O
</s>
<s>
In	O
an	O
application	O
showing	O
many	O
different	O
image	O
thumbnails	O
in	O
a	O
mosaic	O
on	O
screen	O
,	O
the	O
program	O
may	O
not	O
be	O
able	O
to	O
load	O
all	O
the	O
adaptive	O
palettes	B-Data_Structure
of	O
every	O
displayed	O
image	O
thumbnail	O
at	O
the	O
same	O
time	O
in	O
the	O
hardware	O
color	B-Data_Structure
registers	I-Data_Structure
.	O
</s>
<s>
A	O
solution	O
is	O
to	O
use	O
a	O
unique	O
,	O
common	O
master	O
palette	B-Data_Structure
or	O
universal	O
palette	B-Data_Structure
,	O
which	O
can	O
be	O
used	O
to	O
display	O
with	O
reasonable	O
accuracy	O
any	O
kind	O
of	O
image	O
.	O
</s>
<s>
This	O
is	O
done	O
by	O
selecting	O
colors	O
in	O
such	O
way	O
that	O
the	O
master	O
palette	B-Data_Structure
comprises	O
a	O
full	O
RGB	O
color	B-Algorithm
space	I-Algorithm
"	O
in	O
miniature	O
"	O
,	O
limiting	O
the	O
possible	O
levels	O
that	O
the	O
red	O
,	O
green	O
and	O
blue	O
components	O
may	O
have	O
.	O
</s>
<s>
This	O
kind	O
of	O
arrangement	O
is	O
sometimes	O
referred	O
as	O
a	O
uniform	O
palette	B-Data_Structure
.	O
</s>
<s>
A	O
master	O
palette	B-Data_Structure
built	O
this	O
way	O
can	O
be	O
filled	O
with	O
up	O
to	O
,	O
but	O
this	O
does	O
not	O
leave	O
space	O
in	O
the	O
palette	B-Data_Structure
for	O
reserved	O
colors	O
,	O
color	O
indices	O
that	O
the	O
program	O
could	O
use	O
for	O
special	O
purposes	O
.	O
</s>
<s>
Then	O
,	O
when	O
loading	O
the	O
mosaic	O
of	O
image	O
thumbnails	O
(	O
or	O
other	O
heterogeneous	O
images	O
)	O
,	O
the	O
program	O
simply	O
maps	O
every	O
original	O
indexed	B-Data_Structure
color	I-Data_Structure
pixel	B-Algorithm
to	O
its	O
most	O
approximated	O
in	O
the	O
master	O
palette	B-Data_Structure
(	O
after	O
dumping	O
this	O
into	O
the	O
hardware	O
color	B-Data_Structure
registers	I-Data_Structure
)	O
,	O
and	O
writes	O
the	O
result	O
in	O
the	O
video	B-Algorithm
buffer	I-Algorithm
.	O
</s>
<s>
Here	O
is	O
a	O
sample	O
of	O
a	O
simple	O
mosaic	O
of	O
the	O
four	O
image	O
thumbnails	O
using	O
a	O
master	O
palette	B-Data_Structure
of	O
240	O
RGB	O
arranged	O
colors	O
plus	O
16	O
additional	O
intermediate	O
shades	O
of	O
gray	O
;	O
all	O
images	O
are	O
put	O
together	O
without	O
a	O
significant	O
loss	O
of	O
color	O
accuracy	O
:	O
</s>
<s>
When	O
using	O
indexed	B-Data_Structure
color	I-Data_Structure
techniques	O
,	O
real	O
life	O
images	O
are	O
represented	O
with	O
better	O
fidelity	O
to	O
the	O
truecolor	O
original	O
one	O
by	O
using	O
adaptive	O
palettes	B-Data_Structure
(	O
sometimes	O
termed	O
adaptative	O
palettes	B-Data_Structure
)	O
,	O
in	O
which	O
the	O
colors	O
are	O
selected	O
or	O
quantized	B-Algorithm
through	O
some	O
algorithm	O
directly	O
from	O
the	O
original	O
image	O
(	O
by	O
picking	O
the	O
most	O
frequent	O
colors	O
)	O
.	O
</s>
<s>
This	O
way	O
,	O
and	O
with	O
further	O
dithering	O
,	O
the	O
indexed	B-Data_Structure
color	I-Data_Structure
image	O
can	O
nearly	O
match	O
the	O
original	O
.	O
</s>
<s>
But	O
this	O
creates	O
a	O
heavy	O
dependence	O
between	O
the	O
image	O
pixels	B-Algorithm
and	O
its	O
adaptive	O
palette	B-Data_Structure
.	O
</s>
<s>
Assuming	O
a	O
limited	O
8-bit	O
depth	O
graphic	O
display	O
,	O
it	O
is	O
necessary	O
to	O
load	O
a	O
given	O
image	O
's	O
adaptive	O
palette	B-Data_Structure
into	O
the	O
color	O
hardware	O
registers	O
prior	O
to	O
loading	O
the	O
image	O
surface	O
itself	O
into	O
the	O
frame	B-Algorithm
buffer	I-Algorithm
.	O
</s>
<s>
To	O
display	O
different	O
images	O
with	O
different	O
adaptive	O
palettes	B-Data_Structure
,	O
they	O
must	O
be	O
loaded	O
one	O
by	O
one	O
,	O
as	O
in	O
a	O
slideshow	O
.	O
</s>
<s>
Here	O
are	O
samples	O
of	O
four	O
different	O
indexed	B-Data_Structure
color	I-Data_Structure
images	O
with	O
color	O
patches	O
to	O
show	O
their	O
respective	O
(	O
and	O
largely	O
incompatible	O
)	O
adaptive	O
palettes	B-Data_Structure
:	O
</s>
<s>
A	O
single	O
palette	B-Data_Structure
entry	I-Data_Structure
in	O
an	O
indexed	B-Data_Structure
color	I-Data_Structure
image	O
can	O
be	O
designated	O
as	O
a	O
transparent	O
color	O
,	O
in	O
order	O
to	O
perform	O
a	O
simple	O
video	O
overlay	O
:	O
superimposing	O
a	O
given	O
image	O
over	O
a	O
background	O
in	O
such	O
way	O
that	O
some	O
part	O
of	O
the	O
overlapped	O
image	O
obscures	O
the	O
background	O
and	O
the	O
remaining	O
not	O
.	O
</s>
<s>
In	O
the	O
image	O
to	O
be	O
superimposed	O
(	O
indexed	B-Data_Structure
color	I-Data_Structure
is	O
assumed	O
)	O
,	O
a	O
given	O
palette	B-Data_Structure
entry	I-Data_Structure
plays	O
the	O
role	O
of	O
the	O
transparent	O
color	O
.	O
</s>
<s>
At	O
design	O
time	O
,	O
the	O
transparent	O
color	O
palette	B-Data_Structure
entry	I-Data_Structure
is	O
assigned	O
to	O
an	O
arbitrary	O
(	O
usually	O
distinctive	O
)	O
color	O
.	O
</s>
<s>
In	O
the	O
example	O
below	O
,	O
a	O
typical	O
arrow	O
pointer	O
for	O
a	O
pointing	B-Device
device	I-Device
is	O
designed	O
over	O
an	O
orange	O
background	O
,	O
so	O
here	O
the	O
orange	O
areas	O
denoted	O
the	O
transparent	O
areas	O
(	O
left	O
)	O
.	O
</s>
<s>
At	B-Library
runtime	I-Library
,	O
the	O
overlapped	O
image	O
is	O
placed	O
anywhere	O
over	O
the	O
background	O
image	O
,	O
and	O
it	O
is	O
blended	O
in	O
such	O
way	O
that	O
if	O
the	O
pixel	B-Algorithm
color	O
index	O
is	O
the	O
transparent	O
color	O
,	O
the	O
background	O
pixel	B-Algorithm
is	O
kept	O
,	O
otherwise	O
it	O
is	O
replaced	O
.	O
</s>
<s>
Some	O
early	O
computers	O
,	O
as	O
Commodore	O
64	O
,	O
MSX	B-Operating_System
and	O
Amiga	B-Device
supports	O
sprites	O
and/or	O
full	O
screen	O
video	O
overlay	O
by	O
hardware	O
.	O
</s>
<s>
In	O
these	O
cases	O
,	O
the	O
transparent	O
palette	B-Data_Structure
entry	I-Data_Structure
number	O
is	O
defined	O
by	O
the	O
hardware	O
,	O
and	O
it	O
used	O
to	O
be	O
the	O
number	O
0	O
.	O
</s>
<s>
Some	O
indexed	B-Data_Structure
color	I-Data_Structure
image	O
file	O
formats	O
as	O
GIF	O
natively	O
support	O
the	O
designation	O
of	O
a	O
given	O
palette	B-Data_Structure
entry	I-Data_Structure
as	O
transparent	O
,	O
freely	O
selectable	O
among	O
any	O
of	O
the	O
palette	B-Data_Structure
entries	I-Data_Structure
used	O
for	O
a	O
given	O
image	O
.	O
</s>
<s>
The	O
BMP	B-Device
file	I-Device
format	I-Device
reserves	O
space	O
for	O
Alpha	B-Algorithm
channel	I-Algorithm
values	O
in	O
its	O
Color	B-Data_Structure
Table	I-Data_Structure
,	O
however	O
currently	O
this	O
space	O
is	O
not	O
being	O
used	O
to	O
hold	O
any	O
translucency	O
data	O
and	O
is	O
set	O
to	O
zero	O
.	O
</s>
<s>
By	O
contrast	O
,	O
PNG	O
supports	O
alpha	B-Algorithm
channels	I-Algorithm
in	O
palette	B-Data_Structure
entries	I-Data_Structure
,	O
enabling	O
semi-transparency	O
in	O
paletted	O
images	O
.	O
</s>
<s>
The	O
same	O
way	O
,	O
typical	O
desktop	O
publishing	O
software	O
can	O
assume	O
pure	O
white	O
,	O
RGB	O
triplet	O
(	O
255,255,255	O
)	O
from	O
photos	O
and	O
illustrations	O
to	O
be	O
excluded	O
in	O
order	O
to	O
let	O
the	O
text	O
paragraphs	O
to	O
invade	O
the	O
image	O
's	O
bounding	B-Algorithm
box	I-Algorithm
for	O
irregular	O
text	O
arrangement	O
around	O
the	O
image	O
's	O
subjects	O
.	O
</s>
<s>
2-D	O
painting	O
programs	O
,	O
like	O
Microsoft	B-Application
Paint	I-Application
and	O
Deluxe	B-Application
Paint	I-Application
,	O
can	O
employ	O
the	O
user	O
designated	O
background	O
color	O
as	O
the	O
transparent	O
color	O
when	O
performing	O
cut	B-General_Concept
,	I-General_Concept
copy	I-General_Concept
,	I-General_Concept
and	I-General_Concept
paste	I-General_Concept
operations	O
.	O
</s>
<s>
Although	O
related	O
(	O
due	O
to	O
they	O
are	O
used	O
for	O
the	O
same	O
purposes	O
)	O
,	O
image	O
bit	O
masks	O
and	O
alpha	B-Algorithm
channels	I-Algorithm
are	O
techniques	O
which	O
do	O
not	O
involve	O
the	O
use	O
of	O
palettes	B-Data_Structure
nor	O
transparent	O
color	O
at	O
all	O
,	O
but	O
off-image	O
added	O
extra	O
binary	O
data	O
layers	O
.	O
</s>
<s>
Microsoft	B-Application
Windows	I-Application
applications	O
manage	O
the	O
palette	B-Data_Structure
of	O
4-bit	O
or	O
8-bit	O
indexed	B-Data_Structure
color	I-Data_Structure
display	O
devices	O
through	O
specialized	O
functions	O
of	O
the	O
Win32	B-Library
API	I-Library
.	O
</s>
<s>
The	O
applicability	O
of	O
palettes	B-Data_Structure
in	O
Highcolor	O
and	O
Truecolor	O
display	O
modes	O
becomes	O
questionable	O
.	O
</s>
<s>
These	O
APIs	O
deals	O
with	O
the	O
so-called	O
"	O
system	O
palette	B-Data_Structure
"	O
and	O
with	O
many	O
"	O
logical	O
palettes	B-Data_Structure
"	O
.	O
</s>
<s>
The	O
"	O
system	O
palette	B-Data_Structure
"	O
is	O
a	O
copy	O
in	O
RAM	B-Architecture
of	O
the	O
color	O
display	O
's	O
hardware	O
registers	O
,	O
primarily	O
a	O
physical	O
palette	B-Data_Structure
,	O
and	O
it	O
is	O
a	O
unique	O
,	O
shared	O
common	O
resource	O
of	O
the	O
system	O
.	O
</s>
<s>
At	O
boot	O
,	O
it	O
is	O
loaded	O
with	O
the	O
default	O
system	O
palette	B-Data_Structure
(	O
mainly	O
a	O
"	O
master	O
palette	B-Data_Structure
"	O
which	O
works	O
well	O
enough	O
with	O
most	O
programs	O
)	O
.	O
</s>
<s>
When	O
a	O
given	O
application	O
intends	O
to	O
output	O
colorized	O
graphics	O
and/or	O
images	O
,	O
it	O
can	O
set	O
their	O
own	O
"	O
logical	O
palette	B-Data_Structure
"	O
,	O
that	O
is	O
,	O
its	O
own	O
private	O
selection	O
of	O
colors	O
(	O
up	O
to	O
256	O
)	O
.	O
</s>
<s>
It	O
is	O
supposed	O
that	O
every	O
graphic	O
element	O
that	O
the	O
application	O
tries	O
to	O
show	O
on	O
screen	O
employs	O
the	O
colors	O
of	O
its	O
logical	O
palette	B-Data_Structure
.	O
</s>
<s>
Every	O
program	O
can	O
manage	O
freely	O
one	O
or	O
more	O
logical	O
palettes	B-Data_Structure
without	O
further	O
expected	O
interference	O
(	O
in	O
advance	O
)	O
.	O
</s>
<s>
Before	O
the	O
output	O
is	O
effectively	O
made	O
,	O
the	O
program	O
must	O
realize	O
its	O
logical	O
palette	B-Data_Structure
:	O
The	O
system	O
tries	O
to	O
match	O
the	O
"	O
logical	O
"	O
colors	O
with	O
"	O
physical	O
"	O
ones	O
.	O
</s>
<s>
If	O
an	O
intended	O
color	O
is	O
already	O
present	O
in	O
the	O
system	O
palette	B-Data_Structure
,	O
the	O
system	O
internally	O
maps	O
the	O
logical	O
to	O
the	O
system	O
palette	B-Data_Structure
indexes	O
(	O
because	O
they	O
rarely	O
coincide	O
)	O
.	O
</s>
<s>
If	O
the	O
intended	O
color	O
is	O
not	O
present	O
yet	O
,	O
the	O
system	O
applies	O
an	O
internal	O
algorithm	O
to	O
discard	O
the	O
least-used	O
color	O
in	O
the	O
system	O
palette	B-Data_Structure
(	O
generally	O
,	O
one	O
used	O
by	O
another	O
window	O
in	O
the	O
background	O
)	O
and	O
substitutes	O
it	O
with	O
the	O
new	O
color	O
.	O
</s>
<s>
Due	O
to	O
there	O
being	O
limited	O
room	O
for	O
colors	O
in	O
the	O
system	O
palette	B-Data_Structure
,	O
the	O
algorithm	O
also	O
tries	O
to	O
remap	O
similar	O
colors	O
together	O
and	O
will	O
always	O
avoid	O
creating	O
redundant	O
colors	O
.	O
</s>
<s>
When	O
the	O
system	O
palette	B-Data_Structure
changes	O
,	O
the	O
system	O
triggers	O
a	O
specific	O
event	B-Application
to	O
inform	O
every	O
application	O
.	O
</s>
<s>
When	O
received	O
,	O
a	O
window	O
can	O
quickly	O
redraw	O
itself	O
using	O
a	O
single	O
Win32	B-Library
API	I-Library
function	O
.	O
</s>
<s>
But	O
this	O
must	O
be	O
done	O
explicitly	O
in	O
the	O
program	O
code	O
;	O
hence	O
the	O
fact	O
that	O
many	O
programs	O
fail	O
to	O
handle	O
this	O
event	B-Application
,	O
and	O
their	O
windows	O
will	O
become	O
corrupt	O
in	O
this	O
situation	O
.	O
</s>
<s>
An	O
application	O
can	O
force	O
the	O
system	O
palette	B-Data_Structure
to	O
be	O
loaded	O
with	O
specific	O
colors	O
(	O
even	O
in	O
a	O
specific	O
order	O
)	O
,	O
"	O
tricking	O
"	O
the	O
system	O
by	O
telling	O
it	O
they	O
are	O
color	O
entries	O
intended	O
for	O
animation	O
(	O
quick	O
color	O
changes	O
of	O
the	O
colors	O
in	O
the	O
physical	O
palette	B-Data_Structure
at	O
specific	O
entries	O
)	O
.	O
</s>
<s>
The	O
system	O
will	O
then	O
assume	O
that	O
those	O
hardware	O
palette	B-Data_Structure
entries	I-Data_Structure
no	O
longer	O
are	O
free	O
for	O
its	O
palette	B-Data_Structure
color	I-Data_Structure
management	O
algorithm	O
.	O
</s>
