Skip to content

Clarify various aspects of interpreting DIBs with compression of BI_BITFIELDS #5241

Closed

Description

Type of issue

Missing information

Feedback

This feedback relates to Windows device-independent bitmap (DIB) formats with the BI_BITFIELDS compression mode.

When a DIB has the compression mode BI_BITFIELDS (biCompression of BITMAPINFOHEADER or bV*Compression of BITMAPV4HEADER or BITMAPV5HEADER equals BI_BITFIELDS):

  • Clarify the meaning of b*ClrUsed. Is this member 0? Is this member equal to 3, the size of bmiColors, or the number of colors in the color table if any?
  • Can the DIB contain both a color table and color masks that follow the BITMAPINFOHEADER, BITMAPV4HEADER, or BITMAPV5HEADER?
  • In the case of a packed DIB's BITMAPV4HEADER or BITMAPV5HEADER, is the DIB allowed to have color masks that follow the header? Or must the bV*RedMask, bV*GreenMask, bV*BlueMask, and bV*AlphaMask fields be used as the masks in this case?
  • Clarify the valid choices for color masks (including the alpha mask, if any). For example, can one of the color masks be zero and can the fields of the masks overlap?
  • Clarify the conversion of color components to 8 bits per color component, especially when the color masks reflect that a color component has fewer or greater than 8 bits or when a color mask is 0.

Is the member bV*AlphaMask valid only for the compression mode BI_BITFIELDS? If no, then for DIBs of which bits-per-pixel values can this member be specified?

Also, the documentation for BITMAPV4HEADER says bV4V4Compression in one place, rather than bV4Compression.

Activity

  1. changed the title [-]Clarify meaning of `biClrUsed` and presence of color tables and color masks in DIBs when compression is `BI_BITFIELDS`[/-] [+]Clarify meaning of `biClrUsed` and presence of a color table in DIBs when compression is `BI_BITFIELDS`[/+] on Dec 12, 2024
  2. changed the title [-]Clarify meaning of `biClrUsed` and presence of a color table in DIBs when compression is `BI_BITFIELDS`[/-] [+]Clarify meaning of `biClrUsed`, presence of a color table, and valid color masks in DIBs when compression is `BI_BITFIELDS`[/+] on Dec 12, 2024
  3. changed the title [-]Clarify meaning of `biClrUsed`, presence of a color table, and valid color masks in DIBs when compression is `BI_BITFIELDS`[/-] [+]Clarify various aspects of interpreting DIBs with compression of `BI_BITFIELDS`[/+] on Dec 14, 2024
  4. stevewhims commented on Jan 22, 2025

    @stevewhims
    Contributor

    Hi, Peter Occil (@peteroupc),

    I'll consult the product team for help with these questions.

    -Steve

  5. stevewhims commented on Jan 22, 2025

    @stevewhims
    Contributor

    This is the same response for issues 5241 and 5265.

    It sounds like you want to retrieve information about a bitmap. Parsing a bitmap that way in your own code is extremely complicated and error-prone, and we don’t recommend it.

    If you could describe exactly what it is you want to do, then perhaps there are other ways we can help.

  6. peteroupc commented on Jan 23, 2025

    @peteroupc
    Author

    I am indeed working on a routine to read Windows bitmap (.bmp) files, in Python, and the points in this issue and in #5265 are points where the documentation for BITMAPINFOHEADER, etc. needs some more clarity so that I know whether to accept, reject, or properly interpret such files in tricky cases.

    Consider, for example, a DIB which—

    • contains both a color table and color masks that follow the BITMAPINFOHEADER, or
    • has color masks that overlap in their bits, or
    • has color masks at least one of which is 0, or
    • has color masks that follow the BITMAPV4HEADER or BITMAPV5HEADER, or
    • has a compression mode and a biSizeImage that equals the uncompressed size rather than the compressed size.

    Should I accept or reject any of these cases when they arise?

  7. added a commit that references this issue on Mar 6, 2025
  8. peteroupc commented on Jul 17, 2026

    @peteroupc
    Author

    I still seek clarification in the API documentation on this issue as well as #5265.

  9. GrantMeStrength commented on Sep 2, 2026

    @GrantMeStrength
    Collaborator

    Thanks for the detailed questions, and for the earlier thread here.

    These clarifications all concern the Win32 API reference for BITMAPINFOHEADER, BITMAPV4HEADER, and BITMAPV5HEADER (the /windows/win32/api/wingdi/... pages), including the bV4V4Compression vs. bV4Compression typo you spotted. That reference content is generated from a separate repository than this one (MicrosoftDocs/windows-dev-docs), so feedback filed here won't reach the team that maintains those pages.

    The most reliable way to get these routed is the Feedback control at the bottom of the specific API reference page (for example, on the BITMAPINFOHEADER page) — that files against the correct source repo. We're also flagging this internally (jkendirs@microsoft.com) so the header-interpretation questions and the bV4V4Compression typo are on the right team's radar.

    I'm going to close this issue here since it can't be actioned in this repo, but please don't hesitate to reopen or file via the reference page's feedback control if anything above is unclear.

  10. peteroupc commented on Sep 2, 2026

    @peteroupc
    Author

    I should note, though, the following:

    • There is no feedback control or link on the BITMAPINFOHEADER, BITMAPV4HEADER, or BITMAPV5HEADER page.
    • The repository for those pages, https://github.com/MicrosoftDocs/win32 , does not accept the filing of issues (no "Issues" link is present in the repository's home page).

    These two circumstances motivated me to post an issue in this repository, which is related to the win32 repository and does accept the filing of issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions