/* * This software is copyrighted as noted below. It may be freely copied, * modified, and redistributed, provided that the copyright notices are * preserved on all copies. * * There is no warranty or other guarantee of fitness for this software, * it is provided solely "as is". Bug reports or fixes may be sent * to the author, who may or may not act on them as he desires. * * You may not include this software in a program or other software product * without supplying the source, or without informing the end-user that the * source is available for no extra charge. * * If you modify this software, you should include a notice giving the * name of the person performing the modification, the date of modification, * and the reason for such modification. */ /* * graytorle.c - Create an RLE image from gray pixels. * * Author: Michael J. Banks * Computer Science Dept. * University of Utah * Date: Wed Jun 22 1988 * Copyright (c) 1988, University of Utah */ #include #include "rle.h" #ifdef USE_STDLIB_H #include #else #ifdef VOID_STAR extern void *malloc(); #else extern char *malloc(); #endif extern void free(); #endif /* USE_STDLIB_H */ typedef FILE *FILPTR; /* * usage : graytorle xsize ysize [-h hdrsize] [-o outfile] [-a] files ... * * xsize,ysize Size of input files. * -h hdrsize Input file header to discard. * -o outfile Output file name. * -a Uses first input file as alpha channel. */ void main(argc, argv) int argc; char *argv[]; { int hflag = 0; /* Header size flag */ int aflag = 0; /* Alpha channel flag. */ int stdin_used = 0; char *oname = NULL; /* Output file name. */ FILE **inpfil; /* Input file pointers. */ int xsize, ysize; /* Image size. */ int hsize; /* Image header size. */ int oflag; /* Output file flag. */ int files; /* Number of files. */ char **fname; /* List of input file names. */ rle_pixel **outrow; /* Output buffer. */ int i, row; char *trash; if (! scanargs( argc,argv, "% a%- h%-hdrsize!d o%-outfile!s xsize!d ysize!d files!*s", &aflag, &hflag, &hsize, &oflag, &oname, &xsize, &ysize, &files, &fname )) exit( -1 ); /* * Get enough file pointers for all input files that are specified, * and try to open them. */ inpfil = (FILE **)malloc( sizeof( FILE * ) * files ); for ( i=0; i 0) ) { trash = (char *)malloc( hsize ); for ( i=0; i