by EMRZ · 8y ago · 0 comments
He bundled the whole source code and binary data used in the game/tech demo to use the in browser image decompression, avoiding to write a custom (de)compression code, saving KBs this way.
Then he just eval() the needed parts for each thing.
I found this extremely clever, game jam limitations, specially size ones, evolve into clever programming tricks that are interesting both to code and to look at.
I am not really into javascript/frontend development, but following js13k on twitter showed me a lot of things you can do to gain KBs on the client side.
However, is this that common?
Thanks for the info btw.
Each of the possible filters is very simple, but the difference between a great PNG exporter, a mediocre one, and a trash fire is the use of a heuristic to decide which of the pre-processing filters should be applied to each line of output. libpng, the free implementation, includes a heuristic that does a fairly OK job, if you just don't implement a heuristic and use no filtering at all, the results are enormous PNG files as seen in turn of the century Adobe Photoshop. So, no, a general purpose compression algorithm isn't very good for image data on its own.
(Choose for yourself whether you think Adobe wanted to discourage use of a popular free image format in favour of licensed formats for which it held relevant IP, or their development team are just incompetent morons, or both).
Yes, as a means of making the data fed into the compressor repetitive enough to benefit from the compression algorithm.
> So, no, a general purpose compression algorithm isn't very good for image data on its own.
That's not what I said.
You definitely won't save enough bytes with better input heuristics than the amount of code needed to decompress them if you're only working with 13Kb of data.