aboutsummaryrefslogtreecommitdiff
path: root/sys/imio/tf/impl3s.x
blob: 63da06e260b44362c0a6df891ca39bb07e849110 (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
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

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

# IMPL3? -- Put a line to an apparently three dimensional image.  If there
# is only one input buffer, no image section, we are not referencing out of
# bounds, and no datatype conversion needs to be performed, directly access
# the pixels to reduce the overhead per line.

pointer procedure impl3s (im, line, band)

pointer	im		# image header pointer
int	line		# line number within band
int	band		# band number

int	fd, nchars
long	vs[3], ve[3], offset
pointer	bp, impgss(), fwritep()
errchk	imopsf, imerr

begin
	repeat {
	    if (IM_FAST(im) == YES && IM_PIXTYPE(im) == TY_SHORT) {
		fd = IM_PFD(im)
		if (fd == NULL) {
		    call imopsf (im)
		    next
		}
		if (line < 1 || line > IM_LEN(im,2) ||
		    band < 1 || band > IM_LEN(im,3))
		    call imerr (IM_NAME(im), SYS_IMREFOOB)

		offset = (((band - 1) * IM_PHYSLEN(im,2) + line - 1) *
		    IM_PHYSLEN(im,1)) * SZ_SHORT + IM_PIXOFF(im)
		nchars = IM_PHYSLEN(im,1) * SZ_SHORT
		ifnoerr (bp = (fwritep (fd, offset, nchars) - 1) / SZ_SHORT + 1)
		    return (bp)
	    }

	    vs[1] = 1
	    ve[1] = IM_LEN(im,1)
	    vs[2] = line
	    ve[2] = line
	    vs[3] = band
	    ve[3] = band

	    return (impgss (im, vs, ve, 3))
	}
end