TEST: PNG/Deflate compression option for sprites #2111
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WARNING: for test only, not for merging at the moment.
This is a remake of #2098, with properly linked zlib, fixed compilation and logical mistakes.
Introduces a new compression option for sprites, called "PNG" for simplicity sake, which uses Deflate algorithm.
Current implementation requires to link a zlib library. But I'd like to investigate if it's feasible to embed necessary set of functions directly into the engine, similar to how stb_image library does this (for example).
I did not configure CMake scripts yet, so for now here's a compiled Editor & windows engine for testing:
https://www.dropbox.com/scl/fi/frvbx4fbaxuk4ebz098cz/ags-3.6.1-testpng.zip?rlkey=5mmy8vyfasfqhir5rxpywgr9o&dl=0
WARNING: do either backup "acsprset.spr" before testing this on a real game, or make sure that you have all the sprite sources to recreate it from them, in case something goes wrong. Because of the new PNG option the spritefile's format will be changed and compression type not recognized by a standard version of AGS.
Tests on a real game shows improvement up to x2 in compressed size compared to LZW option (example: 485 MB vs 278 MB). More tests may be required to gather better statistics, but it's already looks very promising in regards to saved disk size.
The question of runtime performance (speed) still remains; I did not do any tests for that so far. Imo it's best to test speed with a high-resolution games, but I don't have an actual project source atm to try different compression options.
(although we could make a standalone tool that recompiles a spritefile, changing compression in a ready game).
But if decompression does not slow gameplay noticeably, the LZW option may actually be deprecated in favor of PNG.
Another potential future option would be to use PNG compression for room files too, in place of LZW, which might reduce game size further.