So, it need to be returning an image, but its retuning null

And we can se in the simples sprite, that indded there is texture generated. Code:

extends Node

func _ready(): caos_64(100,100) pass

func caos_64(var1,var2): var imag = Image.new() var caosR = NoiseTexture.new() var sprite = Sprite.new() add_child(sprite) caosR.noise = OpenSimplexNoise.new() caosR.height = var1 caosR.width = var2 imag.create(var1,var2,false,Image.FORMAT_BPTC_RGBA) sprite.texture = caosR print("as reference, this is a image: ", imag) print("This should be a Object Image: ", caosR.get_data())

So, this is a bug, right? Or something wrong doing on my part?

Thanks.

https://docs.godotengine.org/en/stable/classes/class_image.html

Looking at the docs the property data should be a Dictionary. The method get_data should return PoolByteArray.

edit: and I looked at the wrong line...From the docs on NoiseTexture:

The class uses Threads to generate the texture data internally, so Texture.get_data may return null if the generation process has not completed yet. In that case, you need to wait for the texture to be generated before accessing the data:

Get_data is a Texture() function. I am not generating the noise, i am geting a image from it. But maybe, thats the case, i will do a simple wait protocol, to see if something changes (will wait for OS.ticks to return a value grater tem 10 seconds, that is plenty of time for the noise to be generated

yes but when the image isn't done generating yet, as per the note in the docs, you may see it return null, which teh the way I understand it will be reported as Object:null since the object that would hold the data isn't ready/created yet.

And i tried using the yield, but got myself in to a error.

var texture = preload("res://noise.tres") yield(texture, "changed") var image = texture.get_data()

is for loading external noise

How to use in a locally created one?

@Megalomaniak said: Did you mean to return where you typed pass?

I dont think thats matter, was only fast way to hold the program a little.

The correct way is the way you are sugesting, but:> @PeterPM said:

And i tried using the yield, but got myself in to a error.

var texture = preload("res://noise.tres") yield(texture, "changed") var image = texture.get_data()

is for loading external noise

How to use in a locally created one?

How to use in this simple context i am presenting here?

REaly thanks for the elucidation.

The example in the docs is just an example. For your code in OP try

yield(caosR, "changed")
print("This should be a Object Image: ", caosR.get_data())

@PeterPM said:

@Megalomaniak said: Did you mean to return where you typed pass?

I dont think thats matter, was only fast way to hold the program a little.

pass is just for empty functions

@Megalomaniak said: The example in the docs is just an example. For your code in OP try

yield(caosR, "changed")
print("This should be a Object Image: ", caosR.get_data())

I am pretty shure that i have done something like that, but it does not worked.

But, indeed, that returned a image object, and so, everthing must be okay. My fault.

Thanks.

7 months later