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
58
59
60
61
62
63
|
############################################################################
#
# File: rectile.icn
#
# Subject: Program to extract portion of image
#
# Author: Ralph E. Griswold
#
# Date: August 26, 1996
#
############################################################################
#
# This file is in the public domain.
#
############################################################################
#
# This program extracts a fixed rectangle from the images given on the
# command line.
#
# The supported options are:
#
# -x i x coordinate of upper-left corner of rectangle; default 0
# -y i y coordinate of upper-left corner of rectangle; default 0
# -w i width of rectangle; default 64
# -h i height of rectangle; default 64
# -p s prefix for name of saved file; default "rect_"; may be
# "", in which case the input file is overridden.
#
############################################################################
#
# Requires: Version 9 graphics
#
############################################################################
#
# Links: options, wopen
#
############################################################################
link options
link wopen
procedure main(args)
local opts, prefix, x, y, w, h, win
opts := options(args, "x+y+w+h+p:")
x := \opts["x"] | 0
y := \opts["y"] | 0
w := \opts["w"] | 64
h := \opts["h"] | 64
prefix := \opts["p"] | "rect_"
every name := !args do {
win := WOpen("canvas=hidden", "image=" || name) | {
write(&errout, "*** cannot open ", name)
next
}
WriteImage(win, prefix || name, x, y, w, h) |
write(&errout, "*** cannot write rectangle for ", name)
WClose(win)
}
end
|