This document is archived and information here might be outdated.  Recommended version.


Create Dynamic Marker Glyph from Image Snippet (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference

Create Dynamic Marker Glyph from Image Snippet

Create a dynamic glyph for a marker symbol.

[C#]
///<summary>Create a dynamic glyph for a marker symbol.</summary>
///  
///<param name="dynamicGlyphFactory">An IDynamicGlyphFactory interface that is used to create the new glyph.</param>
///<param name="imagePath">A System.String  that is the full path of the input image. Example: "C:\temp\myImage.jpg"</param>
///  
///<returns>An IDynamicGlyph interface.</returns>
///  
///<remarks>This method will create the glyph according to the image path.</remarks>
public ESRI.ArcGIS.Display.IDynamicGlyph CreateDynamicMarkerGlyphFromImage(ESRI.ArcGIS.Display.IDynamicGlyphFactory dynamicGlyphFactory, System.String imagePath)
{
  if (!System.IO.File.Exists(imagePath) || dynamicGlyphFactory == null)
  {
    return null;
  }
  // set black as the transparency color
  ESRI.ArcGIS.Display.IColor rgbColor=new ESRI.ArcGIS.Display.RgbColorClass();
  rgbColor.RGB=0x0;

  // return a new marker glyph
  return dynamicGlyphFactory.CreateDynamicGlyphFromFile(ESRI.ArcGIS.Display.esriDynamicGlyphType.esriDGlyphMarker, imagePath, rgbColor);
}
[Visual Basic .NET]
'''<summary>Create a dynamic glyph for a marker symbol.</summary>
'''  
'''<param name="dynamicGlyphFactory">An IDynamicGlyphFactory interface that is used to create the new glyph.</param>
'''<param name="imagePath">A System.String  that is the full path of the input image. Example: "C:\temp\myImage.jpg"</param>
'''  
'''<returns>An IDynamicGlyph interface.</returns>
'''  
'''<remarks>This method will create the glyph according to the image path.</remarks>
Public Function CreateDynamicMarkerGlyphFromImage(ByVal dynamicGlyphFactory As ESRI.ArcGIS.Display.IDynamicGlyphFactory, ByVal imagePath As System.String) As ESRI.ArcGIS.Display.IDynamicGlyph

  If (Not System.IO.File.Exists(imagePath)) OrElse dynamicGlyphFactory Is Nothing Then
    Return Nothing
  End If

  ' set black as the transparency color
  Dim rgbColor As ESRI.ArcGIS.Display.IColor=New ESRI.ArcGIS.Display.RgbColorClass
  rgbColor.RGB=0

  ' return a new marker glyph
   Return dynamicGlyphFactory.CreateDynamicGlyphFromFile(ESRI.ArcGIS.Display.esriDynamicGlyphType.esriDGlyphMarker, imagePath, rgbColor)

End Function

Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.Display
  • ESRI.ArcGIS.System