Skip to main content
All docs
V25.2
  • TdxCustomChartControl.ExportToJPEG(TStream,Integer,Integer) Method

    Exports content to a stream in the JPEG (Joint Photographic Experts Group) format.

    Declaration

    procedure ExportToJPEG(const AStream: TStream; AImageWidth: Integer = 0; AImageHeight: Integer = 0); overload;

    Parameters

    Name Type Description
    AStream TStream

    The target stream.

    AImageWidth Integer

    Optional. The exported image width, in pixels. If this parameter is omitted, the target image width matches the current pixel width of the Chart control client area on the parent form.

    The export procedure stretches or shrinks the Chart control layout horizontally to fit the resulting image into the target width.

    All font sizes remain unchanged. If title or label text does not fit into the corresponding visual Chart element, the Chart control crops the text and ends it with an ellipsis in the exported layout.

    AImageHeight Integer

    Optional. The exported image height, in pixels. If this parameter is omitted, the target image height matches the current pixel height of the Chart control client area on the parent form.

    The export procedure stretches or shrinks the Chart control layout vertically to fit the resulting image into the target height.

    All font sizes remain unchanged. If title or label text does not fit into the corresponding visual Chart element, the Chart control crops the text and ends it with an ellipsis in the exported layout.

    Remarks

    Call the ExportToJPEG procedure to export content of the Chart control client area to a stream in JPEG format. The resulting image size matches the actual pixel dimensions of the Chart control client area on a form.

    VCL Chart Control: An Exported Image Example

    Adjust Target Image Dimensions

    You can pass required target pixel dimensions for the resulting image as optional AImageWidth and AImageHeight parameters. In this case, the ExportToJPEG procedure resizes all visible diagrams to fit into the target dimensions. All font sizes remain unchanged.

    Code Example: Export Chart Content as an Image

    The following code example exports shrunk content of the Chart control client area whose original dimensions on the parent form are 600 by 700 pixels:

    var
      AStream: TMemoryStream;
    begin
      dxSavePictureDialog1.Execute(Handle);
      if dxSavePictureDialog1.FileName = '' then Exit;
      AStream := TMemoryStream.Create;
      try
        dxChartControl1.ExportToJPEG(AStream, 400, 500);
        AStream.SaveToFile(dxSavePictureDialog1.FileName);
      finally
        AStream.Free;
      end;
    end;
    

    VCL Chart Control: An Exported Chart with Three XY Diagrams

    To see the export to JPEG functionality in action, run the Chart Control demo in the VCL Demo Center installed with compiled DevExpress VCL demos. Click Export and choose the Export to Image option to export chart content in any image format (including JPEG).

    Download: Compiled VCL Demos

    Tip

    Compiled DevExpress demos ship with source code installed in the Public Documents folder (%Public%) for all users (default). You can find all project and source code files for the Chart control in the following folder:

    %Public%\Documents\DevExpress VCL Demos\MegaDemos\Product Demos\ExpressChart\

    Other Export Methods

    You can call the following procedures to export chart content to a file or stream in other formats:

    ExportToImage
    Export the current state of the Chart control client area as an individual image in any supported format.
    ExportToBMP | ExportToGIF | ExportToPNG | ExportToSVG | ExportToTIFF
    Export the current state of the Chart control client area as an individual image in corresponding formats.
    ExportToDOCX | ExportToXLSX
    Export the current state of the Chart control client area as an inline or floating image in the resulting DOCX or XLSX document.
    ExportToEMF | ExportToWMF
    Export the current state of the Chart control client area as an individual image in Windows Metafile (EMF and WMF) formats.
    See Also