ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / BMPFormat Class
Members Example

In This Topic
    BMPFormat Class
    In This Topic
    Represents a Microsoft Windows Bitmap (BMP) object that can be used to export a MapView, MapFrame, or a Layout.
    Syntax
    public class BMPFormat : ExportFormat 
    Public Class BMPFormat 
       Inherits ExportFormat
    Remarks
    BMP files are simple, native Windows raster images. In general, BMPs are much larger than formats such as JPEG or PNG. They do not scale as well as vector files and may appear blocky or jagged when increased in size. BMPs can be generated with an accompanying world file for use as georeferenced raster data.
    Example
    ExportBMP_Layout
    //This example demonstrates how to export a layout to BMP.
    
    //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 ExportLayoutToBMPExample
    {
      public static Task ExportLayoutToBMPAsync(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 BMP format with appropriate settings
        BMPFormat BMP = new BMPFormat();
        BMP.Resolution = 300;
        BMP.OutputFileName = Path;
    
        return QueuedTask.Run(() =>
        {
                //Export Layout
                Layout lyt = layoutItem.GetLayout(); //Loads and returns the layout associated with a LayoutItem
                if (BMP.ValidateOutputFilePath())
          {
            lyt.Export(BMP);
          }
        });
      }
    }
    ExportBMP_MapFrame
    //This example demonstrates how to export an individual map frame on a layout to BMP.
    
    //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 ExportMapFrameToBMPExample
    {
      public static Task ExportMapFrameToBMPAsync(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 BMP format with appropriate settings
        BMPFormat BMP = new BMPFormat();
        BMP.HasWorldFile = true;
        BMP.Resolution = 300;
        BMP.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;
          BMP.OutputFileName = Path;
          if (BMP.ValidateOutputFilePath())
          {
            mf.Export(BMP);
          }
        });
      }
    }
    ExportBMP_ActiveMap
    //This example demonstrates how to export the active mapview to BMP.
    
    //Added references
    using ArcGIS.Desktop.Framework.Threading.Tasks;    //QueuedTask
    using ArcGIS.Desktop.Mapping;                      //MapView and Export formats
    
    public class ExportActiveMapToBMPExample
    {
      public static Task ExportActiveMapToBMPAsync(string Path)
      {
        return QueuedTask.Run(() =>
        {
          //Reference the active map view
          MapView map = MapView.Active;
    
          //Create BMP format with appropriate settings
          BMPFormat BMP = new BMPFormat();
          BMP.Resolution = 300;
          BMP.Height = 500;
          BMP.Width = 800;
          BMP.HasWorldFile = true;
          BMP.OutputFileName = Path;
    
          //Export active map view
          if (BMP.ValidateOutputFilePath())
          {
            map.Export(BMP);
          }
        });
      }
    }
    BMP_Constructor
    BMPFormat BMP = new BMPFormat();
    Export the map view associated with a map frame to BMP
    //Export the map view associated with a map frame to BMP.
    
    //Create BMP format with appropriate settings
    //EMF, EPS, GIF, JPEG, PDF, PNG, SVG, TGA, and TFF formats are also available for export
    BMPFormat BMP = new BMPFormat()
    {
      Resolution = 300,
      Height = 500,
      Width = 800,
      HasWorldFile = true,
      OutputFileName = filePath
    };
    
    //Reference the active layout view
    LayoutView lytView = LayoutView.Active;
    
    //Reference the map frame and its map view
    MapFrame mf_bmp = layout.FindElement("Map Frame") as MapFrame;
    MapView mv_bmp = mf_bmp.GetMapView(lytView);
    
    if (mv_bmp != null)
    {
      //Export on the worker thread
      await QueuedTask.Run(() =>
      {
    
        //Check to see if the path is valid and export
        if (BMP.ValidateOutputFilePath())
        {
          mv_bmp.Export(BMP);  //Export to BMP
        }
      });
    }
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Mapping.ExportFormat
          ArcGIS.Desktop.Mapping.BMPFormat

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also