Skip to content

Fix stbi_write_bmp invalid bV4CSType header value for 32-bit images - #1975

Open
cpsurfer wants to merge 1 commit into
nothings:masterfrom
cpsurfer:fix-bmp-v4-cstype
Open

Fix stbi_write_bmp invalid bV4CSType header value for 32-bit images#1975
cpsurfer wants to merge 1 commit into
nothings:masterfrom
cpsurfer:fix-bmp-v4-cstype

Conversation

@cpsurfer

@cpsurfer cpsurfer commented Jul 7, 2026

Copy link
Copy Markdown

Problem

When writing 32-bit RGBA images via stbi_write_bmp, the function utilizes a BITMAPV4HEADER but assigns 0 (LCS_CALIBRATED_RGB) to the bV4CSType field. Because the subsequent endpoint profiles are also written as zero, strict image parsers—such as Microsoft Paint (pbrush)—fail to validate the header, resulting in a file load error.

Solution

This PR changes the bV4CSType parameter from 0 to 0x73524742 (LCS_sRGB). This explicitly marks the color space as standard sRGB, ensuring compliance with strict OS-level parsers and fixing the load failures without altering the structural layout or size of the header.


I dedicate this modification to the public domain.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant