C Example - gr_gi.c
#include "mfgr.h"
#define X_LENGTH 15
#define Y_LENGTH 10
main( )
{
int32 gr_id, ri_id, ri_idx, file_id, status, il;
int32 ndatasets, nfattrs;
int32 nt, dimsizes[2], ncomp, nattrs;
char name[MAX_GR_NAME];
/* Open the file. */
file_id = Hopen("gr1.hdf", DFACC_READ, 0);
/* Initiate the GR interface. */
gr_id = GRstart(file_id);
status = GRfileinfo (gr_id, &ndatasets, &nfattrs);
printf ("\nNumber of Datasets: %i\n", ndatasets);
printf ("Number of File Attributes: %i\n", nfattrs);
/* Select the image in the file. */
ri_idx = GRnametoindex (gr_id, "Image_1");
ri_id = GRselect(gr_id, ri_idx);
/* Verify the characteristics of the image. */
status = GRgetiminfo(ri_id, name, &ncomp, &nt, &il, dimsizes, &nattrs);
printf ("Data Set Name: %s\n", name);
printf ("Number of Components: %i\n", ncomp);
printf ("Number Type: %i\n", nt);
printf ("Interlace: %i\n", il);
printf ("Number of Attributes: %i\n", nattrs);
printf ("Dimension 1: %i\n", dimsizes[0]);
printf ("Dimension 2: %i\n", dimsizes[1]);
printf ("\n");
/* Terminate access to the image. */
status = GRendaccess(ri_id);
/* Terminate access to the GR interface. */
status = GRend(gr_id);
/* Close the file. */
status = Hclose(file_id);
}