aboutsummaryrefslogtreecommitdiff
path: root/sys/imio/imseti.x
blob: 9fd0bc2d6a5cf4b737ca911767e363aab83f1bc6 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<syserr.h>
include	<imhdr.h>
include	<imset.h>
include	<imio.h>
include	<fset.h>

# IMSETI -- Set an IMIO parameter of type integer (or pointer).  For
# completeness this routine can be used to set real valued parameters, but
# obviously since the input value is integer a fractional value cannot be
# set.

procedure imseti (im, param, value)

pointer	im			#I image descriptor
int	param			#I parameter to be set
int	value			#I integer value of parameter

int	i
pointer	ibdes
errchk	calloc

begin
	switch (param) {
	case IM_ADVICE:
	    IM_VADVICE(im) = value
	case IM_BUFSIZE:
	    IM_VBUFSIZE(im) = value
	case IM_BUFFRAC:
	    IM_VBUFFRAC(im) = value
	case IM_BUFMAX:
	    IM_VBUFMAX(im) = value
	case IM_COMPRESS:
	    IM_VCOMPRESS(im) = value
	case IM_NBNDRYPIX:
	    IM_VNBNDRYPIX(im) = max (0, value)
	case IM_TYBNDRY:
	    IM_VTYBNDRY(im) = value
	case IM_BNDRYPIXVAL:
	    IM_OOBPIX(im) = real(value)
	case IM_FLAGBADPIX:
	    IM_VFLAGBADPIX(im) = value
	case IM_PIXFD:
	    IM_PFD(im) = value
	case IM_WHEADER:
	    IM_UPDATE(im) = value

	case IM_PLDES:
	    IM_PL(im) = value
	case IM_RLIO:
	    # Enable/disable range list i/o (for image masks).
	    if (value == YES)
		IM_PLFLAGS(im) = or (IM_PLFLAGS(im), PL_RLIO)
	    else
		IM_PLFLAGS(im) = and (IM_PLFLAGS(im), not(PL_RLIO))

	case IM_NBUFS:
	    # Free any existing input buffers.
	    ibdes = IM_IBDES(im)
	    if (ibdes != NULL)
		for (i=0;  i < IM_VNBUFS(im);  i=i+1)
		    call mfree (BD_BUFPTR(ibdes + LEN_BDES * i), TY_CHAR)

	    # Change size of buffer pool.
	    IM_VNBUFS(im) = value

	    # Reinit input buffer descriptors.  The actual input buffers will
	    # be reallocated upon demand.

	    if (ibdes != NULL) {
		call mfree (IM_IBDES(im), TY_STRUCT)
		call calloc (IM_IBDES(im), LEN_BDES * IM_VNBUFS(im), TY_STRUCT)
		IM_NGET(im) = 0
	    }

	case IM_CANCEL:
	    # Free any pixel data buffers associated with an image.
	    call imrmbufs (im)

	case IM_CLOSEFD:
	    # Set F_CLOSEFD on the pixel file.
	    IM_VCLOSEFD(im) = value
	    if (IM_PFD(im) != NULL)
		call fseti (IM_PFD(im), F_CLOSEFD, value)

	default:
	    call imerr (IM_NAME(im), SYS_IMSETUNKPAR)
	}
end