Sample code
This sample code loads an image service, which is published on a server, and requests an image given the extents and the number of rows and columns.
For this sample to work, open a VB 6.0 standard EXE project. Add in references:
• | ImageServer Client 1.0 Type Library [ISClient.Dll] |
• | Microsoft XML |
Place a button and name it Command1. Copy the code below and modify the name of the image service to something that is published on the server. Also change the SetImageInfo parameters according to the service loaded.
Private Sub Command1_Click()
Dim client As New CClientObject
If client.Init("") = False Then
MsgBox client.Status
Exit Sub
End If
'Open the image service
Dim cService As CImageService
Set cService = client.OpenImageService("ImageService://hawkings:10000/Dxb_Tif", "")
If cService Is Nothing Then
MsgBox client.Status
Exit Sub
End If
'Set the extents and the dimensions of the requested image
Dim returnVal As Boolean
returnVal = cService.SetImageInfo(120034.5, 869002.6, 120500.13, 869711.39, 500, 500)
If returnVal = False Then
MsgBox cService.Status
Exit Sub
End If
Dim imageInfoXml As String
imageInfoXml = "<ImageServer><Client><GetImage><OutputType></OutputType><FileName></FileName><Format></Format></GetImage></Client></ImageServer>"
'Load the XML string in DOM Document object and modify the values of each node.
Dim imageInfoDoc As New DOMDocument
If imageInfoDoc.loadXML(imageInfoXml) = False Then
MsgBox "Failed to load the XML"
Exit Sub
End If
imageInfoDoc.selectSingleNode("//ImageServer/Client/GetImage/OutputType").Text = "File"
imageInfoDoc.selectSingleNode("//ImageServer/Client/GetImage/FileName").Text = "C:\Temp\OutImage.tif”"
imageInfoDoc.selectSingleNode("//ImageServer/Client/GetImage/Format").Text = "TIFF"
imageInfoXml = imageInfoDoc.Text
'Create the image file to the output location
Dim isGetImageDone As String
isGetImageDone = cService.GetImage(imageInfoXml)
'Close the service and disconnect the connection to ImageServer
cService.Close
client.Close
End Sub