ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Export Graph to jpeg/gif

Hello,

How might I export the image of a graph to jpg/gif format using measurement studio for Visual Basic .NET?


0 Kudos
Message 1 of 4
(3,587 Views)

If you have Measurement Studio 7.1, you can do this via the ToFile method. For example:

' Export to a .gif file
graph.ToFile("C:\Graph.gif", ImageType.Gif)
 
' Export to a .jpg file
graph.ToFile("C:\Graph.jpg", ImageType.Jpeg)

- Elton

0 Kudos
Message 2 of 4
(3,578 Views)
The graph is of type   AxCWUIControlsLib.AxCWGraph (not NationalInstruments.UI.WindowsForms.Graph) and does not have a toFIle function.


0 Kudos
Message 3 of 4
(3,575 Views)

Sorry, I assumed you were using the Measurement Studio .NET Windows Forms graph since this was posted to the .NET forum. If you're using the interop wrappers to the Measurement Studio ActiveX UI controls, you can call ControlImage to get an image (metafile) of the graph, then you can save the image to a file via the Image.Save method by specifying a file name and either ImageFormat.Gif or ImageFormat.Jpeg. For example:

Dim controlImage As Image = Nothing
Try
    controlImage = AxCWGraph1.ControlImage()
 
    ' Export to a .gif file
    controlImage.Save("C:\Graph.gif", System.Drawing.Imaging.ImageFormat.Gif)
 
    ' Export to a .jpg file
    controlImage.Save("C:\Graph.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
Finally
    If Not controlImage Is Nothing Then
        controlImage.Dispose()
    End If
End Try

Just out of curiosity, why are you using the interop wrapper to the Measurement Studio ActiveX UI controls rather than using the native Measurement Studio .NET Windows Forms controls?

- Elton

0 Kudos
Message 4 of 4
(3,563 Views)