Hey! I'm trying to link my StableDiffusion client which generates images via an endpoint to godot 4, currently I am successfully fetching the image's base64 and it's all well and good, I tested the base64 and it's valid through multiple services and different languages such as JS and Java, my question is:
How would I be able to turn a Base64 into a Texture? Right now the following is my code:
if foundImages["image"] != null:
var bytes = Marshalls.base64_to_raw(foundImages["image"])
print("Got " + str(bytes.size()) + " bytes")
var i = Image.new()
i.load_png_from_buffer(bytes)
var t = ImageTexture.new()
t.create_from_image(i);
$CanvasLayer/TextureRect.texture = i; # This is a temporary debug UI Element for me to see if the texture shows up, but all it does it looks like the attached screenshot ( nothing on screen )
print("Created image texture, trying to instanciate and spawn");
# Spawn a polaroid
var polaroid: RigidBody3D = polaroidImageScene.instantiate();
get_tree().root.add_child(polaroid)
polaroid.global_transform = cardSpawnPoint.global_transform;
# Try and find the child
var polaroidModel: PolaroidModel = polaroid.find_child("PolaroidModel");
polaroidModel.setPolaroidImage(t); # This is a function from the polaroidModel, the function does run