Next: Compiling and linking C programs
Up: Examples of using HDR from C
Previous: Accessing header items by index
It is possible to read and write header items from/to many images in
one call and some examples follow. Note that arrays of strings can
only be passed using fixed string length. It is not possible to use
arrays of pointers to char forming a ragged array. When
using a character array you should pass a pointer to the first element
not the actual array (as the HDR routines expect to see char *).
This example shows how to read the same header item from two images
at the same time.
char RA[2][80];
char DEC[2][80];
hdrIn( "IN1,IN2", " ", "RA", 1, (char *) RA, 80, status ); [1]
hdrIn( "IN1,IN2", " ", "DEC", 1, (char *) DEC, 80, status ); [1]
printf( "The RA and DEC of IN1 are: %s, %s\n", RA[0], DEC[0] );
printf( "and the RA and DEC of IN2 are: %s, %s\n", RA[1], DEC[1] );
imgFree( "*", status );
The following notes refer to the numbered statements:
- 1.
- The address to the first element of the RA and DEC
arrays is passed. This could have been written as
&RA[0][0] and &DEC[0][0].
This example shows how to write values to the same header item of two images.
char obstype[2][5] = {"BIAS","FLAT"};
hdrOut( "BIAS,FLAT", " ", "OBSTYPE", "Type of observation",
(char *) obstype, 5, istat );
imgFree( "*", istat );
Next: Compiling and linking C programs
Up: Examples of using HDR from C
Previous: Accessing header items by index
IMG Simple Image Data Access
Starlink User Note 160
P.W. Draper
R.F. Warren-Smith
3 March 2003
E-mail:P.W.Draper@durham.ac.uk
Copyright © 2000-2003 Council for the Central Laboratory of the Research Councils