30 int xsize = 512, ysize = 480, nsteps = 16, cflag = 0, oflag = 0;
35 char buf[80], *out_fname = NULL;
38 "% c%- l%- n%-nsteps!d o%-outfile!s xsize%d ysize%d\n(\
39 \tDraw a step scale in gray or color.\n\
40 \t-c\tDraw color scales: gray, red, green, blue\n\
41 \t-l\tChange linearly between steps (default is exponential).\n\
42 \t-n\tNumber of steps in scale.)",
43 &cflag
, &lflag
, &nsteps
, &nsteps
,
44 &oflag
, &out_fname
, &xsize
, &ysize
) == 0 )
48 if ( xsize < 3 * nsteps || xsize < 24 )
51 "Image isn't wide enough for %d steps, should be at least %d pixels.\n",
52 nsteps, 24 < 3 * nsteps ? 3 * nsteps : 24 );
67 sprintf( buf,
"IMAGE_TYPE=%s scale image with %d log steps",
68 cflag ?
"Color" :
"Gray", nsteps );
79 for ( i = 0; i < 8; i++ )
81 scans[0][i].u.run_val = (i & 1) ? 255 : 0;
83 scans[0][i]
.xloc = i * xsize / 8;
84 scans[0][i]
.length = (i + 1) * xsize / 8 - scans[0][i]
.xloc;
85 scans[1][i] = scans[0][i];
86 scans[1][i].u.run_val = (i & 2) ? 255 : 0;
87 scans[2][i] = scans[0][i];
88 scans[2][i].u.run_val = (i & 4) ? 255 : 0;
95 for ( y = 0; y < ysize / 8; y++ )
99 for ( i = 0; i < nsteps; i++ )
103 scans[0][i].u.run_val = (
int)(i * 255.0 / (nsteps - 1) + 0.5);
106 scans[0][i].u.run_val =
107 (
int)(255.0 / pow(2.0, i*(8.0/nsteps)) + 0.5);
109 scans[0][i]
.xloc = i * xsize / nsteps;
110 scans[0][i]
.length = (i + 1) * xsize / nsteps - scans[0][i]
.xloc;
111 scans[1][i] = scans[0][i];
112 scans[2][i] = scans[0][i];
120 for ( ; y < ysize; y++ )
125 nscan[0] = nscan[1] = 0;
126 for ( ; y < ysize * 11./32. ; y++ )
131 for ( ; y < ysize * 18./32.; y++ )
136 for ( ; y < ysize * 25./32.; y++ )
139 nscan[1] = nscan[2] = nsteps;
140 for ( ; y < ysize; y++ )
FILE * rle_open_f(char *prog_name, char *file_name, char *mode)
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
int rle_raw_alloc(rle_hdr *the_hdr, rle_op ***scanp, int **nrawp)
char * cmd_name(char **argv)
void main(int argc, char **argv)
void rle_putraw(rle_op **scanraw, int *nraw, rle_hdr *the_hdr)
int scanargs(int argc, char **argv, const char *format,...)
void rle_puteof(rle_hdr *the_hdr)
void rle_addhist(argv, rle_hdr *in_hdr, rle_hdr *out_hdr)
void rle_put_setup(rle_hdr *the_hdr)
const char * rle_putcom(char *value, rle_hdr *the_hdr) const
void rle_raw_free(rle_hdr *the_hdr, rle_op **scanp, nrawp)
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)
#define RLE_CHECK_ALLOC(pgm, ptr, name)