Skip to main content

TdxCustomGanttControl.ExportToImage Method

Converts the control’s content to an SVG image.

Declaration

function ExportToImage: TdxCustomSmartImage;

Returns

Type Description
TdxCustomSmartImage

A Smart Image container.

Remarks

Call this function to export an active View’s content to an SVG image. An export operation performs the following actions:

Additional Formats

The control allows you save its content as an image in any of the following formats: BMP, TIFF, PNG, JPEG, EMF, WMF, or GIF. You can do this in the following ways:

  • Call the control’s SaveToFile procedure and specify any of supported extensions in a file name (for instance, ‘MyChart.png’) to export content directly in a file.

  • Call the ExportToImage function and specify an image codec to export content as an image in the corresponding format.

The following code snippet shows how to export the Chart View‘s content as a BMP image and paste this image in the image editor (cxImage1).

uses
..., Vcl.Clipbrd, dxSmartImage, dxGDIPlusClasses;
var
  AImage: TdxCustomSmartImage;
  AFormat : Word;
  AData : THandle;
  APalette : HPALETTE;
begin
  // Exports the control's content to an image container
  AImage := dxGanttControl1.ExportToImage;
  // Associates the image container with the BMP codec 
  AImage.ImageCodec := TdxGPImageCodecBMP;
  // Converts the bitmap in the container to a clipboard format
  AImage.SaveToClipboardFormat(AFormat, AData, APalette);
  // Adds the the bitmap to the clipboard
  ClipBoard.SetAsHandle(AFormat,AData);
  // Adds the bitmap from the clipboard to the image editor
  cxImage1.PasteFromClipboard;
  //Deletes the AImage object
  AImage.Free;
end; 

Important

The mentioned formats have restrictions that can affect a chart export (for instance, an export operation can result in the “Out of Memory” exception).

See Also