Image sprite

Posted on
  • Hi,
    I want to image sprite of fixed dimension small icon images(~10 to 15) in to one single image and store in to storage.

    What is the best way to read each individual image from the sprite. I can store individual image in storage but that is something I don't want to do (jus because I don't like soring lots of small files.)

    Any clue how I can achieve this?


  • Hi - I'd just store all the images (as you'd get from the image generator site) into one big file one after the other and store the offsets somewhere.


    var images = require("Storage").read("myimages");
    // note 'images' is not actually using up your RAM, it's still stored in flash

    The substr will do a copy of the small image into RAM, but honestly if it's a small icon that's not going to cause a big problem.

  • Thank you @Gordon as always for a super quick response!!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Image sprite

Posted by Avatar for Abhigkar @Abhigkar