ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / StretchColorizerDefinition Class / StretchColorizerDefinition Constructor / StretchColorizerDefinition Constructor(Int32,RasterStretchType,Double,CIMColorRamp)
The band index of the band being displayed.
(Optional) The ArcGIS.Core.CIM.RasterStretchType. (default value = RasterStretchType.DefaultFromSource)
(Optional) The gamma value. (default value = 1.0)
(Optional) The color ramp. (default value = null)
Example

In This Topic
    StretchColorizerDefinition Constructor(Int32,RasterStretchType,Double,CIMColorRamp)
    In This Topic
    Creates a Stretch colorizer definition using parameters.
    Syntax
    public StretchColorizerDefinition( 
       int bandIndex,
       RasterStretchType stretchType,
       double gamma,
       CIMColorRamp colorRamp
    )
    Public Function New( _
       ByVal bandIndex As Integer, _
       Optional ByVal stretchType As RasterStretchType, _
       Optional ByVal gamma As Double, _
       Optional ByVal colorRamp As CIMColorRamp _
    )

    Parameters

    bandIndex
    The band index of the band being displayed.
    stretchType
    (Optional) The ArcGIS.Core.CIM.RasterStretchType. (default value = RasterStretchType.DefaultFromSource)
    gamma
    (Optional) The gamma value. (default value = 1.0)
    colorRamp
    (Optional) The color ramp. (default value = null)
    Example
    Create a new colorizer based on a default colorizer definition and apply it to the raster layer
    await QueuedTask.Run(async () =>
    {
      // Check if the Stretch colorizer can be applied to the raster layer.
      if (rasterLayer.GetApplicableColorizers().Contains(RasterColorizerType.StretchColorizer))
      {
        // Create a new Stretch Colorizer Definition using the default constructor.
        StretchColorizerDefinition stretchColorizerDef_default = new StretchColorizerDefinition();
        // Create a new Stretch colorizer using the colorizer definition created above.
        CIMRasterStretchColorizer newStretchColorizer_default =
    await rasterLayer.CreateColorizerAsync(stretchColorizerDef_default) as CIMRasterStretchColorizer;
        // Set the new colorizer on the raster layer.
        rasterLayer.SetColorizer(newStretchColorizer_default);
      }
    });
    Create a new colorizer based on a custom colorizer definition and apply it to the raster layer
    await QueuedTask.Run(async () =>
    {
      // Check if the Stretch colorizer can be applied to the raster layer.
      if (rasterLayer.GetApplicableColorizers().Contains(RasterColorizerType.StretchColorizer))
      {
        // Create a new Stretch Colorizer Definition specifying parameters 
        // for band index, stretch type, gamma and color ramp.
        StretchColorizerDefinition stretchColorizerDef_custom =
    new StretchColorizerDefinition(1, RasterStretchType.ESRI, 2, colorRamp);
        // Create a new stretch colorizer using the colorizer definition created above.
        CIMRasterStretchColorizer newStretchColorizer_custom =
    await rasterLayer.CreateColorizerAsync(stretchColorizerDef_custom) as CIMRasterStretchColorizer;
        // Set the new colorizer on the raster layer.
        rasterLayer.SetColorizer(newStretchColorizer_custom);
      }
    });
    Create a raster layer with a new colorizer definition
      // Create a new stretch colorizer definition using default constructor.
      StretchColorizerDefinition stretchColorizerDef = new StretchColorizerDefinition();
      var rasterLayerCreationParams = new RasterLayerCreationParams(new Uri(url))
      {
        ColorizerDefinition = stretchColorizerDef,
        Name = layerName,
        MapMemberIndex = 0
      };
      await QueuedTask.Run(() =>
      {
        // Create a raster layer using the colorizer definition created above.
        // Note: You can create a raster layer from a url, project item, or data connection.
        RasterLayer rasterLayerfromURL =
    LayerFactory.Instance.CreateLayer<RasterLayer>(rasterLayerCreationParams, aMap);
      });
    Create a new colorizer based on a default colorizer definition and apply it to the mosaic layer
    await QueuedTask.Run(async () =>
    {
      // Get the image sub-layer from the mosaic layer.
      ImageMosaicSubLayer mosaicImageSubLayer = mosaicLayer.GetImageLayer();
      // Check if the Stretch colorizer can be applied to the image sub-layer.
      if (mosaicImageSubLayer.GetApplicableColorizers().Contains(RasterColorizerType.StretchColorizer))
      {
        // Create a new Stretch Colorizer Definition using the default constructor.
        StretchColorizerDefinition stretchColorizerDef_default = new StretchColorizerDefinition();
        // Create a new Stretch colorizer using the colorizer definition created above.
        CIMRasterStretchColorizer newStretchColorizer_default =
    await mosaicImageSubLayer.CreateColorizerAsync(stretchColorizerDef_default) as CIMRasterStretchColorizer;
        // Set the new colorizer on the image sub-layer.
        mosaicImageSubLayer.SetColorizer(newStretchColorizer_default);
      }
    });
    Create a new colorizer based on a custom colorizer definition and apply it to the mosaic layer
    await QueuedTask.Run(async () =>
    {
      // Get the image sub-layer from the mosaic layer.
      ImageMosaicSubLayer mosaicImageSubLayer = mosaicLayer.GetImageLayer();
      // Check if the Stretch colorizer can be applied to the image sub-layer.
      if (mosaicImageSubLayer.GetApplicableColorizers().Contains(RasterColorizerType.StretchColorizer))
      {
        // Create a new Stretch colorizer definition specifying parameters
        // for band index, stretch type, gamma and color ramp.
        StretchColorizerDefinition stretchColorizerDef_custom =
    new StretchColorizerDefinition(1, RasterStretchType.ESRI, 2, colorRamp);
        // Create a new stretch colorizer using the colorizer definition created above.
        CIMRasterStretchColorizer newStretchColorizer_custom =
    await mosaicImageSubLayer.CreateColorizerAsync(stretchColorizerDef_custom) as CIMRasterStretchColorizer;
        // Set the new colorizer on the image sub-layer.
        mosaicImageSubLayer.SetColorizer(newStretchColorizer_custom);
      }
    });
    Create a mosaic layer with a new colorizer definition
      // Create a new colorizer definition using default constructor.
      StretchColorizerDefinition stretchColorizerDef = new StretchColorizerDefinition();
      var rasterLayerCreationParams = new RasterLayerCreationParams(new Uri(url))
      {
        Name = layerName,
        ColorizerDefinition = stretchColorizerDef,
        MapMemberIndex = 0
    
      };
      await QueuedTask.Run(() =>
      {
        // Create a mosaic layer using the colorizer definition created above.
        // Note: You can create a mosaic layer from a url, project item, or data connection.
        MosaicLayer newMosaicLayer =
    LayerFactory.Instance.CreateLayer<MosaicLayer>(rasterLayerCreationParams, aMap);
      });
    Create a new colorizer based on a default colorizer definition and apply it to the image service layer
    await QueuedTask.Run(async () =>
    {
      // Check if the Stretch colorizer can be applied to the image service layer.
      if (isLayer.GetApplicableColorizers().Contains(RasterColorizerType.StretchColorizer))
      {
        // Create a new Stretch Colorizer Definition using the default constructor.
        StretchColorizerDefinition stretchColorizerDef_default = new StretchColorizerDefinition();
        // Create a new Stretch colorizer using the colorizer definition created above.
        CIMRasterStretchColorizer newStretchColorizer_default =
    await isLayer.CreateColorizerAsync(stretchColorizerDef_default) as CIMRasterStretchColorizer;
        // Set the new colorizer on the image service layer.
        isLayer.SetColorizer(newStretchColorizer_default);
      }
    });
    Create a new colorizer based on a custom colorizer definition and apply it to the image service layer
    await QueuedTask.Run(async () =>
    {
      // Check if the Stretch colorizer can be applied to the image service layer.
      if (isLayer.GetApplicableColorizers().Contains(RasterColorizerType.StretchColorizer))
      {
        // Create a new Stretch Colorizer Definition specifying parameters
        // for band index, stretch type, gamma and color ramp. 
        StretchColorizerDefinition stretchColorizerDef_custom =
    new StretchColorizerDefinition(1, RasterStretchType.ESRI, 2, colorRamp);
        // Create a new stretch colorizer using the colorizer definition created above.
        CIMRasterStretchColorizer newStretchColorizer_custom =
    await isLayer.CreateColorizerAsync(stretchColorizerDef_custom) as CIMRasterStretchColorizer;
        // Set the new colorizer on the image service layer.
        isLayer.SetColorizer(newStretchColorizer_custom);
      }
    });
    Create an image service layer with a new colorizer definition
      // Create a new colorizer definition using default constructor.
      StretchColorizerDefinition stretchColorizerDef = new StretchColorizerDefinition();
      var rasterLayerCreationParams = new RasterLayerCreationParams(new Uri(url))
      {
        Name = layerName,
        ColorizerDefinition = stretchColorizerDef,
        MapMemberIndex = 0
      };
      await QueuedTask.Run(() =>
      {
        // Create an image service layer using the colorizer definition created above.
        ImageServiceLayer imageServiceLayer =
    LayerFactory.Instance.CreateLayer<ImageServiceLayer>(rasterLayerCreationParams, aMap);
      });
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also