-
Notifications
You must be signed in to change notification settings - Fork 143
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
API Evolution #534
Comments
This sounds good. FWIW all inputs that I've worked with so far can implement
This seems a bit tricky:
One idea that we may want to consider (I don't feel strongly about this) would be to offer 3 levels of API: Just my 2 cents... |
Worst case, they could be wrapped in a
The idea is that the Reader would internally track the canvas and apply blend+dispose ops to it. That's how the
This is something that I wasn't really aware of before hearing about how Chrome has a common abstraction. Each of the format specifications has its own description of how compositing works, and I never did a detailed comparison between them to realize they were all the same. It could totally make sense to spin this logic into its own crate. |
I'm not a fan of APIs that write to
|
What about unknown chunks? I imagine there would be some visitor to collect them, along with their position. Needed to transcode arbitrary PNGs. In
The client is not allowed to do this. Blending happens inside the decoder, on raw pixel intensities: https://www.w3.org/TR/png-3/#13Alpha-channel-processing |
Currently the All of this complication is because It would be replaced with something else that lets it get/read a certain number of bytes when it needs it. It could be Alternatively, the |
Is OTOH it's probably already buggy, since it doesn't reset all the fields used in the constructor, and that may be a recurring theme with it. |
I have been wondering whether we should make Edit: I've got a branch where I've been exploring using |
Yeah, something like this. I'm concerned that I'd go further and instead loading |
Oh, I can do that even without changing the API! Part of the |
Interesting idea. The main challenge here is that as long as the scratch buffer is not empty, it needs to be consumed first. So once we start using the scratch buffer, it's tricky to stop.
You probably already realize this, but let me point it out explicitly - we may need to consume small input chunks even if using a |
I'm not planning to support such buffering model. What I'm proposing is an interface where asking for Such buffering interface is not usable for inflate, but it should be fine for the PNG structure where all sizes needed can be known ahead of time. The scratch buffer can be filled up exactly to the level it needs to be, used up entirely every time, and leave nothing behind. |
Thank you for explaining. This does address my concern (especially the "used up entirely every time" part).
FWIW I tried to implement my idea - see the commits here. The main idea has 2 parts (implemented in the 1st commit):
This way we can remove all other buffers from And as a follow-up, in the 3rd commit I changed how the first bytes (including the PNG signature) are handled - instead of two U32s, I just ask for 16 bytes. I like how |
In response to another issue, I started writing up some thoughts on how what I'd do if I were designing this crate's API from scratch, but realized it would probably be a better fit as a standalone discussion...
One difference would be the use of
Seek
to expose a more flexible API. The default behavior would be to composite frames, with an opt-out to get the raw frame contents. Also probably a clearer distinction between low-level and high-level decoding, though I'm not 100% sure how I'd handle the interaction between the two.The text was updated successfully, but these errors were encountered: