ComponentOne Chart for .NET (2.0) Search HelpCentral 

Saving Chart Images

The C1Chart provides the ability to save the current chart as an image. By calling the SaveImage method, all of the items within the chart bounds can be saved to the clipboard, a byte array, a stream, or to an image file. 

The SaveImage method can save to four different output types by using one of eight different overloaded parameter sets. For each output type, there is an option to save the chart image as it appears on the screen, or to save the chart image as a specified size. 

To save the chart image to the clipboard, simply specify an image format, the size parameter is not specified here:

·      Visual Basic

C1Chart1.SaveImage(System.Drawing.Imaging.ImageFormat.Bmp)

·      C#

C1Chart1.SaveImage(System.Drawing.Imaging.ImageFormat.Bmp);

·      Delphi

C1Chart1.SaveImage(System.Drawing.Imaging.ImageFormat.Bmp);

To save the chart image to an image file, simply specify the pathname for the new image and an image format, the size parameter is not specified here:

·      Visual Basic

C1Chart1.SaveImage("C:\temp\ChartImages\CandleChart.bmp",_

   System.Drawing.Imaging.ImageFormat.Bmp)

·      C#

C1Chart1.SaveImage("C:\\temp\\ChartImages\\CandleChart.bmp",

   System.Drawing.Imaging.ImageFormat.Bmp);

·      Delphi

begin

  C1Chart1.SaveImage('C:\\temp\\ChartImages\\CandleChart.bmp',

     System.Drawing.Imaging.ImageFormat.Bmp);

end;

To save the chart image to a stream, simply specify the stream object and an image format, the size parameter is not specified here:

·      Visual Basic

Dim coutstream As New System.IO.MemoryStream()

C1Chart1.SaveImage(coutstream, System.Drawing.Imaging.ImageFormat.Bmp)

·      C#

System.IO.MemoryStream  coutstream = new System.IO.MemoryStream();

C1Chart1.SaveImage(coutstream, System.Drawing.Imaging.ImageFormat.Bmp);

·      Delphi

var

  coutstream: System.IO.MemoryStream;

begin

  C1Chart1.SaveImage(coutstream, System.Drawing.Imaging.ImageFormat.Bmp);

end;

To save the chart image as a byte array, simply specify the byte array, and an image format, the size parameter is not specified here:

·      Visual Basic

Dim bytes() As Byte

C1Chart1.SaveImage(bytes, System.Drawing.Imaging.ImageFormat.Bmp)

·      C#

Byte[] bytes;

C1Chart1.SaveImage(bytes, System.Drawing.Imaging.ImageFormat.Bmp);

·      Delphi

var

  bytes: array of Byte;

begin

  C1Chart1.SaveImage(bytes, System.Drawing.Imaging.ImageFormat.Bmp);

end;

See also, ImageFormat for more information.


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.