Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | WedAry |
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 slow@!!@#
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()
texture.create_from_image(image)
have you considered loading the image on a background thread to avoid slowing the main thread?
rustyStriker | 2020-11-02 21:22
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
Skipperro | 2020-11-02 22:00