To read a raster image from an HDF file, the calling program must contain the following:
C: status = DFR8getimage(filename, image, width, height, palette);
FORTRAN: status = d8gimg(filename, image, width, height, palette)DFR8getimage retrieves the next 8-bit image from the HDF file name specified by the
filename
parameter. If the image in the file is compressed, DFR8getimage first decompresses it then places it in memory at the location pointed to by the image
parameter. The dimensions of the array allocated to hold the image are specified by the width
and height
parameters and may be larger than the actual image.The palette, if present, is stored in memory at the location pointed to by the palette
parameter. If it contains a NULL
value the palette is not loaded, even if there is one stored with the image. The parameters for DFR8getimage are defined further in Table 6G below. Notice that in Example 4, as in the case of DFR8addimage, the order in which the dimensions for the image array are declared differs between C and FORTRAN-77. FORTRAN-77 declarations require the width before the height while the C declaration requires the height before the width as FORTRAN-77 arrays are stored in column-major order, while C arrays are stored in row-major order. (row-major order implies that the second coordinate varies fastest). When d8gimg reads an image from a file, it assumes column-major order.
To determine the dimensions of an image before attempting to read it, the calling program must include the following routines:
C: status = DFR8getdims(filename, width, height, haspalette);
status = DFR8getimage(filename, image, width, height, palette);
FORTRAN: status = d8gdim(filename, width, height, haspalette)
status = d8gimg(filename, image, width, height, palette)DFR8getdims retrieves dimension and palette information about the next 8-bit image in the file specified by
filename
. The returned information is pointed to by the width
and height
parameters. The haspalette
parameter determines the presence of a palette and returns a value of 1 if it exists and 0 otherwise. The parameters for DFR8getdims are defined further in the following table.
NULL
is passed as the palette parameter. If the palette argument is NULL
(or "0" in FORTRAN-77), all palette data is ignored. FORTRAN-77 version
To access a specific raster image set, use the following calling sequence:
C: status = DFR8readref(filename, ref);
status = DFR8getimage(filename, image, width, height, palette);
FORTRAN: status = d8rref(filename, ref)
status = d8gimg(filename, image, width, height, palette)DFR8readref specifies that the target for the next read operation performed on the HDF file specified by the
filename
parameter is the object with the reference number named in the ref
parameter. The parameters required for DFR8readref are defined further in the following table.
C: status = DFR8restart( );
FORTRAN: status = d8first( )