![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Firty |
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:
I solved my problem.
Server
var t0 = Main.crate_image(temp[1])
var t1 = t0.get_data()
var dic:Dictionary = t1.data
dic.erase("data")
var t2:PoolByteArray = t1.get_data()
var t3 = t2.compress(3)
var t4:Array = [temp[1],t3,dic]
Servidor.get_peer(id).put_var(t4)
Client
var t0:Dictionary = dados_temp[2]
var t1:PoolByteArray = dados_temp[1].decompress(2048000,3)
var image = Image.new()
image.create_from_data(t0["width"],t0["height"],t0["mipmaps"],5,t1)
var _t1 = image.save_png(dados_temp[0])
Firty | 2020-11-12 15:48