home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume2 / pbm / Part1 / FORMATS < prev    next >
Encoding:
Text File  |  1991-08-07  |  3.1 KB  |  86 lines

  1. The portable bitmap format is a lowest common denominator.
  2.  
  3. Formats currently supported are:
  4.  
  5.     X11 and X10 bitmaps
  6.     X11 window dump files
  7.     Sun icons
  8.     Sun raster files.
  9.     Macintosh MacPaint files
  10.     PostScript
  11.     Printronix printer graphics
  12.     "portable bitmap format"
  13.     "compact bitmap format"
  14.  
  15.  
  16. The portable bitmap format is something I came up with while I was
  17. at Xerox.  It is a lowest common denominator.  It was originally
  18. designed to make it reasonable to mail bitmaps between different
  19. types of machines using the typical stupid network mailers we have
  20. today.  Now it serves as the common language for this family of
  21. bitmap conversion filters.  The definition is as follows:
  22.  
  23.     - A width, formatted as ASCII characters in decimal.
  24.  
  25.     - Whitespace (blanks, TABs, CRs, LFs).
  26.  
  27.     - A height, again in ASCII decimal.
  28.  
  29.     - Whitespace.
  30.  
  31.     - Width * height bits, each either '1' or '0', starting at the top-left
  32.     corner of the bitmap, proceding in normal English reading order.
  33.  
  34.     - The character '1' means black, '0' means white.
  35.  
  36.     - Whitespace in the bits section is ignored.
  37.  
  38.     - Characters from a "#" to the next end-of-line are ignored (comments).
  39.  
  40.     - No line may be longer than 70 characters.
  41.  
  42. Here is an example of a small bitmap in this format:
  43.  
  44.     # feep.pbm
  45.     24 7
  46.     0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  47.     0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0
  48.     0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0
  49.     0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 1 0
  50.     0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0
  51.     0 1 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 0 0 0 0
  52.     0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  53.  
  54. Programs that read this format should be as lenient as possible,
  55. accepting anything that looks remotely like a bitmap.  For instance,
  56. the above example does not actually conform to the standard, since
  57. it has whitespace before the width; neverthless, it should be accepted.
  58.  
  59.  
  60. The compact bitmap format is the same basic idea as the portable
  61. format, but it assumes the underlying filesystem can reliably store
  62. 8-bit bytes.  If you have the compress and zcat programs, you should
  63. not bother with compact bitmaps -- all formats are about the same size
  64. after being compressed.  Otherwise, compact bitmaps are probably the
  65. most space-efficient format.  The definition:
  66.  
  67.     - Two bytes of "magic number", which are always 0x2A 0x17.
  68.  
  69.     - Two bytes representing the width.  The bytes are in "big-endian"
  70.     order, i.e. the formula for the width is firstbyte * 256 + secondbyte.
  71.  
  72.     - Two bytes representing the height, same order as above.
  73.  
  74.     - The bits, in the same order as in the portable format: starting
  75.     at the top-left, proceeding in normal English reading order.
  76.     Within each byte, the most significant bit is used first, and so
  77.     on down to the least significant bit.
  78.  
  79.     - Nothing special happens at the end of a row -- no padding, not even
  80.     to the end of the current byte.
  81.     
  82.     - A 1 bit means black, a 0 bit means white;
  83.  
  84.     - All eight bits of each byte are used, except of course for the
  85.     last byte, where there may be some extra bits.  These are ignored.
  86.