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

Fixed int -> float truncation warning in pixel.hpp #689

Closed
wants to merge 2 commits into from

Conversation

jsenn
Copy link

@jsenn jsenn commented Jun 17, 2022

Description

The underlying channel type for grayscale pixels is a 32-bit float. If Channel cannot be losslessly converted to a float--for example, if it is int--this would generate a compiler warning. The fix here is to perform an explicit cast. Fixes #688.

References

See related issue: #688.

jsenn added 2 commits June 17, 2022 14:26
The underlying channel type for grayscale pixels is a 32-bit float. If `Channel` cannot be losslessly converted to a float--for example, if it is `int`--this would generate a compiler warning. The fix here is to perform an explicit cast. Fixes boostorg#688.
@jsenn
Copy link
Author

jsenn commented Jun 17, 2022

The proposed change fixes the warning for the sample code given, but fails template instantiation for pixels that have a raw channel type (i.e., that don't use scoped_channel_value).

Also, on further inspection I'm not sure that a simple cast is even warranted here--the warning in #688 results from a piece of code in numeric.hpp that's multiplying 2 shorts (producing an int) and then assigning it to a 32-bit float grayscale pixel (which is scoped to [0, 1]). I'm not sure what the correct behaviour even is there, so I'll close this and let someone more knowledgeable figure this out.

@jsenn jsenn closed this Jun 17, 2022
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.

Compiler warning in pixel.hpp
1 participant