1*** ../../tools/avg4.c Thu Jan 23 11:19:48 1992 2--- /tmp/avg2.c Fri Feb 21 14:26:35 1992 3*************** 4*** 16,25 **** 5 * and the reason for such modification. 6 */ 7 /* 8! * avg4.c - Reduce image by half in X and Y, producing alphas even 9 * if they weren't there originally. 10 * 11! * Author: Rod Bogart & John W. Peterson 12 * Computer Science Dept. 13 * University of Utah 14 * Date: Fri Jun 20 1986 15--- 16,27 ---- 16 * and the reason for such modification. 17 */ 18 /* 19! * avg2.c - Reduce image by half in X, producing alphas even 20 * if they weren't there originally. 21 * 22! * Author: Kriton Kyrimis 23! * Based on avg4 by: 24! * Rod Bogart & John W. Peterson 25 * Computer Science Dept. 26 * University of Utah 27 * Date: Fri Jun 20 1986 28*************** 29*** 34,41 **** 30 #include <stdio.h> 31 #include "rle.h" 32 33! static bit_count[16] = {0, 63, 63, 127, 63, 127, 127, 34! 192, 63, 127, 127, 192, 127, 192, 192, 255}; 35 36 void 37 main(argc, argv) 38--- 36,42 ---- 39 #include <stdio.h> 40 #include "rle.h" 41 42! static bit_count[4] = {0, 127, 127, 255}; 43 44 void 45 main(argc, argv) 46*************** 47*** 53,59 **** 48 int rle_err; 49 rle_hdr in_hdr, out_hdr; 50 rle_pixel **rows0, **rows1, **rowsout; 51! rle_pixel *ptr0, *ptr1, *ptrout, *alphptr; 52 int A, chan; 53 54 in_hdr = *rle_hdr_init( NULL ); 55--- 54,60 ---- 56 int rle_err; 57 rle_hdr in_hdr, out_hdr; 58 rle_pixel **rows0, **rows1, **rowsout; 59! rle_pixel *ptr0, *ptrout, *alphptr; 60 int A, chan; 61 62 in_hdr = *rle_hdr_init( NULL ); 63*************** 64*** 78,86 **** 65 rle_addhist( argv, &in_hdr, &out_hdr ); 66 67 new_xlen = (in_hdr.xmax - in_hdr.xmin +1 ) / 2; 68! new_ylen = (in_hdr.ymax - in_hdr.ymin +1 ) / 2; 69 out_hdr.xmin = in_hdr.xmin / 2; 70! out_hdr.ymin = in_hdr.ymin / 2; 71 out_hdr.xmax = out_hdr.xmin + new_xlen - 1; 72 out_hdr.ymax = out_hdr.ymin + new_ylen - 1; 73 74--- 79,87 ---- 75 rle_addhist( argv, &in_hdr, &out_hdr ); 76 77 new_xlen = (in_hdr.xmax - in_hdr.xmin +1 ) / 2; 78! new_ylen = (in_hdr.ymax - in_hdr.ymin +1 ); 79 out_hdr.xmin = in_hdr.xmin / 2; 80! out_hdr.ymin = in_hdr.ymin; 81 out_hdr.xmax = out_hdr.xmin + new_xlen - 1; 82 out_hdr.ymax = out_hdr.ymin + new_ylen - 1; 83 84*************** 85*** 92,98 **** 86 87 /* Oink. */ 88 if ( rle_row_alloc( &in_hdr, &rows0 ) < 0 || 89- rle_row_alloc( &in_hdr, &rows1 ) < 0 || 90 rle_row_alloc( &out_hdr, &rowsout ) < 0 ) 91 RLE_CHECK_ALLOC( cmd, 0, "image" ); 92 93--- 93,98 ---- 94*************** 95*** 99,110 **** 96 for ( j = 0; j < new_ylen*2; j+=2 ) 97 { 98 rle_getrow(&in_hdr, rows0 ); 99- rle_getrow(&in_hdr, rows1 ); 100 101 for (chan = RLE_ALPHA; chan < in_hdr.ncolors; chan++) 102 { 103 ptr0 = &(rows0[chan][in_hdr.xmin]); 104- ptr1 = &(rows1[chan][in_hdr.xmin]); 105 ptrout = rowsout[chan]; 106 alphptr = rowsout[RLE_ALPHA]; 107 /* 108--- 99,108 ---- 109*************** 110*** 123,130 **** 111 { 112 if (!in_hdr.alpha) 113 { 114! *alphptr |= (*ptr0 ? 1 : 0) | (ptr0[1] ? 2 : 0) | 115! (*ptr1 ? 4 : 0) | (ptr1[1] ? 8 : 0); 116 117 /* calc fake alpha from bit count */ 118 if (chan == (in_hdr.ncolors - 1)) 119--- 121,127 ---- 120 { 121 if (!in_hdr.alpha) 122 { 123! *alphptr |= (*ptr0 ? 1 : 0) | (ptr0[1] ? 2 : 0); 124 125 /* calc fake alpha from bit count */ 126 if (chan == (in_hdr.ncolors - 1)) 127*************** 128*** 132,140 **** 129 130 alphptr++; 131 } 132! A = (int) *ptr0++ + (int) *ptr1++; 133! A += (int) *ptr0++ + (int) *ptr1++; 134! *ptrout++ = (rle_pixel) (A / 4); 135 } 136 } 137 rle_putrow( rowsout, new_xlen, &out_hdr ); 138--- 129,137 ---- 139 140 alphptr++; 141 } 142! A = (int) *ptr0++; 143! A += (int) *ptr0++; 144! *ptrout++ = (rle_pixel) (A / 2); 145 } 146 } 147 rle_putrow( rowsout, new_xlen, &out_hdr ); 148*************** 149*** 142,148 **** 150 rle_puteof( &out_hdr ); 151 152 rle_row_free( &in_hdr, rows0 ); 153- rle_row_free( &in_hdr, rows1 ); 154 rle_row_free( &out_hdr, rowsout ); 155 } 156 157--- 139,144 ---- 158