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 / gifs2pdb.icn < prev    next >
Text File  |  2000-07-29  |  1KB  |  57 lines

  1. ############################################################################
  2. #
  3. #    File:     gifs2pdb.icn
  4. #
  5. #    Subject:  Program to produce custom palettes from GIF images
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     April 13, 2000
  10. #
  11. ############################################################################
  12. #
  13. #  This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  This program makes a custom palette database from the colors in GIF
  18. #  images
  19. #
  20. ############################################################################
  21. #
  22. #  Requires:  Version 9 graphics  
  23. #
  24. ############################################################################
  25. #
  26. #  Links:  basename, palettes, wopen, xcode
  27. #
  28. ############################################################################
  29.  
  30. link basename
  31. link palettes
  32. link wopen
  33. link xcode
  34.  
  35. global PDB_
  36.  
  37. procedure main(args)
  38.    local file, name, output, colors, win
  39.  
  40.    every file := !args do {
  41.       win := WOpen("image=" || file, "canvas=hidden") | {
  42.           write(&errout, "*** cannot open image: ", image(file))
  43.           next
  44.           }
  45.       name := basename(file, ".gif")
  46.       colors := set()
  47.       every insert(colors, Pixel(win, 0, 0, WAttrib(win, "width"),
  48.          WAttrib(win, "height")))
  49.       WClose(win)
  50.       makepalette(name, sort_colors(colors)) |
  51.          write(&errout, "*** cannot make palette from ", image(file))
  52.       }
  53.  
  54.     xencode(PDB_, &output)
  55.  
  56. end
  57.