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 / seamcut.icn < prev    next >
Text File  |  2001-05-02  |  2KB  |  71 lines

  1. ############################################################################
  2. #
  3. #    File:     seamcut.icn
  4. #
  5. #    Subject:  Program to cut image for seamless tiling
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     May 2, 2001
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  This program takes image file names and does top/bottom separation and
  18. #  reordering, follows by the same for left and right.  The result is an
  19. #  image that tiles seamlessly, although the center part may be a mess.
  20. #
  21. #  The technique is described in Painter 2.0 Companion.
  22. #
  23. #  Files are expected to have the suffix .gif.  The corresponding files
  24. #  are given the suffix _s.gif.
  25. #
  26. ############################################################################
  27. #
  28. #  Requires:  Version 9 graphics
  29. #
  30. ############################################################################
  31. #
  32. #  Links:  basename, wopen
  33. #
  34. ############################################################################
  35.  
  36. link basename
  37. link wopen
  38.  
  39. procedure main(args)
  40.    local name, base, width, height, half_width, half_height, win1, win2
  41.  
  42.    every name := !args do {
  43.       base := basename(name, ".gif") | {
  44.          write(&errout, "*** unexpected file extension ", name)
  45.          next
  46.          }
  47.       win1 := WOpen("canvas=hidden", "image=" || name) | {
  48.          write(&errout, "*** cannot open ", name)
  49.          next
  50.          }
  51.  
  52.       width := WAttrib(win1, "width")
  53.       height := WAttrib(win1, "height")
  54.       half_width := width / 2
  55.       half_height := height / 2
  56.  
  57.       win2 := WOpen("canvas=hidden", "width=" || width, "height=" || height) |
  58.          stop("*** cannot open target window")
  59.  
  60.       CopyArea(win1, win2, 0, 0, half_width, height, half_width, 0)
  61.       CopyArea(win1, win2, half_width, 0, half_width, height, 0, 0)
  62.       EraseArea(win1)
  63.       CopyArea(win2, win1, 0, 0, width, half_height, 0, half_height)
  64.       CopyArea(win2, win1, 0, half_height, width, half_height, 0, 0)
  65.       WriteImage(win1, base || "_s.gif")
  66.       WClose(win1)
  67.       WClose(win2)
  68.       }
  69.  
  70. end
  71.