From fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 8 Jul 2015 20:46:52 -0400 Subject: Initial commit --- sys/imio/impl2.gx | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 sys/imio/impl2.gx (limited to 'sys/imio/impl2.gx') diff --git a/sys/imio/impl2.gx b/sys/imio/impl2.gx new file mode 100644 index 00000000..545d2ed3 --- /dev/null +++ b/sys/imio/impl2.gx @@ -0,0 +1,47 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include +include +include + +# IMPL2? -- Put a line to an apparently two 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 impl2$t (im, linenum) + +pointer im # image header pointer +int linenum # line to be written + +int fd, nchars +long vs[2], ve[2], offset +pointer bp, impgs$t(), fwritep() +errchk imopsf, imerr + +begin + repeat { + if (IM_FAST(im) == YES && IM_PIXTYPE(im) == TY_PIXEL) { + fd = IM_PFD(im) + if (fd == NULL) { + call imopsf (im) + next + } + if (linenum < 1 || linenum > IM_LEN(im,2)) + call imerr (IM_NAME(im), SYS_IMREFOOB) + + offset = (linenum - 1) * IM_PHYSLEN(im,1) * SZ_PIXEL + + IM_PIXOFF(im) + nchars = IM_PHYSLEN(im,1) * SZ_PIXEL + ifnoerr (bp = (fwritep (fd, offset, nchars) - 1) / SZ_PIXEL + 1) + return (bp) + } + + vs[1] = 1 + ve[1] = IM_LEN(im,1) + vs[2] = linenum + ve[2] = linenum + + return (impgs$t (im, vs, ve, 2)) + } +end -- cgit