3 ms·
That was the goal, but the underlying library is general-purpose. Writing a minimal uncompressed PNG writer from scratch is a fun exercise; the spec is pretty
by andrewla 9y ago
That was the goal, but the underlying library is general-purpose.
Writing a minimal uncompressed PNG writer from scratch is a fun exercise; the spec is pretty clear and the only tricky part, really, is getting the uncompressed zlib part right, especially since the block sizes are undocumentedly little-endian, while everything else is big-endian.
Self-contained code for image generation and consumption can be pretty useful. It's one of the reasons that I like farbfeld, suckless's incredible simple binary image format, because libraries for processing it are essentially unnecessary since the format itself is so straightforward.
- _alastair 9y ago> especially since the block sizes are undocumentedly little-endian, while everything else is big-endian. Yes! That stumped me for a long time. Along the way to solving it I found this great Stack Overflow answer where the creator of ADLER32 popped in to give some advice: https://stackoverflow.com/questions/32633486/why-are-png-deflate-block-lengths-being-ignored#comment53120790_32635822 https://stackoverflow.com/questions/32633486/why-are-png-def... "Also just realized that you are that Mark Adler."