ArcGIS中 IPictureMarkerSymbol中size和图片大小的关系(10.2)

IPictureMarkerSymbol为ArcGIS中图片点符号, 图片点符号顾名思义使用图片绘制在某个点位. 但是为了将他的符号转为自有符号,一直没搞懂大小关系,  首先看官网描述:

 

(the largest measurement, height or width  取长宽的最大值. 

按照此思路去设计自有符号,发现大小基本都会偏大.  最后无解了, 直接用QQ截图去量算各种长宽比的图片设置size到底占用几个像素, 选择几张不同尺寸图片,  长较大,宽较大 ,长宽相似. 如下图:

size为10 , 的三类图片符号中, size 等于图片高度.

二类分类的size=20,  等于图片在地图上显示的宽度

 

这完全证明 这和官方文档说明上是相反的,  就是用的图片长宽中较小的值做的size, 现在如果想将此类符号转为以宽高中最大值描述size的方式,就很简单了, 伪代码如下:

 

 

            //图片从像素转毫米单位
            ESRI.ArcGIS.esriSystem.XMLSerializer ser = new ESRI.ArcGIS.esriSystem.XMLSerializer();
            ESRI.ArcGIS.esriSystem.PropertySet env = new ESRI.ArcGIS.esriSystem.PropertySet();
            ESRI.ArcGIS.esriSystem.XMLFlags flag = new ESRI.ArcGIS.esriSystem.XMLFlags();
            string strXML = ser.SaveToString(sym, env, flag);
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.LoadXml(strXML);

            string strBase64img = doc.DocumentElement.SelectSingleNode("Picture").InnerText;
            byte[] imageBytes = System.Convert.FromBase64String(strBase64img);
              MemoryStream f = new MemoryStream(imageBytes);
            Image img =  Image.FromStream(f);
         
            double imgWidth = img.Width;
            double imgHeight = img.Height;
            double symSzie = symbol.Size.
.	    PicturePointSymbol ps = new GeoStar.Core.PicturePointSymbol();
            ps.LoadPicture(imageBytes, imageBytes.Length);///加载图片
            //  ArcGIS 图片size根据最小宽高来算, 
            double smallValue = symSzie;
            ////像素 = 毫米 / 25.4 * dpi
            if (imgWidth > imgHeight)
            {
   
                ps.Width = smallValue * imgWidth / imgHeight;
                ps.Size = ps.Width;
                ps.Height = smallValue;
            }
            else
            {
                ps.Width = smallValue;
                ps.Height = smallValue * imgHeight / imgWidth;
                ps.Size = smallValue;
	    }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章