Up | Previous | Next | Title Page | Contents

6.2 Translation API

Below are the ten subroutines that comprise the Translation API.

6.2.1 x/zvhost—Integer and real data representations of a host given the host type name

call xvhost(host, intfmt, realfmt, status) 
status = zvhost(host, intfmt, realfmt);
Returns the integer and real data representations of a host given the host type name. The returned values may be used with the translation routines or the INTFMT and REALFMT system label items. This routine can also return the host type name, for use with the HOST system label.
This routine is rarely needed, as the normal case is to read any type of file (where you get INTFMT and REALFMT from the file), and to write in native format (where you don't need to specify the formats). However, this routine is useful in the rare case that a program needs to write in a non-native format. The user can select the machine type for output, and this routine will return the data representations needed for that machine type.

Arguments:

The value “HOSTNAME” is special. If this value is given for HOST, then the return values change. The parameter INTFMT returns the host type name for the machine currently running. The parameter REALFMT is undefined on output. The value returned in INTFMT could then be used in another call to x/zvhost (which wouldn't gain much since “NATIVE” or “LOCAL” do the same thing), or it could be used in a HOST label. This should be needed only from FORTRAN. A C program should use the “ NATIVE _HOST_LABEL” macro defined in x/zvmaininc.h instead. Similarly, “NATIVE” and “LOCAL” will be mainly useful in a FORTRAN program, as a C program should use the NATIVE_INTFMT and NATIVE_REALFMT macros.

6.2.2 x/zvpixsize—Size of a pixel in bytes given the data type and host representation

status = xvpixsize(pixsize, type, ihost, rhost) 
status = zvpixsize(pixsize, type, ihost, rhost);
Returns the size of a pixel in bytes given the data type and host representation. One of the pixsize routines should be used to figure out the size of a pixel. Do not assume any particular size, like 4 bytes for a REAL. It may be different on other machines. It is valid to use sizeof() in C to get the size of a pixel in the native representation only, but the pixsize routines are the only valid way to get the size of a pixel on any other hosts.

Arguments:

6.2.3 x/zvpixsizeb—Size of a binary label value in bytes from a file

status = xvpixsizeb(pixsize, type, unit) 
status = zvpixsizeb(pixsize, type, unit);
Return the size of a binary label value in bytes from a file. This routine is exactly like x/zvpixsize except that the IHOST and RHOST values are obtained for binary labels from the file specified by UNIT, which must be open. It is provided merely as a shortcut to get the size of a binary label value for a file.

Arguments:

6.2.4 x/zvpixsizeu—Size of a pixel in bytes from a file

status = xvpixsizeu(pixsize, type, unit) 
status = zvpixsizeu(pixsize, type,unit);
Return the size of a pixel in bytes from a file. This routine is exactly like x/zvpixsize except that the IHOST and RHOST values are obtained from the file specified by UNIT, which must be open. It is provided merely as a shortcut to get the pixel size of a file.

Arguments:

6.2.5 x/zvtrans—Translate pixels from one format to another

call xvtrans(buf, source, dest, npix) 
zvtrans(buf, source, dest, npix);
Translate pixels from one format to another. One of the translation setup routines must have been called first to set up the translation buffer. This routine is the only standard way to translate data in the VICAR system, both between host representations ( e. g. VAX to IEEE) and between data types (e.g. integer to real).
This routine is coded to be very efficient, so it may be called inside a tight loop with very little performance penalty .

Arguments:

6.2.6 x/zvtrans_in—Create translation buffer for input

call xvtrans_in(buf, stype, dtype, sihost, srhost, status) 
status = zvtrans_in(buf, stype, dtype, sihost, srhost);
Create translation buffer for input. The data will be converted from a host representation of (SIHOST, SRHOST) and data type of STYPE into the machine's native representation and data type DTYPE. So, it converts from foreign to local format. Since all processing must be done in native format on the machine the program is running on, this translation is most often needed for input from a file .

Arguments:

6.2.7 x/zvtrans_inb—Create translation buffer for input from binary labels of a file

call xvtrans_inb(buf, stype, dtype, unit, status) 
status = zvtrans_inb(buf,stype, dtype, unit);
Create translation buffer for input from the binary labels of a file. This routine is exactly like x/zvtrans_in except that the SIHOST and SRHOST values are obtained for binary labels from the file specified by UNIT, which must be open. It is provided merely as a shortcut for the common case of reading binary label data from a labeled file .

Arguments:

6.2.8 x/zvtrans_inu—Create translation buffer for input from a file

call xvtrans_inu(buf, stype, dtype, unit, status) 
status = zvtrans_in u(buf,stype, dtype, unit);
Create translation buffer for input from a file. This routine is exactly like x/zvtrans_in except that the SIHOST and SRHOST values are obtained from the file specified by UNIT, which must be open. It is provided as a shortcut for the common case of reading image data from a labeled file .

Arguments:

6.2.9 x/zvtrans_out—Create translation buffer for output

call xvtrans_out(buf, stype, dtype, dihost, drhost, status) 
status =zvtrans_out(buf, stype, dtype, dihost, drhost);
Create translation buffer for output. The data will be converted from the machine's native representation and data type of STYPE into a host representation of (DIHOST, DRHOST) and data type of DTYPE. So, it converts from local to foreign format. Since all processing must be done in native format on the machine the program is running on, this translation is most often needed for output to a file.
This routine is less commonly used than the input routines. The general rule for applications is to read any format, but write the native format. Translation on output is not needed in this case. However, x/zvtrans_out is provided for special cases where the data must be written in a different host representation .

Arguments:

6.2.10 x/zvtrans_set—Create translation buffer for data types only

call xvtrans_set(buf, stype, dtype, status)
status = zvtrans_set(buf, stype, dtype);
Create translation buffer for data types only. Both the source and the destination must be in the native host representation. It is useful for converting internal buffers from one data type to another. Don't use it with data direct from a file, however, as files are not guaranteed to be in the native host representation .

Arguments:


Up | Previous | Next | Title Page | Contents