Image service GetImage method

Gets an image in Esri binary format for a given image description.

GetImage(GeoImageDescription ImageDescription)

Parameter

Description

ImageDescription

Defines the properties of the image generated by the service. Pixel data will be processed on-the-fly to fit description properties. The properties you can specify include extent, spatial reference, compression, interpolation, band selection, etc.

ImageDescription also defines a mosaic rule on how mosaic should be performed using a MosaicRule value object, and a rendering rule on how the image should be rendered using a RenderingRule value object.

Return Value

A base64Binary object (byte[]).

Remarks

The returned image data contains pixel values followed by a NoData (transparency) bit mask, i.e. <pixels><mask>. The pixel values are organized in a band interleaved by pixel format, like the following example:

Where nCols, nRows, and nBands are the number of columns, number of rows, and number of bands of the returned image, and v[b,I,j] is a pixel value at band number b, row number I, and column number j. Size in terms of number of bytes of a pixel value depends on pixel type. The following table shows the pixel type to pixel size mapping:

Pixel Type

Pixel Size

PT_U1

1

PT_U2

1

PT_U4

1

PT_UCHAR

1

PT_CHAR

1

PT_USHORT

2

PT_SHORT

2

PT_ULONG

4

PT_LONG

4

PT_FLOAT

4

PT_DOUBLE

8

The location of the pixel at band b, row I, and column j can be calculated using the following formula:

The pixel data are always in Intel (Little Endian) byte order. For pixel types of more than 1 byte, byte swapping may be needed.

The NoData mask is a bit mask, one bit per pixel for all bands, with no padding to the byte boundary for a row. Value 1 indicates the pixel is valid, and 0 indicates NoData. The mask value for a pixel at row I and column j can be calculated using the following:

NoData immediately follows pixel data. The size of the NoData mask in bytes is (nCols*nRows+7)/8. The NoData mask is optional. If the total size of the returned image data is greater than the pixel data size (for example, nRows*nCols*nBands*pixelsize) then the NoData mask is present.

If LZ77 compressed, the returned image data must be uncompressed (zlib). The uncompressed image data follow the same format as above. If JPEG compressed, the returned image data are organized as JPEG data stream followed NoData mask, and followed by the size of the JPEG stream. The NoData mask is the same format as above, but it is LZ77 compressed. The JPEG data stream size is a 4-byte integer in Intel byte order.

Examples

C#

//define image server

string url_DEMService = "http://ais3/arcgis/services/testDEM/ImageServer";

testDTED_ImageServer imageSrv = new testDTED_ImageServer();

imageSrv.Url = url_DEMService;

 

//define image description

GeoImageDescription geoImgDesc = new GeoImageDescription();

geoImgDesc.Height = 600;

geoImgDesc.Width = 800;

geoImgDesc.Interpolation = rstResamplingTypes.RSP_BilinearInterpolation;

ImageServiceInfo isInfo = imageSrv.GetServiceInfo();

geoImgDesc.Extent = isInfo.Extent;

 

//get the image

byte[] imageResult = imageSrv.GetImage(geoImgDesc);

Java

String serviceURL = "http://localhost:6080/arcgis/services/ImageService/ImageServer";

ImageServerBindingStub imageService = new ImageServerBindingStub(serviceURL);

 

GeoImageDescription imgDesc = new GeoImageDescription();

 

int[] bandIds = new int[3];

bandIds[0] = 1;

bandIds[1] = 0;

bandIds[2] = 1;

imgDesc.setBandIDs(bandIds);

 

imgDesc.setHeight(500);

imgDesc.setWidth(500);

imgDesc.setExtent(imageService.getServiceInfo().getExtent());

 

byte[] image = imageService.getImage(imgDesc);

System.out.println("Image Byte Array Length: " + image.length);

11/8/2016