ArcObjects Library Reference

Create Picture Marker Symbol Snippet

Create a Picture Marker Symbol of the .EMF or .BMP file type.

[C#]

///<summary>Create a Picture Marker Symbol of the .EMF or .BMP file type.</summary>
///  
///<param name="pictureType">An ESRI.ArcGIS.Display.esriIPictureType enumeration. Example: ESRI.ArcGIS.Display.esriIPictureType.esriIPictureEMF or ESRI.ArcGIS.Display.esriIPictureType.esriIPictureBitmap</param>
///<param name="filename">A System.String that is the path and file name of the picture marker. Example: "c:\temp\mypict.bmp" or "c:\temp\mypict.emf"</param>
///<param name="markerSize">A System.Double that is the marker size of the picture. Example: 24.0</param>
///   
///<returns>An IPictureMarkerSymbol interface.</returns>
///   
///<remarks></remarks>
public ESRI.ArcGIS.Display.IPictureMarkerSymbol CreatePictureMarkerSymbol(ESRI.ArcGIS.Display.esriIPictureType pictureType, System.String filename, System.Double markerSize)
{

  // This example creates two PictureMarkerSymbols
  // One from an .EMF file and another from a .BMP file.
  
  if(pictureType == null)
  {
    return null;
  }

  // Set the Transparent background color for the Picture Marker symbol to white.
  ESRI.ArcGIS.Display.IRgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColorClass();
  rgbColor.Red = 255;
  rgbColor.Green = 255;
  rgbColor.Blue = 255;

  // Create the Marker and assign properties.
  ESRI.ArcGIS.Display.IPictureMarkerSymbol pictureMarkerSymbol = new ESRI.ArcGIS.Display.PictureMarkerSymbolClass();
  pictureMarkerSymbol.CreateMarkerSymbolFromFile(pictureType, filename);
  pictureMarkerSymbol.Angle = 0;
  pictureMarkerSymbol.BitmapTransparencyColor = rgbColor;
  pictureMarkerSymbol.Size = markerSize;
  pictureMarkerSymbol.XOffset = 0;
  pictureMarkerSymbol.YOffset = 0;

  return pictureMarkerSymbol;
}
[Visual Basic .NET]

'''<summary>Create a Picture Marker Symbol of the .EMF or .BMP file type.</summary>
'''  
'''<param name="pictureType">An ESRI.ArcGIS.Display.esriIPictureType enumeration. Example: ESRI.ArcGIS.Display.esriIPictureType.esriIPictureEMF or ESRI.ArcGIS.Display.esriIPictureType.esriIPictureBitmap</param>
'''<param name="filename">A System.String that is the path and file name of the picture marker. Example: "c:\temp\mypict.bmp" or "c:\temp\mypict.emf"</param>
'''<param name="markerSize">A System.Double that is the marker size of the picture. Example: 24.0</param>
'''   
'''<returns>An IPictureMarkerSymbol interface.</returns>
'''   
'''<remarks></remarks>
Public Function CreatePictureMarkerSymbol(ByVal pictureType As ESRI.ArcGIS.Display.esriIPictureType, ByVal filename As System.String, ByVal markerSize As System.Double) As ESRI.ArcGIS.Display.IPictureMarkerSymbol

  ' This example creates two PictureMarkerSymbols
  ' One from an .EMF file and another from a .BMP file.

  If pictureType = Nothing Then
    Return Nothing
  End If

  ' Set the Transparent background color for the Picture Marker symbol to white.
  Dim rgbColor As ESRI.ArcGIS.Display.IRgbColor = New ESRI.ArcGIS.Display.RgbColorClass
  rgbColor.Red = 255
  rgbColor.Green = 255
  rgbColor.Blue = 255

  ' Create the Marker and assign properties.
  Dim pictureMarkerSymbol As ESRI.ArcGIS.Display.IPictureMarkerSymbol = New ESRI.ArcGIS.Display.PictureMarkerSymbolClass
  With pictureMarkerSymbol
    .CreateMarkerSymbolFromFile(pictureType, filename)
    .Angle = 0
    .BitmapTransparencyColor = rgbColor
    .Size = markerSize
    .XOffset = 0
    .YOffset = 0
  End With

  Return pictureMarkerSymbol

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