How to store a compressed Image in memory.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Guilherme Furst

My situation is as follows:
My game is going to be using loads of simple images. I’m using a extensive loading process to generate objects from raw data (not packed scenes), while it won’t all be used at once they may be referencing each other at run time, so its crucial to preload this data.

The problem itself is with the preloading method of Godot, because even if the resource is not being shown on screen, or even within the scene tree, it is automagically loaded to the graphics card for use, and it needs to be stored as raw textures too, taking considerably larger amounts of memory then it would otherwise in its compressed form.

Of course another method is to just keep references to these resources, and load/unload them on demand. But I’ve wondered if keeping the resources in their compressed form is possible as well, as it would make the design much more sensible.

ps: asking for Godot2, for would also be worth knowing if there is a way in Godot3.

Have you checked the Godot Engine forums? I haven’t really looked at it, but many of the engine’s developers hang out there, and may know a way of using compressed images in the way you want to use them.

Ertain | 2018-03-15 22:59

Well that is kinda redundant, even though I am aware of the forums, this is supposedly the place for questions of the kind (no its not for stupid noob question only, people should do their research).

Guilherme Furst | 2018-03-16 13:06

:bust_in_silhouette: Reply From: Guilherme Furst

Sort of figured this one out.
The keyword here is texture, where as ImageTexture gets loaded to memory automatically, the Image it self doesn’t. As its standard behavior all loaded textures should be ready to use.

Its a bit of a tricky subject in Godot, because its not so much known to the common developer, something that most can just skip by. There is also very little detailed documentation, and something that changed from 2 to 3.
On Godot3 Image is a resource class, so it can be referenced and treated in different ways, whereas Image in Godot2 is a native data type.

Regardless, I can make it work now, but I still haven’t achieved any sort of compression, even though I can manipulated the image, any compression I’ve tried errors out, as an incomplete feature yet (and changed in the newer version).

oh and btw here is a reference over the “image” changes in godot3 A change of Image

Guilherme Furst | 2018-03-18 18:25