Hi!
I need send a texture from a server to a client.
var t0 = Main.crate_image(temp[1])
var t1 = t0.get_data()
var t2:PoolByteArray = t1.get_data()
var t3 = t2.compress(1)
var t4:Array = [temp[1],t3]
Servidor.get_peer(id).put_var(t4)
Main.GDScript
func crate_image(path):
var img = Image.new()
img.load(path)
var img_tex: = ImageTexture.new()
img_tex.create_from_image(img)
return img_tex
temp is one Array received from client. [order type,texture path]
t0 = ImageTexture
t1 = Image
t2 = PoolByteArray
and t3 is t2 compressed (without this, client has returned: is too big for it to
process.)
The client received this, but I can't transform this PoolByteArray in texture
var t0:PoolByteArray = dados_temp[1].decompress(1,1)
var image = Image.new()
image.load_png_from_buffer(t0)
var _t1 = image.save_png(dados_temp[0])
I have tried several things... Decompress dont work... I didn't find anything about buffer_size()... Let alone other ideas.
Even that didn't help me:
https://www.reddit.com/r/godot/comments/gilgpo/attempted_guide_on_how_to_transmit_images_over_a/