I have a project that where I want the user to be able to save a screenshot in-game to their filesystem.
Here's how I generate the screenshot image:
var img = self.get_viewport().get_texture().get_data()
When the project is exported as a desktop app (tested on windows), this works just fine and saves the generated image to the project's directory.
However, in a web export, this doesn't work. Nothing is prompted for the user to save the image.
I tried a work around where it'd open the image in a new tab so the user could save it from there, using the below code:
var url = "data:image/png;base64," + Marshalls.raw_to_base64(img.data.data)
But this doesn't work. Godot's
OS.shell_open() doesn't seem to recognize
data:image/png;base64, as a link to open using the web browser.
Is there anyway for me to save an image from a Godot project to the user's filesystem (either directly or by popping up a file-save prompt or by opening the image in a new tab) in a web exported build?