地圖輸出

很多的時候在地圖製作完成以後,我們需要將它用不同的格式輸出,如PDF,bmp等格式,這樣的格式方便我們用戶在沒有安裝ArcMap的計算機平臺上對地圖進行瀏覽,查看。地圖輸出可以分爲兩大類,即柵格數據和適量數據格式,前者的如BMP,JPG,而後者的如PDF,,SVG.IExport接口作爲地圖輸出的主要接口,被不同的類實現,如下圖所示:

 

這10個類都是組件類,可以直接用來實例化,同樣,這10個類對應了ArcGIS 所支持的地圖輸出格式,同時這10個類也可以劃分爲兩大類,即矢量格式和柵格格式。Window平臺的分辨率一般爲96dpi,而這個也是ArcGIS柵格 數據輸出的默認分辨率,而對於像PDF這樣的分辨率,默認爲300dpi。IExport接口定義了地圖輸出的通用方法和屬性,如下圖:

矢量格式地圖輸出

矢量格式文件的輸出主要是依靠IExportVector接口,該接口被以下5個類實現:

示例:輸出EMF格式:
private void ExportEMF()
{
IActiveView pActiveView;
pActiveView = axPageLayoutControl1.ActiveView;
IExport pExport;
pExport = new ExportEMFClass();
pExport.ExportFileName = @"E:\arcgis\Engine\ExportEMF.emf";
pExport.Resolution = 300;
tagRECT exportRECT;
exportRECT = pActiveView.ExportFrame;
IEnvelope pPixelBoundsEnv;
pPixelBoundsEnv = new EnvelopeClass();
pPixelBoundsEnv.PutCoords(exportRECT.left, exportRECT.top,
exportRECT.right, exportRECT.bottom);
pExport.PixelBounds = pPixelBoundsEnv;
int hDC;
hDC = pExport.StartExporting();
pActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, null, null);
pExport.FinishExporting();
pExport.Cleanup();
}

示例:輸出PDF格式:
private void ExportPDF()
{
IActiveView pActiveView;
pActiveView = axPageLayoutControl1.ActiveView;
IEnvelope pEnv;

pEnv = pActiveView.Extent;
IExport pExport;
pExport = new ExportPDFClass();
pExport.ExportFileName = @"E:\arcgis\Engine\ExportPDF.pdf";
pExport.Resolution = 30;
tagRECT exportRECT;
exportRECT.top = 0;
exportRECT.left = 0;
exportRECT.right = (int)pEnv.Width;
exportRECT.bottom = (int)pEnv.Height;
IEnvelope pPixelBoundsEnv;
pPixelBoundsEnv = new EnvelopeClass();
pPixelBoundsEnv.PutCoords(exportRECT.left, exportRECT.bottom,
exportRECT.right, exportRECT.top);
pExport.PixelBounds = pPixelBoundsEnv;
int hDC ;
hDC = pExport.StartExporting();
pActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, null, null);
pExport.FinishExporting();
pExport.Cleanup();
}

柵格格式地圖輸出 
柵格格式文件的輸出主要是依靠IExportImage接口,該接口被以下5個類實現:

示例:根據傳入的分辨率輸出JPG格式
public void CreateJPEGHiResolutionFromActiveView(IActiveView pActiveView,String pFileName, Int32 pScreenResolution,
Int32 pOutputResolution)
{
ESRI.ArcGIS.Output.IExport pExport = new ESRI.ArcGIS.Output.ExportJPEGClass();
pExport.ExportFileName = pFileName;
pExport.Resolution = pOutputResolution;

ESRI.ArcGIS.Display.tagRECT pExportRECT;

pExportRECT.left = 0;

pExportRECT.top = 0;
pExportRECT.right = pActiveView.ExportFrame.right * (pOutputResolution / pScreenResolution);
pExportRECT.bottom = pActiveView.ExportFrame.bottom * (pOutputResolution / pScreenResolution);
ESRI.ArcGIS.Geometry.IEnvelope pEnvelope = new ESRI.ArcGIS.Geometry.EnvelopeClass();
pEnvelope.PutCoords(pExportRECT.left, pExportRECT.top, pExportRECT.right, pExportRECT.bottom);
pExport.PixelBounds = pEnvelope;
System.Int32 hDC = pExport.StartExporting();
pActiveView.Output(hDC, (System.Int16)pExport.Resolution, ref pExportRECT, null, null);
pExport.FinishExporting();
pExport.Cleanup();
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章