Nevron Open Vision Documentation
Diagram / File Formats / Export / Drawing Raster Image Export
In This Topic
    Drawing Raster Image Export
    In This Topic

    The NDrawingRasterImageExporter lets you export the content of the active page (or portions of it) to a raster image in the following file formats:

     Saving with Dialog

    The following code shows how to display the default raster image export dialog provided by NOV:

    Showing the default raster image export dialog
    Copy Code
    NDrawingRasterImageExporter imageExporter = new NDrawingRasterImageExporter(drawingView.Content);
    imageExporter.ShowDialog(DisplayWindow, true);
    

    The following code shows a save image file dialog that allows the user to create an image from the active page content:

    Saving with a save file dialog
    Copy Code
    NDrawingRasterImageExporter imageExporter = new NDrawingRasterImageExporter(drawingView.Content);
    imageExporter.SaveAsImage(NImageFormat.Png); // Save to image with PNG file format selected by default
    
     Saving to File or Stream

    To export the active page of a drawing to image and save it directly to a file, without showing a save file dialog, use the SaveToFile method. Note that the saving to file is an asynchronous (async) operation, so if you are interested in its completion, you should call the Then method of the promise it returns and handle the completion of the export in the passed delegate. The following is a code example:

    Saving to a file
    Copy Code
    NDrawingRasterImageExporter imageExporter = new NDrawingRasterImageExporter(drawingView.Content);
    imageExporter.SaveToFileAsync("C:\\ExportedImage.png").Then(
        delegate (NUndefined ud)
        {
            // Export to PNG completed
        }
    );
    
    Exporting a drawing to an arbitrary file works only on non-sandboxed platforms like WinForms, WPF and Xamarin.Mac.

    To export the active page of the drawing to an image stream, use the SaveToStream method. Unlike the SaveToFile method, the SaveToStream method runs synchronously and blocks code execution until it completes. Exporting drawings to stream is useful when you wish to generate images in memory instead of saving them to the disc. The following code snippet shows how to export the active page of a drawing to a stream:

    Saving to a stream
    Copy Code
    NDrawingRasterImageExporter imageExporter = new NDrawingRasterImageExporter(drawingView.Content);
    imageExporter.SaveToStream(stream, NImageFormat.Png);
    
     Generating a Raster Image

    To generate an image on the fly without saving it, use the CreateImage method:

    Generating Image
    Copy Code
    NDrawingRasterImageExporter imageExporter = new NDrawingRasterImageExporter(drawingView.Content);
    NImage image = imageExporter.CreateImage();
    
     Copying to Clipboard

    To copy the image to the clipboard, use the CopyToClipboard method:

    Generating Image
    Copy Code
    NDrawingRasterImageExporter imageExporter = new NDrawingRasterImageExporter(drawingView.Content);
    imageExporter.CopyToClipboard();
    
    See Also