C: status = DFPaddpal(filename, palette); FORTRAN: status = dpapal(filename, palette)
C: status = DFPputpal(filename, palette, overwrite, filemode); FORTRAN: status = dpppal(filename, palette, overwrite, filemode)
DFPaddpal and DFPputpal will write a palette to an HDF file named by filename. When given a new filename, DFPputpal and DFPaddpal creates a new file and writes the palette as the first object in the file. When given an existing filename, DFPaddpal appends the palette to the end of the file.
TABLE 9B DFPputpal and DFPaddpal Parameter List
C:
#include "hdf.h" main( ) { uint8 palette_data[768]; intn i; int32 status; /* Initialize the palette to grayscale. */ for (i = 0; i < 256; i++) { palette_data[i * 3] = i; palette_data[i * 3 + 1] = i; palette_data[i * 3 + 2] = i; } /* Write the palette to file. */ status = DFPaddpal("Example1.hdf", (VOIDP)palette_data); }
PROGRAM WRITE PALETTE integer dpapal, status, i character palette_data(768) C Initialize the palette to greyscale. do 10, i = 1, 256 palette_data((i - 1) * 3 + 1) = char(i - 1) palette_data((i - 1) * 3 + 2) = char(i - 1) palette_data((i - 1) * 3 + 3) = char(i - 1) 10 continue C Write the palette to the HDF file. status = dpapal('Example1.hdf', palette_data) end
9.4.2 Specifying the Reference Number of a Palette: DFPwriteref
DFPwriteref specifies the reference number of the palette to be written on the next call to DFPaddpal or DFPputpal:
C: status = DFPwriteref(filename, ref); status = DFPaddpal(filename, palette);
FORTRAN: status = dpwref(filename, ref) status = dpapal(filename, palette)
DFPwriteref assigns the specified reference number to the next palette written to the file filename. If the value of ref is the same as the reference number of an existing palette, the existing palette will be overwritten.
TABLE 9C DFPwriteref Parameter List