Skip to content

lbm: Fix Extra-Half-Brite usage. - #758

Merged
slouken merged 1 commit into
libsdl-org:mainfrom
icculus:sdl3image-ilbm-ehb-fix
Aug 21, 2026
Merged

lbm: Fix Extra-Half-Brite usage.#758
slouken merged 1 commit into
libsdl-org:mainfrom
icculus:sdl3image-ilbm-ehb-fix

Conversation

@icculus

@icculus icculus commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

If the caller loads an ILBM file with 64 colors, and either provided a colormap with <= 32 colors or set the Extra_Half-Brite flag, then duplicate the lower 32 entries to half-intensity versions in the upper half.

This also initializes colormap to zero unconditionally, in case this logic would otherwise touch uninitialized stack memory. Now if there's a weird file that didn't provide all 32 colors, the original and half-brite ones will just be black instead of random data.

https://en.wikipedia.org/wiki/ILBM#Extra_Half-Brite

(Also an SDL_memset for an unrelated thing was changed to SDL_zero, since I was in here anyhow.)

If the caller loads an ILBM file with 64 colors, and either provided a
colormap with <= 32 colors or set the Extra_Half-Brite flag, then duplicate
the lower 32 entries to half-intensity versions in the upper half.

This also initializes colormap to zero unconditionally, in case this logic
would otherwise touch uninitialized stack memory. Now if there's a weird file
that didn't provide all 32 colors, the original and half-brite ones will just
be black instead of random data.

https://en.wikipedia.org/wiki/ILBM#Extra_Half-Brite

(Also an SDL_memset for an unrelated thing was changed to SDL_zero, since I
was in here anyhow.)
@icculus icculus added this to the 3.4.6 milestone Aug 15, 2026
@slouken
slouken merged commit ce8ba6e into libsdl-org:main Aug 21, 2026
5 checks passed
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.

2 participants