MapControl.ExportToImage(String, ImageFormat) Method
Creates an image file in the specified format from the current map and outputs it to the specified path.
Namespace: DevExpress.XtraMap
Assembly: DevExpress.XtraMap.v20.1.dll
NuGet Package: DevExpress.Win.Map
Declaration
Parameters
Name | Type | Description |
---|---|---|
filePath | String | A String containing the full path to where the image file will be created. |
format | ImageFormat | A ImageFormat value representing the format in which the map is exported. |
Remarks
This method exports the current map as an image to the specified path calling the PrintingSystemBase.ExportToImage method. The image format should be specified by the format parameter, for instance, ImageFormat.BMP. After creating an image file, the map can be displayed in an appropriate application. For more information, refer to the PrintingSystemBase.ExportToImage topic.
Note
The MapControl’s data can only be exported if the XtraPrinting Library is available.
Example
To export a map image to a file, use one of the following methods.
- MapControl.ExportToImage - exports the map to an image file;
- MapControl.ExportToMht - exports the map to a *.MHT file;
- MapControl.ExportToPdf - exports the map to a *.PDF file;
- MapControl.ExportToXls - exports the map to a *.XLS file;
- MapControl.ExportToXlsx - exports the map to a *.XLSX file;
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-print-or-export-a-map-t185956
private void ddbExport_Click(object sender, EventArgs e) {
string filepath = filepathBase + exportFormat.ToString();
switch (exportFormat) {
case (ExportFormat.Image):
mapControl.ExportToImage(filepath, ImageFormat.Jpeg);
break;
case (ExportFormat.Mht):
mapControl.ExportToMht(filepathBase);
break;
case (ExportFormat.Pdf):
mapControl.ExportToPdf(filepathBase);
break;
case (ExportFormat.Xls):
mapControl.ExportToXls(filepathBase);
break;
case (ExportFormat.Xlsx):
mapControl.ExportToXlsx(filepathBase);
break;
default:
MessageBox.Show("Export to a *" + exportFormat.ToString() + " file format is impossible.", "Export to " + exportFormat.ToString());
return;
}
MessageBox.Show("Export to a *" + exportFormat.ToString() + " file is done.", "Export to " + exportFormat.ToString());
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the ExportToImage(String, ImageFormat) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.