- Edited
jonSS That's not how things work.
The only thing you can get from the main viewport are the literal pixels you see on the screen. There's no other data stored there. If something is "drawn" out of the screen, it gets clipped away. It doesn't exist for retrieval. If your view is zoomed, you get pixels of the zoomed image, etc... The main viewport is not a "viewport container" for some larger viewport that magically stores everything you draw at its maximal size.
So if you want to reconstruct a full image of all existing tiles in your map, you'll have to maintain your own tilemap-like data structure that holds coordinates of all "drawn" tiles and references to their original image data, and then blit original image pixels into your final exported image. You can't retrieve that from just what's drawn on the screen, except in rare situations where everything you need is contained within the screen and zoomed exactly 1:1.
Since Godot's TileMap
maintains precisely such data structure (among other things), it's be best to just use that instead of reinventing the wheel by making your own clunkier version of it. Especially if you're not well versed in using and combining common data structures.