#ifndef lint static char SccsId[] = "%W% %G%"; #endif /* Module: imgflip.c (Image Flip) * Purpose: Rotate buffer 180 degrees on any orthogonal axis * Subroutine: xflip_buf() returns: void * Subroutine: yflip_buf() returns: void * Subroutine: zflip_buf() returns: void * Subroutine: transfer_buf() returns: void * Copyright: 1988 Smithsonian Astrophysical Observatory * You may do anything you like with this file except remove * this copyright. The Smithsonian Astrophysical Observatory * makes no representations about the suitability of this * software for any purpose. It is provided "as is" without * express or implied warranty. * Modified: {0} Michael VanHilst initial version 8 December 1988 * {n} -- -- */ /* Subroutine: xflip_buf * Purpose: Flip buf to make Y coordinates run in opposite direction * (upside down) */ #ifdef ANSIC void xflip_buf ( short *buf, int cols, int rows ) #else void xflip_buf ( buf, cols, rows ) short *buf; int cols, rows; #endif { register int bytes; short *linebuf; short *toprow, *botrow; char *calloc_errchk(); linebuf = (short *)calloc_errchk(cols, sizeof(short), "Temp line"); toprow = buf; botrow = buf + ((rows - 1) * cols); bytes = cols * sizeof(short); while( toprow < botrow ) { #ifdef ANSIC (void)memcpy((void *)linebuf, (void *)botrow, (size_t)bytes); (void)memcpy((void *)botrow, (void *)toprow, (size_t)bytes); (void)memcpy((void *)toprow, (void *)linebuf, (size_t)bytes); #else bcopy((char *)botrow, (char *)linebuf, bytes); bcopy((char *)toprow, (char *)botrow, bytes); bcopy((char *)linebuf, (char *)toprow, bytes); #endif toprow += cols; botrow -= cols; } free((char *)linebuf); } /* Subroutine: yflip_buf * Purpose: Mirror buf to make x coordinates run in opposite direction */ #ifdef ANSIC void yflip_buf ( short *buf, int cols, int rows ) #else void yflip_buf ( buf, cols, rows ) short *buf; int cols, rows; #endif { short *row; register short *right, *left; int wdth; int i; short temp; row = buf; wdth = cols - 1; for( i=0; i