diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /pkg/utilities/nttools/stxtools/copyimg.x | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'pkg/utilities/nttools/stxtools/copyimg.x')
-rw-r--r-- | pkg/utilities/nttools/stxtools/copyimg.x | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/pkg/utilities/nttools/stxtools/copyimg.x b/pkg/utilities/nttools/stxtools/copyimg.x new file mode 100644 index 00000000..0248cfa9 --- /dev/null +++ b/pkg/utilities/nttools/stxtools/copyimg.x @@ -0,0 +1,78 @@ +include <imhdr.h> + +# COPYIMG -- Copy one image to another +# +# B.Simon 02-Mar-92 Original +# B.Simon 16-Mar-94 Delete fast copy, check for existing image + +procedure copyimg (old, new) + +char old[ARB] # i: old image +char new[ARB] # i: new image +#-- +int npix, junk +pointer buf1, buf2, im1, im2 +long v1[IM_MAXDIM], v2[IM_MAXDIM] + +int imaccess() +int imgnls(), imgnll(), imgnlr(), imgnld(), imgnlx() +int impnls(), impnll(), impnlr(), impnld(), impnlx() +pointer immap() + +errchk immap, imunmap + +begin + # Map the input and output images + # Code adapted from iraf's imcopy task + + im1 = immap (old, READ_ONLY, 0) + if (imaccess (new, READ_WRITE) == NO) { + im2 = immap (new, NEW_COPY, im1) + } else { + im2 = immap (new, READ_WRITE, NULL) + } + + # Setup start vector for sequential reads and writes + + call amovkl (long(1), v1, IM_MAXDIM) + call amovkl (long(1), v2, IM_MAXDIM) + + # Copy the image. + + npix = IM_LEN(im1, 1) + switch (IM_PIXTYPE(im1)) { + case TY_SHORT: + while (imgnls (im1, buf1, v1) != EOF) { + junk = impnls (im2, buf2, v2) + call amovs (Mems[buf1], Mems[buf2], npix) + } + case TY_USHORT, TY_INT, TY_LONG: + while (imgnll (im1, buf1, v1) != EOF) { + junk = impnll (im2, buf2, v2) + call amovl (Meml[buf1], Meml[buf2], npix) + } + case TY_REAL: + while (imgnlr (im1, buf1, v1) != EOF) { + junk = impnlr (im2, buf2, v2) + call amovr (Memr[buf1], Memr[buf2], npix) + } + case TY_DOUBLE: + while (imgnld (im1, buf1, v1) != EOF) { + junk = impnld (im2, buf2, v2) + call amovd (Memd[buf1], Memd[buf2], npix) + } + case TY_COMPLEX: + while (imgnlx (im1, buf1, v1) != EOF) { + junk = impnlx (im2, buf2, v2) + call amovx (Memx[buf1], Memx[buf2], npix) + } + default: + call error (1, "unknown pixel datatype") + } + + # Unmap the images + + call imunmap (im2) + call imunmap (im1) + +end |