*** ../../tools/avg4.c	Thu Jan 23 11:19:48 1992
--- /tmp/avg2.c	Fri Feb 21 14:26:35 1992
***************
*** 16,25 ****
   * and the reason for such modification.
   */
  /* 
!  * avg4.c - Reduce image by half in X and Y, producing alphas even
   *          if they weren't there originally.
   * 
!  * Author:	Rod Bogart & John W. Peterson
   * 		Computer Science Dept.
   * 		University of Utah
   * Date:	Fri Jun 20 1986
--- 16,27 ----
   * and the reason for such modification.
   */
  /* 
!  * avg2.c - Reduce image by half in X, producing alphas even
   *          if they weren't there originally.
   * 
!  * Author:	Kriton Kyrimis
!  *    Based on avg4 by:
!  *		Rod Bogart & John W. Peterson
   * 		Computer Science Dept.
   * 		University of Utah
   * Date:	Fri Jun 20 1986
***************
*** 34,41 ****
  #include <stdio.h>
  #include "rle.h"
  
! static bit_count[16] = {0, 63, 63, 127, 63, 127, 127,
!     192, 63, 127, 127, 192, 127, 192, 192, 255};
  
  void
  main(argc, argv)
--- 36,42 ----
  #include <stdio.h>
  #include "rle.h"
  
! static bit_count[4] = {0, 127, 127, 255};
  
  void
  main(argc, argv)
***************
*** 53,59 ****
      int		rle_err;
      rle_hdr 	in_hdr, out_hdr;
      rle_pixel **rows0, **rows1, **rowsout;
!     rle_pixel *ptr0, *ptr1, *ptrout, *alphptr;
      int		A, chan;
      
      in_hdr = *rle_hdr_init( NULL );
--- 54,60 ----
      int		rle_err;
      rle_hdr 	in_hdr, out_hdr;
      rle_pixel **rows0, **rows1, **rowsout;
!     rle_pixel *ptr0, *ptrout, *alphptr;
      int		A, chan;
      
      in_hdr = *rle_hdr_init( NULL );
***************
*** 78,86 ****
  	rle_addhist( argv, &in_hdr, &out_hdr );
  
  	new_xlen = (in_hdr.xmax - in_hdr.xmin +1 ) / 2;
! 	new_ylen = (in_hdr.ymax - in_hdr.ymin +1 ) / 2;
  	out_hdr.xmin = in_hdr.xmin / 2;
! 	out_hdr.ymin = in_hdr.ymin / 2;
  	out_hdr.xmax = out_hdr.xmin + new_xlen - 1;
  	out_hdr.ymax = out_hdr.ymin + new_ylen - 1;
  
--- 79,87 ----
  	rle_addhist( argv, &in_hdr, &out_hdr );
  
  	new_xlen = (in_hdr.xmax - in_hdr.xmin +1 ) / 2;
! 	new_ylen = (in_hdr.ymax - in_hdr.ymin +1 );
  	out_hdr.xmin = in_hdr.xmin / 2;
! 	out_hdr.ymin = in_hdr.ymin;
  	out_hdr.xmax = out_hdr.xmin + new_xlen - 1;
  	out_hdr.ymax = out_hdr.ymin + new_ylen - 1;
  
***************
*** 92,98 ****
  
  	/* Oink. */
  	if ( rle_row_alloc( &in_hdr, &rows0 ) < 0 ||
- 	     rle_row_alloc( &in_hdr, &rows1 ) < 0 ||
  	     rle_row_alloc( &out_hdr, &rowsout ) < 0 )
  	    RLE_CHECK_ALLOC( cmd, 0, "image" );
  
--- 93,98 ----
***************
*** 99,110 ****
  	for ( j = 0; j < new_ylen*2; j+=2 )
  	{
  	    rle_getrow(&in_hdr, rows0 );
- 	    rle_getrow(&in_hdr, rows1 );
  
  	    for (chan = RLE_ALPHA; chan < in_hdr.ncolors; chan++)
  	    {
  		ptr0 = &(rows0[chan][in_hdr.xmin]);
- 		ptr1 = &(rows1[chan][in_hdr.xmin]);
  		ptrout = rowsout[chan];
  		alphptr = rowsout[RLE_ALPHA];
  		/*
--- 99,108 ----
***************
*** 123,130 ****
  		{
  		    if (!in_hdr.alpha)
  		    {
! 			*alphptr |= (*ptr0 ? 1 : 0) | (ptr0[1] ? 2 : 0) |
! 			    (*ptr1 ? 4 : 0) | (ptr1[1] ? 8 : 0);
  
  			/* calc fake alpha from bit count */
  			if (chan == (in_hdr.ncolors - 1))
--- 121,127 ----
  		{
  		    if (!in_hdr.alpha)
  		    {
! 			*alphptr |= (*ptr0 ? 1 : 0) | (ptr0[1] ? 2 : 0);
  
  			/* calc fake alpha from bit count */
  			if (chan == (in_hdr.ncolors - 1))
***************
*** 132,140 ****
  
  			alphptr++;
  		    }
! 		    A  = (int) *ptr0++ + (int) *ptr1++;
! 		    A += (int) *ptr0++ + (int) *ptr1++;
! 		    *ptrout++ = (rle_pixel) (A / 4);
  		}
  	    }
  	    rle_putrow( rowsout, new_xlen, &out_hdr );
--- 129,137 ----
  
  			alphptr++;
  		    }
! 		    A  = (int) *ptr0++;
! 		    A += (int) *ptr0++;
! 		    *ptrout++ = (rle_pixel) (A / 2);
  		}
  	    }
  	    rle_putrow( rowsout, new_xlen, &out_hdr );
***************
*** 142,148 ****
  	rle_puteof( &out_hdr );
  
  	rle_row_free( &in_hdr, rows0 );
- 	rle_row_free( &in_hdr, rows1 );
  	rle_row_free( &out_hdr, rowsout );
      }
  
--- 139,144 ----
