Can I save RenderTexture as png file?

I need to take ingame captures of the screen, so I render the camera output to a RenderTexture. Now, I need that texture to be saved as a png (or bmp, anything but jpg). Looking into stride API I was unable to find a proper function. So, is there a way yo save a rendertexture to a png file?

The external screen capture software is NOT a solution, it may be done inside the game.

Thx in advance.

1 Like

Here’s how you could dump a texture to a file:

using (var image = texture.GetDataAsImage(GraphicsContext.CommandList))
using (var resultFileStream = File.OpenWrite(filename))
    image.Save(resultFileStream, ImageFileType.Png);
2 Likes