Skip to content

[rtextures] fix integer overflow in cast for ImageBlurGaussian #5037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2025

Conversation

garrisonhh
Copy link
Contributor

I had a weird bug where ImageBlurGaussian with blurSize=1 added weird discolored lines:

lightblub-noblur lightbulb-blur

The bug happens in the final 'reverse premultiply' step where a rounding error can produce RGB color values that are >=256.0. When cast back to unsigned char for storage, this overflows to zero -- producing colors that are way off. This fix rounds these values down to 255 instead.

@garrisonhh garrisonhh changed the title [retextures] fix integer overflow in cast for ImageBlurGaussian [rtextures] fix integer overflow in cast for ImageBlurGaussian Jul 10, 2025
@raysan5 raysan5 merged commit 20a07a6 into raysan5:master Jul 10, 2025
15 checks passed
@raysan5
Copy link
Owner

raysan5 commented Jul 10, 2025

@garrisonhh Oh! Good catch! Thanks for the review!

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