您的位置:首页 > 其它

保存为栅格图片-MapControl截图——保存ActiveView为jpg图片

2016-09-06 09:15 302 查看
///<summary>Creates a .jpg (JPEG) file from IActiveView. Default values of 96 DPI are used for the image creation.</summary>
///
///<param name="activeView">An IActiveView interface</param>
///<param name="pathFileName">A System.String that the path and filename of the JPEG you want to create. Example: "C:\temp\test.jpg"</param>
///
///<returns>A System.Boolean indicating the success</returns>
///
///<remarks></remarks>
public System.Boolean CreateJPEGFromActiveView(ESRI.ArcGIS.Carto.IActiveView activeView, System.String pathFileName)
{
//parameter check
if (activeView == null || !(pathFileName.EndsWith(".jpg")))
{
return false;
}
ESRI.ArcGIS.Output.IExport export = new ESRI.ArcGIS.Output.ExportJPEGClass();
export.ExportFileName = pathFileName;

// Microsoft Windows default DPI resolution
export.Resolution = 96;
ESRI.ArcGIS.Display.tagRECT exportRECT = activeView.ExportFrame;
ESRI.ArcGIS.Geometry.IEnvelope envelope = new ESRI.ArcGIS.Geometry.EnvelopeClass();
envelope.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
export.PixelBounds = envelope;
System.Int32 hDC = export.StartExporting();
activeView.Output(hDC, (System.Int16)export.Resolution, ref exportRECT, null, null);

// Finish writing the export file and cleanup any intermediate files
export.FinishExporting();
export.Cleanup();

return true;
}


源:http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/Create_JPEG_from_ActiveView_Snippet/004900000064000000/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: