Creating a local image service
The following code example shows how to create a local image server object from a mosaic dataset, and set configurations:
[C#]
public static IImageServer InitializeImageServer(string mosaicDatasetPath)
{
//Initialize.
IImageServerInit2 isInit2 = new ImageServerClass();
isInit2.Initialize(mosaicDatasetPath);
//Set configuration parameters (default compression: JPEG; default mosaic method: MosaicToCenter).
isInit2.AllowedCompressions = "JPEG,None,LZ77";
isInit2.AllowedFields = "MinPS,MaxPS,LowPS,HighPS,CenterX,CenterY";
isInit2.AllowedItemMetadata = "Full";
isInit2.AllowedMosaicMethods = "Center,NorthWest,ByAttribute,LockRaster";
isInit2.ExcludedFields = "Raster";
isInit2.MaxImageHeight = 4100;
isInit2.MaxImageWidth = 15000;
isInit2.MaxRecordCount = 20;
//Cast to IImageServer.
IImageServer imageServer = isInit2 as IImageServer;
return imageServer;
}
[VB.NET]
Public Shared Function InitializeImageServer(ByVal mosaicDatasetPath As String) As IImageServer
'Initialize.
Dim isInit2 As IImageServerInit2 = New ImageServerClass()
isInit2.Initialize(mosaicDatasetPath)
'Set configuration parameters (default compression: JPEG; default mosaic method: MosaicToCenter).
isInit2.AllowedCompressions = "JPEG,None,LZ77"
isInit2.AllowedFields = "MinPS,MaxPS,LowPS,HighPS,CenterX,CenterY"
isInit2.AllowedItemMetadata = "Full"
isInit2.AllowedMosaicMethods = "Center,NorthWest,ByAttribute,LockRaster"
isInit2.ExcludedFields = "Raster"
isInit2.MaxImageHeight = 4100
isInit2.MaxImageWidth = 15000
isInit2.MaxRecordCount = 20
'Cast to IImageServer.
Dim imageServer As IImageServer = CType(isInit2, IImageServer)
Return imageServer
End Function
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.System (ESRI.ArcGIS.esriSystem)ESRI.ArcGIS.Server
Development licensing | Deployment licensing |
---|---|
ArcGIS for Desktop Advanced | ArcGIS for Desktop Standard |
ArcGIS for Desktop Standard | ArcGIS for Desktop Advanced |
ArcGIS for Desktop Basic | ArcGIS for Desktop Basic |
Engine Developer Kit | Engine |