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 / imltogif.icn < prev    next >
Text File  |  2000-07-29  |  2KB  |  86 lines

  1. ############################################################################
  2. #
  3. #    File:     imltogif.icn
  4. #
  5. #    Subject:  Program to convert image strings to GIF files
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     May 23, 1996
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  This program converts a list of image strings given in standard input
  18. #  to corresponding GIF images.
  19. #
  20. ############################################################################
  21. #
  22. #  The options supported are:
  23. #
  24. #    -n s    sets prefix for image file names to s, default "image"
  25. #    -c i    number of columns for serial numbers in file names;
  26. #          default 4
  27. #    -f i    first number, default 1
  28. #    -p    treats image string as a pattern and fills a square
  29. #           window of its maximum dimension
  30. #
  31. ############################################################################
  32. #
  33. #  Requires:  Version 9 graphics
  34. #
  35. ############################################################################
  36. #
  37. #  Links:  imageseq, imutils, numbers, options, wopen
  38. #
  39. ############################################################################
  40.  
  41. link imageseq
  42. link imutils
  43. link numbers
  44. link options
  45. link wopen
  46.  
  47. procedure main(args)
  48.    local count, ims, image, w, h, s, opts, pattern, prefix
  49.  
  50.    count := 0
  51.  
  52.    opts := options(args, "n:c+f+p")
  53.    /opts["c"] := 4
  54.  
  55.    seq_init(opts)
  56.    pattern := opts["p"]
  57.  
  58.    while ims := read() do {
  59.       count +:= 1
  60.       w := imswidth(ims)
  61.       h := imsheight(ims)
  62.       if (w | h) = 0 then {
  63.          write(&errout, "line ", count, ": bad image string")
  64.          next
  65.          }
  66.       if \pattern then w := h := max(w,h)
  67.       image := WOpen("canvas=hidden", "size=" || w || "," || h) | {
  68.          write(&errout, "line ", count, ": cannot open window")
  69.          next
  70.          }
  71.       if \pattern then {
  72.          WAttrib(image, "fillstyle=opaquepatterned")
  73.          Pattern(image, ims)
  74.          FillRectangle(image)
  75.          }
  76.       else DrawImage(image, 0, 0, ims) | {
  77.          write(&errout, "line ", count, ":  cannot draw image")
  78.          WClose(image)
  79.          next
  80.          }
  81.       save_image(image)
  82.       WClose(image)
  83.       }
  84.  
  85. end
  86.