Image importing in 3.0

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Maverik

So in 3.0 you can’t simply load just any image file into the game as they must be imported first. I have an option for users to load their images into the game, but as they can’t be processed instantly now, is there some way to “import” from the script?

:bust_in_silhouette: Reply From: volzhs

I’m not sure there is a better way but this code works.

extends Sprite

func _ready():
	var image = Image.new()
	image.load("/home/volzh/Pictures/Screenshot.png")

	var tex = ImageTexture.new()
	tex.create_from_image(image)

	texture = tex

Seems to be something, thank you.

Maverik | 2018-02-25 20:42

That doesn’t work Sir!

Okan Ozdemir | 2020-04-04 19:39

Did you use your own image link?

Amateur.game.dev. | 2021-04-23 18:58