1 SaveFileDialog dialog = new SaveFileDialog();
2 dialog.Title = "保存输出图片";
3 dialog.Filter = "JPG文件(*.jpg)|*.jpg|BMP文件(*.bmp)|*.bmp||";
4 if (dialog.ShowDialog() == DialogResult.OK)
5 {
6 tagRECT grect;
7 string str = System.IO.Path.GetExtension(dialog.FileName).ToLower();
8 IExport export = null;
9 if (str == ".jpg")
10 {
11 export = new ExportJPEGClass();
12 }
13 else
14 {
15 export = new ExportBMPClass();
16 }
17 export.ExportFileName = dialog.FileName;
18 int num = 0x60;
19 int num2 = 300;
20 export.Resolution = num2;
21 grect.left = 0;
22 grect.top = 0;
23 tagRECT deviceFrame = this.m_pMapControl.ActiveView.ScreenDisplay.DisplayTransformation.get_DeviceFrame();//.DeviceFrame;
24 grect.right = (int) (((deviceFrame.right - deviceFrame.left) * num2) / ((double) num));
25 grect.bottom = (int) (((deviceFrame.bottom - deviceFrame.top) * num2) / ((double) num));
26 IEnvelope envelope = new EnvelopeClass();
27 envelope.PutCoords((double) grect.left, (double) grect.top, (double) grect.right, (double) grect.bottom);
28 export.PixelBounds = envelope;
29 int hdc = export.StartExporting();
30 double resolution = export.Resolution;
31 this.m_pMapControl.ActiveView.Output(hdc, (int) resolution, ref grect, null, null);
32 export.FinishExporting();
33 export.Cleanup();
34 }