home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume26 / pico / part01 / README < prev    next >
Encoding:
Text File  |  1991-12-14  |  5.0 KB  |  128 lines

  1. pico -- 1st approximation, Byron Rakitzis, 12/10/91.
  2.  
  3. This is a first stab at an implementation of pico, the picture editor
  4. from Bell Labs described in Gerard Holzman's book "The Digital
  5. Darkroom".
  6.  
  7. This program is *not* a full-blown implementation of pico. However, I
  8. think the code is interesting enough that someone might be able to do
  9. something quite useful with it without too much effort.
  10.  
  11. HOW TO BUILD PICO:
  12.  
  13. Pico runs on SGI's and Sun-4's. Edit the Makefile to get the right 
  14. compiler and LDFLAGS. On a Sun4, you will need gcc or Sun's ansi
  15. cc, since pico is written with prototypes and new-style definitions.
  16.  
  17. HOW TO USE IT:
  18.  
  19. There are two options to pico, "-n" and "-d". "-n" suppresses the
  20. display output, and "-d" provides an assembly dump of the generated
  21. code after each expression is typed (using "dis" on the SGI and "adb"
  22. on the Sun).
  23.  
  24. If you type "pico" you are prompted with a ">". You can now try typing
  25. in a C expression involving x and y. The greyscale value of the point
  26. [x,y] is determined by the value of the expression you type. e.g.,
  27.  
  28.     > x+y
  29.  
  30. creates a series of diagonal bands, since at x+y == 256 the grey
  31. value wraps from white to black. x*y is striking, as is x^y, x*x+y*y
  32. and many others.
  33.  
  34. You can refer to the current image as old[x,y], e.g.,
  35.  
  36.     > old[y,x]
  37.  
  38. rotates the current image 90 degrees. The "u" command performs one
  39. level of undo, alternating between the current and previous images.
  40.  
  41. If you create a file that you like, you can write it out (in pgm
  42. format) with the "w" command. Use double quotes to quote any special
  43. characters in the filename. i.e.,
  44.  
  45.     > w foo
  46. but
  47.     > w "/tmp/foo"
  48.  
  49. Similarly, "r" can be used to read pgm files (which for now must be
  50. 512x512, 8-bit greyscale images).
  51.  
  52. Once you have a file, you can always refer to it by the shorthand "$n"
  53. where n is the number of the file in the order it was read/written.
  54. Type "f" to see what files you have in memory.
  55.  
  56. For example, to combine chris and dmr (the two sample bitmaps in the
  57. ftp directory) so that chris fades into dmr from left to right, you can
  58. try:
  59.  
  60.     > r dmr
  61.     > r chris
  62.     > (x*dmr + (X-x)*chris) / (2*X)
  63.         [this can also be entered as]
  64.     > (x*$1 + (X-x)*$2) / (2*X)
  65.  
  66. to reflect dmr's face along the line y=256, do:
  67.  
  68.     y < Y/2 ? dmr[x,Y-y] : dmr
  69.  
  70. (X refers to the constant 512, the maximum x coordinate. The other
  71. built in constants are Y (obvious) and Z, the maximum brightness level,
  72. 255.)
  73.  
  74. Finally, to quit type "q" or control-D.
  75.  
  76. HOW IT WORKS:
  77.  
  78. The program is made up of a parser of C expressions, a simple rd code
  79. generator for the MIPS and SPARC architectures, minimal display support
  80. for the GL (Silicon Graphics) library, and file I/O in pgm format. The
  81. image format is hardcoded at 512*512, 8-bit greyscale. An expression is
  82. compiled straight into an array and then gets called by pico in order
  83. to perform the operations on the image as fast as possible. This pico
  84. is at least an order of magnitude faster (if not more) than the popi
  85. posted to the net a few months back.
  86.  
  87. To use this program you must be on an SGI or a Sun. The Sun version
  88. currently has no visual support, so you must explicitly write out pgm
  89. files and use "xloadimage" or some similar program to view the pico
  90. output.
  91.  
  92. THINGS TO DO:
  93.  
  94. I would consider extending the program in the following ways, though I
  95. don't have the time for it right now:
  96.  
  97. 1) Support different displays. Since the format of pico images is so
  98. simple, 8-bit greyscale, it should be easy to pop up images on just
  99. about any kind of computer with a color display. I have used pico
  100. crudely under X-windows by writing a pgm file out to /tmp and then
  101. running "xloadimage /tmp/pico" in order to view the file.
  102.  
  103. 2) Extend the pico language. Right now only C expressions are
  104. supported.  The only two variables recognized are x and y. This is a
  105. drawback, but as I mentioned, this isn't a full-blown pico. The command
  106. set is limited to r, w, f, u, q. (read, write, showfiles, undo, quit)
  107.  
  108. 3) Add support for polar coordinates, transcendental functions, and so
  109. on. The current implementation works only with the MIPS integer unit,
  110. i.e., add, subtract, multiply, divide and the bit operations. The SPARC
  111. port is even cruder; a function call is made for every multiply, divide
  112. and mod operation, since there is no hardware multiply etc.  A future
  113. version may address this problem by performing strength reduction on
  114. loops, but this is really beyond the scope of the project I started.
  115. (However, I do perform strength reduction on power of 2 multiplies
  116. and divides by substituting a shift.)
  117.  
  118. 4) Support color images. A very interesting project would be to support
  119. arbitrary 32-bit color images, i.e., with alpha channel. This might
  120. actually be of use to people who need to, say, boost the alpha channel
  121. of a particular image file. This also entails supporting "real" image
  122. file formats like rla.
  123.  
  124. 4) Support new architectures. I wrote pico on the MIPS, and spent about
  125. 2 afternoons porting it to the SPARC. Consequently, the quality of the
  126. SPARC port is probably quite mediocre. Porting to other RISC machines,
  127. however should be equally straightforward.
  128.