欢迎您来到GIS动力

加入收藏 免费注册 用户登陆 帮助中心
首页 新闻动态 技术专栏 银杏树下 学习考研 软件下载 求职招聘 许愿瓶 节日祝福 用户中心 精彩推荐 资源搜索 地图
专栏导航: AO开发 | SO开发 | ArcGIS桌面 | 超图桌面 | 开发语言 | 数据库 | WebGIS | 银杏文学 | 研究生考题 | FreeMap FreeTalk
   您现在位于: 首页技术专栏ArcGIS应用与开发AO开发 → 正文
自定义范围输出为栅格图像
08-09-01 09:54:21 作者: 出处:
/// <summary>
        
/// 打印输出.该功能目前测试只适用于JPEG,BMP.格式
        
/// </summary>
        
/// <param name="pExport"></param>
        
/// <param name="dResolution">分辨率</param>
        
/// <param name="outputPath">输出路径</param>
        
/// <param name="pVisibleBounds">自定义可见区域</param>
        private void FunExportImage(IExport pExport, double dResolution, string outputPath,IEnvelope pVisibleBounds)
        {
            IEnvelope pPixelBounds;
            ESRI.ArcGIS.Display.tagRECT outtagRECT;
            ESRI.ArcGIS.Display.tagRECT DisplayBounds 
= m_ActiveView.ExportFrame;
            
double iScreenResolution;
            
if (pExport == null)
            {
                MessageBox.Show(
"打印类型未指定");
                
return;
            }

            
if(pVisibleBounds!=null//自定义框范围
            {
                IDisplayTransformation pDisplayTransformation 
= m_ActiveView.ScreenDisplay.DisplayTransformation;
                pDisplayTransformation.TransformRect(pVisibleBounds, 
ref DisplayBounds, 8);//8代表esriDisplayTransformEnum.esriTransformToDevice
            }

            
if (pExport is IExportImage)
            {
                IExportImage pExportImage 
= pExport as IExportImage;
                pExportImage.ImageType 
= esriExportImageType.esriExportImageTypeTrueColor;
            }

            iScreenResolution 
= m_ActiveView.ScreenDisplay.DisplayTransformation.Resolution;
                      
            
double l_resolution = Convert.ToDouble(domainResolution.Value);

            
//=====================================================================
            
//
            
//方法一
            
//
            
//一厘米包含37.79524个像素
            
//double dPixel = 37.79524;
            ////按照设置输入分辨率计算一厘米所含的像素数
            //double tempratio = l_resolution * dPixel / iScreenResolution;
            ////输出图形的高度
            //double tempbottom = (DisplayBounds.bottom - DisplayBounds.top) * tempratio;
            ////输出图形的宽度
            //double tempright = (DisplayBounds.right - DisplayBounds.left) * tempratio + 0.1 * tempratio;
            
//======================================================================
            
//
            
//方法二:暂时可行.
            
//
            double tempratio = l_resolution / iScreenResolution;
            
double tempbottom = (DisplayBounds.bottom - DisplayBounds.top) * tempratio;
            
double tempright = (DisplayBounds.right - DisplayBounds.left) * tempratio;
            
//=====================================================================
            outtagRECT.left = 0;
            outtagRECT.top 
= 0;
            outtagRECT.bottom 
= Convert.ToInt32(Math.Truncate(tempbottom));
            outtagRECT.right 
= Convert.ToInt32(Math.Truncate(tempright));

            pPixelBounds 
= new EnvelopeClass();
            pPixelBounds.PutCoords(outtagRECT.left, outtagRECT.top, outtagRECT.right, outtagRECT.bottom);

            pExport.Resolution 
= dResolution;
            pExport.PixelBounds 
= pPixelBounds;
            pExport.ExportFileName 
= outputPath;

            
try
            {
                ITrackCancel pTrackCancel 
= new TrackCancelClass();
                
int hDC;
                hDC 
= pExport.StartExporting();

                
if (m_frmProBar == null//m_frmProBar为进度条窗体
                    FunProgressBar();
                m_frmProBar.Show();

                m_ActiveView.Output(hDC, (
int)dResolution, ref outtagRECT, pVisibleBounds, pTrackCancel);
                pExport.FinishExporting();

                m_frmProBar.Hide();

                
if (DialogResult.Yes == MessageBox.Show("出图成功! \n图片保存在" + txtOutPutPath.Text+"\n是否需要打开文件所在的目录?""提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information))
                {
                    System.Diagnostics.Process.Start(
"explorer.exe", txtOutPutPath.Text); 
                }
                pExport.Cleanup();
            }
            
catch
            {
                MessageBox.Show(
"出图失败!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
                
//释放变量
                m_frmProBar = null;
                pExport 
= null;
                pVisibleBounds 
= null;
            }
            
//释放变量
            pExport = null;
            pVisibleBounds 
= null;

        }

(本文已被浏览 次)
发布人:admin
推荐给好友:发送给好友
上篇新闻:
下篇新闻:
相关评论
发表我的评论
  • 尊重网上道德,遵守《全国人大常委会关于维护互联网安全的决定》及中华人民共和国其他各项有关法律法;
  • 本站有权保留或删除您发表的任何评论内容;
  •   相关文章  
    无相关新闻

    关于我们友情链接 ┋ 与我在线 ┋ 管理 ┋ TOP
     
    网站当前版本:GisPower CMS V3.0
    『GIS 动力』- http://www.gispower.org/
    联系我们:webmaster#gispower.org
    Copyright (c) 2003-2007 GisPOwer.Org. All Rights Reserved.
     

                   滇ICP备05006901号