Skip to content
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

Fix endian dependent color reading #25

Merged
merged 5 commits into from
Mar 28, 2022
Merged

Fix endian dependent color reading #25

merged 5 commits into from
Mar 28, 2022

Conversation

Eathox
Copy link
Contributor

@Eathox Eathox commented Mar 28, 2022

Issue

When reading the HEX colors from a xpm42 file strtol is used over the whole HEX sequence, strtol treats this whole sequence as one number. Therefor when the endian doesn't match the presumed RGBA order the result is not the expected color.

Sample image with incorrect endian:
incorect

Solution

Instead of using strtol over the whole HEX sequence, use it only over the individual color channels and then manually bit shift the channels to the expected location.

Sample image with HEX channel correction:
corect

src/textures/mlx_xpm42.c Outdated Show resolved Hide resolved
src/textures/mlx_xpm42.c Outdated Show resolved Hide resolved
src/textures/mlx_xpm42.c Outdated Show resolved Hide resolved
src/textures/mlx_xpm42.c Outdated Show resolved Hide resolved
@W2Wizard W2Wizard added the Fix Fixed or resolved an issue label Mar 28, 2022
@W2Wizard
Copy link
Collaborator

Looks all good! Thank you 👍

@W2Wizard W2Wizard merged commit b960ccb into codam-coding-college:master Mar 28, 2022
@Eathox Eathox deleted the windows-xpm branch March 28, 2022 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix Fixed or resolved an issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants