Beispiel #1
0
        /// <summary>
        /// 出图
        /// </summary>
        /// <param name="pActiveView"></param>
        /// <param name="fileName"></param>
        public static void ExporterMap(IActiveView pActiveView, string fileName)
        {
            IExport pExporter = new ExportJPEGClass();
            //IEnvelope是指地物的外接矩形,用来表示地物图形的大体位置和形状,一般可用于检索地物,判断地物间的拓扑关系,
            //可以使得检索、判断的速度加快,因为有了IEnvelope,可以首先判断该外接矩形是否在检索范围内,而判断一个外接矩形是比较简单的。
            IEnvelope pEnvelope = new EnvelopeClass();
            // 设置跟踪取消对象   可用于取消操作
            ITrackCancel pTrackCancel = new CancelTrackerClass();
            tagRECT      ptagRECT;

            ptagRECT.left   = 0;
            ptagRECT.top    = 0;
            ptagRECT.right  = (int)pActiveView.Extent.Width;
            ptagRECT.bottom = (int)pActiveView.Extent.Height;
            // 获取输出分辨率 96 ——高清
            int pResolution = (int)(pActiveView.ScreenDisplay.DisplayTransformation.Resolution);

            // 设置一个边框范围
            pEnvelope.PutCoords(ptagRECT.left, ptagRECT.bottom, ptagRECT.right, ptagRECT.top);
            //出图分辨率
            pExporter.Resolution     = pResolution;
            pExporter.ExportFileName = fileName;
            // 将打印像素范围 设置给输出对象
            pExporter.PixelBounds = pEnvelope;
            // 进行视图控件的视图输出操作,设置对应参数
            pActiveView.Output(pExporter.StartExporting(), pResolution, ref ptagRECT, pActiveView.Extent, pTrackCancel);
            pExporter.FinishExporting();
            //释放资源
            System.Runtime.InteropServices.Marshal.ReleaseComObject(pExporter);
        }
        /// <summary>
        /// 导出图片
        /// </summary>
        public void ExportPictureMyself(string fileName)
        {
            IActiveView pActiveView = pagelayout.ActiveView;
            IEnvelope   pEnv;
            int         iOutputResolution = 600;
            int         iScreenResolution = 96;
            int         hDC;
            tagRECT     exportRECT;

            exportRECT.left   = 0;
            exportRECT.top    = 0;
            exportRECT.right  = pActiveView.ExportFrame.right * (iOutputResolution / iScreenResolution);
            exportRECT.bottom = pActiveView.ExportFrame.bottom * (iOutputResolution / iScreenResolution);

            pEnv = new EnvelopeClass();
            pEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
            IExportFileDialog pExportFileDialog = new ExportFileDialogClass();

            string  filename = fileName;
            IExport pExport  = new ExportJPEGClass();

            pExport.ExportFileName = filename;
            pExport.Resolution     = iOutputResolution;
            pExport.PixelBounds    = pEnv;
            hDC = pExport.StartExporting();
            pActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, null, null);
            pExport.FinishExporting();
            pExport.Cleanup();
        }
Beispiel #3
0
        public static bool OutputJPEG(IActiveView activeView, string pathFileName)
        {
            //parameter check
            if (activeView == null || !(pathFileName.EndsWith(".jpg")))
            {
                return(false);
            }

            IExport export = new ExportJPEGClass();

            export.ExportFileName = pathFileName;

            // Microsoft Windows default DPI resolution
            export.Resolution = 96;
            tagRECT exportRECT = activeView.ExportFrame;

            ESRI.ArcGIS.Geometry.IEnvelope envelope = new ESRI.ArcGIS.Geometry.EnvelopeClass();
            envelope.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
            export.PixelBounds = envelope;
            int hDC = export.StartExporting();

            activeView.Output(hDC, (System.Int16)export.Resolution, ref exportRECT, null, null);

            // Finish writing the export file and cleanup any intermediate files
            export.FinishExporting();
            export.Cleanup();

            return(true);
        }
        /// <summary>
        /// 导出图片
        /// </summary>
        public void ExportPictureMyself(string fileName)
        {
            IActiveView pActiveView = pagelayout.ActiveView;
            IEnvelope pEnv;
            int iOutputResolution = 600;
            int iScreenResolution = 96;
            int hDC;
            tagRECT exportRECT;
            exportRECT.left = 0;
            exportRECT.top = 0;
            exportRECT.right = pActiveView.ExportFrame.right * (iOutputResolution / iScreenResolution);
            exportRECT.bottom = pActiveView.ExportFrame.bottom * (iOutputResolution / iScreenResolution);

            pEnv = new EnvelopeClass();
            pEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
            IExportFileDialog pExportFileDialog = new ExportFileDialogClass();

            string filename = fileName;
            IExport pExport = new ExportJPEGClass();
            pExport.ExportFileName = filename;
            pExport.Resolution = iOutputResolution;
            pExport.PixelBounds = pEnv;
            hDC = pExport.StartExporting();
            pActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, null, null);
            pExport.FinishExporting();
            pExport.Cleanup();
        }
Beispiel #5
0
        public static void exportMaptoJPEG(AxPageLayoutControl axPageLayoutControl)
        {
            SaveFileDialog saveDialog = new SaveFileDialog();

            saveDialog.Title    = "保存图像";
            saveDialog.FileName = "output";
            saveDialog.Filter   = "JGP图片(*.jpg)|*.jpg";
            if (saveDialog.ShowDialog() == DialogResult.OK)
            {
                double resolution =
                    axPageLayoutControl.ActiveView.ScreenDisplay.DisplayTransformation.Resolution;
                IExport pExport = new ExportJPEGClass();
                pExport.ExportFileName = saveDialog.FileName;
                pExport.Resolution     = resolution;
                tagRECT deviceRect =
                    axPageLayoutControl.ActiveView.ScreenDisplay.DisplayTransformation.get_DeviceFrame();
                IEnvelope pDeviceEnvelope = new EnvelopeClass();
                pDeviceEnvelope.PutCoords(deviceRect.left, deviceRect.bottom,
                                          deviceRect.right, deviceRect.top);
                pExport.PixelBounds = pDeviceEnvelope;

                axPageLayoutControl.ActiveView.Output(pExport.StartExporting(), (int)pExport.Resolution,
                                                      ref deviceRect, axPageLayoutControl.ActiveView.Extent, new CancelTrackerClass());
                Application.DoEvents();
                pExport.FinishExporting();
            }
        }
Beispiel #6
0
        public static void ExportView(IActiveView activeView, IGeometry pGeo, int OutputResolution, int Width,
                                      int Height, string ExpPath, bool bRegion)
        {
            IExport   pExport;
            tagRECT   exportRect = new tagRECT();
            IEnvelope pEnvelope  = pGeo.Envelope;
            string    sType      = System.IO.Path.GetExtension(ExpPath);

            switch (sType)
            {
            case ".jpg":
                pExport = new ExportJPEGClass();
                break;

            case ".bmp":
                pExport = new ExportBMPClass();
                break;

            case ".gif":
                pExport = new ExportGIFClass();
                break;

            case ".tif":
                pExport = new ExportTIFFClass();
                break;

            case ".png":
                pExport = new ExportPNGClass();
                break;

            case ".pdf":
                pExport = new ExportPDFClass();
                break;

            default:
                MessageBox.Show("没有输出格式,默认到JPEG格式");
                pExport = new ExportJPEGClass();
                break;
            }
            pExport.ExportFileName = ExpPath;

            exportRect.left   = 0;
            exportRect.top    = 0;
            exportRect.right  = Width;
            exportRect.bottom = Height;
            if (bRegion)
            {
                //删除区域导出拖出的多边形框
                activeView.GraphicsContainer.DeleteAllElements();
                activeView.Refresh();
            }
            IEnvelope envelope = new EnvelopeClass();

            envelope.PutCoords(exportRect.left, exportRect.top, exportRect.right, exportRect.bottom);
            pExport.PixelBounds = envelope;
            activeView.Output(pExport.StartExporting(), OutputResolution, ref exportRect, pEnvelope, null);
            pExport.FinishExporting();
            pExport.Cleanup();
        }
Beispiel #7
0
        //使用静态方法提高代码的复用性
        public static void ExportView(IActiveView ActiveView, int _resolution, IGeometry pGeo, int Width, int Height, string pathtxt, bool bRegion)
        {
            IExport   pExort     = null;
            tagRECT   pRect      = new tagRECT();
            IEnvelope pEnvelope  = pGeo.Envelope;
            string    outputType = System.IO.Path.GetExtension(pathtxt).ToLower();

            switch (outputType)
            {
            case ".jpg":
                pExort = new ExportJPEGClass();
                break;

            case ".bmp":
                pExort = new ExportBMPClass();
                break;

            case ".gif":
                pExort = new ExportGIFClass();
                break;

            case ".tif":
                pExort = new ExportTIFFClass();
                break;

            case ".png":
                pExort = new ExportPNGClass();
                break;

            case ".pdf":
                pExort = new ExportPDFClass();
                break;

            default:
                MessageBox.Show("未设置输出格式,默认为jpg格式", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                pExort = new ExportJPEGClass();
                break;
            }
            pExort.ExportFileName = pathtxt;
            pRect.left            = 0; pRect.top = 0;
            pRect.right           = Width; pRect.bottom = Height;
            //
            if (bRegion)
            {
                ActiveView.GraphicsContainer.DeleteAllElements();
                ActiveView.Refresh();
            }
            //获取输出影像范围的矩形大小
            IEnvelope envelope = new EnvelopeClass();

            envelope.PutCoords((double)pRect.left, (double)pRect.top, (double)pRect.right, (double)pRect.bottom);
            pExort.PixelBounds = envelope;
            ActiveView.Output(pExort.StartExporting(), _resolution, ref pRect, pEnvelope, null);
            pExort.FinishExporting();
            pExort.Cleanup();
        }
Beispiel #8
0
        /// <summary>
        /// 导出地图
        /// </summary>
        /// <param name="activeView">当前地图</param>
        /// <param name="geo">几何图形</param>
        /// <param name="OutputResolution">输出分辨率</param>
        /// <param name="width">宽</param>
        /// <param name="height">高</param>
        /// <param name="expPath">输出路径</param>
        /// <param name="isRegion">是否时范围输出</param>
        public static void ExportView(IActiveView activeView, IGeometry geo, int OutputResolution, int width, int height, string expPath, bool isRegion)
        {
            IExport   export     = null;
            IEnvelope envelope   = geo.Envelope;
            string    outputType = System.IO.Path.GetExtension(expPath);

            switch (outputType)
            {
            case ".jpg":
                export = new ExportJPEGClass();
                break;

            case ".bmp":
                export = new ExportBMPClass();
                break;

            case ".gif":
                export = new ExportGIFClass();
                break;

            case ".tif":
                export = new ExportTIFFClass();
                break;

            case ".png":
                export = new ExportPNGClass();
                break;

            case ".pdf":
                export = new ExportPDFClass();
                break;

            default:
                MessageBox.Show("没有输出格式,默认到JPEG格式");
                export = new ExportJPEGClass();
                break;
            }

            export.ExportFileName = expPath;
            tagRECT rect = new tagRECT();

            rect.top   = 0; rect.left = 0;
            rect.right = width; rect.bottom = height;
            if (isRegion)
            {
                activeView.GraphicsContainer.DeleteAllElements();
                activeView.Refresh();
            }
            IEnvelope env = new EnvelopeClass();

            env.PutCoords((double)rect.left, (double)rect.top, (double)rect.right, (double)rect.bottom);
            export.PixelBounds = env;
            activeView.Output(export.StartExporting(), OutputResolution, ref rect, envelope, null);
            export.FinishExporting();
            export.Cleanup();
        }
Beispiel #9
0
        private void MapSelectPrint()//拉框打印框内地图
        {
            try
            {
                IEnvelope pEnv = new EnvelopeClass();
                pEnv = axMapControl1.TrackRectangle();
                SaveFileDialog exportJPGDialog = new SaveFileDialog();
                exportJPGDialog.Title            = "导出JPEG图像";
                exportJPGDialog.Filter           = "Jpeg Files(*.jpg,*.jpeg)|*.jpg,*.jpeg";
                exportJPGDialog.RestoreDirectory = true;
                exportJPGDialog.ValidateNames    = true;
                exportJPGDialog.OverwritePrompt  = true;
                exportJPGDialog.DefaultExt       = "jpg";

                if (exportJPGDialog.ShowDialog() == DialogResult.OK)
                {
                    double lScreenResolution;
                    lScreenResolution = axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.Resolution;
                    // lScreenResolution =  axPageLayoutControl1.ActiveView.ScreenDisplay.DisplayTransformation.Resolution;
                    IExport pExporter = new ExportJPEGClass() as IExport;
                    //IExport pExporter = new ExportPDFClass() as IExport;//直接可以用!!
                    pExporter.ExportFileName = exportJPGDialog.FileName;
                    pExporter.Resolution     = lScreenResolution;

                    tagRECT deviceRECT;
                    //用这句的话执行到底下的output()时就会出现错误:Not enough memory to create requested bitmap
                    //MainaxMapControl.ActiveView.ScreenDisplay.DisplayTransformation.set_DeviceFrame(ref deviceRECT);
                    deviceRECT = axMapControl1.ActiveView.ExportFrame;
                    ////////////////////////////
                    //deviceRECT.left = 0;
                    //deviceRECT.top = 0;
                    // deviceRECT.right = (int)pActiveView.Extent.Width;
                    //deviceRECT.bottom = (int)pActiveView.Extent.Height;
                    ///////////////////////////////////

                    IEnvelope pDriverBounds = new EnvelopeClass();
                    //pDriverBounds = MainaxMapControl.ActiveView.FullExtent;

                    pDriverBounds.PutCoords(deviceRECT.left, deviceRECT.bottom, deviceRECT.right, deviceRECT.top);

                    pExporter.PixelBounds = pDriverBounds;

                    ITrackCancel pCancel = new CancelTrackerClass();
                    axMapControl1.ActiveView.Output(pExporter.StartExporting(), (int)lScreenResolution, ref deviceRECT, pEnv, pCancel);
                    pExporter.FinishExporting();
                    pExporter.Cleanup();
                }
            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; }
        }
        /// <summary>
        /// 全域导出
        /// </summary>
        /// <param name="OutputResolution">输出分辨率</param>
        /// <param name="ExpPath">输出路径</param>
        /// <param name="view">视图</param>
        public static void ExportActiveView(int OutputResolution, string ExpPath, IActiveView view)
        {
            IExport   pExport = null;
            tagRECT   exportRect;
            IEnvelope envelope2 = view.Extent;
            int       num       = (int)Math.Round(view.ScreenDisplay.DisplayTransformation.Resolution);
            string    sType     = System.IO.Path.GetExtension(ExpPath);

            switch (sType)
            {
            case ".jpg":
                pExport = new ExportJPEGClass();
                break;

            case ".bmp":
                pExport = new ExportBMPClass();
                break;

            case ".gif":
                pExport = new ExportGIFClass();
                break;

            case ".tif":
                pExport = new ExportTIFFClass();
                break;

            case ".png":
                pExport = new ExportPNGClass();
                break;

            case ".pdf":
                pExport = new ExportPDFClass();
                break;

            default:
                MessageBox.Show("没有输出格式,默认到JPEG格式");
                pExport = new ExportJPEGClass();
                break;
            }
            pExport.ExportFileName = ExpPath;
            exportRect.left        = 0; exportRect.top = 0;
            exportRect.right       = (int)Math.Round((double)(view.ExportFrame.right * (((double)OutputResolution) / ((double)num))));
            exportRect.bottom      = (int)Math.Round((double)(view.ExportFrame.bottom * (((double)OutputResolution) / ((double)num))));
            IEnvelope envelope = new EnvelopeClass();

            envelope.PutCoords((double)exportRect.left, (double)exportRect.top, (double)exportRect.right, (double)exportRect.bottom);
            pExport.PixelBounds = envelope;
            view.Output(pExport.StartExporting(), OutputResolution, ref exportRect, envelope2, null);
            pExport.FinishExporting();
            pExport.Cleanup();
        }
Beispiel #11
0
        public void screenShot(IEnvelope IN_Envelope, string IN_SaveFile, AxMapControl IN_Axmapcontrols, double ratio)
        {
            /*
             * IN_Envelope为输出范围,单位为米
             * IN_SaveFile为输出文件名
             * IN_Axmapcontrols map控件
             * ratio 影像空间分辨率的倒数
             *
             */
            if (IN_Envelope == null)
            {
                IN_Envelope = IN_Axmapcontrols.ActiveView.Extent;
            }

            IExport     Temp_Exporter          = new ExportJPEGClass(); //定义输出设备 Temp_Exporter
            IActiveView Temp_CurrentActiveView = IN_Axmapcontrols.ActiveView;

            tagRECT Temp_TtagRECT; //定义的是输出设备的像素大小

            Temp_TtagRECT.left   = 0;
            Temp_TtagRECT.top    = 0;
            Temp_TtagRECT.right  = (int)(IN_Envelope.Width * ratio);
            Temp_TtagRECT.bottom = (int)(IN_Envelope.Height * ratio);

            int Temp_DPI = 300;                            //DPI 设置

            IEnvelope Temp_Envelope = new EnvelopeClass(); //定义一个Envelope来确定设备单元中输出的图片大小

            Temp_Envelope.PutCoords(Temp_TtagRECT.left, Temp_TtagRECT.top, Temp_TtagRECT.right, Temp_TtagRECT.bottom);
            //Temp_Envelope.PutCoords(0, 0, 500, 500); 此参数只会显示图片左上角500*500区域

            Temp_Exporter.Resolution     = Temp_DPI;
            Temp_Exporter.ExportFileName = IN_SaveFile;
            Temp_Exporter.PixelBounds    = Temp_Envelope;

            //IOutputRasterSettings pOutputRasterS = (IOutputRasterSettings)IN_Axmapcontrols.ActiveView.ScreenDisplay.DisplayTransformation;
            IOutputRasterSettings pOutputRasterS = (IOutputRasterSettings)Temp_CurrentActiveView.ScreenDisplay.DisplayTransformation;

            pOutputRasterS.ResampleRatio = 1;   //设置了这个采样比例后,输出图片的像素和原始影像的像素一样!

            Temp_CurrentActiveView.Output(Temp_Exporter.StartExporting(), (int)Temp_DPI, ref Temp_TtagRECT, IN_Envelope, null);

            Temp_Exporter.FinishExporting();
            Temp_Exporter.Cleanup();

            System.Runtime.InteropServices.Marshal.ReleaseComObject(Temp_Exporter);
        }
Beispiel #12
0
        public static bool OutputJPEGHiResolution(IActiveView activeView, string pathFileName)
        {
            //parameter check
            if (activeView == null || !(pathFileName.EndsWith(".jpg")))
            {
                return(false);
            }

            IExport export = new ExportJPEGClass();

            export.ExportFileName = pathFileName;

            // Because we are exporting to a resolution that differs from screen
            // resolution, we should assign the two values to variables for use
            // in our sizing calculations
            System.Int32 screenResolution = 96;
            System.Int32 outputResolution = 300;

            export.Resolution = outputResolution;

            tagRECT exportRECT; // This is a structure

            exportRECT.left   = 0;
            exportRECT.top    = 0;
            exportRECT.right  = activeView.ExportFrame.right * (outputResolution / screenResolution);
            exportRECT.bottom = activeView.ExportFrame.bottom * (outputResolution / screenResolution);

            // Set up the PixelBounds envelope to match the exportRECT
            IEnvelope envelope = new EnvelopeClass();

            envelope.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
            export.PixelBounds = envelope;

            int hDC = export.StartExporting();

            activeView.Output(hDC, (System.Int16)export.Resolution, ref exportRECT, null, null); // Explicit Cast and 'ref' keyword needed
            export.FinishExporting();
            export.Cleanup();

            return(true);
        }
Beispiel #13
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (System.IO.File.Exists(textBoxFileName.Text.ToString()) == true)
            {
                MessageBox.Show("该文件已经存在,请重新命名!");
                textBoxFileName.SelectAll();
            }
            else
            {
                IExport            pExport    = null;
                IWorldFileSettings pWorldFile = null;
                IExportImage       pExportType;
                IEnvelope          pDriverBounds = null;

                ESRI.ArcGIS.esriSystem.tagRECT userRECT = new ESRI.ArcGIS.esriSystem.tagRECT();
                IEnvelope pEnv = new EnvelopeClass();

                string   FilePath    = this.m_strFileName;
                string[] strFileName = FilePath.Split('.');
                string   strFileType = strFileName[1];
                switch (strFileType)
                {
                case "jpg":
                    pExport = new ExportJPEGClass();
                    break;

                case "bmp":
                    pExport = new ExportBMPClass();
                    break;

                case "gif":
                    pExport = new ExportGIFClass();
                    break;

                case "tif":
                    pExport = new ExportTIFFClass();
                    break;

                case "png":
                    pExport = new ExportPNGClass();
                    break;

                case "emf":
                    pExport = new ExportEMFClass();
                    break;

                case "pdf":
                    pExport = new ExportPDFClass();
                    break;

                case ".ai":
                    pExport = new ExportAIClass();
                    break;

                case "svg":
                    pExport = new ExportSVGClass();
                    break;

                default:
                    pExport = new ExportJPEGClass();
                    break;
                }

                pExport.ExportFileName = this.m_strFileName;
                pExport.Resolution     = Convert.ToInt32(numUDresolution.Value);
                pExportType            = pExport as IExportImage;
                pExportType.ImageType  = esriExportImageType.esriExportImageTypeTrueColor;
                pEnv                       = m_pageLayoutControl.ActiveView.Extent;
                pWorldFile                 = (IWorldFileSettings)pExport;
                pWorldFile.MapExtent       = pEnv;
                pWorldFile.OutputWorldFile = false;
                userRECT.top               = 0;
                userRECT.left              = 0;
                userRECT.right             = Convert.ToInt32(txtBoxWidth.Text);
                userRECT.bottom            = Convert.ToInt32(txtBoxHeight.Text);
                pDriverBounds              = new EnvelopeClass();
                pDriverBounds.PutCoords(userRECT.top, userRECT.bottom, userRECT.right, userRECT.top);
                pExport.PixelBounds = pDriverBounds;
                ITrackCancel pTrackCancel = new TrackCancelClass();
                m_pageLayoutControl.ActiveView.Output(pExport.StartExporting(), Convert.ToInt32(numUDresolution.Value), ref userRECT, m_pageLayoutControl.ActiveView.Extent, pTrackCancel);
                pExport.FinishExporting();
                MessageBox.Show("打印图片保存成功!", "保存", MessageBoxButtons.OK);
                this.Close();
            }
        }
        /// <summary>
        /// Create Bitmap From ESRI Dataset
        /// </summary>
        /// <param name="dataset">Dataset to generate an image from</param>
        /// <param name="imageFormat">Output image format</param>
        /// <param name="size">Size of output image</param>
        /// <param name="resolution">Resolution of output image (dpi)</param>
        /// <param name="background">Background color</param>
        /// <param name="filename">Ouput filename</param>
        public static void CreateBitmap(IDataset dataset, esriImageFormat imageFormat, Size size, ushort resolution, Color background, string filename) {
            ILayer layer = null;

            switch (dataset.Type) {
                case esriDatasetType.esriDTFeatureClass:
                    IFeatureClass featureClass = (IFeatureClass)dataset;
                    switch (featureClass.FeatureType) {
                        case esriFeatureType.esriFTDimension:
                            layer = new DimensionLayerClass();
                            break;
                        case esriFeatureType.esriFTAnnotation:
                            layer = new FeatureLayerClass();
                            IGeoFeatureLayer geoFeaureLayer = (IGeoFeatureLayer)layer;
                            geoFeaureLayer.DisplayAnnotation = true;
                            break;
                        case esriFeatureType.esriFTComplexEdge:
                        case esriFeatureType.esriFTComplexJunction:
                        case esriFeatureType.esriFTSimple:
                        case esriFeatureType.esriFTSimpleEdge:
                        case esriFeatureType.esriFTSimpleJunction:
                            layer = new FeatureLayerClass();
                            break;
                    }
                    if (layer == null) { return; }

                    IFeatureLayer featureLayer = (IFeatureLayer)layer;
                    featureLayer.FeatureClass = featureClass;

                    break;
                case esriDatasetType.esriDTRasterDataset:
                    layer = new RasterLayerClass();
                    IRasterLayer rasterLayer = (IRasterLayer)layer;
                    rasterLayer.CreateFromDataset((IRasterDataset)dataset);
                    break;
                default:
                    string message = string.Format("[{0}] is not supported", dataset.Type.ToString());
                    throw new Exception(message);
            }
            if (layer == null) { return; }

            // Create In-memory Map
            IMap map = new MapClass();
            map.AddLayer(layer);
            IActiveView activeView = (IActiveView)map;
            IExport export = null;
            tagRECT rect = new tagRECT();

            // Set Format Specific Properties
            switch (imageFormat) {
                case esriImageFormat.esriImageJPG:
                    export = new ExportJPEGClass();
                    IExportJPEG exportJpeg = (IExportJPEG)export;
                    exportJpeg.ProgressiveMode = false;
                    exportJpeg.Quality = 100;

                    break;
                default:
                    throw new Exception("[" + imageFormat.ToString() + "] is not supported");
            }
            if (export == null) {
                throw new Exception("Failed to Created Exporter");
            }

            // Set Background
            if ((export is IExportBMP) ||
                (export is IExportGIF) ||
                (export is IExportJPEG) ||
                (export is IExportPNG) ||
                (export is IExportTIFF)) {
                IExportImage exportImage = (IExportImage)export;
                exportImage.ImageType = esriExportImageType.esriExportImageTypeTrueColor;
                exportImage.BackgroundColor = GeodatabaseUtility.ToESRIColor(background);
            }

            // Set Export Frame
            rect = activeView.ExportFrame;
            rect.left = 0;
            rect.top = 0;
            rect.right = size.Width;
            rect.bottom = size.Height;

            // Set Output Extent
            IEnvelope envelope = new EnvelopeClass();
            envelope.PutCoords(rect.left, rect.top, rect.right, rect.bottom);
            export.PixelBounds = envelope;
            export.Resolution = resolution;
            export.ExportFileName = filename;

            // Export map to image
            int intHdc = export.StartExporting();
            activeView.Output(intHdc, resolution, ref rect, null, null);
            export.FinishExporting();
            export.Cleanup();

            // Clear Layers
            map.ClearLayers();

            // Release COM Objects
            GeodatabaseUtility.ReleaseComObject(layer);
            GeodatabaseUtility.ReleaseComObject(envelope);
            GeodatabaseUtility.ReleaseComObject(map);
            GeodatabaseUtility.ReleaseComObject(activeView);
            GeodatabaseUtility.ReleaseComObject(export);
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
Beispiel #15
0
        /// <summary>
        /// 导出图片
        /// </summary>
        public void ExportPicture(string strdefaultfilename)
        {
            if (strdefaultfilename.Contains("制"))
            {
                strdefaultfilename = strdefaultfilename.Replace("制","");
            }
            try
            {
                IActiveView pActiveView =axPageLayoutControl1.ActiveView;
                IEnvelope pEnv;
                int iOutputResolution = 600;
                int iScreenResolution = 96;
                int hDC;
                tagRECT exportRECT;
                exportRECT.left = 0;
                exportRECT.top = 0;
                //exportRECT.right = pActiveView.ExportFrame.right;
                //exportRECT.bottom = pActiveView.ExportFrame.bottom;
                exportRECT.right = pActiveView.ExportFrame.right * (iOutputResolution / iScreenResolution);
                exportRECT.bottom = pActiveView.ExportFrame.bottom * (iOutputResolution / iScreenResolution);

                pEnv = new EnvelopeClass();
                pEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
                IExportFileDialog pExportFileDialog = new ExportFileDialogClass();
                pExportFileDialog.DocumentName = strdefaultfilename;
                //bool bl;
                //bl = pExportFileDialog.DoModal(pEnv, pActiveView.Extent, pActiveView.Extent, 900);
                //if (!bl) return;
                //IExport pExport = pExportFileDialog.Export;
                //pExport.Resolution = iOutputResolution;
                //pExport.PixelBounds = pEnv;
                string filename = Application.StartupPath + @"\Image\1.jpg";
                if (File.Exists(filename))
                {
                    File.Delete(filename);
                }
                IExport pExport = new ExportJPEGClass();
                pExport.ExportFileName = filename;
                pExport.Resolution = iOutputResolution;
                pExport.PixelBounds = pEnv;
                hDC = pExport.StartExporting();
                pActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, null, null);
                pExport.FinishExporting();
                pExport.Cleanup();

                hDC = pExport.StartExporting();
                pActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, null, null);
                pExport.FinishExporting();
                pExport.Cleanup();
               // MessageBox.Show("保存成功", "提示");
            }
            catch (Exception ax)
            {
                MessageBox.Show(ax.ToString());
            }

            //try
            //{
            //    System.Windows.Forms.SaveFileDialog sfd = new SaveFileDialog();
            //    sfd.Filter = "*.jpeg|*.jpeg|*.pdf|*.pdf|*.bmp|*.bmp";
            //    if (sfd.ShowDialog() == DialogResult.OK)
            //    {
            //        IExport pExport = null;
            //        if (1 == sfd.FilterIndex)
            //        {
            //            pExport = new ExportJPEGClass();
            //        }
            //        else if (2 == sfd.FilterIndex)
            //        {
            //            pExport = new ExportPDFClass();
            //        }
            //        else if (3 == sfd.FilterIndex)
            //        {
            //            pExport = new ExportBMPClass();
            //        }
            //        pExport.ExportFileName = sfd.FileName;
            //        //设置参数
            //        //默认精度
            //        int reslution = 300;
            //        pExport.Resolution = reslution;
            //        //获取导出范围
            //        tagRECT exportRECT = axPageLayoutControl1.ActiveView.ExportFrame;
            //        //tagRECT exportRECT = axMapMain.ActiveView.ExportFrame;
            //        IEnvelope pPixelBoundsEnv = new EnvelopeClass();
            //        pPixelBoundsEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
            //        pExport.PixelBounds = pPixelBoundsEnv;
            //        //开始导出,获取DC
            //        int hDC = pExport.StartExporting();
            //        IEnvelope pVisbounds = null;
            //        ITrackCancel ptrac = null;
            //        //导出
            //        axPageLayoutControl1.ActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, pVisbounds, ptrac);
            //        //结束导出
            //        pExport.FinishExporting();
            //        //清理导出类
            //        pExport.Cleanup();
            //        MessageBox.Show("导出成功","提示");
            //    }
            //}
            //catch
            //{

            //}
        }
Beispiel #16
0
        /// <summary>
        /// 根据Mxd输出JPG图片
        /// </summary>
        /// <param name="pActiveView"></param>
        /// <param name="Resolution">分辨率</param>
        /// <param name="strFilePath">保存图片路径</param>
        /// <param name="strMxdPath">Mxd文档路径</param>
        private void ExportJPG(IActiveView pActiveView, int Resolution, string strFilePath, string strMxdPath)
        {
            long iPrevOutputImageQuality;
            IOutputRasterSettings  docOutputRasterSettings;
            IDisplayTransformation docDisplayTransformation;
            tagRECT        DisplayBounds;
            IPageLayout    docPageLayout;
            IEnvelope      docGraphicsExtentEnv;
            IEnvelope      docMapExtEnv;
            IUnitConverter pUnitConvertor;
            IEnvelope      PixelBoundsEnv;
            IExport        pExport = new ExportJPEGClass();

            try
            {
                string strPath = strFilePath + "\\" + System.IO.Path.GetFileNameWithoutExtension(strMxdPath) + ".jpg";
                pExport.ExportFileName = strPath;
                if (System.IO.File.Exists(strPath))
                {
                    System.IO.File.Delete(strPath);
                }
                int iOutputResolution = Resolution;
                pExport.Resolution = iOutputResolution;

                docOutputRasterSettings = pActiveView.ScreenDisplay.DisplayTransformation as IOutputRasterSettings;
                iPrevOutputImageQuality = docOutputRasterSettings.ResampleRatio;
                SetOutputQuality(pActiveView, 1);
                if (pActiveView is IPageLayout)
                {
                    DisplayBounds        = pActiveView.ExportFrame;
                    docGraphicsExtentEnv = GetGraphicsExtent(pActiveView);
                }
                else
                {
                    docDisplayTransformation = pActiveView.ScreenDisplay.DisplayTransformation;
                    DisplayBounds            = docDisplayTransformation.get_DeviceFrame();
                }
                tagRECT exportRECT;
                PixelBoundsEnv = new Envelope() as IEnvelope;


                double tempratio  = iOutputResolution / Resolution;
                double tempbottom = DisplayBounds.bottom * tempratio;
                double tempright  = DisplayBounds.right * tempratio;

                exportRECT.bottom = (int)Math.Truncate(tempbottom);
                exportRECT.left   = 0;
                exportRECT.top    = 0;
                exportRECT.right  = (int)Math.Truncate(tempright);

                PixelBoundsEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
                docMapExtEnv = null;



                pExport.PixelBounds = PixelBoundsEnv;
                int hDc = pExport.StartExporting();
                pActiveView.Output(hDc, (int)pExport.Resolution, ref exportRECT, docMapExtEnv, null);
                pExport.FinishExporting();
            }
            catch { }
            finally
            {
                //完成输出后清理临时文件
                pExport.Cleanup();
                docMapExtEnv         = null;
                PixelBoundsEnv       = null;
                docGraphicsExtentEnv = null;
            }
        }
Beispiel #17
0
        private void OutputMap(string mxdPath, string saveMxdPath)
        {
            try
            {
                if (txtResolution.Text.Trim() == "" && cbxExpention.Text.Trim() == "")
                {
                    MessageBox.Show("保存类型和分辨率不能为空!");
                    return;
                }

                //   string fpath;
                IActiveView  pActiveView;
                IExport      pExport;
                IEnvelope    pPixelBoundsEnv;
                int          iOutputResolution;
                int          iScreenResolution;
                int          hDC;
                IMxdContents pMxdC;
                IMapDocument pMapDocument = new MapDocumentClass();
                pMapDocument.Open(mxdPath, "");
                pMxdC = pMapDocument.PageLayout as IMxdContents;

                //    IMap pMap = pMxdC.ActiveView.FocusMap; //this.axPageLayoutControl1.ActiveView.FocusMap;
                //   IPageLayout pPageLayout = pMxdC.PageLayout;//this.axPageLayoutControl1.PageLayout;
                //    AxPageLayoutControl pPageLayoutControl = pMapDocument as AxPageLayoutControl;
                pActiveView = pMapDocument.ActiveView;
                pExport     = new ExportJPEGClass();
                //  SaveFileDialog saveFileDialog1 = new SaveFileDialog();
                //  saveFileDialog1.InitialDirectory = Application.StartupPath;
                //  saveFileDialog1.Filter =string.Format("{0} files (*.{0})|*.{0}",cbxExpention.Text.Trim());
                string fpath = saveMxdPath + "." + cbxExpention.Text.Trim();
                //if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                //{
                // fpath = saveFileDialog1.FileName.Trim();
                pExport.ExportFileName = fpath;
                iScreenResolution      = 96;
                iOutputResolution      = 300;
                pExport.Resolution     = iOutputResolution;
                tagRECT pExportFrame;
                pExportFrame = pActiveView.ExportFrame;
                tagRECT exportRECT;
                exportRECT.left  = 0;
                exportRECT.top   = 0;
                exportRECT.right = pActiveView.ExportFrame.right * (iOutputResolution /
                                                                    iScreenResolution);
                exportRECT.bottom = pActiveView.ExportFrame.bottom * (iOutputResolution /
                                                                      iScreenResolution);
                pPixelBoundsEnv = new EnvelopeClass();
                pPixelBoundsEnv.PutCoords(exportRECT.left, exportRECT.top,
                                          exportRECT.right, exportRECT.bottom);
                pExport.PixelBounds = pPixelBoundsEnv;
                hDC = pExport.StartExporting();
                pActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, null, null);
                pExport.FinishExporting();
                pExport.Cleanup();
                // }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// Create Bitmap From ESRI Dataset
        /// </summary>
        /// <param name="dataset">Dataset to generate an image from</param>
        /// <param name="imageFormat">Output image format</param>
        /// <param name="size">Size of output image</param>
        /// <param name="resolution">Resolution of output image (dpi)</param>
        /// <param name="background">Background color</param>
        /// <param name="filename">Ouput filename</param>
        public static void CreateBitmap(IDataset dataset, esriImageFormat imageFormat, Size size, ushort resolution, Color background, string filename)
        {
            ILayer layer = null;

            switch (dataset.Type)
            {
            case esriDatasetType.esriDTFeatureClass:
                IFeatureClass featureClass = (IFeatureClass)dataset;
                switch (featureClass.FeatureType)
                {
                case esriFeatureType.esriFTDimension:
                    layer = new DimensionLayerClass();
                    break;

                case esriFeatureType.esriFTAnnotation:
                    layer = new FeatureLayerClass();
                    IGeoFeatureLayer geoFeaureLayer = (IGeoFeatureLayer)layer;
                    geoFeaureLayer.DisplayAnnotation = true;
                    break;

                case esriFeatureType.esriFTComplexEdge:
                case esriFeatureType.esriFTComplexJunction:
                case esriFeatureType.esriFTSimple:
                case esriFeatureType.esriFTSimpleEdge:
                case esriFeatureType.esriFTSimpleJunction:
                    layer = new FeatureLayerClass();
                    break;
                }
                if (layer == null)
                {
                    return;
                }

                IFeatureLayer featureLayer = (IFeatureLayer)layer;
                featureLayer.FeatureClass = featureClass;

                break;

            case esriDatasetType.esriDTRasterDataset:
                layer = new RasterLayerClass();
                IRasterLayer rasterLayer = (IRasterLayer)layer;
                rasterLayer.CreateFromDataset((IRasterDataset)dataset);
                break;

            default:
                string message = string.Format("[{0}] is not supported", dataset.Type.ToString());
                throw new Exception(message);
            }
            if (layer == null)
            {
                return;
            }

            // Create In-memory Map
            IMap map = new MapClass();

            map.AddLayer(layer);
            IActiveView activeView = (IActiveView)map;
            IExport     export     = null;
            tagRECT     rect       = new tagRECT();

            // Set Format Specific Properties
            switch (imageFormat)
            {
            case esriImageFormat.esriImageJPG:
                export = new ExportJPEGClass();
                IExportJPEG exportJpeg = (IExportJPEG)export;
                exportJpeg.ProgressiveMode = false;
                exportJpeg.Quality         = 100;

                break;

            default:
                throw new Exception("[" + imageFormat.ToString() + "] is not supported");
            }
            if (export == null)
            {
                throw new Exception("Failed to Created Exporter");
            }

            // Set Background
            if ((export is IExportBMP) ||
                (export is IExportGIF) ||
                (export is IExportJPEG) ||
                (export is IExportPNG) ||
                (export is IExportTIFF))
            {
                IExportImage exportImage = (IExportImage)export;
                exportImage.ImageType       = esriExportImageType.esriExportImageTypeTrueColor;
                exportImage.BackgroundColor = GeodatabaseUtility.ToESRIColor(background);
            }

            // Set Export Frame
            rect        = activeView.ExportFrame;
            rect.left   = 0;
            rect.top    = 0;
            rect.right  = size.Width;
            rect.bottom = size.Height;

            // Set Output Extent
            IEnvelope envelope = new EnvelopeClass();

            envelope.PutCoords(rect.left, rect.top, rect.right, rect.bottom);
            export.PixelBounds    = envelope;
            export.Resolution     = resolution;
            export.ExportFileName = filename;

            // Export map to image
            int intHdc = export.StartExporting();

            activeView.Output(intHdc, resolution, ref rect, null, null);
            export.FinishExporting();
            export.Cleanup();

            // Clear Layers
            map.ClearLayers();

            // Release COM Objects
            GeodatabaseUtility.ReleaseComObject(layer);
            GeodatabaseUtility.ReleaseComObject(envelope);
            GeodatabaseUtility.ReleaseComObject(map);
            GeodatabaseUtility.ReleaseComObject(activeView);
            GeodatabaseUtility.ReleaseComObject(export);
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
Beispiel #19
0
        /// <summary>
        /// 导出图片
        /// </summary>
        public void ExportPicture(string strdefaultfilename)
        {
            if (strdefaultfilename.Contains("制"))
            {
                strdefaultfilename = strdefaultfilename.Replace("制", "");
            }
            try
            {
                IActiveView pActiveView = axPageLayoutControl1.ActiveView;
                IEnvelope   pEnv;
                int         iOutputResolution = 600;
                int         iScreenResolution = 96;
                int         hDC;
                tagRECT     exportRECT;
                exportRECT.left = 0;
                exportRECT.top  = 0;
                //exportRECT.right = pActiveView.ExportFrame.right;
                //exportRECT.bottom = pActiveView.ExportFrame.bottom;
                exportRECT.right  = pActiveView.ExportFrame.right * (iOutputResolution / iScreenResolution);
                exportRECT.bottom = pActiveView.ExportFrame.bottom * (iOutputResolution / iScreenResolution);

                pEnv = new EnvelopeClass();
                pEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
                IExportFileDialog pExportFileDialog = new ExportFileDialogClass();
                pExportFileDialog.DocumentName = strdefaultfilename;
                //bool bl;
                //bl = pExportFileDialog.DoModal(pEnv, pActiveView.Extent, pActiveView.Extent, 900);
                //if (!bl) return;
                //IExport pExport = pExportFileDialog.Export;
                //pExport.Resolution = iOutputResolution;
                //pExport.PixelBounds = pEnv;
                string filename = Application.StartupPath + @"\Image\1.jpg";
                if (File.Exists(filename))
                {
                    File.Delete(filename);
                }
                IExport pExport = new ExportJPEGClass();
                pExport.ExportFileName = filename;
                pExport.Resolution     = iOutputResolution;
                pExport.PixelBounds    = pEnv;
                hDC = pExport.StartExporting();
                pActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, null, null);
                pExport.FinishExporting();
                pExport.Cleanup();

                hDC = pExport.StartExporting();
                pActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, null, null);
                pExport.FinishExporting();
                pExport.Cleanup();
                // MessageBox.Show("保存成功", "提示");
            }
            catch (Exception ax)
            {
                MessageBox.Show(ax.ToString());
            }

            //try
            //{
            //    System.Windows.Forms.SaveFileDialog sfd = new SaveFileDialog();
            //    sfd.Filter = "*.jpeg|*.jpeg|*.pdf|*.pdf|*.bmp|*.bmp";
            //    if (sfd.ShowDialog() == DialogResult.OK)
            //    {
            //        IExport pExport = null;
            //        if (1 == sfd.FilterIndex)
            //        {
            //            pExport = new ExportJPEGClass();
            //        }
            //        else if (2 == sfd.FilterIndex)
            //        {
            //            pExport = new ExportPDFClass();
            //        }
            //        else if (3 == sfd.FilterIndex)
            //        {
            //            pExport = new ExportBMPClass();
            //        }
            //        pExport.ExportFileName = sfd.FileName;
            //        //设置参数
            //        //默认精度
            //        int reslution = 300;
            //        pExport.Resolution = reslution;
            //        //获取导出范围
            //        tagRECT exportRECT = axPageLayoutControl1.ActiveView.ExportFrame;
            //        //tagRECT exportRECT = axMapMain.ActiveView.ExportFrame;
            //        IEnvelope pPixelBoundsEnv = new EnvelopeClass();
            //        pPixelBoundsEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
            //        pExport.PixelBounds = pPixelBoundsEnv;
            //        //开始导出,获取DC
            //        int hDC = pExport.StartExporting();
            //        IEnvelope pVisbounds = null;
            //        ITrackCancel ptrac = null;
            //        //导出
            //        axPageLayoutControl1.ActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, pVisbounds, ptrac);
            //        //结束导出
            //        pExport.FinishExporting();
            //        //清理导出类
            //        pExport.Cleanup();
            //        MessageBox.Show("导出成功","提示");
            //    }
            //}
            //catch
            //{

            //}
        }
Beispiel #20
0
        public static void ExportView(IActiveView view, IGeometry pGeo, int OutputResolution, int Width, int Height, string ExpPath, bool bRegion)
        {
            IExport   pExport    = null;
            tagRECT   exportRect = new tagRECT();
            IEnvelope pEnvelope  = pGeo.Envelope;
            string    sType      = System.IO.Path.GetExtension(ExpPath);

            switch (sType)
            {
            case ".jpg":
                pExport = new ExportJPEGClass();
                break;

            case ".bmp":
                pExport = new ExportBMPClass();
                break;

            case ".gif":
                pExport = new ExportGIFClass();
                break;

            case ".tif":
                pExport = new ExportTIFFClass();
                break;

            case ".png":
                pExport = new ExportPNGClass();
                break;

            case ".pdf":
                pExport = new ExportPDFClass();
                break;

            default:
                MessageBox.Show("没有输出格式,默认到JPEG格式");
                pExport = new ExportJPEGClass();
                break;
            }
            pExport.ExportFileName = ExpPath;

            exportRect.left   = 0;
            exportRect.top    = 0;
            exportRect.right  = Width;
            exportRect.bottom = Height;//bottom 写成 left 两天才排出错误 2016年4月17日20:24:13
            if (bRegion)
            {
                view.GraphicsContainer.DeleteAllElements();
                view.Refresh();
            }

            IEnvelope envelope = new EnvelopeClass();

            envelope.PutCoords((double)exportRect.left, (double)exportRect.top, (double)exportRect.right, (double)exportRect.bottom);
            pExport.PixelBounds = envelope;
            //MessageBox.Show("Go Here!  OutputResolution  " + OutputResolution, "yahooo");
            view.Output(pExport.StartExporting(), OutputResolution, ref exportRect, pEnvelope, null);//无法运行2016年4月17日14:42:25

            /*
             * 当时发现错误出现在上句,对分辨率参数做了排查,但是忽略了其它参数,而最终的问题就在于其中的pEnvelope参数
             * 这次能够排出错误,是因为对照了原来的代码,而在自己写程序时没有参考代码,仅靠对照排错是不够的,
             * 因此,要逐步缩小出错的代码块,对每一个参数都要进行检验。(2016年4月17日20:31:12)
             */
            pExport.FinishExporting();
            pExport.Cleanup();
        }
Beispiel #21
0
        private void toolStripButton10_Click(object sender, EventArgs e)
        {
            try
            {
                SaveFileDialog exportJPGDialog = new SaveFileDialog();
                exportJPGDialog.Title = "导出JPEG图像";
                exportJPGDialog.Filter = "Jpeg Files(*.jpg,*.jpeg)|*.jpg,*.jpeg";
                exportJPGDialog.RestoreDirectory = true;
                exportJPGDialog.ValidateNames = true;
                exportJPGDialog.OverwritePrompt = true;
                exportJPGDialog.DefaultExt = "jpg";

                if (exportJPGDialog.ShowDialog() == DialogResult.OK)
                {
                    double lScreenResolution;
                    lScreenResolution = axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.Resolution;

                    IExport pExporter = new ExportJPEGClass() as IExport;
                    //IExport pExporter = new ExportPDFClass() as IExport;//直接可以用!!
                    pExporter.ExportFileName = exportJPGDialog.FileName;
                    pExporter.Resolution = lScreenResolution;

                    tagRECT deviceRECT;
                    //用这句的话执行到底下的output()时就会出现错误:Not enough memory to create requested bitmap
                    //axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.set_DeviceFrame(ref deviceRECT);
                    deviceRECT = axMapControl1.ActiveView.ExportFrame;

                    IEnvelope pDriverBounds = new EnvelopeClass();
                    //pDriverBounds = axMapControl1.ActiveView.FullExtent;

                    pDriverBounds.PutCoords(deviceRECT.left, deviceRECT.bottom, deviceRECT.right, deviceRECT.top);

                    pExporter.PixelBounds = pDriverBounds;

                    ITrackCancel pCancel = new CancelTrackerClass();
                    axMapControl1.ActiveView.Output(pExporter.StartExporting(), (int)lScreenResolution, ref deviceRECT, axMapControl1.ActiveView.Extent, pCancel);
                    pExporter.FinishExporting();
                    pExporter.Cleanup();
                    MessageBox.Show("图像保存在" + exportJPGDialog.FileName, "保存成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message); return; }
        }