Conversation
saveImage and saveImageMem read the channel buffers back as float regardless of the input type, so a u8 image (or f64, or any non-f32 type) was written as garbage, all zeros in the reported case. The input is now cast to f32 after the range scaling, and the docs say which types and value range are accepted. Fixes #3544.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
saveImage and saveImageMem read their channel buffers back as float whatever the input type, so a u8 image (or f64, or any non-f32 type) was written as garbage, all zeros in the reported case (#3544). The input is now cast to f32 after the existing range scaling, and the saveImage docs say any real type is accepted with values in [0, 255] (a maximum of at most 1 is scaled by 255, as before). Adds a round-trip test through a PNG file and the in-memory path for u8, u16, s16, s32, u32 and f64.
Verified on the CPU backend and on OpenCL (Intel Arc B580 and UHD 770): the new test fails on master and passes with the fix, and the imageio suite passes on all three.