Skip to content

[afterimage] fix corrupt loop index when bmp bitcount is 16 and correctly normalize 5-bit color#21801

Open
ferdymercury wants to merge 2 commits intoroot-project:masterfrom
ferdymercury:patch-16
Open

[afterimage] fix corrupt loop index when bmp bitcount is 16 and correctly normalize 5-bit color#21801
ferdymercury wants to merge 2 commits intoroot-project:masterfrom
ferdymercury:patch-16

Conversation

@ferdymercury
Copy link
Copy Markdown
Collaborator

@ferdymercury ferdymercury commented Apr 6, 2026

Fixes #8125

x is the loop variable for both data and buf
buf->color contains N elements
data contains 2*N elements
hence, keep separate indices for each array.

A further change is needed for correct color normalization, since buf-> expects a range between 0 and 255 but data contains 5-bit colors from 0 to 31.

Found the fix thanks to easy debug via #21649

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

Now BMP file in the issue correctly shows:

image

Fixes root-project#8125

x is the loop variable for both data and buf
buf->color contains N elements
data contains 2*N elements
hence, keep separate indices for each array.
@ferdymercury ferdymercury requested a review from couet as a code owner April 6, 2026 15:56
@ferdymercury ferdymercury changed the title [afterimage] fix corrupt loop index when bmp bitcount is 16 [afterimage] fix corrupt loop index when bmp bitcount is 16 and correctly normalize 5-bit color Apr 6, 2026
This is needed for correct color normalization, since buf-> expects a range between 0 and 255 but data contains 5-bit colors from 0 to 31.
@ferdymercury ferdymercury requested a review from linev April 6, 2026 16:02
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 6, 2026

Test Results

    21 files      21 suites   2d 22h 41m 16s ⏱️
 3 828 tests  3 827 ✅  1 💤 0 ❌
72 099 runs  72 081 ✅ 18 💤 0 ❌

Results for commit 5bd9897.

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.

BMP TASImage artefacts and crashes

1 participant