home *** CD-ROM | disk | FTP | other *** search
/ Encyclopedia of Graphics File Formats Companion / GFF_CD.ISO / formats / drhalo / spec / dr_halo.txt
Text File  |  1994-06-01  |  3KB  |  77 lines

  1. Media Cybernetics CUT File Format
  2.  
  3. The Media Cybernetics CUT file format is a device-independent image storage
  4. file format. It is used by most Media Cybernetics applications products to allow
  5. transmission of image data between different types of hardware environments.
  6. HALO does not directly implement this format, but it is implemented through
  7. HALO calls.
  8.  
  9. CUT files feature run-length encoded image compression, normalized (one
  10. pixel per byte) pixel representation, and allow any rectangular region of image
  11. data to be stored.
  12.  
  13. File Organization
  14.  
  15. A CUT fiie begins with a header in the following form:
  16.  
  17. Bytes     Name    Description
  18.  
  19. 1-2      width    Width of image in pixels
  20. 3-4      height   Height of image in lines
  21. 5-6      0        Not used
  22.  
  23. All 16 bit quantities are stored in INTEL (LSB,MSB) format.
  24.  
  25. After the header, a CUT file contains records. There is one record for each line
  26. of image data. The record has the following form:
  27.  
  28. Bytes     Name     Description
  29.  
  30. 1-2       length  Length of line record in bytes
  31. 3-...     data    One line of image data stored
  32.                   in run-length encoded form
  33.  
  34. The run-length encoding scheme used in CUT files (like that in GWRlTE files)
  35. compresses redundant data out of lines of image data. This is done by identifying
  36. when there is a run of pixels in a line of the same color index. When this occurs,
  37. the number of matching pixels is recorded in the file rather than the actual
  38. pixels. Run-length encoding is implemented in two parts: a compression flag
  39. byte followed by one or more image data bytes. Compression flag bytes are as
  40. follows:
  41.  
  42. Flag (in binary)Meaning
  43. 1 nnn nnnn      Indicates that there is one data byte to follow
  44.                 that is to be duplicated nnn nnnn (127 maximum)
  45.                 times.
  46.  
  47.  
  48. 0 nnn nnnn      Indicates that there are nnn nnnn bytes of image
  49.                 data to follow (127 bytes maximum) and that
  50.                 there are no duplications.
  51.  
  52. n 000 0000      End of line field. Indicates the end of a line
  53.                 record. The value of n may be either zero or one.
  54.                 Note that the end of line field is required and
  55.                 that it is reflected in the length of line record
  56.                 field mentioned above.
  57.  
  58. To read a CUT file, the following steps should be taken:
  59.  
  60. 1. Open the CUT file.
  61.  
  62. 2. Read the header, including the width and height of the CUT.
  63.  
  64. 3. For line = 1 to height
  65.  
  66.           Read integer count.
  67.           Read count bytes into arrayl.
  68.           Uncompress data from arrayl into array2.
  69.           Unnormalize data from array2 into array3.
  70.  
  71. 4. Close the file.
  72.  
  73.  
  74. -- 
  75. Roger Fujii - Media Cybernetics        Phone: (301)495-3305 x259
  76. Internet: rmf%media@uunet.uu.net        UUCP: {uunet,hqda-ai}!media!rmf
  77.