This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

load: Loaded resource as image file, this will not work on export: 'res://resources/Myfile.png'. Instead, import the image file as an Image resource and load it normally as a resource.
Could any body explain what does this mean?
It works on windows but not on ios or android, what is the solution ?
This is the code I'm using to load the image, It works

var avatar_file ="res://resources/Myfile.png"
var img =
$AvatarSP.texture = imagetexture
in Engine by (118 points)

1 Answer

+2 votes
Best answer

You need to create the Image from the Texture, not the other way around.

var img_texture_path := "res://resources/Myfile.png"
var img_texture: StreamTexture = load(img_texture_path)
$AvatarSP.texture = img_texture

# You don't need to create an Image unless you need to edit the pixels or something
var img: Image = img_texture.get_data() # You can delete this line

I don't know the technical reason for this, but see the related issue:

by (240 points)
selected by

Thank you so much !!!

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.