ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / OutputImageFormat Enumeration
Example Example

In This Topic
    OutputImageFormat Enumeration
    In This Topic
    Specifies image output format type.
    Syntax
    Members
    MemberDescription
    BMP BMP.
    GIF GIF.
    JPEG JPEG.
    PNG Default PNG format.
    SVG SVG.
    SVGZ SVG zipped.
    Example
    Convert Point Symbol to SVG
    //Note: Run within QueuedTask.Run
    //Create a point symbol
    var pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(
      ColorFactory.Instance.RedRGB, 24, SimpleMarkerStyle.RoundedSquare);
    
    //Generate image returns a stream
    //OutputImageFormat specified the format for the image - in this case
    //we want SVG (an xml-based format)
    //
    //output fmt: SVG, scale factor x2, centerAnchorPoint = true
    //dpi = 300, wd x ht: 100x100px, background: white
    var mem_strm = SymbolFactory.Instance.GenerateImage(
      pointSymbol, OutputImageFormat.SVG, 2.0, true, 300, 100, 100,
      ColorFactory.Instance.WhiteRGB);
    
    //Set the memory stream position to the beginning
    mem_strm.Seek(0, SeekOrigin.Begin);
    
    //File path and name for saving the SVG file
    var fileName = "RoundedSquareSymbol.svg";
    string path_svg = Path.Combine(Path.GetTempPath() + fileName);
    
    //Write the memory stream to the file
    System.IO.File.WriteAllBytes(path_svg, mem_strm.ToArray());
    
    //////////////////////////////////////////////
    //Note: to convert SVG to image format, use a 3rd party
    //e.g. Aspose.SVG for .NET, for example convert SVG to PNG
    //using (var svg_doc = new Aspose.Svg.SVGDocument(path_svg))
    //{
    //  string path_png = Path.Combine(Path.GetTempPath() + "RoundedSquareSymbol.png");
    //  using (var img_png = new Aspose.Svg.Rendering.Image.ImageDevice(
    //    new ImageRenderingOptions(ImageFormat.Png), path_png))
    //  {
    //    svg_doc.RenderTo(img_png);
    //  }
    //  //also: https://docs.aspose.com/imaging/net/convert-svg-to-png/
    //}
    
    Convert Point Symbol to PNG
    //Note: Run within QueuedTask.Run
    //Create a point symbol
    var pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(
      ColorFactory.Instance.RedRGB, 24, SimpleMarkerStyle.RoundedSquare);
    
    //Generate image returns a stream
    //OutputImageFormat specified the format for the image - in this case
    //we want PNG
    //
    //output fmt: PNG, scale factor x2, centerAnchorPoint = true
    //dpi = 300, wd x ht: 100x100px, background: white
    var mem_strm = SymbolFactory.Instance.GenerateImage(
      pointSymbol, OutputImageFormat.PNG, 2.0, true, 300, 100, 100,
      ColorFactory.Instance.WhiteRGB);
    
    //Set the memory stream position to the beginning
    mem_strm.Seek(0, SeekOrigin.Begin);
    
    //Write the stream to a bit map
    var bitmapImage = new System.Windows.Media.Imaging.BitmapImage();
    
    bitmapImage.BeginInit();
    bitmapImage.StreamSource = mem_strm;
    bitmapImage.CacheOption = System.Windows.Media.Imaging.BitmapCacheOption.OnLoad;
    bitmapImage.EndInit();
    bitmapImage.Freeze();
    
    //Write the bit map out to a file
    //File path and name for saving the PNG file
    var fileName = "RoundedSquareSymbol.png";
    string path_png = Path.Combine(Path.GetTempPath() + fileName);
    
    BitmapEncoder encoder = new PngBitmapEncoder();
    encoder.Frames.Add(BitmapFrame.Create(bitmapImage));
    
    using (var fileStream = new System.IO.FileStream(
      path_png, System.IO.FileMode.Create))
    {
      encoder.Save(fileStream);
    }
    
    Inheritance Hierarchy

    System.Object
       System.ValueType
          System.Enum
             ArcGIS.Desktop.Mapping.OutputImageFormat

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.4 or higher.
    See Also