-
Notifications
You must be signed in to change notification settings - Fork 142
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
Writer needs an .into_inner() function #298
Comments
Couldn't you do: let mut bytes = Vec::new();
{
let mut encoder = png::Encoder::new(Cursor::new(&mut bytes), info.width, info.height);
encoder.set_color(png::ColorType::RGB);
encoder.set_depth(info.bit_depth);
let mut writer = encoder.write_header()?;
writer.write_image_data(&frame)?;
} |
Yes, that worked. Thanks! |
This workaround no longer works in
I believe this is because Lines 173 to 174 in c24fc93
I think this issue should be reopened for version 0.17 and #299 may be revived as well. |
Could you check why the static bound was added? Might be that we could remove that instead |
It was added in 7ed5169 I don't understand the motivation behind it well though... |
I don't quite understand that either, but it looks like the static bound isn't meant to apply to the writer at all! |
It still works: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=769e84f77aae22624b26ec51df1a74c1 The return value does not force |
I believe Rust Playground imports |
Okay, that's a separate problem for let mut writer = encoder
.write_header()?;
let mut writer = writer
.stream_writer()?; So it only works as long as you do not want to store the Specifically in this enum: Lines 981 to 984 in c24fc93
This links the lifetime parameter to the |
Thanks!
worked for me. I'd happily avoid using |
I want to write a PNG to memory. I wrote code like this:
I can't get the bytes back out without an
into_inner()
function. The line letcursor = writer.into_inner();
fails to compile because there's no.into_inner()
function.The text was updated successfully, but these errors were encountered: