home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / ppmtoxpm.zoo / ppmtoxpm / XPM.README < prev   
Text File  |  1990-02-21  |  4KB  |  122 lines

  1. Most of you are familiar with Jef Poskanzer's pbmplus utilities.
  2. For those of you who are not, they are a wonderful collection of
  3. routines which transform images from one format to another.  This
  4. package is distributed on the X11R4 contrib tape and can be found
  5. on many archive sites.
  6.  
  7. A relatively new format is XPM whose origins can be traced back to the
  8. people at Groupe Bull -- the same wonderful folks who brought you the
  9. gwm window manager.
  10.  
  11. This article contains the source and man page for a "ppmtoxpm" tool
  12. which transforms an image from the ppm (portable pixmap) format, found
  13. in the pbmplus utilities, to the XPM format.
  14.  
  15. XPM is an ASCII based *color* pixmap format.  It's similar to the XBM
  16. format in that it can be #include'd in C source code, or read from a file
  17. at run time.  An example is probably worth a thousand words; the X11
  18. bitmap file ".../include/X11/bitmaps/dot" looks like:
  19.  
  20. #define dot_width 16
  21. #define dot_height 16
  22. static char dot_bits[] = {
  23.    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0xf0, 0x0f, 0xf0, 0x0f,
  24.    0xf8, 0x1f, 0xf8, 0x1f, 0xf8, 0x1f, 0xf8, 0x1f, 0xf0, 0x0f, 0xf0, 0x0f,
  25.    0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  26.  
  27. The same file in XPM format would be:
  28.  
  29. #define dot_format 1
  30. #define dot_width  16
  31. #define dot_height 16
  32. #define dot_ncolors 2
  33. #define dot_chars_per_pixel 1
  34. static char *dot_colors[] = {
  35.    "`", "black",
  36.    "a", "white"
  37. };
  38. static char *dot_pixels[] = {
  39. "aaaaaaaaaaaaaaaa",
  40. "aaaaaaaaaaaaaaaa",
  41. "aaaaaaaaaaaaaaaa",
  42. "aaaaaa````aaaaaa",
  43. "aaaa````````aaaa",
  44. "aaaa````````aaaa",
  45. "aaa``````````aaa",
  46. "aaa``````````aaa",
  47. "aaa``````````aaa",
  48. "aaa``````````aaa",
  49. "aaaa````````aaaa",
  50. "aaaa````````aaaa",
  51. "aaaaaa````aaaaaa",
  52. "aaaaaaaaaaaaaaaa",
  53. "aaaaaaaaaaaaaaaa",
  54. "aaaaaaaaaaaaaaaa"
  55. };
  56.  
  57. Although the above example only uses two colors, XPM files can have an
  58. arbitrary number of colors.  Colors can be specified by using either the
  59. color name mnemonics found in the X11 server's RGB database (e.g. "black"),
  60. or the X11 hexadecimal #RGB, ..., #RRRRGGGGBBBB convention.
  61.  
  62. A good example of a program that understands XPM format is "xloadimage"
  63. (a.k.a. "xview" and "xsetbg") by Jim Frost (jimf@saber.com).  This program
  64. is on the X11R4 contrib tape and has also been posted on comp.sources.x.
  65. "xloadimage" requires patchlevel 3 to correctly understand the XPM format.
  66. This patchlevel should be posted on comp.sources.x in the near future.  In
  67. the mean while, you can obtain a patchlevel 3 version of "xloadimage" via
  68. ftp from expo.lcs.mit.edu (18.30.0.212) [/contrib/xloadimage.1.03.tar.Z],
  69. or via uucp from zok [/usrX/contrib/xldim103.tar.Z].  (BTW, "xloadimage"
  70. has also been tested on unusual X11 servers, those that only have 2 or
  71. 4 bitplanes.)
  72.  
  73. After you unshar the ppmtoxpm.c and ppmtoxpm.1 files, place them into your
  74. .../pbmplus/ppm directory.  The .../pbmplus/ppm/Imakefile can be updated
  75. by applying the following patch:
  76.  
  77. *** Imakefile.org    Tue Nov 21 22:24:43 1989
  78. --- Imakefile    Sun Feb 18 14:34:59 1990
  79. ***************
  80. *** 28,34 ****
  81.   PORTBINARIES =    giftoppm ilbmtoppm imgtoppm mtvtoppm ppmarith ppmconvol \
  82.           ppmcscale ppmhist ppmquant ppmscale ppmtogif ppmtoilbm \
  83.           ppmtopgm ppmtops ppmtorast ppmtoxwd qrttoppm rasttoppm \
  84. !         tgatoppm xwdtoppm
  85.   MATHBINARIES =    ppmpat ppmrotate ppmshear
  86.   BINARIES =    $(PORTBINARIES) $(MATHBINARIES)
  87.   
  88. --- 28,34 ----
  89.   PORTBINARIES =    giftoppm ilbmtoppm imgtoppm mtvtoppm ppmarith ppmconvol \
  90.           ppmcscale ppmhist ppmquant ppmscale ppmtogif ppmtoilbm \
  91.           ppmtopgm ppmtops ppmtorast ppmtoxwd qrttoppm rasttoppm \
  92. !         tgatoppm xwdtoppm ppmtoxpm
  93.   MATHBINARIES =    ppmpat ppmrotate ppmshear
  94.   BINARIES =    $(PORTBINARIES) $(MATHBINARIES)
  95.   
  96. ***************
  97. *** 36,42 ****
  98.           ppmconvol.1 ppmcscale.1 ppmhist.1 ppmpat.1 ppmquant.1 \
  99.           ppmrotate.1 ppmscale.1 ppmshear.1 ppmtogif.1 ppmtoilbm.1 \
  100.           ppmtopgm.1 ppmtops.1 ppmtorast.1 ppmtoxwd.1 qrttoppm.1 \
  101. !         rasttoppm.1 tgatoppm.1 xwdtoppm.1
  102.   MANUALS3 =    libppm.3
  103.   MANUALS5 =    ppm.5
  104.   
  105. --- 36,42 ----
  106.           ppmconvol.1 ppmcscale.1 ppmhist.1 ppmpat.1 ppmquant.1 \
  107.           ppmrotate.1 ppmscale.1 ppmshear.1 ppmtogif.1 ppmtoilbm.1 \
  108.           ppmtopgm.1 ppmtops.1 ppmtorast.1 ppmtoxwd.1 qrttoppm.1 \
  109. !         rasttoppm.1 tgatoppm.1 xwdtoppm.1 ppmtoxpm.1
  110.   MANUALS3 =    libppm.3
  111.   MANUALS5 =    ppm.5
  112.  
  113.   
  114. Enjoy.
  115.  
  116. -- Mark
  117.  
  118. Mark W. Snitily                 Consulting Services:
  119. 894 Brookgrove Lane             Graphics, Operating Systems, Compilers
  120. Cupertino, CA 95014             (408) 252-0456
  121. mark@zok.uucp
  122.