![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | pento |
So I’m trying to do what’s suggested here and here:
how-to-save-node-and-children-to-png, how-to-crop-screenshots-around-a-node
Now, I don’t know if I just don’t understand what they’re saying to do, but I’m getting a blank image with my code below. (To summarize, I am just duplicating the parent node of the composite image I want to save and chucking that in an otherwise empty Viewport node. I get the image_node
and viewport
nodes much earlier in the code.)
var j = image_node.duplicate()
viewport.add_child(j)
j.set_owner(viewport)
var img = viewport.get_texture().get_data()
img.flip_y()
var buf = img.save_png_to_buffer()
JavaScript.download_buffer(buf,"whatever.png")
j.queue_free()
With the node structure:
-root
----Background
--------Viewport
--------image
------------ …
--------interface
------------ …
I’ve also tried fully moving the node into the Viewport node in the script, not making a duplicate, and then moving it back when I was done, but I also got a blank image from this.
(I checked to see that if I add it as a child node manually, the preview in the GUI will show the composite image (and it does), but I’d prefer to not leave my image_node in the Viewport node if I can help it, since it would break a lot to move it.)
Am I just fundamentally misunderstanding the solutions in those other answers? Any help would be massively appreciated!
FYI I did give up on this. I ended up just get/set pixeling all of the visible nodes onto a fresh image.
pento | 2022-07-04 02:45