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

  1. The MTV Raytracer Image File Format
  2.  
  3. Introduction
  4.  
  5. During my graduate school education at the University of Oregon, I wrote
  6. a raytracer called "MTV" which was widely distributed over comp.graphics
  7. and the Internet.  I meant it to be simple and easy to modify, and it enjoyed
  8. a short period of popularity among the graphics hacker crowd before being
  9. replaced by other, more advanced raytracers, such as RayShade and Persistance
  10. of Vision.
  11.  
  12. Unfortunately for all, long after the raytracer has fallen by the wayside, 
  13. the file format that I stored images in remains.  I designed the format to
  14. be as simple as possible, so that I could easily write a variety of display
  15. programs for the wide variety of one-of-a-kind graphics devices that I seemed
  16. to have throughout my graduate career.
  17.  
  18. I consider the MTV image format dead.  It differs only trivially from the 
  19. much more popular PPM image format, and a simple change in my raytracer's 
  20. output code (which I made long ago to my own copy of MTV) will allow it to
  21. write PPM format files.  PPM has most of the simplicity of MTV, with the 
  22. advantage of possessing a magic number at the beginning to identify it.
  23.  
  24. The Format
  25.  
  26. An MTV format image consists of an ASCII header followed directly by the
  27. image data bytes.  The ASCII header is merely a string containing the 
  28. width and height followed by a newline character.  The following C statement
  29. will print out the ASCII header:
  30.  
  31. fprintf(fp, "%d %d\n", width, height) ;
  32.  
  33. This is followed directly by the image data, which is written out as 
  34. three unsigned bytes per pixel, originating at the upper left of the image.
  35. This is identical to how the bytes are written out in the PPM image format.
  36.  
  37. If you desire to write PPM format files, you merely need to change the 
  38. line which outputs the ASCII header to the following:
  39.  
  40. fprintf(fp, "P6\n%d %d\n255\n", width, height) ;
  41.  
  42. That is basically all there is to the MTV image format.  It served its
  43. purpose as a trivial, portable image format, but I would recommend against
  44. its continued use, as the PPM format is just as simple to write, and much 
  45. more portable.
  46.  
  47.  
  48. Mark VandeWettering
  49. markv@pixar.com
  50.