77 double step = 255. / 63.;
87 "% p%- w%-squares-wide!d o%-outfile!s cube-side%d",
88 &pflag, &wflag, &squares_wide,
89 &oflag, &ofname, &cube_side ) == 0 )
92 if ( cube_side != 64 )
95 if ( cube_side < 2 || cube_side > 256 )
98 "%s: cube_side (%d given) must be >=2 and <= 256.\n",
107 if ( cube_side > 64 )
110 "%s: cube_side (%d given) must be <= 64 for Peano curve display.\n",
114 for ( nbits = 0, i = 1; i < cube_side; i <<= 1, nbits += 1 )
116 if ( cube_side != i )
118 "%s: cube_side (%d given) adjusted to %d for Peano curve display.\n",
124 "%s: squares_wide (%d given) ignored for Peano curve display.\n",
130 step = 255. / (cube_side - 1);
133 squares_wide = (
int)sqrt((
double)cube_side);
138 while ( cube_side % squares_wide != 0 )
146 if ( squares_wide < 1 || squares_wide > cube_side )
149 "%s: squares_wide (%d given) must be >= 1 and <= %d.",
150 cmd_name( argv ), squares_wide, cube_side );
156 "%s: squares_wide (%d given) ignored for Peano curve display.\n",
169 cube_side * ((cube_side + squares_wide - 1) / squares_wide) - 1;
185 g = (
int)(step * (y % cube_side));
193 b = (
int)(step * (x % cube_side));
195 r = (
int)(step * (x / cube_side +
196 squares_wide * y / cube_side));
206 int two_d_bits = (nbits * 3 / 2),
207 two_d_max = 1 << two_d_bits,
208 max_r = 1 << (3 * nbits);
219 a[0] = 2 * two_d_max - x - 1;
221 if ( x >= two_d_max )
224 rows[0][
x] = c[0] << (8 -
nbits);
225 rows[1][
x] = c[1] << (8 -
nbits);
226 rows[2][
x] = c[2] << (8 -
nbits);
void hilbert_c2i(int n, int m, int a[], long int *r)
void hilbert_i2c(int n, int m, long int r, int a[])
int scanargs(int argc, char **argv, const char *format,...)
int rle_row_alloc(rle_hdr *the_hdr, rle_pixel ***scanp)
static unsigned char nbits[256]
void rle_putrow(rle_pixel *rows[], int rowlen, rle_hdr *the_hdr)
void rle_addhist(char *argv[], rle_hdr *in_hdr, rle_hdr *out_hdr)
void rle_puteof(rle_hdr *the_hdr)
FILE * rle_open_f(const char *prog_name, const char *f_name, const char *mode)
void rle_put_setup(rle_hdr *the_hdr)
char * cmd_name(char **argv)
#define RLE_CHECK_ALLOC(pgm, ptr, name)