Atlas with large background images

Im creating info-panel (kiosk) app for client. How to handle large 1920x1080 background images in Defold? There is alot of them, over 100 images and placing them all into Atlas crashes engine.

What is preferred way to include and handle all those large images in Defold?

You have a number of different options:

6 Likes

I decided to go with image.load() and gui.new_texture() method and it works with my other code:

local function set_background_image(texture_id, image_filename)
    background_node = gui.get_node("info_screen_background")
             
    -- check if image file exists
    local file_exists = lfs.attributes(image_filename, "mode") == "file"
    if not file_exists then
        gui.set_texture(background_node, "background")
        print("Background image file does not exist.")
    else
        local file = io.open(image_filename, "rb")
        local bytes = file:read("*a")
        local background_image = image.load(bytes)

        math.randomseed(os.time())
        _texture_id = texture_id .. "_" .. math.random()
        if gui.new_texture(_texture_id, background_image.width, background_image.height, background_image.type, background_image.buffer) then
            gui.set_texture(background_node, _texture_id)
            print("Set new texture")
        else
            gui.delete_texture(_texture_id)
            gui.set_texture(background_node, "background")
            print("Unable to create texture")
        end
    end
end

However, Im interested about memory management. When image is loaded, does it stay in memory and should I delete it with gui.delete_texture after being replaced with other image?

Yes, you are responsible for managing the textures you create. You need to delete the texture when you no longer need it.