Accessing Palettes


Contents:



How to Access Palettes

Typical functions that you would use to access a palette are as follows: (The functions in bold are used in the program example in this tutorial.)

Sample Program

The gr_pal program is a sample program for attaching a palette to a GR image, and then reading it back in and printing it to the screen. You can either download the C program at the end, or just take a look at the HTML version, with the HDF calls highlighted: If you have downloaded this program, then you can compile and run it. Following is a detailed review of what this program does:

Contents of HDF File Created

If you have compiled and run the gr_pal program, you can view the palette that gets added to the gr1.hdf file, using the hdfed utility, as follows:
    hdfed gr1.hdf
    hdfed>info -all
    hdfed>next tag=301
    hdfed>dump -byte
    hdfed>quit
Currently, you are unable to view the palette using the hdp utility.

Following is the palette data output that the gr_pal program displays to the screen:


Download Sample Program (optional)

Programs used in this tutorial: [Compiling a program]