arcengine 將地圖文件保存為圖片(包括各種圖片格式)


1,最近做了個地圖文件輸出圖片的功能,思想主要就是利用MapControl的ActiveView中的out方法:

2代碼如下:歡迎交流指正

 1             SaveFileDialog m_save = new SaveFileDialog();
 2             m_save.Filter = "jpeg圖片(*.jpg)|*.jpg|tiff圖片(*.tif)|*.tif|bmp圖片(*.bmp)|*.bmp|emf圖片(*.emf)|*.emf|png圖片(*.png)|*.png|gif圖片(*.gif)|*.gif";
 3             m_save.ShowDialog();
 4             string Outpath = m_save.FileName;
 5             if (Outpath != "")
 6             {
 7                 //分辨率
 8                 double resulotion = MapControl.ActiveView.ScreenDisplay.DisplayTransformation.Resolution;
 9                 IExport m_export = null;
10                 if (Outpath.EndsWith(".jpg"))
11                 {
12                     m_export = new ExportJPEG() as IExport;
13 
14                 }
15                 else if (Outpath.EndsWith(".tig"))
16                 {
17                     m_export = new ExportTIFF() as IExport;
18 
19                 }
20                 else if (Outpath.EndsWith(".bmp"))
21                 {
22                     m_export = new ExportBMP() as IExport;
23 
24                 }
25                 else if (Outpath.EndsWith(".emf"))
26                 {
27                     m_export = new ExportEMF() as IExport;
28                 }
29                 else if (Outpath.EndsWith(".png"))
30                 {
31                     m_export = new ExportPNG() as IExport;
32                 }
33                 else if (Outpath.EndsWith(".gif"))
34                 {
35                     m_export = new ExportGIF() as IExport;
36                 }
37                 //設置輸出的路徑
38                 m_export.ExportFileName = Outpath;
39                 //設置輸出的分辨率
40                 m_export.Resolution = resulotion;
41                 tagRECT piexPound;
42                 piexPound = MapControl.ActiveView.ScreenDisplay.DisplayTransformation.get_DeviceFrame();
43                 IEnvelope m_envelope = new Envelope() as IEnvelope;
44                 m_envelope.PutCoords(piexPound.left, piexPound.bottom, piexPound.right, piexPound.top);
45                 //設置輸出的IEnvelope
46                 m_export.PixelBounds = m_envelope;
47 
48                 ITrackCancel m_trackCancel = new CancelTracker();
49                 //輸出的方法
50                 MapControl.ActiveView.Output(m_export.StartExporting(), (short)resulotion, ref piexPound, MapControl.ActiveView.Extent, m_trackCancel);
51                 m_export.FinishExporting();

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM