/* Write one row of pixel values */
inline void write_one_line(pixel* line, int cols, FILE* outfile)
{
-
int i, index;
unsigned int* maptable;
-void initbuffers(int multi, int comp) {
+void initbuffers(int multi, int comp)
+{
int i;
c_cscanline[i] = c_cscanl0[i] + (LEFTMARGIN-1);
}
-void closebuffers(int multi) {
+void closebuffers(int multi)
+{
- int i;
+ int i;
fclose(in);
if (multi==0)
- fclose(out);
- else
- for (i=0;i<components;i++)
- fclose(c_out[i]);
+ fclose(out);
+ else
+ for (i=0;i<components;i++)
+ fclose(c_out[i]);
- free(pscanl0);
- free(cscanl0);
+ free(pscanl0);
+ free(cscanl0);
}
-
-
-int initialize(int argc, char *argv[]) {
+/* command line argument parsing */
+int initialize(int argc, char *argv[])
+{
char *infilename = NULL,
*outfilename = OUTFILE ".out",
*c_outfilename[MAX_COMPONENTS],
void usage()
{
fprintf(stderr,"Usage: %s [flags] [infile] [outfile1 [outfile2, ...]]\n\
-DEFAULTS:\n\
-infile = %s.\n\
-outfile1 = %s for color image in a single (PPM) output file.\n\
-outfile1 = %s for monochrome image in a single (PGM) output file.\n\
-outfile[1,2,...] = %s for multiple (PGM) output files \n\
- in plane or line interleaved modes.\n",
+ DEFAULTS:\n\
+ infile = %s.\n\
+ outfile1 = %s for color image in a single (PPM) output file.\n\
+ outfile1 = %s for monochrome image in a single (PGM) output file.\n\
+ outfile[1,2,...] = %s for multiple (PGM) output files \n\
+ in plane or line interleaved modes.\n",
"locod", "specified JLS file", OUTFILE ".out",
OUTFILE "1.out",
OUTFILE "[1,2,...].out");
-fprintf(stderr,"FLAGS:\n\
-outfile2, ... : Multiple output specification for plane or line int. mode.\n\
--i<infile> : Alternate input specification, use -i- for stdin.\n\
--o<outfile> : Alternate output specification, use -o- for stdout.\n\
--P : Generate single (.ppm) output file for sample/line int. mode.\n\
-");
- fprintf(stderr,"\
--h : Print this help.\n\
-*** No spaces allowed between a flag and its argument.\n\
-");
+ fprintf(stderr,"FLAGS:\n\
+ outfile2, ... : Multiple output specification for plane or line int. mode.\n\
+ -i<infile> : Alternate input specification, use -i- for stdin.\n\
+ -o<outfile> : Alternate output specification, use -o- for stdout.\n\
+ -P : Generate single (.ppm) output file for sample/line int. mode.\n\
+ ");
+ fprintf(stderr,"\
+ -h : Print this help.\n\
+ *** No spaces allowed between a flag and its argument.\n\
+ ");
}
void bad_flag(char *s)
{
- fprintf(stderr,"Bad flag %s\n",s);
- usage();
- exit(10);
+ fprintf(stderr,"Bad flag %s\n",s);
+ usage();
+ exit(10);
}
/*** watch it! actual pixels in the scan line are numbered 1 to no .
pixels with indices < 1 or > no are dummy "border" pixels */
{
- int i, psfix;
+ int i;
pixel Ra, Rb, Rc, Rd;
int SIGN;
int cont;
int run_int_type;
- psfix = 0;
-
/**********************************************/
/* Do for all pixels in the row in 8-bit mode */
/**********************************************/
/*** watch it! actual pixels in the scan line are numbered 1 to no .
pixels with indices < 1 or > no are dummy "border" pixels */
{
- int i, psfix, n_c, color, enter_run=0, was_in_run = 0,
+ int i, n_c, color, was_in_run = 0,
test_run;
pixel Ra, Rb, Rc, Rd;
pixel c_aa[MAX_COMPONENTS],
int SIGN;
int cont,c_cont[MAX_COMPONENTS];
- psfix = 0;
-
/**********************************************/
/* Do for all pixels in the row in 8-bit mode */
Rd=c_dd[color];
cont=c_cont[color];
- enter_run = was_in_run = test_run = 0;
+ was_in_run = test_run = 0;
if (color == 0) {
test_run = 1;
register int n, m;
- enter_run = was_in_run = 1;
+ was_in_run = 1;
/* get length of the run */
/* arg is # of pixels left */
Rd=c_dd[color];
cont=c_cont[color];
- enter_run = was_in_run = test_run = 0;
+ was_in_run = test_run = 0;
if (color == 0) {
test_run = 1;
register int n, m;
- enter_run = was_in_run = 1;
+ was_in_run = 1;
/* get length of the run */
/* arg is # of pixels left */