[Top] [Prev] [Next]

pal_ex1.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);

}

pal_ex1.f

      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

pal_ex2.c

#include "hdf.h"

main( )
{

	uint8 palette_data[768];
	intn status;

	/* Read the palette data from a file. */
	status = DFPgetpal("Example1.hdf", (VOIDP)palette_data);

}

pal_ex2.f

      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



[Top] [Prev] [Next]

hdfhelp@ncsa.uiuc.edu
HDF User's Guide - 07/21/98, NCSA HDF Development Group.