00001
00002 #include <stdio.h>
00003
00004
00005
00006
00007
00008
00009
00010 make_colormap (unsigned char* red, unsigned char* green, unsigned char* blue)
00011 {
00012 int i;
00013
00014 red[0] = green[0] = blue[0] = 0;
00015 for (i = 1; i < 255; i++) {
00016 red[i] = random() % 256;
00017 green[i] = random() % 256;
00018 blue[i] = random() % 256;
00019 while (red[i] + green[i] + blue[i] < 128) {
00020 red[i] *= 2;
00021 green[i] *= 2;
00022 blue[i] *= 2;
00023 }
00024 }
00025 red[255] = green[255] = blue[255] = 255;
00026 }
00027
00028 main(int argc, char *argv[])
00029 {
00030 int i;
00031 unsigned char red[256], green[256], blue[256];
00032
00033 if (argc <= 1)
00034 srand(42);
00035 else
00036 srand(atoi(argv[1]));
00037
00038 make_colormap(red, green, blue);
00039
00040
00041
00042 for (i = 0; i < 256; i++) putchar(red[i]);
00043 for (i = 0; i < 256; i++) putchar(green[i]);
00044 for (i = 0; i < 256; i++) putchar(blue[i]);
00045 }