-
Notifications
You must be signed in to change notification settings - Fork 99
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
fix image example buffer size calculation #359
Conversation
… constant `::MAX`
Also i went through the clippy suggestions. Please pay extra attention to the changed slice size calculations as I'm extremely tired at the moment and not sure if i overlooked reasons to not use |
Thanks for the PR! LGTM 👍 |
I will do some testing before merging this |
This change breakes the image test
Gives
|
Sorry, I kinda screwed up when merging this and then reverting it. I wonder if you can open up a new PR with the correct fixes? |
The calculation of the buffer size for a loaded image in the example code currently allocates a
Vec<u32>
that is exactly 4 times longer than needed.This is due to
png::decoder::Reader::output_buffer_size()
returning the size of the buffer in bytes.These bytes are later packed to
u32
s, which reduces the needed length of theu32
buffer topng::decoder::Reader::output_buffer_size() / 4