Skip to content

api: convert images to float before saving them - #3730

Draft
melonakos wants to merge 1 commit into
masterfrom
fix/3544-save-image-types
Draft

melonakos wants to merge 1 commit into
masterfrom
fix/3544-save-image-types

Conversation

@melonakos

Copy link
Copy Markdown
Member

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.

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.
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.

1 participant