58 unsigned char *
image ;
63 "% o%-outfile!s infile%s",
64 &oflag, &outfname, &infname ) == 0 )
77 fprintf( stderr,
"%s is not RGB or b&w image",
78 infname ? infname :
"stdin" );
82 outfile =
rle_open_f(
"rletorast", outfname,
"w" );
116 buffer = (
unsigned char *)
malloc( ncol );
119 header.ras_magic = RAS_MAGIC ;
124 case GREY: nochan = 1 ; break ;
125 case COLOR: nochan = 3 ; break ;
127 default: nochan = 4;
break;
129 header.ras_depth = 8 * nochan ;
130 linebytes =
header.ras_width * nochan ;
131 linebytes += linebytes % 2 ;
133 header.ras_type = RT_STANDARD ;
136 header.ras_maptype = RMT_EQUAL_RGB ;
141 header.ras_maptype = RMT_NONE ;
142 header.ras_maplength = 0 ;
147 if(
header.ras_maptype == RMT_EQUAL_RGB )
162 nco =
header.ras_maplength ;
165 for(chan=0; chan<nch; ++chan)
167 iptr = hdr.
cmap + (chan<<8) ;
170 out = (*iptr++ + 0x80) >> 8 ;
171 fwrite(&out, 1,1, outfile) ;
179 while(*comment != NULL)
181 fprintf(stderr,
"%s\n", *comment) ;
186 image = (
unsigned char *)
malloc(linebytes *
header.ras_height) ;
190 register int row,col,chan ;
191 register unsigned char *
ptr ;
195 ptr = image + row*linebytes ;
196 for(col=ncol; --col >= 0; )
201 for(chan=hdr.
ncolors; --chan >= 0; )
212 register unsigned char *optr, *a,*
r,*
g,*
b ;
215 optr = image + (nscan-y-1+hdr.
ymin)*linebytes ;
220 for(col=ncol; --col >= 0; )
227 for(col=ncol; --col >= 0; )
230 *optr++ = *optr++ = *optr++ = *r++ ;
238 for(col=ncol; --col >= 0; )
251 for(col=ncol; --col >= 0; )
261 fwrite(image, linebytes *
header.ras_height, 1, outfile) ;
int scanargs(int argc, char **argv, const char *format,...)
int rle_row_alloc(rle_hdr *the_hdr, rle_pixel ***scanp)
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
FILE * rle_open_f(const char *prog_name, const char *f_name, const char *mode)
char * cmd_name(char **argv)
void rle_get_setup_ok(rle_hdr *the_hdr, const char *prog_name, const char *file_name)
int rle_getrow(rle_hdr *the_hdr, rle_pixel *scanline[])
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)