C#AE将当前地图导出为一张图片地图

using (saveFileDialog = new SaveFileDialog())
            {
                saveFileDialog.Filter = "jpeg图片(*.jpg)|*.jpg|tiff图片(*.tif)|*.tif|bmp图片(*.bmp)|*.bmp|emf图片(*.emf)|*.emf|png图片(*.png)|*.png|gif图片(*.gif)|*.gif";
                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    fileSavePath = saveFileDialog.FileName;
                    if (fileSavePath.Length > 0)
                    {
                        try
                        {
                            //分辨率
                            double resulotion = axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.Resolution;
                            IExport pExport = null;
                            if (fileSavePath.EndsWith(".jpg"))
                            {
                                pExport = new ExportJPEG() as IExport;

                            }
                            else if (fileSavePath.EndsWith(".tig"))
                            {
                                pExport = new ExportTIFF() as IExport;

                            }
                            else if (fileSavePath.EndsWith(".bmp"))
                            {
                                pExport = new ExportBMP() as IExport;

                            }
                            else if (fileSavePath.EndsWith(".emf"))
                            {
                                pExport = new ExportEMF() as IExport;
                            }
                            else if (fileSavePath.EndsWith(".png"))
                            {
                                pExport = new ExportPNG() as IExport;
                            }
                            else if (fileSavePath.EndsWith(".gif"))
                            {
                                pExport = new ExportGIF() as IExport;
                            }
                            //设置输出的路径
                            pExport.ExportFileName = fileSavePath;
                            //设置输出的分辨率
                            pExport.Resolution = resulotion;
                            tagRECT piexPound;
                            piexPound = axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.get_DeviceFrame();
                            IEnvelope pEnvelope = new ESRI.ArcGIS.Geometry.Envelope() as IEnvelope;
                            pEnvelope.PutCoords(piexPound.left, piexPound.bottom, piexPound.right, piexPound.top);
                            //设置输出的IEnvelope
                            pExport.PixelBounds = pEnvelope;
                            ITrackCancel pTrackCancel = new CancelTracker();
                            //输出的方法
                            axMapControl1.ActiveView.Output(pExport.StartExporting(), (short)resulotion, ref piexPound, axMapControl1.ActiveView.Extent, pTrackCancel);
                            pExport.FinishExporting();
                            MessageBox.Show("导出地图成功!");
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show("导出地图失败!" + e.ToString());
                        }
                    }
                }
            }

猜你喜欢

转载自blog.csdn.net/qq_38370387/article/details/89189021