Steps 1 and 2 can be invoked in any order, as long as they are executed before Step 3. By default, images are stored uncompressed using pixel interlacing.
7.4.1 Writing a 24-Bit Raster Image: DF24putimage and DF24addimage
To write a raster image to an HDF file, the calling program must contain one of the following function calls:C: status = DF24putimage(filename, image, width, height);
FORTRAN: status = d2pimg(filename, image, width, height)
OR
C: status = DF24addimage(filename, image, width, height);
FORTRAN: status = d2aimg(filename, image, width, height)
DF24putimage and DF24addimage write a 24-bit raster images to the HDF file specified by the filename
parameter. When given a new file name, DF24putimage and DF24addimage create a new file and write the raster image as the first raster image in the file. If a file with the specified filename exists, DF24putimage overwrites the previous contents of the file whereas DF24addimage appends data to the end of the file. image
parameter and the width and height of the image in the width
and height
parameters. The array image
is assumed to be the width times the height times three bytes in length for each color component. The parameters for DF24putimage and DF24addimage are further defined below. Table 7D on page 251
TABLE 7D - DF24putimage and DF24addimage Parameter List
C version
7.4.2 Setting the Interlace Format: DF24setil
DF24setil indicates the interlace format to be used for all subsequent write operations. DF24setil changes the default setting from pixel interlacing to the selected format. When the format is set, it acts as the default until it is reset by another call to DF24setil. To change the default interlace format , the calling program must contain the following routines:C: status = DF24setil(il);
status = DF24addimage(filename, image, width, height);
FORTRAN: status = d2setil(il)
DF24setil takes il
as its only parameter. Valid values for il
are DFIL_PIXEL
, DFIL_LINE
, and DFIL_PLANE
. The parameters for DF24setil are further defined below. Table 7E on page 253
EXAMPLE 2. Writing 24-Bit Raster Images Using Scan-plane Interlacing
In the following examples, DF24addimage is used to write a 24-bit image to an HDF file called "Example2.hdf". The DF24setil function used here to change the default format setting from pixel interlacing to scan-plane interlacing.
7.4.3 Compressing Image Data: DF24setcompress and d2sjpeg
DF24setcompress invokes JPEG compression and sets the JPEG quality and baseline options. To store a 24-bit raster image using JPEG compression, the calling program must contain the following function calls:C: status = DF24setcompress(type, c_info);
status = DF24addimage(filename, image, width, height);
FORTRAN: status = d2scomp(type)
OR status = d2sjpeg(quality, baseline)
status = d2aimg(filename, image, width, height, compress)
Notice that the calling sequence for C is different from the calling sequence for FORTRAN-77. Once it is set, the parameter type
in the DF24setcompress routine, or d2scomp in FORTRAN-77, routine specifies the compression method that will be used to store the raster images. However, the c_info
parameter in DF24setcompress is missing from d2scomp which is a pointer to a structure that contains information specific to the compression method indicated by the type
parameter. Because data structures of variable size are not supported in FORTRAN-77, a second compression-specific routine (d2sjpeg) is required in the FORTRAN-77 calling sequence.c_info
structure refer to Chapter 6, 8-Bit Raster Images (DFR8 API).
Default values for quality and baseline (quality=75%
, baseline=on
) are used if c_info
is a null structure or d2sjpeg is omitted. Parameters for DF24setcompress and d24sjpeg are further described in Table 7E below.
TABLE 7E - DF24setil and DF24setcompress Parameter List
C version