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

DynamicImage:from SubImage<&DynamicImage>::to_image creates Rgba8 instead of L16 #2274

Open
emirror-de opened this issue Jul 1, 2024 · 3 comments · May be fixed by #2344
Open

DynamicImage:from SubImage<&DynamicImage>::to_image creates Rgba8 instead of L16 #2274

emirror-de opened this issue Jul 1, 2024 · 3 comments · May be fixed by #2344
Labels
kind: API missing or awkward public APIs next: breaking Information tag for PRs and ideas that require an interface break

Comments

@emirror-de
Copy link

I am using the code below to transform a grayscale image from SubImage<&DynamicImage> to DynamicImage.
Is there something I am missing during this conversion?

Expected

I would expect the new dest image to be L16 as well.

Actual behaviour

dest image is of Rgba8.

Reproduction steps

// source = SubImage<&DynamicImage>
debug!("{}", source.inner().color()); // outputs: L16
let dest = DynamicImage::from(source.to_image());
debug!("{}", dest.color()); // outputs: Rgba8
@emirror-de
Copy link
Author

I am now using this workaround:

let tmp_img = source.to_image();
let mut dest = DynamicImage::new(tmp_img.width(), tmp_img.height(), img.inner().color());
dest.copy_from(&*source, 0, 0)?;

But this feels a bit complicated and suboptimal?

@fintelia
Copy link
Contributor

fintelia commented Jul 2, 2024

This is related to #1952. The DynamicImage enum implements GenericImage<Rgba<u8>> even though it really shouldn't

@emirror-de
Copy link
Author

Ahh I see. Thanks for the hint.

@Shnatsel Shnatsel mentioned this issue Jul 28, 2024
7 tasks
@Shnatsel Shnatsel added next: breaking Information tag for PRs and ideas that require an interface break kind: API missing or awkward public APIs labels Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: API missing or awkward public APIs next: breaking Information tag for PRs and ideas that require an interface break
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants