#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
#include "hdf.h"
main( )
{
uint8 palette_data[768];
intn status;
/* Read the palette data from a file. */
status = DFPgetpal("Example1.hdf", (VOIDP)palette_data);
}
PROGRAM READ PALETTE
integer dpgpal, status
character palette_data(768)
C Read the palette from the HDF file.
status = dpgpal(`Example1.hdf', palette_data)
end