Media Cybernetics CUT File Format The Media Cybernetics CUT file format is a device-independent image storage file format. It is used by most Media Cybernetics applications products to allow transmission of image data between different types of hardware environments. HALO does not directly implement this format, but it is implemented through HALO calls. CUT files feature run-length encoded image compression, normalized (one pixel per byte) pixel representation, and allow any rectangular region of image data to be stored. File Organization A CUT fiie begins with a header in the following form: Bytes Name Description 1-2 width Width of image in pixels 3-4 height Height of image in lines 5-6 0 Not used All 16 bit quantities are stored in INTEL (LSB,MSB) format. After the header, a CUT file contains records. There is one record for each line of image data. The record has the following form: Bytes Name Description 1-2 length Length of line record in bytes 3-... data One line of image data stored in run-length encoded form The run-length encoding scheme used in CUT files (like that in GWRlTE files) compresses redundant data out of lines of image data. This is done by identifying when there is a run of pixels in a line of the same color index. When this occurs, the number of matching pixels is recorded in the file rather than the actual pixels. Run-length encoding is implemented in two parts: a compression flag byte followed by one or more image data bytes. Compression flag bytes are as follows: Flag (in binary)Meaning 1 nnn nnnn Indicates that there is one data byte to follow that is to be duplicated nnn nnnn (127 maximum) times. 0 nnn nnnn Indicates that there are nnn nnnn bytes of image data to follow (127 bytes maximum) and that there are no duplications. n 000 0000 End of line field. Indicates the end of a line record. The value of n may be either zero or one. Note that the end of line field is required and that it is reflected in the length of line record field mentioned above. To read a CUT file, the following steps should be taken: 1. Open the CUT file. 2. Read the header, including the width and height of the CUT. 3. For line = 1 to height Read integer count. Read count bytes into arrayl. Uncompress data from arrayl into array2. Unnormalize data from array2 into array3. 4. Close the file. -- Roger Fujii - Media Cybernetics Phone: (301)495-3305 x259 Internet: rmf%media@uunet.uu.net UUCP: {uunet,hqda-ai}!media!rmf