zoukankan      html  css  js  c++  java
  • 实现图像添加label

    void CmapwingisTest2View::OnToolsAddTiffLayer()

    {

             TCHAR szFilters[]= _T("TIFF Files (*.tif)|*.tif||");  

             CFileDialog fileDlg (TRUE,_T("tif"),_T("*.tif"),  

                       OFN_FILEMUSTEXIST| OFN_HIDEREADONLY, szFilters, this);  

             if( fileDlg.DoModal ()!=IDOK )   return;

             CString m_strFilePath = fileDlg.GetPathName();  

             if (_T("")!=m_strFilePath)  

             {  

                       // 先删除所有图层  

                       //m_map.RemoveAllLayers();  

                       // 获取后缀名判断文件是tif图像还是shp文件  

                       CString strExt = m_strFilePath.Right(3);  

                       if (_T("tif")==strExt)  

                       {  

                                // 创建图像接口打开图像加入地图  

                                mapWindow::IImagePtr pImage;  

                                pImage.CreateInstance(__uuidof(mapWindow::Image));  

                                pImage->Open(_bstr_t(m_strFilePath),mapWindow::USE_FILE_EXTENSION,TRUE,NULL);  

                                m_map.AddLayer(pImage,true);  

                                mapWindow::ILabelsPtr labels;

                                pImage->get_Labels( &labels );

                                labels->PutFontSize(12);

                                labels->PutFontBold(true);

                                labels->PutFontOutlineVisible(true);

                                labels->PutFontOutlineWidth(4);

                                mapWindow::ILabelCategoryPtr cat;

                                labels->AddCategory("Red");

                                //cat->PutFontColor(RGB(255,0,0));

                                mapWindow::IExtentsPtr ext = pImage->GetExtents();

                                double xmin,xmax,ymin,ymax;

                                ext->get_xMax(&xmax);

                                ext->get_xMin(&xmin);

                                ext->get_yMax(&ymax);

                                ext->get_yMin(&ymin);

                                double  xRange = xmax-xmin;

                                double  yRange = ymax-ymin;

                                CString str;

                                for (int i = 0; i < 100; i++)

                                {

                                         double x=xRange*(rand()%9)*0.1;

                                         double y=yRange* ( rand()%9 )/10.0;

                                         int categoryIndex = i % 3;

                                         str.Format("%d",i);(http://www.amjmh.com/v/BIBRGZ_558768/)

                                         labels->AddLabel( _bstr_t(str ),xmin+x,ymin+y,i*3.6,categoryIndex);

                                }

                     }

             }

             return;

    }

  • 相关阅读:
    Linux strace 命令 说明
    存储区域网(SANStorage Area Network)
    RAC 中 ASM 实例名 与 节点的对应关系
    光纤通道(FC: Fibre Channel)
    Oracle expdp/impdp 使用示例
    RAC 中 ASM 实例名 与 节点的对应关系
    RAC 修改 DB 实例名 步骤
    InfiniBand 网络
    ORA09817: Write to audit file failed 解决方法
    RAC 安装patch 后启动实例 报错 ORA00439 feature not enabled Real Application Clusters 解决方法
  • 原文地址:https://www.cnblogs.com/ly570/p/11491438.html
Copyright © 2011-2022 走看看