Accessing the color map of an image service
Do the following steps to access a color map for an image service:
      - Get the color map from an image service.
- Export an image from the image service while applying a color map function.
 See the following code example:
        
public static void GetAndApplyColormap(IImageServer imageServer)
{
    //Get the color map.
    IImageServiceInfo3 isInfo = imageServer.ServiceInfo as IImageServiceInfo3;
    IRasterColormap colormap = isInfo.Colormap;
    //Create the color map function using the color map.
    IRenderingRule rule = new RenderingRuleClass();
    ColormapFunction colormapfunction = new ColormapFunctionClass();
    IColormapFunctionArguments colormapargs = new ColormapFunctionArgumentsClass();
    colormapargs.Colormap = colormap;
    rule.Function = colormapfunction;
    rule.Arguments = (IRasterFunctionArguments)colormapargs;
    rule.VariableName = "Raster";
    //Define export image request.
    IGeoImageDescription2 geoImageDesc = new GeoImageDescriptionClass();
    geoImageDesc.Width = 800;
    geoImageDesc.Height = 600;
    geoImageDesc.Extent = isInfo.Extent;
    geoImageDesc.RenderingRule = rule;
    //Export an image using service's color map.
    IImageType imageType = new ImageTypeClass();
    imageType.Format = esriImageFormat.esriImageJPGPNG;
    imageType.ReturnType = esriImageReturnType.esriImageReturnURL;
    IMapImage mapImage = ((IImageServer2)imageServer).ExportMapImage(geoImageDesc,
        imageType);
    System.Diagnostics.Process.Start("iexplore.exe", mapImage.URL);
}
      [VB.NET]
        
Public Shared Sub GetAndApplyColormap(imageServer As IImageServer)
'Get the color map.
Dim isInfo As IImageServiceInfo3 = TryCast(imageServer.ServiceInfo, IImageServiceInfo3)
Dim colormap As IRasterColormap = isInfo.Colormap
'Create the color map function using the color map.
Dim rule As IRenderingRule = New RenderingRuleClass()
Dim colormapfunction As ColormapFunction = New ColormapFunctionClass()
Dim colormapargs As IColormapFunctionArguments = New ColormapFunctionArgumentsClass()
colormapargs.Colormap = colormap
rule.[Function] = colormapfunction
rule.Arguments = DirectCast(colormapargs, IRasterFunctionArguments)
rule.VariableName = "Raster"
'Define export image extent.
Dim geoImageDesc As IGeoImageDescription2 = New GeoImageDescriptionClass()
geoImageDesc.Width = 800
geoImageDesc.Height = 600
geoImageDesc.Extent = isInfo.Extent
geoImageDesc.RenderingRule = rule
'Export an image using service's color map.
Dim imageType As IImageType = New ImageTypeClass()
imageType.Format = esriImageFormat.esriImageJPGPNG
imageType.ReturnType = esriImageReturnType.esriImageReturnURL
Dim mapImage As IMapImage = DirectCast(imageServer, IImageServer2).ExportMapImage(geoImageDesc, imageType)
System.Diagnostics.Process.Start("iexplore.exe", mapImage.URL)
End Sub
      To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
- ESRI.ArcGIS.Carto 
- ESRI.ArcGIS.Server 
- ESRI.ArcGIS.System (ESRI.ArcGIS.esriSystem)
- ESRI.ArcGIS.Geodatabase 
- ESRI.ArcGIS.DataSourcesRaster 
| Development licensing | Deployment licensing | 
|---|---|
| ArcGIS for Desktop Advanced | ArcGIS for Desktop Advanced | 
| ArcGIS for Desktop Standard | ArcGIS for Desktop Standard | 
| ArcGIS for Desktop Basic | ArcGIS for Desktop Basic | 
| Engine Developer Kit | Engine |