ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / TGAFormat Class
Members Example Version

TGAFormat Class
Represents a Truevision Graphics Adaptor (TGA) object that can be used to export a MapView, MapFrame, or a Layout.
Syntax
public class TGAFormat : ExportFormat 
Remarks
TGA files have historically been used for content that is meant to be used in other applications (for example, image sprites for animated games) and is read and written by many popular graphic arts applications.
Example
ExportTGA_Layout
//This example demonstrates how to export a layout to TGA.

//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 ExportLayoutToTGAExample
{
  public static Task ExportLayoutToTGAAsync(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 TGA format with appropriate settings
    TGAFormat TGA = new TGAFormat();
    TGA.Resolution = 300;
    TGA.OutputFileName = Path;

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

//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 ExportMapFrameToTGAExample
{
  public static Task ExportMapFrameToTGAAsync(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 TGA format with appropriate settings
    TGAFormat TGA = new TGAFormat();
    TGA.Resolution = 300;
    TGA.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;
      TGA.OutputFileName = Path;
      if (TGA.ValidateOutputFilePath())
      {
        mf.Export(TGA);
      }
    });
  }
}
ExportTGA_ActiveMap
//This example demonstrates how to export the active mapview to TGA.

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

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

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

            //Export active map view
            if (TGA.ValidateOutputFilePath())
      {
        mapv.Export(TGA);
      }
    });
  }
}
TGA_Constructor
TGAFormat TGA = new TGAFormat();
Inheritance Hierarchy

System.Object
   ArcGIS.Desktop.Mapping.ExportFormat
      ArcGIS.Desktop.Mapping.TGAFormat

Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3 or higher.
See Also