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();

 

你可能感兴趣的:(ArcEngine)