aboutsummaryrefslogtreecommitdiff
path: root/noao/imred/ccdred/src/setoutput.x
blob: b401b5aa85b879fdd8c40b21fc28e14ac8f8fc4d (plain) (blame)
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
include	<imhdr.h>
include	<imset.h>

# SET_OUTPUT -- Setup the output image.
# The output image is a NEW_COPY of the input image.
# The user may select a pixel datatype with higher precision though not
# lower.

procedure set_output (in, out, output)

pointer	in			# Input IMIO pointer to copy
pointer	out			# Output IMIO pointer
char	output[SZ_FNAME]	# Output image name

int	i, clscan(), nscan()
char	type[1]
pointer	immap()
errchk	immap

begin
	out = immap (output, NEW_COPY, in)
	IM_PIXTYPE(out) = TY_REAL
	if (clscan ("pixeltype")  != EOF) {
	    call gargwrd (type, 1)
	    if (nscan() == 1) {
		i = IM_PIXTYPE(in)
		IM_PIXTYPE(out) = i
		switch (type[1]) {
		case 's':
		    if (i == TY_USHORT)
			IM_PIXTYPE(out) = TY_SHORT
		case 'u':
		    if (i == TY_SHORT)
			IM_PIXTYPE(out) = TY_USHORT
		case 'i':
		    if (i == TY_SHORT || i == TY_USHORT)
			IM_PIXTYPE(out) = TY_INT
		case 'l':
		    if (i == TY_SHORT || i == TY_USHORT || i == TY_INT)
			IM_PIXTYPE(out) = TY_LONG
		case 'r':
		    if (i != TY_DOUBLE)
			IM_PIXTYPE(out) = TY_REAL
		case 'd':
		    IM_PIXTYPE(out) = TY_DOUBLE
		default:
		    call imunmap (out)
		    call error (0, "Unknown pixel type")
		}
	    }
	}
end