int convert_volume( header *hdr, void **data, enum data_type newtype)
Range checking is performed. Values are truncated to highest representable/lowest representable when outside range. NOTE : Range checking is only performed when converting from
anytype -> byte
sshort, float, long, double -> ushort
ushort, float, long, double -> sshort
See volio.h for available data_type's
Returns ERROR (=0) if memory allocation error occurs.
The function is typically used after read_volume() to ensure that the data is stored is the correct data format in memory.
This example program converts a file to float format.
#include "volio.h"
int
main (int argc, char *argv[]) {
header *hdr;
char *data; // Could be any type!
if (read_volume(argv[1], hdr, (void**) &data))
exit(1);
if (convert_volume(hdr, (void**) &data, T_FLOAT))
exit(1);
if (write_volume(argv[2], hdr, (void**) &data ))
exit(1);
free_header(hdr);
free(data);
}
1.0 29/10-96 Ulrik Kjems