summaryrefslogtreecommitdiff
path: root/ipl/gprogs/imgtolst.icn
blob: 49a498161d4f7c795bd8fb841d7b1091173ebd14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
############################################################################
#
#	File:     imgtolst.icn
#
#	Subject:  Program to convert image to list of pixel colors
#
#	Author:   Ralph E. Griswold
#
#	Date:     November 22, 1997
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
#  This program converts images to lists of pixel values.  The
#  first line of output gives the dimensions of the image.
#
#  The extension of the image file is replaced by .lst in the list
#  file.
#
############################################################################
#
#  Requires:  Version 9 graphics
#
############################################################################
#
#  Links:  basename, wattrib, wopen
#
############################################################################

link basename
link wattrib
link wopen

procedure main(args)
   local file, name, output

   every file := !args do {
      name := basename(file, ".gif")
      output := open(name || ".lst", "w") | {
         write(&errout, "*** cannot open ", name, ".lst")
         next
         }
      WOpen("canvas=hidden", "image=" || file) | {
         write(&errout, "*** cannot open ", file)
         next
         }
      write(output, "width=", Width(), " height=", Height())
      every write(output, Pixel())
      WClose()
      &window := &null
      close(output)
      }

end