+3 votes

So basically I want to do loading images via code, there will a lot of them, so I want to know exactly what is going, in terms of storage, what format they are stored in, what gives best optimization memory wise.

I've did several experimentation, but it is still unclear how to yield results. For example this piece of code design to load image resources:

func loading_resource(path):
    for ext in ResourceLoader.get_recognized_extensions_for_type("ImageTexture"):
        if path.extension() == ext:
            var texture = ImageTexture.new();
            var image = Image();
            image.load(path);
            texture.create_from_image(image,0);
            texture.set_storage(ImageTexture.STORAGE_COMPRESS_LOSSLESS);
            texture.set_path(path);
            texture.set_name(path.basename());
            resBank.add_resource(path,texture);
            return OK;
    return FAILED;

Another alternative would be to use texture.load(path) in that case. Either way I don't seem to get any difference between type of compression, wether lossless, or lossy. It does however have a difference from just using a plain load(path), of about 40% in corresponding memory size.

in Engine by (58 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.