Previous: Pixel Type Declarations Up: Data Types and Host Representations Next: Converting Data Types & Hosts
In the VMS-only world, pixels were always fixed sizes. Many programs assumed that FULL (integer) was 4 bytes, DOUB was 8 bytes, HALF was 2 bytes, etc. This assumption is no longer valid. A given machine may have different sized data types, such as 64-bit (8 byte) integers. Although all current supported machines have the same sized data, it is still important to code programs such that they will work with different sizes.
There are really two aspects to pixel sizes. The first is when you are dealing with files. The file could be from a different machine, with different pixel sizes. In this case, you must use one of the RTL pixel size routines, x/ zvpixsize, x/ zvpixsizeu, or x/ zvpixsizeb. These routines give you the size of a pixel in bytes, given the data type and machine formats ( x/ zvpixsizeu and x/ zvpixsizeb pick up the machine formats from an image label). Do not simply assume that REALs are 4 bytes long, as that may not be the case on every supported machine. The pixel size routines are designed to be easy to call.
The second is when you are dealing with internal buffers. Since internal buffers are almost always in native format for the machine you are running on, you can use the C function sizeof() to get the size of an element in bytes. Make sure that you use the proper data type for the pixel (see Table ). Fortran has no sizeof() operator or equivalent, so you should use xvpixsize with machine formats of ``NATIVE'' or ``LOCAL'' instead.