Nevron .NET Vision
Chart for .NET / User's Guide / Image Export / Exporting an Image to a File or Stream

In This Topic
    Exporting an Image to a File or Stream
    In This Topic

    The NImageExporter object has a function called SaveToImageFile that allows you to export the image displayed by the component to a file in different file formats. This releases you from the burden to create an ImageCodecInfo object just to specify a simple parameter like quality in the case of JPEG. The function has two versions:

    C#
    Copy Code
    public void SaveToFile(string fileName, INImageFormat imageFormat)
    public void SaveToFile(string fileName, Size dimensions, NResolution resolution, INImageFormat imageFormat)
    
    Visual Basic
    Copy Code
    Public Sub SaveToFile(ByVal fileName As String, ByVal imageFormat As INImageFormat)
    Public Sub SaveToFile(ByVal fileName As String, ByVal dimensions As Size, ByVal resolution As NResolution , ByVal imageFormat As INImageFormat)
    

    The difference between the two variants of the function is that the fist one will generate an image with dimensions synchronized with the chart size in the form and screen resolution. The second variant allows you to manually specify the dimensions and the resolution of the image. To specify the image format you have to create an instance of one of the types described in the Image Formats topic and pass it as a parameter of the function.

    The following code exports the current chart contents to a bitmap image:

    C#
    Copy Code
    chartControl.ImageExporter.SaveToFile("c:\\temp\\temp.bmp", new NSize(200, 200), NResolution.ScreenResolution, new NBitmapImageFormat());
    
    Visual Basic
    Copy Code
    chartControl.ImageExporter.SaveToFile("c:\\temp\\temp.bmp", New NSize(200, 200), NResolution.ScreenResolution, New NBitmapImageFormat)
    
    See Also