实现图像添加label

Posted ly570

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了实现图像添加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;

}

 

以上是关于实现图像添加label的主要内容,如果未能解决你的问题,请参考以下文章

点击按钮在panel中动态添加label控件

c#中把鼠标悬停到label标签上显示文字怎么实现

echarts label 如何添加点击事件 如果echarts中没有该功能,如何实现

我想实现在Qt上按钮上添加背景图片不知怎样实现,

Matlab 二值图像label regions

如何在 Java Swing 中使用 Label 实现视图?