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 / gif2rows.icn < prev    next >
Text File  |  2002-01-24  |  1KB  |  49 lines

  1. ############################################################################
  2. #
  3. #    File:     gif2rows.icn
  4. #
  5. #    Subject:  Program to convert B&W GIF to 0/1 rows
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     August 11, 2001
  10. #
  11. ############################################################################
  12. #
  13. #  This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  AD HOC.  Assumes any non-black pixel is white.
  18. #
  19. ############################################################################
  20. #
  21. #  Requires:  Version 9 graphics
  22. #
  23. ############################################################################
  24. #
  25. #  Links:  wopen
  26. #
  27. ############################################################################
  28.  
  29. link wopen
  30.  
  31. procedure main(args)
  32.    local width, height, row, p, y
  33.  
  34.    WOpen("image=" || args[1], "canvas=hidden") |
  35.       stop("*** cannot open image")
  36.  
  37.    width := WAttrib("width")
  38.    height := WAttrib("height")
  39.  
  40.    every y := 0 to height - 1 do {
  41.       row := ""
  42.       every p := Pixel(0, y, width, 1) do
  43.          if ColorValue(p) == "0,0,0" then row ||:= "1"
  44.             else row ||:= "0"
  45.       write(row)
  46.       }
  47.  
  48. end
  49.