ESRI.ArcGIS.Carto.IPictureElement pPictureElement; pPictureElement = new ESRI.ArcGIS.Carto.PngPictureElementClass(); pPictureElement.ImportPictureFromFile(@"D:\__VS\???????\????? ?????\????? ??????? ??????.png");
Solved! Go to Solution.
How we can get a picture with transparent background in PngPictureElementClass item?
private void createPictureElement(Image img) { ESRI.ArcGIS.Carto.IPictureElement pPictureElement; pPictureElement = new ESRI.ArcGIS.Carto.PngPictureElementClass(); pPictureElement.ImportPictureFromFile(@"D:\__VS\picture.png"); // ((IOlePictureElement)pPictureElement).ImportPicture(IPictureDispHost.GetIPictureDispFromPicture(img) as stdole.IPictureDisp); ESRI.ArcGIS.Geometry.IEnvelope pEnv = new ESRI.ArcGIS.Geometry.EnvelopeClass(); Size s = getSizeInMapUnits(new Size(105,75)); pEnv.PutCoords(mapX, mapY, mapX + s.Width, mapY + s.Height); ESRI.ArcGIS.Carto.IElement pElement; pElement = pPictureElement as ESRI.ArcGIS.Carto.IElement; pElement.Geometry = pEnv; ESRI.ArcGIS.Carto.IGraphicsContainer pGraphicContainer; pGraphicContainer = axMapControl1.Map as IGraphicsContainer; pGraphicContainer.AddElement(pElement, 0); ESRI.ArcGIS.Carto.IActiveView pActiveView; pActiveView = pGraphicContainer as ESRI.ArcGIS.Carto.IActiveView; pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGraphics, pElement, pEnv); }
How we can get a picture with transparent background in PngPictureElementClass item?
///<summary>Draw a specified graphic on the map using the supplied colors.</summary> /// ///<param name="map">An IMap interface.</param> ///<param name="geometry">An IGeometry interface. It can be of the geometry type: esriGeometryPoint, esriGeometryPolyline, or esriGeometryPolygon.</param> ///<param name="rgbColor">An IRgbColor interface. The color to draw the geometry.</param> ///<param name="outlineRgbColor">An IRgbColor interface. For those geometry's with an outline it will be this color.</param> /// ///<remarks>Calling this function will not automatically make the graphics appear in the map area. Refresh the map area after after calling this function with Methods like IActiveView.Refresh or IActiveView.PartialRefresh.</remarks> public void AddGraphicToMap(double x, double y) { ESRI.ArcGIS.Display.IRgbColor rgbColorCls = new ESRI.ArcGIS.Display.RgbColorClass(); rgbColorCls.Red = 255; rgbColorCls.Green = 255; rgbColorCls.Blue = 255; ESRI.ArcGIS.Geometry.Point p = new ESRI.ArcGIS.Geometry.Point(); p.X = x; p.Y = y; ESRI.ArcGIS.Geometry.IGeometry geometry = (IGeometry)p; ESRI.ArcGIS.Carto.IGraphicsContainer graphicsContainer = (ESRI.ArcGIS.Carto.IGraphicsContainer)axMapControl1.Map; // Explicit Cast ESRI.ArcGIS.Carto.IElement element = null; IPictureMarkerSymbol MarkerSymbol = new ESRI.ArcGIS.Display.PictureMarkerSymbol(); MarkerSymbol.Size = 50; MarkerSymbol.BitmapTransparencyColor = rgbColorCls; MarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, @"D:\__VS\�?конки\Новая папка\�?она пожа�?а с�?ема.bmp"); ESRI.ArcGIS.Carto.IMarkerElement markerElement = new ESRI.ArcGIS.Carto.MarkerElementClass(); markerElement.Symbol = MarkerSymbol; element = (ESRI.ArcGIS.Carto.IElement)markerElement; // Explicit Cast element.Geometry = geometry; graphicsContainer.AddElement(element, 0); IActiveView activeView = axMapControl1.Map as IActiveView; activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, MarkerSymbol, null); }