0 votes

I want to load a remote image that will be centered on the screen. Using HTTPRequest I successfully loaded the image.. but it's toooo [email protected][email protected]#

My project settings are using Stretch mode: 2D which means the image needs to be a big size because of scaling. If I try to load a 1472x849 image.. it takes about 5 secs to display the image.

Is there a way to load an image faster or maybe make it ignore the scaling of the window. In this way I can load an image with smaller size

func _on_request_completed(result: int, response_code: int, headers: PoolStringArray, body: PoolByteArray) -> void:

    var image = Image.new()
    var image_error = image.load_png_from_buffer(body) if fileExtension == "png" else image.load_jpg_from_buffer(body)

    if image_error != OK:
        print("An error occurred while trying to display the image.")

    var texture = ImageTexture.new()
in Engine by (20 points)

have you considered loading the image on a background thread to avoid slowing the main thread?

Yup - if you don't need it instantly and can plan 5 seconds ahead - use thread.

Otherwise I would check what actually takes this 5 seconds. If it's download itself, there is not much you can do, except improving network infrastructure :(

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 Frequently asked questions and 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 [email protected] with your username.