ArcGIS Pro 2.8 API Reference Guide
PNGFormat Class
Members  Example 

ArcGIS.Desktop.Mapping Namespace : PNGFormat Class
Represents a Portable Network Graphics (PNG) object that can be used to export a MapView, MapFrame, or a Layout.
Syntax
public class PNGFormat : ExportFormat 
Public Class PNGFormat 
   Inherits ExportFormat
Remarks
PNG is a versatile raster format that can display in web browsers and inserted into other documents. It supports high-bit-depth color and uses a lossless compression. For maps, PNG is often the best raster format, since the lossless compression keeps text and line work legible by preventing the compression artifacts that can occur in JPEG format. PNGs can be generated with an accompanying world file for use as georeferenced raster data.
Example
The following examples demonstrate how to export a Layout, a MapFrame, and a MapView to PNG format.
//This example demonstrates how to export a layout to PNG.

//Added references
using ArcGIS.Desktop.Core;                         //Project
using ArcGIS.Desktop.Layouts;                      //Layout classes
using ArcGIS.Desktop.Framework.Threading.Tasks;    //QueuedTask
using ArcGIS.Desktop.Mapping;                      //Export formats

public class ExportLayoutToPNGExample
{
  public static Task ExportLayoutToPNGAsync(string LayoutName, string Path)
  {
    //Reference a layoutitem in a project by name
    LayoutProjectItem layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals(LayoutName));
    if (layoutItem == null)
      return Task.FromResult<Layout>(null);

    //Create PNG format with appropriate settings
    PNGFormat PNG = new PNGFormat();
    PNG.Resolution = 300;
    PNG.OutputFileName = Path;

    return QueuedTask.Run(() =>
    {
            //Export Layout
            Layout lyt = layoutItem.GetLayout(); //Loads and returns the layout associated with a LayoutItem
            if (PNG.ValidateOutputFilePath())
      {
        lyt.Export(PNG);
      }
    });
  }
}
//This example demonstrates how to export an individual map frame on a layout to PNG.

//Added references
using ArcGIS.Desktop.Core;                         //Project
using ArcGIS.Desktop.Layouts;                      //Layout classes
using ArcGIS.Desktop.Framework.Threading.Tasks;    //QueuedTask
using ArcGIS.Desktop.Mapping;                      //Export formats

public class ExportMapFrameToPNGExample
{
  public static Task ExportMapFrameToPNGAsync(string LayoutName, string MFName, string Path)
  {
    //Reference a layoutitem in a project by name
    LayoutProjectItem layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals(LayoutName));
    if (layoutItem == null)
      return Task.FromResult<Layout>(null);

    //Create PNG format with appropriate settings
    PNGFormat PNG = new PNGFormat();
    PNG.Resolution = 300;
    PNG.OutputFileName = Path;

    return QueuedTask.Run(() =>
    {
            //Export MapFrame
            Layout lyt = layoutItem.GetLayout(); //Loads and returns the layout associated with a LayoutItem
            MapFrame mf = lyt.FindElement(MFName) as MapFrame;
      PNG.OutputFileName = Path;
      if (PNG.ValidateOutputFilePath())
      {
        mf.Export(PNG);
      }
    });
  }
}
//This example demonstrates how to export the active mapview to PNG.

//Added references
using ArcGIS.Desktop.Framework.Threading.Tasks;    //QueuedTask
using ArcGIS.Desktop.Mapping;                      //MapView and Export formats

public class ExportActiveMapToPNGExample
{
  public static Task ExportActiveMapToPNGAsync(string Path)
  {
    return QueuedTask.Run(() =>
    {
            //Reference the active map view
            MapView map = MapView.Active;

            //Create PNG format with appropriate settings
            PNGFormat PNG = new PNGFormat();
      PNG.Resolution = 300;
      PNG.Height = 500;
      PNG.Width = 800;
      PNG.OutputFileName = Path;

            //Export active map view
            if (PNG.ValidateOutputFilePath())
      {
        map.Export(PNG);
      }
    });
  }
}
Inheritance Hierarchy

System.Object
   ArcGIS.Desktop.Mapping.ExportFormat
      ArcGIS.Desktop.Mapping.PNGFormat

Requirements

Target Platforms: Windows 10, Windows 8.1

See Also

Reference

PNGFormat Members
ArcGIS.Desktop.Mapping Namespace