Utility: reproduce an image in code

It may be convenient to encode some images (ie use code to draw them) rather than having to include them separately. This utility creates the code to reproduce any image within reason. It uses RLE compression so is quite efficient, but could be improved if there was demand for it.


Don’t be put off by the size of the code provided, there are some big examples that take up most of the space!

Comments and suggestions welcome, I am still learning.

I’ve been playing some more with this, just for fun, and I can now store images in code very compactly, so the size is not substantially larger than the original png in most cases.

This is done by encoding the image in a set of all ASCII characters that don’t upset Codea when used in a string. If you want to know more, or might want to use it, let me know.

Sure, if you want to share it you are welcome! In another post someone pointed a base64 convertor. It was based on the following characters: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/

I have 81 characters, and I’m compressing a good deal more than base 64, I’m sure

This is great and super useful! Thanks!

@Ignatz… I’ve found your projects to be very helpful. I certainly would be interested in seeing how you compress images and reproduce it in code.