Topic was automatically imported from the old Question2Answer platform.
Asked By
ulabael
Hello.
I’ve a canvas on which i draw a lot of stuff through draw* functions.
This canvas can be very big so it won’t fit viewport. The question is, is there a way to draw/save entire canvas to image or i have to do it other way?
I care about the final image quality.
I think the way to go about this is using the custom_viewport property of CanvasLayer
I got saving of the image working with this giant label that is bigger than the main Viewport
For this node setup, the node Content is a PanelContainer and therefore the size of the everything being draw on this CanvasLayer. It doesn’t need to be a PanelContainer just something that contains everything being drawn.
The CanvasLayer has a script attached to it with the following code:
The Viewport can be manually updated again (therefore updating the image) with the following line code: custom_viewport.render_target_update_mode = Viewport.UPDATE_ONCE
If you just want to save the texture and then free everything you can call .duplicate() on the texture (this must be done after at least one frame is drawn or else it’ll be fully black) and then .queue_free() on the Viewport and your CanvasLayer
Hope this helps
Ah, big thanks
I’ve already done this with viewport but more bruteforce way, hope your code 'll help do it better way