Exemplo n.º 1
0
void convert_scr7 (image *img) {
  image *temp;
  int i,j;
  histogram hist[256];

  temp=(image *) malloc (sizeof (image));
  temp->x=img->x;
  temp->y=img->y;
  temp->buffer=(unsigned char *) malloc (img->x*img->y);

  for (i=0; i<256; i++) {
    hist[i].value=0;
    hist[i].index=i;
  }
  
  for (j=0; j<img->y; j++)
    for (i=0; i<img->x; i++)
      hist[ENCODE(img,i,j)].value++;

  qsort (hist,256,sizeof (histogram),sort_histogram);
  
  for (j=0; j<temp->y; j++)
    for (i=0; i<temp->x; i++)
      PIXEL8(temp,i,j)=
        match_color(PIXEL(img,i,j,R),PIXEL(img,i,j,G),PIXEL(img,i,j,B),hist);

  custom_blit (temp);
  show_pal (0,hist);
}
Exemplo n.º 2
0
static void read_config(const char *dft_cfile, const char *cfile) {
	esl_config_t cfg;
	if (esl_config_open_file(&cfg, cfile) ||
		esl_config_open_file(&cfg, dft_cfile)) {
		char *var, *val;
		char cur_cat[128] = "";
		while (esl_config_next_pair(&cfg, &var, &val)) {
			if (strcmp(cur_cat, cfg.category)) {
				esl_set_string(cur_cat, cfg.category);
				esl_set_string(profiles[pcount].name, cur_cat);
				esl_set_string(profiles[pcount].host, "127.0.0.1");
				esl_set_string(profiles[pcount].pass, "ClueCon");
				profiles[pcount].port = 8021;
				set_fn_keys(&profiles[pcount]);
				esl_set_string(profiles[pcount].prompt_color, prompt_color);
				esl_set_string(profiles[pcount].input_text_color, input_text_color);
				esl_set_string(profiles[pcount].output_text_color, output_text_color);
				esl_log(ESL_LOG_DEBUG, "Found Profile [%s]\n", profiles[pcount].name);
				pcount++;
			}
			if (!strcasecmp(var, "host")) {
				esl_set_string(profiles[pcount-1].host, val);
			} else if (!strcasecmp(var, "user")) {
				esl_set_string(profiles[pcount-1].user, val);
			} else if (!strcasecmp(var, "password")) {
				esl_set_string(profiles[pcount-1].pass, val);
			} else if (!strcasecmp(var, "port")) {
				int pt = atoi(val);
				if (pt > 0) {
					profiles[pcount-1].port = (esl_port_t)pt;
				}
			} else if (!strcasecmp(var, "batchmode")) {
				profiles[pcount-1].batch_mode = esl_true(val);
			} else if (!strcasecmp(var, "debug")) {
				int dt = atoi(val);
				if (dt > -1 && dt < 8){
					profiles[pcount-1].debug = dt;
				}
			} else if(!strcasecmp(var, "loglevel")) {
				esl_set_string(profiles[pcount-1].loglevel, val);
			} else if(!strcasecmp(var, "log-uuid")) {
				profiles[pcount-1].log_uuid = esl_true(val);
			} else if(!strcasecmp(var, "quiet")) {
				profiles[pcount-1].quiet = esl_true(val);
			} else if(!strcasecmp(var, "prompt-color")) {
				esl_set_string(profiles[pcount-1].prompt_color, match_color(val));
			} else if(!strcasecmp(var, "input-text-color")) {
				esl_set_string(profiles[pcount-1].input_text_color, match_color(val));
			} else if(!strcasecmp(var, "output-text-color")) {
				esl_set_string(profiles[pcount-1].output_text_color, match_color(val));
			} else if (!strncasecmp(var, "key_F", 5)) {
				char *key = var + 5;
				if (key) {
					int i = atoi(key);
					if (i > 0 && i < 13) {
						profiles[pcount-1].console_fnkeys[i - 1] = strdup(val);
					}
				}
			} else if (!strcasecmp(var, "timeout")) {
				timeout = atoi(val);
			} else if (!strcasecmp(var, "connect-timeout")) {
				connect_timeout = atoi(val);
			}
		}
		esl_config_close_file(&cfg);
	}
}