Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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](https://user-images.githubusercontent.com/28459732/160482459-a4b3bcaf-a28b-42fa-9cfc-e3895be159a4.png)
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](https://user-images.githubusercontent.com/28459732/160482241-2b3c9f93-1cf0-4286-9ac4-2c1bbefd9455.png)