Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
[SOLVED] Preloading large images — Gideros Forum

[SOLVED] Preloading large images

bali001bali001 Member
edited February 2015 in Game & application design
What is the best practice to load a lot of large images?
Our app is crashed (on iPhne 4s and on iPad Mini) when I try to load ~60 jpg (960x640, total ~13M) images.

Background:
US History is an educational app, made with Titanium 4 years ago (it was selected as a Staff Favorite! :) ).
Main features are events, timelines and quiz and all of them use large images.

Thank you for your help in advance.

Comments

  • jdbcjdbc Member
    edited February 2015
    I load all images in memory before any scene is shown, but if you have a lot of them you should try to load images on demand.

    I define a Scene.setup() function to preload images.
    lua
    lua
    main.lua
    3K
  • amin13aamin13a Member
    Accepted Answer
    Hi balli001
    640*960 image is loaded to memory as 1024*1024
    The size of this image: 4*1024*1024 = 4Mb
    60 image size = 60 * 4Mb = 240Mb of RAM
    It is crashed in device with 256Mb of RAM
    +1 -1 (+2 / -0 )Share on Facebook
  • bali001bali001 Member
    edited February 2015
    Thank you!

    In case of slideshow I will try to load images on demand: I made some modification in AceSlide.lua earlier so I have an "afterChange" event. After the slide change is finished I will release image on the "oldest" slide and load another one on the "newest".

    But in timeline mode I need all of them. If there is no other way, I will resize the images.
  • Try using combination of small images and Shapes with solid or gradient color.
  • hgy29hgy29 Maintainer
    @bali001 I am not sure how you intend to use your images, but depending on your logical resolution there may be a trick to use.

    If you intend to show all your image at once on the screen, obviously you will have to scale them down so that they all fit. If this is the case, you could consider allocating a RenderTarget and rendering a scaled down version of each image to it, one a a time. Your RenderTarget could be then used as a texture atlas.

    On the other way, if you intend to show them full scale in scene larger than the screen, you could only keep in memory images that are actually displayed and those that would be displayed if the user moves a little, discarding images not in view. Maybe think the scene like a tile map. This may lag during a move but may be worth the trick.

    Hope this helps

  • I like @hgy29's solution, but be warned that bitmaps stored in memory kan crash low powered devices (including the latest iPod Touch).

    In my game No Brakes I initially capture a nice screenshot of all levels and show them in AceSlide. This worked well up to about 15 images, after that I started getting low memory warnings, especially on the iPod.

    I ended up, quite painstakingly indeed, manually creating a bitmap for each track, then load them from the library instead. This cut the initialisation time of AceSlide in half, as well as consumed a lot less memory.

    Niclas

    My Gideros games: www.totebo.com
  • If you are using render to texture - be careful as unless you set the scaling to noscale it will allocate the wrong amount of memory (a bug!)...
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • w00t! Nice one Sinister!

    Likes: SinisterSoft

    My Gideros games: www.totebo.com
    +1 -1 (+1 / -0 )Share on Facebook
  • Just preload the next 1-3 images to be used in your app flow, remove the rest. Else, don't use preload and show a 'loading' message.
    Loon Games LinkedIn Facebook Twitter - "Something bit me, gaah!"
  • bali001bali001 Member
    edited February 2015
    Thanks everyone! :)

    I will try these suggestions

    Edit:
    I will optimize image resolutions first. I will downscale them to 512x768 from 640x960
Sign In or Register to comment.