原文链接http://bbs.gissky.net/blog.asp?id=114

ArcEngine中导出图片的过程如下:
1.建立导出类(IExport的实例);
2.准备要导出的范围
3.开始导出(从导出类中获取DC)
4.调用IActiveView的Output方法
5.结束导出
6.清除导出类
范例代码如下:
      //获取保存文件的路径/建立导出类
   System.Windows.Forms.SaveFileDialog sfd=new SaveFileDialog();
   sfd.Filter="*.tif|*.tif|*.jpeg|*.jpeg|*.pdf|*.pdf|*.bmp|*.bmp";
   if(sfd.ShowDialog((Form)this.m_appRef)==DialogResult.OK)
   {
    IExport pExport=null;
    if(1==sfd.FilterIndex)
    {
     pExport=new ExportTIFFClass();
    } 
    else if(2==sfd.FilterIndex)
    {
     pExport=new ExportJPEGClass();
    } 
    else if(3==sfd.FilterIndex)
    {
     pExport=new ExportPDFClass();
    } 
    else if(4==sfd.FilterIndex)
    {
     pExport=new ExportBMPClass();
    } 
    pExport.ExportFileName=sfd.FileName;
    设置参数
    //默认精度              
    int reslution=96;    
    pExport.Resolution = reslution;
    //获取导出范围
    tagRECT exportRECT=m_pActiveView.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;
    //导出
    m_pActiveView.Output(hDC,(int)pExport.Resolution,ref exportRECT, pVisbounds, ptrac);
    //结束导出
    pExport.FinishExporting();
    //清理导出类
    pExport.Cleanup(); 

posted on 2010-12-22 17:36  hl3292  阅读(1411)  评论(0编辑  收藏  举报