Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Utility: reproduce an image in code

IgnatzIgnatz Mod
edited February 2013 in Code Sharing Posts: 5,396

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.



  • IgnatzIgnatz Mod
    Posts: 5,396

    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.

  • Jmv38Jmv38 Mod
    Posts: 3,297

    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+/

  • IgnatzIgnatz Mod
    Posts: 5,396

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

  • Posts: 2,820

    This is great and super useful! Thanks!

  • edited April 2013 Posts: 140

    @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.

Sign In or Register to comment.