arengine 指定范围保存为指定大小图片

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;


using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Output;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Display;


namespace Cut
{
    [Guid("2fc46cb3-5bed-42d4-a2fb-b46fe4b05379")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("Cut.ArcGISexpImg")]
    public class ArcGISexpImg
    {

        private static IExport getExportbyExt(string ext)
        {
            IExport pExporter;
            switch (ext.ToLower()) //by gisoracle Email:[email protected] 或则[email protected] 2009.6.23
            {

                case ".jpg":
                    pExporter = new ExportJPEGClass();
                    break;
                case ".bmp":
                    pExporter = new ExportBMPClass();
                    break;

                case ".emf":
                    pExporter = new ExportEMFClass();
                    break;

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

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

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

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

                case ".eps":

                    pExporter = new ExportPSClass();
                    break;

                case ".svg":
                    pExporter = new ExportSVGClass();

                    break;

                case ".tif":

                    pExporter = new ExportTIFFClass();

                    break;

                default:

                    MessageBox.Show("输出格式错误");

                    return null;


            }
            return pExporter;

        }
        public static void ExportImage(IActiveView pActiveView,string sFilePath,int width,int height)
        {

            ExportImage(pActiveView, sFilePath, pActiveView.Extent, width, height);
        }

        public static void ExportImage(IActiveView pActiveView, string sFilePath, IEnvelope outputExtent, int width, int height)
        {


            IExport pExporter = getExportbyExt(System.IO.Path.GetExtension(sFilePath));
            IEnvelope pEnvelope = new EnvelopeClass();
            ITrackCancel pTrackCancel = new CancelTrackerClass();

            tagRECT ptagRECT;
            ptagRECT.left = 0;
            ptagRECT.top = 0;
            ptagRECT.right = width;
            ptagRECT.bottom = height;

            int pResolution = (int)(pActiveView.ScreenDisplay.DisplayTransformation.Resolution);

            pEnvelope.PutCoords(ptagRECT.left, ptagRECT.bottom, ptagRECT.right, ptagRECT.top);

            pExporter.Resolution = pResolution;

            pExporter.ExportFileName = sFilePath;

            pExporter.PixelBounds = pEnvelope;

            pActiveView.Output(pExporter.StartExporting(), pResolution, ref ptagRECT, outputExtent, pTrackCancel);

            pExporter.FinishExporting();

        }


    }
}

你可能感兴趣的:(arengine 指定范围保存为指定大小图片)