Arcengine插入文字和图片

#region 插入文字
            //IFontDisp font = new stdole.StdFontClass() as stdole.IFontDisp;
            //font.Name = "宋体";
            //font.Bold = true;
            //font.Size = 50;
            //IColor color = new RgbColorClass();
            //color.RGB = 0;
            //ITextSymbol textSymbol = new TextSymbolClass();
            //textSymbol.Size = 50;
            //textSymbol.Font = font;
            //textSymbol.Color = color;
            //ITextElement txtElement = new TextElementClass();
            //txtElement.Symbol = textSymbol;
            //txtElement.ScaleText = true;
            //txtElement.Text = "123456";
            //IElement element = txtElement as IElement;
            //element.Geometry = point;
            //activeView.GraphicsContainer.AddElement(element, 0);
            //activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            #endregion
            #region 插入图片
            string path = @"E:\123.bmp";
            IGraphicsContainer pGraphicsContainer = (IGraphicsContainer)activeView;
            IPictureMarkerSymbol pPictureMarkerSymbol = new PictureMarkerSymbolClass();
            double longest = mapEnvelope.Height;
            if (mapEnvelope.Height < mapEnvelope.Width)
                longest = mapEnvelope.Width;
            pPictureMarkerSymbol.Size = longest;
            pPictureMarkerSymbol.Angle = 0;
            pPictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, path);//图片自己可以更改路径即可
            IMarkerElement pMarkerElement = new MarkerElement() as IMarkerElement;
            pMarkerElement.Symbol = pPictureMarkerSymbol as IMarkerSymbol;
            IElement pElement = (IElement)pMarkerElement;
            pElement.Geometry = point;
            pGraphicsContainer.AddElement(pElement, 0);
            activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            #endregion

 

转载自:https://blog.csdn.net/qq_40182225/article/details/80655604

You may also like...