AE实现导出图片

此处实现的是导出axMapControl中,所有图像,成JPEG格式。

        /// <summary>
        /// 导出JPEG
        /// </summary>
        /// <param name="pActiveView"></param>
        /// <param name="IResolution"></param>
        /// <param name="fileName"></param>
        public void ExportLayerout(IActiveView pActiveView, double IResolution, string fileName)
        {
            int hdc;
            IExport pExport;
            IEnvelope pExportTileEnv, pPixelBoundsEnv;
            tagRECT exportRECT;
            try
            {
                exportRECT.left = pActiveView.ExportFrame.left * (int)(IResolution / 96);
                exportRECT.left = 0; exportRECT.top = 0;
                exportRECT.top = pActiveView.ExportFrame.top * (int)(IResolution / 96);
                exportRECT.right = pActiveView.ExportFrame.right * (int)(IResolution / 96);
                exportRECT.bottom = pActiveView.ExportFrame.bottom * (int)(IResolution / 96);

                pPixelBoundsEnv = new EnvelopeClass();
                pPixelBoundsEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);

                pExportTileEnv = new EnvelopeClass();
                pPixelBoundsEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);

                pExport = new ExportJPEGClass();
                pExport.ExportFileName = fileName;
                pExport.Resolution = IResolution;
                pExport.PixelBounds = pPixelBoundsEnv;
                hdc = pExport.StartExporting();
                pActiveView.Output(hdc, (int)pExport.Resolution, ref exportRECT, null, null);
                pExport.FinishExporting();
                pExport.Cleanup();
            }
            catch (Exception exp)
            {
            }
            finally
            {
                pExport = null;
                pExportTileEnv = null;
                pPixelBoundsEnv = null;
            }
        }

posted @ 2012-05-22 14:18  苍龙de链  阅读(1385)  评论(0编辑  收藏  举报