I don't know if I asked the question right? I'm using this code, but I don't know how to display an image
func _ready(): var myimage = preload("res://Untitled.jpg") var theimage = myimage.get_data() theimage.crop(600,600) theimage.lock() print(theimage. get_pixelv(Vector2(350,350)))
I add Sprite and use $Sprite.set_texture(myimage)
Is this a good solution?
If it works for your project, then I’d say it’s a good solution!
but it doesn't really work as if I wanted to
var myimage = preload("res://Untitled.jpg").get_data() myimage.lock() myimage.set_pixel(35,35,color) $Sprite.set_texture(myimage)
And after I've adjusted this code, I can't see the picture
I think you need to unlock the image after you lock it.
it does not work
Ah, I see the problem. An Image is not the same as a Texture. You are attempting to set an image to the sprite's texture property. You would need to make a new ImageTexture and set its data to myimage. Then you can use it for texturing.
Image
Texture
ImageTexture
myimage
Hmm but how to do it? var img = Image.new()
var img = Image.new()
but how to add it data
@dzosek said: Hmm but how to do it? var img = Image.new() but how to add it data
@dzosek said: Hmm but how to do it? var img = Image.new()
I said ImageTexture. Take a look at the docs.
Thank you very much for help . =)
func _ready(): var myimage = preload("res://Untitled.jpg").get_data() var obrazek = ImageTexture.new() obrazek.create_from_image(myimage) $Sprite.set_texture(obrazek)