<s>
The	O
BMP	B-Device
file	I-Device
format	I-Device
or	O
bitmap	O
,	O
is	O
a	O
raster	B-Algorithm
graphics	I-Algorithm
image	O
file	O
format	O
used	O
to	O
store	O
bitmap	O
digital	B-Algorithm
images	I-Algorithm
,	O
independently	O
of	O
the	O
display	B-Device
device	I-Device
(	O
such	O
as	O
a	O
graphics	B-Device
adapter	I-Device
)	O
,	O
especially	O
on	O
Microsoft	B-Application
Windows	I-Application
and	O
OS/2	B-Application
operating	O
systems	O
.	O
</s>
<s>
The	O
BMP	B-Device
file	I-Device
format	I-Device
is	O
capable	O
of	O
storing	O
two-dimensional	O
digital	B-Algorithm
images	I-Algorithm
in	O
various	O
color	O
depths	O
,	O
and	O
optionally	O
with	O
data	B-General_Concept
compression	I-General_Concept
,	O
alpha	B-Algorithm
channels	I-Algorithm
,	O
and	O
color	O
profiles	O
.	O
</s>
<s>
The	O
Windows	B-Application
Metafile	O
(	O
WMF	O
)	O
specification	O
covers	O
the	O
BMP	B-Device
file	I-Device
format	I-Device
.	O
</s>
<s>
They	O
called	O
these	O
device-independent	B-Device
bitmaps	I-Device
or	O
DIBs	O
,	O
and	O
the	O
file	O
format	O
for	O
them	O
is	O
called	O
DIB	O
file	O
format	O
or	O
BMP	B-Device
image	I-Device
file	O
format	O
.	O
</s>
<s>
According	O
to	O
Microsoft	O
support	O
:	O
A	O
device-independent	B-Device
bitmap	I-Device
(	O
DIB	O
)	O
is	O
a	O
format	O
used	O
to	O
define	O
device-independent	B-Device
bitmaps	I-Device
in	O
various	O
color	O
resolutions	O
.	O
</s>
<s>
A	O
DIB	O
is	O
normally	O
transported	O
in	O
metafiles	O
(	O
usually	O
using	O
the	O
StretchDIBits( )	O
function	O
)	O
,	O
BMP	B-Device
files	I-Device
,	O
and	O
the	O
Clipboard	O
(	O
data	O
format	O
)	O
.	O
</s>
<s>
The	O
following	O
sections	O
discuss	O
the	O
data	O
stored	O
in	O
the	O
BMP	B-Device
file	I-Device
or	O
DIB	O
in	O
detail	O
.	O
</s>
<s>
This	O
is	O
the	O
standard	O
BMP	B-Device
file	I-Device
format	I-Device
.	O
</s>
<s>
Structure	O
name	O
Optional	O
Size	O
Purpose	O
Comments	O
Bitmap	O
file	O
header	O
14	O
bytes	O
To	O
store	O
general	O
information	O
about	O
the	O
bitmap	O
image	O
file	O
Not	O
needed	O
after	O
the	O
file	O
is	O
loaded	O
in	O
memory	O
DIB	O
header	O
Fixed-size	O
(	O
7	O
different	O
versions	O
exist	O
)	O
To	O
store	O
detailed	O
information	O
about	O
the	O
bitmap	O
image	O
and	O
define	O
the	O
pixel	O
format	O
Immediately	O
follows	O
the	O
Bitmap	O
file	O
header	O
Extra	O
bit	O
masks	O
3	O
or	O
4	O
DWORDs(12 or 16 bytes )	O
To	O
define	O
the	O
pixel	O
format	O
Present	O
only	O
in	O
case	O
the	O
DIB	O
header	O
is	O
the	O
and	O
the	O
Compression	O
Method	O
member	O
is	O
set	O
to	O
either	O
BI_BITFIELDS	O
or	O
BI_ALPHABITFIELDS	O
Color	B-Data_Structure
table	I-Data_Structure
To	O
define	O
colors	O
used	O
by	O
the	O
bitmap	O
image	O
data	O
(	O
Pixel	O
array	O
)	O
Mandatory	O
for	O
color	O
depths	O
≤	O
8	O
bits	O
Gap1	O
Structure	O
alignment	O
An	O
artifact	O
of	O
the	O
File	O
offset	O
to	O
Pixel	O
array	O
in	O
the	O
Bitmap	O
file	O
header	O
Pixel	O
array	O
To	O
define	O
the	O
actual	O
values	O
of	O
the	O
pixels	O
The	O
pixel	O
format	O
is	O
defined	O
by	O
the	O
DIB	O
header	O
or	O
Extra	O
bit	O
masks	O
.	O
</s>
<s>
A	O
bitmap	O
image	O
file	O
loaded	O
into	O
memory	O
becomes	O
a	O
DIB	O
data	O
structure	O
–	O
an	O
important	O
component	O
of	O
the	O
Windows	B-Application
GDI	B-Operating_System
API	O
.	O
</s>
<s>
The	O
in-memory	O
DIB	O
data	O
structure	O
is	O
almost	O
the	O
same	O
as	O
the	O
BMP	B-Device
file	I-Device
format	I-Device
,	O
but	O
it	O
does	O
not	O
contain	O
the	O
14-byte	O
bitmap	O
file	O
header	O
and	O
begins	O
with	O
the	O
DIB	O
header	O
.	O
</s>
<s>
For	O
DIBs	O
loaded	O
in	O
memory	O
,	O
the	O
color	B-Data_Structure
table	I-Data_Structure
can	O
also	O
consist	O
of	O
16-bit	O
entries	O
that	O
constitute	O
indexes	O
to	O
the	O
currently	O
realized	O
palette	B-Data_Structure
(	O
an	O
additional	O
level	O
of	O
indirection	O
)	O
,	O
instead	O
of	O
explicit	O
RGB	O
color	O
definitions	O
.	O
</s>
<s>
In	O
non-packed	O
DIBs	O
loaded	O
in	O
memory	O
,	O
the	O
optional	O
color	O
profile	O
data	O
should	O
be	O
located	O
immediately	O
after	O
the	O
color	B-Data_Structure
table	I-Data_Structure
and	O
before	O
the	O
gap1	O
and	O
pixel	O
array	O
(	O
unlike	O
in	O
diag	O
.	O
</s>
<s>
In	O
some	O
cases	O
it	O
may	O
be	O
necessary	O
to	O
adjust	O
the	O
number	O
of	O
entries	O
in	O
the	O
color	B-Data_Structure
table	I-Data_Structure
in	O
order	O
to	O
force	O
the	O
memory	O
address	O
of	O
the	O
pixel	O
array	O
to	O
a	O
multiple	O
of	O
4	O
bytes	O
.	O
</s>
<s>
"	O
Packed	O
DIBs	O
"	O
are	O
required	O
by	O
Windows	B-Application
clipboard	O
API	O
functions	O
as	O
well	O
as	O
by	O
some	O
Windows	B-Application
patterned	O
brush	O
and	O
resource	O
functions	O
.	O
</s>
<s>
A	O
typical	O
application	O
reads	O
this	O
block	O
first	O
to	O
ensure	O
that	O
the	O
file	O
is	O
actually	O
a	O
BMP	B-Device
file	I-Device
and	O
that	O
it	O
is	O
not	O
damaged	O
.	O
</s>
<s>
The	O
first	O
2	O
bytes	O
of	O
the	O
BMP	B-Device
file	I-Device
format	I-Device
are	O
the	O
character	O
"	O
B	O
"	O
then	O
the	O
character	O
"	O
M	O
"	O
in	O
ASCII	B-Protocol
encoding	O
.	O
</s>
<s>
Offset	O
hex	O
Offset	O
dec	O
Size	O
Purpose	O
000	O
2	O
bytes	O
The	O
header	O
field	O
used	O
to	O
identify	O
the	O
BMP	B-Device
and	O
DIB	O
file	O
is	O
0x42	O
0x4D	O
in	O
hexadecimal	O
,	O
same	O
as	O
BM	O
in	O
ASCII	B-Protocol
.	O
</s>
<s>
BM	O
Windows	B-Application
3.1x	I-Application
,	O
95	B-Application
,	O
NT	O
,	O
...	O
etc	O
.	O
</s>
<s>
PT	O
OS/2	B-Application
pointer	O
022	O
4	O
bytes	O
The	O
size	O
of	O
the	O
BMP	B-Device
file	I-Device
in	O
bytes	O
066	O
2	O
bytes	O
Reserved	O
;	O
actual	O
value	O
depends	O
on	O
the	O
application	O
that	O
creates	O
the	O
image	O
,	O
if	O
created	O
manually	O
can	O
be	O
0	O
088	O
2	O
bytes	O
Reserved	O
;	O
actual	O
value	O
depends	O
on	O
the	O
application	O
that	O
creates	O
the	O
image	O
,	O
if	O
created	O
manually	O
can	O
be	O
0	O
0A10	O
4	O
bytes	O
The	O
offset	O
,	O
i.e.	O
</s>
<s>
The	O
block	O
also	O
matches	O
the	O
header	O
used	O
internally	O
by	O
Windows	B-Application
and	O
OS/2	B-Application
and	O
has	O
several	O
different	O
variants	O
.	O
</s>
<s>
The	O
new	O
extended	O
headers	O
can	O
be	O
used	O
with	O
some	O
GDI	B-Operating_System
functions	O
instead	O
of	O
the	O
older	O
ones	O
,	O
providing	O
more	O
functionality	O
.	O
</s>
<s>
Since	O
the	O
GDI	B-Operating_System
supports	O
a	O
function	O
for	O
loading	O
bitmap	O
files	O
,	O
typical	O
Windows	B-Application
applications	I-Application
use	O
that	O
functionality	O
.	O
</s>
<s>
One	O
consequence	O
of	O
this	O
is	O
that	O
for	O
such	O
applications	O
,	O
the	O
BMP	B-Device
formats	I-Device
that	O
they	O
support	O
match	O
the	O
formats	O
supported	O
by	O
the	O
Windows	B-Application
version	O
being	O
run	O
.	O
</s>
<s>
+	O
Windows	B-Device
and	I-Device
OS/2	I-Device
bitmap	I-Device
headers	O
Size	O
Header	O
name	O
OS	O
support	O
Features	O
Written	O
by	O
12	O
Windows	B-Application
2.0	I-Application
or	O
laterOS/2	O
1.x	O
64	O
OS/2	B-Application
2	O
Adds	O
halftoning	O
.	O
</s>
<s>
Adds	O
RLE	B-Algorithm
and	O
Huffman	B-General_Concept
1D	O
compression	O
.	O
</s>
<s>
of	O
the	O
BMP	B-Device
Suite	O
.	O
</s>
<s>
40	O
Windows	B-Device
NT	I-Device
,	O
3.1x	B-Application
or	O
later	O
Extends	O
bitmap	O
width	O
and	O
height	O
to	O
4	O
bytes	O
.	O
</s>
<s>
Adds	O
RLE	B-Algorithm
compression	I-Algorithm
.	O
</s>
<s>
Adobe	B-Operating_System
Photoshop	I-Operating_System
56	O
Not	O
officially	O
documented	O
,	O
but	O
this	O
documentation	O
was	O
posted	O
on	O
Adobe	O
's	O
forums	O
,	O
by	O
an	O
employee	O
of	O
Adobe	O
with	O
a	O
statement	O
that	O
the	O
standard	O
was	O
at	O
one	O
point	O
in	O
the	O
past	O
included	O
in	O
official	O
MS	O
documentation	O
Adds	O
alpha	B-Algorithm
channel	I-Algorithm
bit	O
mask	O
.	O
</s>
<s>
The	O
Windows	O
2.x	O
BITMAPCOREHEADER	O
differs	O
from	O
the	O
OS/2	B-Application
1.x	O
BITMAPCOREHEADER	O
(	O
shown	O
in	O
the	O
table	O
above	O
)	O
in	O
the	O
one	O
detail	O
that	O
the	O
image	O
width	O
and	O
height	O
fields	O
are	O
signed	O
integers	O
,	O
not	O
unsigned	O
.	O
</s>
<s>
An	O
integrated	O
alpha	B-Algorithm
channel	I-Algorithm
has	O
been	O
introduced	O
with	O
the	O
undocumented	O
and	O
with	O
the	O
documented	O
(	O
since	O
Windows	B-Application
95	I-Application
)	O
and	O
is	O
used	O
within	O
Windows	B-Application
XP	I-Application
logon	O
and	O
theme	O
system	O
as	O
well	O
as	O
Microsoft	O
Office	O
(	O
since	O
v2000	O
)	O
;	O
it	O
is	O
supported	O
by	O
some	O
image	B-Application
editing	I-Application
software	O
,	O
such	O
as	O
Adobe	B-Operating_System
Photoshop	I-Operating_System
since	O
version	O
7	O
and	O
Adobe	B-Operating_System
Flash	I-Operating_System
since	O
version	O
MX	O
2004	O
(	O
then	O
known	O
as	O
Macromedia	O
Flash	O
)	O
.	O
</s>
<s>
It	O
is	O
also	O
supported	O
by	O
GIMP	B-Application
,	O
Google	B-Application
Chrome	I-Application
,	O
Microsoft	B-Application
PowerPoint	I-Application
and	O
Microsoft	B-Application
Word	I-Application
.	O
</s>
<s>
With	O
OS/2	B-Application
no	O
longer	O
supported	O
after	O
Windows	B-Application
2000	I-Application
,	O
for	O
now	O
the	O
common	O
Windows	B-Application
format	O
is	O
the	O
header	O
.	O
</s>
<s>
Offset	O
(	O
hex	O
)	O
Offset	O
(	O
dec	O
)	O
Size	O
(	O
bytes	O
)	O
Windows	B-Application
0E14	O
4	O
the	O
size	O
of	O
this	O
header	O
,	O
in	O
bytes	O
(	O
40	O
)	O
12	O
18	O
4	O
the	O
bitmap	O
width	O
in	O
pixels	O
(	O
signed	O
integer	O
)	O
16	O
22	O
4	O
the	O
bitmap	O
height	O
in	O
pixels	O
(	O
signed	O
integer	O
)	O
1A26	O
2	O
the	O
number	O
of	O
color	O
planes	O
(	O
must	O
be	O
1	O
)	O
1C28	O
2	O
the	O
number	O
of	O
bits	O
per	O
pixel	O
,	O
which	O
is	O
the	O
color	O
depth	O
of	O
the	O
image	O
.	O
</s>
<s>
An	O
OS/2	B-Application
2.x	O
(	O
in	O
IBM	O
's	O
documentation	O
)	O
contains	O
24	O
additional	O
bytes	O
:	O
</s>
<s>
Offset	O
(	O
hex	O
)	O
Offset	O
(	O
dec	O
)	O
Size	O
(	O
bytes	O
)	O
OS/2	B-Application
(	O
)	O
3654	O
2	O
An	O
enumerated	O
value	O
specifying	O
the	O
units	O
for	O
the	O
horizontal	O
and	O
vertical	O
resolutions	O
(	O
offsets	O
38	O
and	O
42	O
)	O
.	O
</s>
<s>
Note	O
that	O
Windows	B-Device
bitmaps	I-Device
(	O
which	O
do	O
n't	O
include	O
this	O
field	O
)	O
can	O
also	O
specify	O
an	O
upper-left	O
origin	O
(	O
bits	O
fill	O
from	O
left-to-right	O
,	O
then	O
top-to-bottom	O
)	O
by	O
using	O
a	O
negative	O
value	O
for	O
the	O
image	O
height	O
3C60	O
2	O
An	O
enumerated	O
value	O
indicating	O
a	O
halftoning	O
algorithm	O
that	O
should	O
be	O
used	O
when	O
rendering	O
the	O
image	O
.	O
</s>
<s>
4064	O
4	O
Halftoning	O
parameter	O
1	O
(	O
see	O
below	O
)	O
4468	O
4	O
Halftoning	O
parameter	O
2	O
(	O
see	O
below	O
)	O
4872	O
4	O
An	O
enumerated	O
value	O
indicating	O
the	O
color	O
encoding	O
for	O
each	O
entry	O
in	O
the	O
color	B-Data_Structure
table	I-Data_Structure
.	O
</s>
<s>
Value	O
Halftoning	O
algorithm	O
Comments	O
0	O
Most	O
common	O
1	O
Error	B-Algorithm
diffusion	I-Algorithm
Halftoning	O
parameter	O
1	O
(	O
offset	O
64	O
)	O
is	O
the	O
percentage	O
of	O
error	O
damping	O
.	O
</s>
<s>
The	O
color	B-Data_Structure
table	I-Data_Structure
(	O
palette	B-Data_Structure
)	O
occurs	O
in	O
the	O
BMP	B-Device
image	I-Device
file	O
directly	O
after	O
the	O
BMP	B-Device
file	I-Device
header	O
,	O
the	O
DIB	O
header	O
,	O
and	O
after	O
the	O
optional	O
three	O
or	O
four	O
bitmasks	O
if	O
the	O
header	O
with	O
BI_BITFIELDS	O
(	O
12	O
bytes	O
)	O
or	O
BI_ALPHABITFIELDS	O
(	O
16	O
bytes	O
)	O
option	O
is	O
used	O
.	O
</s>
<s>
Note	O
:	O
On	O
Windows	B-Operating_System
CE	I-Operating_System
the	O
header	O
can	O
be	O
used	O
with	O
the	O
BI_ALPHABITFIELDSMSDN	O
-	O
(	O
Windows	B-Operating_System
CE	I-Operating_System
5.0	O
)	O
:	O
BI_ALPHABITFIELDS	O
in	O
biCompression	O
member	O
option	O
in	O
the	O
biCompression	O
member	O
.	O
</s>
<s>
The	O
number	O
of	O
entries	O
in	O
the	O
palette	B-Data_Structure
is	O
either	O
2n	O
(	O
where	O
n	O
is	O
the	O
number	O
of	O
bits	O
per	O
pixel	O
)	O
or	O
a	O
smaller	O
number	O
specified	O
in	O
the	O
header	O
(	O
in	O
the	O
OS/2	B-Application
header	O
format	O
,	O
only	O
the	O
full-size	O
palette	B-Data_Structure
is	O
supported	O
)	O
.	O
</s>
<s>
In	O
most	O
cases	O
,	O
each	O
entry	O
in	O
the	O
color	B-Data_Structure
table	I-Data_Structure
occupies	O
4	O
bytes	O
,	O
in	O
the	O
order	O
blue	O
,	O
green	O
,	O
red	O
,	O
0x00	O
(	O
see	O
below	O
for	O
exceptions	O
)	O
.	O
</s>
<s>
This	O
is	O
indexed	B-Data_Structure
in	O
the	O
in	O
the	O
structure	O
member	O
biBitCount	O
.	O
</s>
<s>
The	O
color	B-Data_Structure
table	I-Data_Structure
is	O
a	O
block	O
of	O
bytes	O
(	O
a	O
table	O
)	O
listing	O
the	O
colors	O
used	O
by	O
the	O
image	O
.	O
</s>
<s>
Each	O
pixel	O
in	O
an	O
indexed	B-Data_Structure
color	B-Algorithm
image	I-Algorithm
is	O
described	O
by	O
a	O
number	O
of	O
bits	O
(	O
1	O
,	O
4	O
,	O
or	O
8	O
)	O
which	O
is	O
an	O
index	O
of	O
a	O
single	O
color	O
described	O
by	O
this	O
table	O
.	O
</s>
<s>
The	O
purpose	O
of	O
the	O
color	O
palette	B-Data_Structure
in	O
indexed	B-Data_Structure
color	O
bitmaps	O
is	O
to	O
inform	O
the	O
application	O
about	O
the	O
actual	O
color	O
that	O
each	O
of	O
these	O
index	O
values	O
corresponds	O
to	O
.	O
</s>
<s>
The	O
purpose	O
of	O
the	O
color	B-Data_Structure
table	I-Data_Structure
in	O
non-indexed	O
(	O
non-palettized	O
)	O
bitmaps	O
is	O
to	O
list	O
the	O
colors	O
used	O
by	O
the	O
bitmap	O
for	O
the	O
purposes	O
of	O
optimization	O
on	O
devices	O
with	O
limited	O
color	B-Device
display	I-Device
capability	O
and	O
to	O
facilitate	O
future	O
conversion	O
to	O
different	O
pixel	O
formats	O
and	O
palettization	O
.	O
</s>
<s>
The	O
colors	O
in	O
the	O
color	B-Data_Structure
table	I-Data_Structure
are	O
usually	O
specified	O
in	O
the	O
4-byte	O
per	O
entry	O
RGBA32	O
format	O
.	O
</s>
<s>
The	O
color	B-Data_Structure
table	I-Data_Structure
used	O
with	O
the	O
OS/2	B-Application
uses	O
the	O
3-byte	O
per	O
entry	O
RGB24	O
format	O
.	O
</s>
<s>
For	O
DIBs	O
loaded	O
in	O
memory	O
,	O
the	O
color	B-Data_Structure
table	I-Data_Structure
can	O
optionally	O
consist	O
of	O
2-byte	O
entries	O
–	O
these	O
entries	O
constitute	O
indexes	O
to	O
the	O
currently	O
realized	O
palette	B-Data_Structure
instead	O
of	O
explicit	O
RGB	O
color	O
definitions	O
.	O
</s>
<s>
Microsoft	O
does	O
not	O
disallow	O
the	O
presence	O
of	O
a	O
valid	O
alpha	B-Algorithm
channel	I-Algorithm
bit	O
mask	O
in	O
and	O
for	O
1bpp	O
,	O
4bpp	O
and	O
8bpp	O
indexed	B-Data_Structure
color	B-Algorithm
images	I-Algorithm
,	O
which	O
indicates	O
that	O
the	O
color	B-Data_Structure
table	I-Data_Structure
entries	O
can	O
also	O
specify	O
an	O
alpha	O
component	O
using	O
the	O
8.8.8.[0-8]	O
.	O
</s>
<s>
As	O
mentioned	O
above	O
,	O
the	O
color	B-Data_Structure
table	I-Data_Structure
is	O
normally	O
not	O
used	O
when	O
the	O
pixels	O
are	O
in	O
the	O
16-bit	O
per	O
pixel	O
(	O
16bpp	O
)	O
format	O
(	O
and	O
higher	O
)	O
;	O
there	O
are	O
normally	O
no	O
color	B-Data_Structure
table	I-Data_Structure
entries	O
in	O
those	O
bitmap	O
image	O
files	O
.	O
</s>
<s>
However	O
,	O
the	O
Microsoft	O
documentation	O
(	O
on	O
the	O
MSDN	O
web	O
site	O
as	O
of	O
Nov	O
.	O
16	O
,	O
2010	O
)	O
specifies	O
that	O
for	O
16bpp	O
(	O
and	O
higher	O
)	O
,	O
the	O
color	B-Data_Structure
table	I-Data_Structure
can	O
be	O
present	O
to	O
store	O
a	O
list	O
of	O
colors	O
intended	O
for	O
optimization	O
on	O
devices	O
with	O
limited	O
color	B-Device
display	I-Device
capability	O
,	O
while	O
it	O
also	O
specifies	O
,	O
that	O
in	O
such	O
cases	O
,	O
no	O
indexed	B-Data_Structure
palette	B-Data_Structure
entries	I-Data_Structure
are	O
present	O
in	O
this	O
Color	B-Data_Structure
Table	I-Data_Structure
.	O
</s>
<s>
This	O
may	O
seem	O
like	O
a	O
contradiction	O
if	O
no	O
distinction	O
is	O
made	O
between	O
the	O
mandatory	O
palette	B-Data_Structure
entries	I-Data_Structure
and	O
the	O
optional	O
color	O
list	O
.	O
</s>
<s>
Unless	O
is	O
used	O
,	O
uncompressed	B-General_Concept
Windows	B-Device
bitmaps	I-Device
also	O
can	O
be	O
stored	O
from	O
the	O
top	O
to	O
bottom	O
,	O
when	O
the	O
Image	O
Height	O
value	O
is	O
negative	O
.	O
</s>
<s>
In	O
the	O
original	O
OS/2	B-Application
DIB	O
,	O
the	O
only	O
four	O
legal	O
values	O
of	O
color	O
depth	O
were	O
1	O
,	O
4	O
,	O
8	O
,	O
and	O
24	O
bits	O
per	O
pixel	O
(	O
bpp	O
)	O
.	O
</s>
<s>
GDI+	B-Operating_System
also	O
permits	O
64	O
bits	O
per	O
pixel	O
.	O
</s>
<s>
Indexed	B-Data_Structure
color	B-Algorithm
images	I-Algorithm
may	O
be	O
compressed	O
with	O
4-bit	O
or	O
8-bit	O
RLE	B-Algorithm
or	O
Huffman	B-General_Concept
1D	O
algorithm	O
.	O
</s>
<s>
OS/2	B-Application
2	O
24bpp	O
images	O
may	O
be	O
compressed	O
with	O
the	O
24-bit	O
RLE	B-Algorithm
algorithm	O
.	O
</s>
<s>
The	O
16bpp	O
and	O
32bpp	O
images	O
are	O
always	O
stored	O
uncompressed	B-General_Concept
.	O
</s>
<s>
An	O
unset	O
bit	O
will	O
refer	O
to	O
the	O
first	O
color	B-Data_Structure
table	I-Data_Structure
entry	O
,	O
and	O
a	O
set	O
bit	O
will	O
refer	O
to	O
the	O
last	O
(	O
second	O
)	O
color	B-Data_Structure
table	I-Data_Structure
entry	O
.	O
</s>
<s>
The	O
2-bit	O
per	O
pixel	O
(	O
2bpp	O
)	O
format	O
supports	O
4	O
distinct	O
colors	O
and	O
stores	O
4	O
pixels	O
per	O
1	O
byte	O
,	O
the	O
left-most	O
pixel	O
being	O
in	O
the	O
two	O
most	O
significant	O
bits	O
(	O
Windows	B-Operating_System
CE	I-Operating_System
only	O
:	O
)	O
.	O
</s>
<s>
Each	O
WORD	O
can	O
define	O
the	O
alpha	O
,	O
red	O
,	O
green	O
and	O
blue	O
samples	B-Algorithm
of	O
the	O
pixel	O
.	O
</s>
<s>
Each	O
pixel	O
value	O
defines	O
the	O
red	O
,	O
green	O
and	O
blue	O
samples	B-Algorithm
of	O
the	O
pixel	O
(	O
8.8.8.0.0	O
in	O
RGBAX	O
notation	O
)	O
.	O
</s>
<s>
Each	O
DWORD	O
can	O
define	O
the	O
alpha	O
,	O
red	O
,	O
green	O
and	O
blue	O
samples	B-Algorithm
of	O
the	O
pixel	O
.	O
</s>
<s>
In	O
order	O
to	O
resolve	O
the	O
ambiguity	O
of	O
which	O
bits	O
define	O
which	O
samples	B-Algorithm
,	O
the	O
DIB	O
headers	O
provide	O
certain	O
defaults	O
as	O
well	O
as	O
specific	O
BITFIELDS	O
,	O
which	O
are	O
bit	O
masks	O
that	O
define	O
the	O
membership	O
of	O
particular	O
group	O
of	O
bits	O
in	O
a	O
pixel	O
to	O
a	O
particular	O
channel	B-Algorithm
.	O
</s>
<s>
The	O
alpha	O
bit	O
mask	O
is	O
valid	O
whenever	O
it	O
is	O
present	O
in	O
the	O
DIB	O
header	O
or	O
when	O
the	O
Compression	O
member	O
of	O
the	O
DIB	O
header	O
is	O
set	O
to	O
BI_ALPHABITFIELDS	O
(	O
Windows	B-Operating_System
CE	I-Operating_System
only	O
)	O
.	O
</s>
<s>
In	O
version	O
2.1.4	O
FFmpeg	B-Library
supported	O
(	O
in	O
its	O
own	O
terminology	O
)	O
the	O
BMP	B-Device
pixel	O
formats	O
bgra	O
,	O
bgr24	O
,	O
rgb565le	O
,	O
rgb555le	O
,	O
rgb444le	O
,	O
rgb8	O
,	O
bgr8	O
,	O
rgb4_byte	O
,	O
bgr4_byte	O
,	O
gray	O
,	O
pal8	O
,	O
and	O
monob	O
;	O
i.e.	O
,	O
bgra	O
was	O
the	O
only	O
supported	O
pixel	O
format	O
with	O
transparency	O
.	O
</s>
<s>
Following	O
is	O
an	O
example	O
of	O
a	O
2×2	O
pixel	O
,	O
24-bit	O
bitmap	O
(	O
Windows	B-Application
DIB	O
header	O
)	O
with	O
pixel	O
format	O
RGB24	O
.	O
</s>
<s>
Offset	O
Size	O
Hex	O
value	O
Value	O
Description	O
BMP	B-Device
Header0h242	O
4D	O
"	O
BM	O
"	O
ID	O
field	O
(	O
42h	O
,	O
4Dh	O
)	O
2h446	O
00	O
00	O
0070	O
bytes	O
(	O
54+16	O
)	O
Size	O
of	O
the	O
BMP	B-Device
file	I-Device
(	O
54	O
bytes	O
header	O
+	O
16	O
bytes	O
data	O
)	O
6h200	O
00UnusedApplication	O
specific8h200	O
00UnusedApplication	O
specificAh436	O
00	O
00	O
0054	O
bytes	O
(	O
14+40	O
)	O
Offset	O
where	O
the	O
pixel	O
array	O
(	O
bitmap	O
data	O
)	O
can	O
be	O
found	O
DIB	O
HeaderEh428	O
00	O
00	O
0040	O
bytesNumber	O
of	O
bytes	O
in	O
the	O
DIB	O
header	O
(	O
from	O
this	O
point	O
)	O
12h402	O
00	O
00	O
002	O
pixels	O
(	O
left	O
to	O
right	O
order	O
)	O
Width	O
of	O
the	O
bitmap	O
in	O
pixels16h402	O
00	O
00	O
002	O
pixels	O
(	O
bottom	O
to	O
top	O
order	O
)	O
Height	O
of	O
the	O
bitmap	O
in	O
pixels	O
.	O
</s>
<s>
Following	O
is	O
an	O
example	O
of	O
a	O
4×2	O
pixel	O
,	O
32-bit	O
bitmap	O
with	O
opacity	O
values	O
in	O
the	O
alpha	B-Algorithm
channel	I-Algorithm
(	O
Windows	B-Application
DIB	O
Header	O
)	O
with	O
pixel	O
format	O
ARGB32	O
.	O
</s>
<s>
The	O
simplicity	O
of	O
the	O
BMP	B-Device
file	I-Device
format	I-Device
,	O
and	O
its	O
widespread	O
familiarity	O
in	O
Windows	B-Application
and	O
elsewhere	O
,	O
as	O
well	O
as	O
the	O
fact	O
that	O
this	O
format	O
is	O
relatively	O
well	O
documented	O
and	O
has	O
an	O
open	O
format	O
,	O
makes	O
BMP	B-Device
a	O
very	O
common	O
format	O
that	O
image	O
processing	O
programs	O
from	O
many	O
operating	O
systems	O
can	O
read	O
and	O
write	O
.	O
</s>
<s>
Many	O
older	O
graphical	B-Application
user	I-Application
interfaces	I-Application
used	O
bitmaps	O
in	O
their	O
built-in	O
graphics	O
subsystems	O
;	O
for	O
example	O
,	O
the	O
Microsoft	B-Application
Windows	I-Application
and	O
OS/2	B-Application
platforms	O
 '	O
GDI	B-Operating_System
subsystem	O
,	O
where	O
the	O
specific	O
format	O
used	O
is	O
the	O
Windows	B-Device
and	I-Device
OS/2	I-Device
bitmap	I-Device
file	O
format	O
,	O
usually	O
named	O
with	O
the	O
file	O
extension	O
of	O
.BMP	B-Device
.	O
</s>
<s>
While	O
most	O
BMP	B-Device
files	I-Device
have	O
a	O
relatively	O
large	O
file	O
size	O
due	O
to	O
lack	O
of	O
any	O
compression	O
(	O
or	O
generally	O
low-ratio	O
run-length	B-Algorithm
encoding	I-Algorithm
on	O
palletized	O
images	O
)	O
,	O
many	O
BMP	B-Device
files	I-Device
can	O
be	O
considerably	O
compressed	O
with	O
lossless	B-Algorithm
data	I-Algorithm
compression	I-Algorithm
algorithms	O
such	O
as	O
ZIP	B-General_Concept
because	O
they	O
contain	O
redundant	O
data	O
.	O
</s>
<s>
The	O
X	B-Operating_System
Window	I-Operating_System
System	I-Operating_System
uses	O
a	O
similar	O
XBM	B-Device
format	O
for	O
black-and-white	O
images	O
,	O
and	O
XPM	O
(	O
pixelmap	B-Algorithm
)	O
for	O
color	B-Algorithm
images	I-Algorithm
.	O
</s>
