43 static char rcsid[] =
"$Header: /tmp_mnt/n/itn/hendrix/u/spencer/RCS/rletopaint.c,v 3.0.1.3 1992/04/30 14:00:05 spencer Exp spencer $";
53 #define MIN(x,y) ( (x) < (y) ? (x) : (y) )
65 int dmgray[8][8] = { 0 ,128 , 32 ,160 , 8 ,136 , 40 ,168 ,
66 192 , 64 ,224 , 96 ,200 , 72 ,232 ,104 ,
67 48 ,176 , 16 ,144 , 56 ,184 , 24 ,152 ,
68 240 ,112 ,208 , 80 ,248 ,120 ,216 , 88 ,
69 12 ,140 , 44 ,172 , 4 ,132 , 36 ,164 ,
70 204 , 76 ,236 ,108 ,196 , 68 ,228 ,100 ,
71 60 ,188 , 28 ,156 , 52 ,220 , 20 ,148 ,
72 252 ,124 ,220 , 92 ,244 ,116 ,212 ,84 } ;
75 void write_paint_line(), bytes_to_bits();
85 int gamma_flag = 0, oflag = 0;
87 char * fname = NULL, * out_fname = NULL;
90 if (
scanargs( argc
, argv
, "% r%- l%- g%-gamma%f o%-outfile!s infile%s",
92 &gamma_flag
, &gam
, &oflag
, &out_fname
, &fname
) == 0)
95 if (gamma_flag) linear_flag = 0;
108 fprintf(stderr,
"%s: malloc failed\n",
hdr.cmd);
113 for ( i = 0; i < 256; i++ )
118 gammamap[i] = (
int)(0.5 + 255 * pow( i / 255.0, 1.0/gam ));
122 for (i = 0; i < 512; i++)
125 for (i = 0; i < 72; i++)
131 databytes = compress_line();
133 write_paint_line(databytes, out_fp);
139 write_paint_line(compress_line(), out_fp);
145 for (i = 0; i < 72; i++)
148 databytes = compress_line();
150 write_paint_line(databytes, out_fp);
157 write_paint_line(num, fp)
162 for (j = 0; j < num; j++)
174 register unsigned char *r, *g, *b;
175 register int i, col, row;
184 for (i = 0; i < 72; i++)
192 for ( row = y % 8, col = 0, i = 0;
194 i++, r++, g++, b++, col = ((col + 1) & 7) )
203 if (pixel < 0) pixel += 256;
206 pixel = ((pixel >
dmgray[col][row]) ? W : B);
209 rawbits[(i / 8)] |= pixel << (7-(i % 8));
226 int i,j,k = 0,cntpsn,count = 0;
256 for( k=i; k<72; k++ )
273 pixel = -1 * (count-1);
288 for( k=i+1; k<72; k++ )
336 for ( j = 0; j < k; j++ )
FILE * rle_open_f(char *prog_name, char *file_name, char *mode)
unsigned char rawbits[73]
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
char * cmd_name(char **argv)
void main(int argc, char **argv)
int rle_row_alloc(rle_hdr *the_hdr, rle_pixel ***scanp)
int rle_getrow(rle_hdr *the_hdr, scanline)
int scanargs(int argc, char **argv, const char *format,...)
void rle_get_setup_ok(rle_hdr *the_hdr, const char *prog_name, const char *file_name)
unsigned char squishedbits[74]
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)