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;
	    }

 

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