Saving a rendered image?

I am trying to dig deeper into the Flax API, and I am looking for an equivalent of saving a RenderTexture to disk as jpeg. The Unity code is something like this:

using UnityEngine;
using System.IO;

    public static void SaveAsJPG(this RenderTexture renderTexture, string filePath, int quality = 75)
        // Create a temporary texture to hold the render output
        Texture2D tex = new Texture2D(renderTexture.width, renderTexture.height, TextureFormat.RGB24, false);

        // Activate the render texture and read its pixels = renderTexture;
        tex.ReadPixels(new Rect(0, 0, renderTexture.width, renderTexture.height), 0, 0);

        // Encode the texture as a JPG
        byte[] bytes = tex.EncodeToJPG(quality);

        // Write the bytes to the file
        File.WriteAllBytes(filePath, bytes); 

        // Clean up resources = null; // Restore the previous active render texture

Is this possible in Flax (not in the editor, in the published application), and what would the equivalent code be?

Basically I want to render something using a custom shader and custom data to a render target, then save this as an image.

Well, maybe I can answer the question myself. Looks like this method in the Screenshot class will do it

public static void Capture(GPUTexture target, string path = null)

Yes, Screenshot class does the thing.

For the viewport render, there is an example docs : Screenshots | Flax Documentation

// Pick a path to the output file
var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "screenshot.png");

// Capture game screen to file (done in async)
FlaxEngine.Screenshot.Capture(MainRenderTask.Instance, path);