/* FILE: /mxtools/src/strawman/ip_shift2d.c * PURPOSE: * AUTHOR: Kenneth J. Mighell (mighell@noao.edu) * LANGUAGE: ANSI C * DATE: 2001OCT25 * COPYRIGHT: (C) 2001 Assoc. of Universities for Research in Astronomy Inc. */ #include #include "inc.h" int ip_Shift2d_i4( struct mxip_image_s *old, double deltax, double deltay, struct mxip_image_s *new ) { char mxfunc[] = "ip_Shift2d_i3"; int mxstatus = 0; int status = 1; int nx; int ny; int nnx; int nny; int ix; int iy; int size; float *ivecd; float *ovecd; nx = old->nxi; ny = old->nyi; nnx = new->nxi; nny = new->nyi; /* Make sure that the mxip_image_s are the same size */ mxstatus++; if (nx!=nnx) { sprintf (MX.tmpmsg, "# old->nxi != new->nxi --> %d != %d\n", nx, nnx); goto mx_error2; } mxstatus++; if (ny!=nny) { sprintf (MX.tmpmsg, "# old->nyi != new->nyi --> %d != %d\n", ny, nny); goto mx_error2; } /* Allocate working vectors */ size = nx; if (ny>nx) size = ny; ivecd = (float *)calloc( size, sizeof(float)); mxstatus++; if ((float *)NULL==ivecd) { sprintf (MX.tmpmsg, "# Could not allocate ivecd with %d floats!\n", size); goto mx_error2; } ovecd = (float *)calloc( size, sizeof(float)); mxstatus++; if ((float *)NULL==ovecd) { sprintf (MX.tmpmsg, "# Could not allocate ovecd with %d floats!\n", size); goto mx_error2; } /* Shift DELTAX pixels in the X direction */ for (iy=0; iymatrixd[iy][ix]; } sshift_ansi( ivecd, nx, (float)deltax, (float)0.0, ovecd); for (ix=0; ixmatrixd[iy][ix] = ovecd[ix]; } } /* Shift DELTAY pixels in the Y direction */ for (ix=0; ixmatrixd[iy][ix]; } sshift_ansi( ivecd, ny, (float)deltay, (float)0.0, ovecd); for (iy=0; iymatrixd[iy][ix] = ovecd[iy]; } } ok: status = 0; goto bye; mx_error1: mxp_tmpmsg_init_f0(); mx_error2: mxp_errmsg_append_f3 (mxfunc, mxstatus, MX.tmpmsg); goto bye; bye: free (ivecd); free (ovecd); return(status); } /* end-of-file */