home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / ipl / gprogs / rectile.icn < prev    next >
Text File  |  2000-07-29  |  2KB  |  64 lines

  1. ############################################################################
  2. #
  3. #    File:     rectile.icn
  4. #
  5. #    Subject:  Program to extract portion of image
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     August 26, 1996
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  This program extracts a fixed rectangle from the images given on the
  18. #  command line.
  19. #
  20. #  The supported options are:
  21. #
  22. #    -x i    x coordinate of upper-left corner of rectangle; default 0
  23. #    -y i    y coordinate of upper-left corner of rectangle; default 0
  24. #    -w i    width of rectangle; default 64
  25. #    -h i    height of rectangle; default 64
  26. #    -p s    prefix for name of saved file; default "rect_"; may be
  27. #        "", in which case the input file is overridden.
  28. #
  29. ############################################################################
  30. #
  31. #  Requires:  Version 9 graphics
  32. #
  33. ############################################################################
  34. #
  35. #  Links:  options, wopen
  36. #
  37. ############################################################################
  38.  
  39. link options
  40. link wopen
  41.  
  42. procedure main(args)
  43.    local opts, prefix, x, y, w, h, win
  44.  
  45.    opts := options(args, "x+y+w+h+p:")
  46.  
  47.    x := \opts["x"] | 0
  48.    y := \opts["y"] | 0
  49.    w := \opts["w"] | 64
  50.    h := \opts["h"] | 64
  51.    
  52.    prefix := \opts["p"] | "rect_"
  53.  
  54.    every name := !args do {
  55.       win := WOpen("canvas=hidden", "image=" || name) | {
  56.          write(&errout, "*** cannot open ", name)
  57.          next
  58.          }
  59.       WriteImage(win, prefix || name, x, y, w, h) |
  60.          write(&errout, "*** cannot write rectangle for ", name)
  61.       WClose(win)
  62.       }
  63. end
  64.