ArcGIS API for Silverlight - Library Reference
ImageFormat Property
See Also  Example Send comments on this topic
ESRI.ArcGIS.Client Namespace > ArcGISDynamicMapServiceLayer Class : ImageFormat Property

Gets or sets the image format used when generating an ArcGISDynamicMapServiceLayer image.

Syntax

Visual Basic (Declaration) 
Public Property ImageFormat As ArcGISDynamicMapServiceLayer.RestImageFormat
C# 
public ArcGISDynamicMapServiceLayer.RestImageFormat ImageFormat {get; set;}

Remarks

The default image format is PNG24. There are four ArcGISDynamicMapServiceLayer.RestImageFormat Enumeration values that can be used for the ImageFormat Property, they are:

  • PNG24
  • JPG
  • PNG8
  • PNG32

The background color for an ArcGISDynamicMapServiceLayer will always be transparent when the ImageFormat is set to use a lossless data compression such as PNG. JPG is considered a lossy data compression and as such will not show the background of the layer to be transparent, meaning it will not drape well over other background layers. Theoretical information related to these compression types can be found for the following topics:

Example

How to use:

Click on the various ImageFormats supported by the ArcGISDynamicMapServiceLayer to see the effect in the Map. PNG8 will display the symbology slightly pixelated. The PNG24 and PNG24 provide clear rendering of the symbology. JPG uses a lossy data compression and hence the background pixels will not show as transparent and will mask the 'World_Light_Gray_Base' ArcGISTiledMapServiceLayer on the bottom.

The XAML code in this example is used in conjunction with the code-behind (C# or VB.NET) to demonstrate the functionality.

The following screen shot corresponds to the code example in this page.

Demonstrating the effect of the various ArcGISDynamicMapServiceLayer.ImageFormat settings.

XAMLCopy Code
<Grid x:Name="LayoutRoot">
  
  <!-- Add a Map Control. Set the Extent to the continental United States. -->
  <esri:Map Background="White" HorizontalAlignment="Left" Margin="12,113,0,0" Name="Map1" 
        VerticalAlignment="Top" Height="367" Width="426" Extent="-14811263,296658,-5960159,7921904">
    
    <!-- Add an ArcGISTiledMapServiceLayer. -->
    <esri:ArcGISTiledMapServiceLayer ID="World_Light_Gray_Base" 
          Url="http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer"/>
    
    <!--Add an ArcGISDynamicMapServiceLayer. -->
    <esri:ArcGISDynamicMapServiceLayer ID="USA_1990-2000_Population_Change"
          Url="http://services.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_1990-2000_Population_Change/MapServer"/>
    
  </esri:Map>
  
  <!-- Pick and ImageFormat from the ListBox to change the image type returned from ArcGIS Server. -->
  <sdk:Label Height="28" HorizontalAlignment="Left" Margin="444,113,0,0" Name="Label1" VerticalAlignment="Top" 
       Width="120" Content="Pick an ImageFormat:"/>
  <ListBox Height="96" HorizontalAlignment="Left" Margin="444,132,0,0" Name="ListBox1" VerticalAlignment="Top" 
           Width="120" SelectionChanged="ListBox1_SelectionChanged" />
  
  <!-- Provide the instructions on how to use the sample code. -->
  <TextBlock Height="107" HorizontalAlignment="Left" Name="TextBlock1" VerticalAlignment="Top" Width="788" 
             TextWrapping="Wrap" Text="Click on the various ImageFormats supported by the ArcGISDynamicMapServiceLayer 
             to see the effect in the Map. PNG8 will display the symbology slightly pixelated. The PNG24 and 
             PNG24 provide clear rendering of the symbology. JPG uses a lossy data compression and hence the 
             background pixels will not show as transparent and will mask the 'World_Light_Gray_Base' 
             ArcGISTiledMapServiceLayer on the bottom."/>
  
</Grid>
C#Copy Code
public MainPage()
{
  InitializeComponent();
  
  // Add all of the supported ArcGISDynamicMapServiceLayer.ImageFormat types into the ListBox.
  ListBox1.Items.Add(ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer.RestImageFormat.PNG8);
  ListBox1.Items.Add(ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer.RestImageFormat.PNG24);
  ListBox1.Items.Add(ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer.RestImageFormat.PNG32);
  ListBox1.Items.Add(ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer.RestImageFormat.JPG);
}
            
private void ListBox1_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
  // Get the ArcGISDynamicMapServiceLayer.
  ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer theArcGISDynamicMapServiceLayer = (ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)(Map1.Layers["USA_1990-2000_Population_Change"]);
  
  // Get the ImageFormat selection from the ListBox.
  ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer.RestImageFormat theSelection = (ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer.RestImageFormat)ListBox1.SelectedItem;
  
  // Set the ImageFormat from the user selection.
  theArcGISDynamicMapServiceLayer.ImageFormat = theSelection;
  
  // Refresh the ArcGISDynamicMapServiceLayer in the Map.
  theArcGISDynamicMapServiceLayer.Refresh();
}
VB.NETCopy Code
Public Sub New()
  InitializeComponent()
  
  ' Add all of the supported ArcGISDynamicMapServiceLayer.ImageFormat types into the ListBox.
  ListBox1.Items.Add(ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer.RestImageFormat.PNG8)
  ListBox1.Items.Add(ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer.RestImageFormat.PNG24)
  ListBox1.Items.Add(ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer.RestImageFormat.PNG32)
  ListBox1.Items.Add(ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer.RestImageFormat.JPG)
  
End Sub
            
Private Sub ListBox1_SelectionChanged(sender As System.Object, e As System.Windows.Controls.SelectionChangedEventArgs)
  
  ' Get the ArcGISDynamicMapServiceLayer.
  Dim theArcGISDynamicMapServiceLayer As ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer = CType(Map1.Layers.Item("USA_1990-2000_Population_Change"), ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)
  
  ' Get the ImageFormat selection from the ListBox.
  Dim theSelection As ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer.RestImageFormat = CType(ListBox1.SelectedItem, ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer.RestImageFormat)
  
  ' Set the ImageFormat from the user selection.
  theArcGISDynamicMapServiceLayer.ImageFormat = theSelection
  
  ' Refresh the ArcGISDynamicMapServiceLayer in the Map.
  theArcGISDynamicMapServiceLayer.Refresh()
  
End Sub

Requirements

Target Platforms: Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family, Windows 7

See Also

© ESRI, Inc. All Rights Reserved.