Reduce apk size by encoding colors using enums
Closed this issue · 4 comments
Currently all images are stored as low quality assets using the standard RGB color space with 16,777,216 colors. There are optimizations that can be done here:
-
Use a more compressed format such as jpeg to reduce the size, since no transparency is being used here and thus png files are not needed.
-
Store each unique color as an enum, and create an image encoding/decoding function that will reduce the size of images by storing a pixel as a single incremental number instead of 3 bytes for the RGB values.
As an example, if you had an image that was only 100 red pixels (#FF0000), you don't need to store all 300 bytes of the image. Just create an enum such that 0=0xFF0000 and then store the image as 100 of the number 0 (reducing the size to 100 bits).
I code in C++, so the implementation of this may be slightly different in C, but the principal is the same.
If you need, I can make a mockup using Python or C++.
The bird has transparency...
The bird has transparency, yes. Method 2 will still work for the bird. Method 1 will work for all assets that do not have transparency, and can be combined with method 2 for even more compression.
The bird has transparency, yes. Method 2 will still work for the bird. Method 1 will work for all assets that do not have transparency, and can be combined with method 2 for even more compression.
I was thinking about it once, the problem is that any jpg decoders are very heavy, so this will increase the weight significantly. I'm closing this topic.