0 votes

I can use Image.load() successfully but get a warning:

WARNING: Loaded resource as image file, this will not work on export: 'res://art/menu/screenshot-logo-bottom.png'. Instead, import the image file as an Image resource and load it normally as a resource.

When I try to workaround this, using load(), it returns a CompressedTexture object.

But how to convert that into an Image?

Or, is there a better way than load()?

Godot version 4.0
in Engine by (456 points)
edited by

1 Answer

+1 vote
Best answer

You can convert CompressedImage2D (and any texture that inherits Texture2D) using get_image method (https://docs.godotengine.org/en/stable/classes/class_texture2d.html#class-texture2d-method-get-image). Note that each time you call this method new Image is created (this method is not cached).

by (1,650 points)
selected by
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.