blog: Asset packing with zip.c - add images

This commit is contained in:
kamkow1
2025-06-28 14:13:27 +02:00
parent e1f0d04409
commit 5ee7e02f7a
4 changed files with 8 additions and 0 deletions

View File

@ -10,6 +10,8 @@ have to worry about this too much right now, since I've reimplemented asset pack
zip library by \`kuba--\` (Polska GUROM!!!111!!). In this article I'd like to demonstrate how I've
minimised the size of our assets using \`zip\` and \`incbin\`.
![zip file](/bakedres/apwz-zip-icon.png)
## References
- zip: https://raw.githubusercontent.com/kuba--/zip/refs/heads/master/src/zip.c
@ -256,6 +258,10 @@ void init_baked_resources(void)
which is unpacking an in-memory .zip file. We iterate each entry in the bundle, get the name and size, preallocate
a buffer and read said entry into the buffer. We can then add the resource to the hash table as we did previously.
## Conclusion
![xkcd](/bakedres/apwz-xkcd1.png)
One question you may ask is, how much space are we saving? I don't remeber the exact sizes of the binary, but
I remember that before compression it was \`~1.2M\` and now after compression is implemented, it's \`~1.6M\`. How is
that an improvement if the binary gained weight? That \`~.4M\` is likely due to zip format overhead - metadata, file and

View File

@ -34,6 +34,8 @@ int main(int argc, char ** argv)
"./etc/me.jpg", \
"./etc/tmoa-engine.jpg", \
"./etc/tmoa-garbage.jpg", \
"./etc/apwz-zip-icon.png", \
"./etc/apwz-xkcd1.png", \
"./blog/blog-welcome.md", \
"./blog/blog-weird-page.md", \
"./blog/blog-curious-case-of-gebs.md", \

BIN
etc/apwz-xkcd1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
etc/apwz-zip-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB