ArcGIS Pro 3.1 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / ElementFactory Class / CreatePictureGraphicElement Method
The parent element container
The picture graphic envelope (frame) or center point
The url of the image to use
An element name (optional)
Select after create flag (default is true) (optional)
Additional element properties (optional)
Example

In This Topic
    CreatePictureGraphicElement Method (ElementFactory)
    In This Topic
    Creates a picture graphic element based on the input geometry and symbol. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Function CreatePictureGraphicElement( _
       ByVal elementContainer As IElementContainer, _
       ByVal frameOrLocation As Geometry, _
       ByVal url As String, _
       Optional ByVal elementName As String, _
       Optional ByVal select As Boolean, _
       Optional ByVal elementInfo As ElementInfo _
    ) As GraphicElement

    Parameters

    elementContainer
    The parent element container
    frameOrLocation
    The picture graphic envelope (frame) or center point
    url
    The url of the image to use
    elementName
    An element name (optional)
    select
    Select after create flag (default is true) (optional)
    elementInfo
    Additional element properties (optional)

    Return Value

    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    empty or null geometry
    invalid geometry type
    empty or null url
    Remarks
    If a point is specified, the picture frame is sized to the extent of the content. If an envelope is specified, the content is sized to fit the extent of the frame.
    Example
    Create a new picture element with advanced symbol settings
    //Create a picture element and also set background and border symbology.
    
    //Construct on the worker thread
    await QueuedTask.Run(() =>
    {
      //Build 2D envelope geometry
      Coordinate2D pic_ll = new Coordinate2D(6, 1);
      Coordinate2D pic_ur = new Coordinate2D(8, 2);
      //At 2.x - Envelope env = EnvelopeBuilder.CreateEnvelope(pic_ll, pic_ur);
      Envelope env = EnvelopeBuilderEx.CreateEnvelope(pic_ll, pic_ur);
    
      //Create and add element to layout
      string picPath = @"C:\Temp\WhitePass.jpg";
      //At 2.x - GraphicElement picElm =
      //    LayoutElementFactory.Instance.CreatePictureGraphicElement(
      //                                             layout, env, picPath);
      //         picElm.SetName("New Picture");
      //
      GraphicElement picElm = ElementFactory.Instance.CreatePictureGraphicElement(
                                           layout, env, picPath, "New Picture");
    
      //(Optionally) Modify the border and shadow 
      CIMGraphic picGra = picElm.GetGraphic();
      CIMPictureGraphic cimPicGra = picGra as CIMPictureGraphic;
      cimPicGra.Frame.BorderSymbol = new CIMSymbolReference();
      cimPicGra.Frame.BorderSymbol.Symbol =
            SymbolFactory.Instance.ConstructLineSymbol(
                   ColorFactory.Instance.BlueRGB, 2.0, SimpleLineStyle.Solid);
    
      cimPicGra.Frame.ShadowSymbol = new CIMSymbolReference();
      cimPicGra.Frame.ShadowSymbol.Symbol =
                  SymbolFactory.Instance.ConstructPolygonSymbol(
                        ColorFactory.Instance.BlackRGB, SimpleFillStyle.Solid);
    
      //Update the element
      picElm.SetGraphic(picGra);
    });
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also