Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
BMP file format
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Color table === The color table (palette) occurs in the BMP image file directly after the BMP file header, the DIB header, and after the optional three or four bitmasks if the {{mono|BITMAPINFOHEADER}} header with BI_BITFIELDS (12 bytes) or BI_ALPHABITFIELDS (16 bytes) option is used. Therefore, its offset is the size of the {{mono|BITMAPFILEHEADER}} plus the size of the DIB header (plus optional 12-16 bytes for the three or four bit masks).<br> <small>''Note: On [[Windows CE]] the {{mono|BITMAPINFOHEADER}} header can be used with the BI_ALPHABITFIELDS<ref name="AlphaBitFields">MSDN - {{mono|BITMAPINFOHEADER}} (Windows CE 5.0): [http://msdn.microsoft.com/en-us/library/aa452885.aspx BI_ALPHABITFIELDS in biCompression member]</ref> option in the biCompression member.''</small> The number of entries in the palette is either 2<sup>''n''</sup> (where n is the number of bits per pixel) or a smaller number specified in the header (in the OS/2 {{mono|BITMAPCOREHEADER}} header format, only the full-size palette is supported).<ref name="os2bmp" /><ref name=DIBhelp/> In most cases, each entry in the color table occupies 4 bytes, in the order blue, green, red, 0x00 (see below for exceptions). This is indexed in the {{mono|BITMAPINFOHEADER}} in the structure member biBitCount. The color table is a block of bytes (a table) listing the colors used by the image. Each pixel in an indexed color image is described by a number of bits (1, 4, or 8) which is an index of a single color described by this table. The purpose of the color palette in indexed color bitmaps is to inform the application about the actual color that each of these index values corresponds to. The purpose of the color table in non-indexed (non-palettized) bitmaps is to list the colors used by the bitmap for the purposes of optimization on devices with limited color display capability and to facilitate future conversion to different pixel formats and palettization. The colors in the color table are usually specified in the 4-byte per entry [[RGBA|ARGB32]] format. The color table used with the OS/2 {{mono|BITMAPCOREHEADER}} uses the 3-byte per entry [[RGB|RGB24]] format.<ref name="os2bmp" /><ref name=DIBhelp/> For DIBs loaded in memory, the color table can optionally consist of 2-byte entries β these entries constitute indexes to the currently realized palette<ref name=BITMAPINFO/> instead of explicit RGB color definitions. Microsoft does not disallow the presence of a valid alpha channel bit mask<ref>MSDN β {{mono|BITMAPV4HEADER}}: [http://msdn.microsoft.com/en-us/library/dd183380%28VS.85%29.aspx The member bV4AlphaMask]</ref> in {{mono|BITMAPV4HEADER}} and {{mono|BITMAPV5HEADER}} for 1bpp, 4bpp and 8bpp indexed color images, which indicates that the color table entries can also specify an alpha component using the [[RGBAX|8.8.8.[0-8].[0-8]]] format via the RGBQUAD.rgbReserved<ref>MSDN β RGBQUAD: [http://msdn.microsoft.com/en-us/library/dd162938%28VS.85%29.aspx rgbReserved member]</ref> member. However, some versions of Microsoft's documentation disallow this feature by stating that the RGBQUAD.rgbReserved member "must be zero". As mentioned above, the color table is normally not used when the pixels are in the 16-bit per pixel (16bpp) format (and higher); there are normally no color table entries in those bitmap image files. However, the Microsoft documentation (on the MSDN web site as of Nov. 16, 2010<ref>see note under biClrUsed [http://msdn.microsoft.com/en-us/library/windows/desktop/dd183376(v=vs.85).aspx MSDN {{mono|BITMAPINFOHEADER}}]</ref>) specifies that for 16bpp (and higher), the color table can be present to store a list of colors intended for optimization on devices with limited color display capability, while it also specifies, that in such cases, no indexed palette entries are present in this Color Table. This may seem like a contradiction if no distinction is made between the mandatory palette entries and the optional color list.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)