void GUI::process_change_colorspace(Controller &controller, uint8_t selected_scale) {

  if ( ! controller.image_file_loaded   ) { return ; }

  long int value = static_cast<long int>(get_scale(selected_scale).get_value()) ;

  if (value == 0) {
    return ;
  }

  const float div = (selected_scale == 9) ? 2.0f : (selected_scale == 7) ? 1.0 : 16.0f ;

  const float factor = (1.0f / (255.0f / div )) * static_cast<double>(value) ;

  cv::Mat tmp = controller.current_image_to_process.clone() ;

  cv::Mat frame ;

  switch (selected_scale) {

    case 6 :

      // Lightness change ;
      change_lightness(tmp, frame, factor) ;
      break ;

    case 7 :

      // Hue change ;
      change_hue(tmp, frame, factor) ;
      break ;

    case 8 :

      // Saturation change ;
      change_saturation(tmp, frame, factor) ;
      break ;

    case 9 :

      // Brightness change ;
      change_brightness(tmp, frame, factor) ;
      break ;

    #ifdef DEBUG
    default :
      // This cannot append due of the GUI interfacing.
      fprintf(stderr,"Error Change HSBL settings\n") ;
      return ;
    #endif

  }

  // We register current frame in vector<cv::Mat> for undo-redo.
  controller.process_after_applying(frame) ;

  // It convert current_image_to_process as src to RGB(A) in dst current_image_to_display.
  set_img(frame, controller.current_image_to_display, controller) ;  // It auto process conversion to RGB(A).



  // Reset some variables.
  after_applying_reset_settings(controller) ;

}
Beispiel #2
0
void checkIR(IRMP_DATA *irmp_data) {

	if (irmp_get_data(irmp_data)) {

		if (pwm_status == POWER_OFF && irmp_data->command != 1)
			return;

		if (!(irmp_data->flags & IRMP_FLAG_REPETITION)) {

			switch (irmp_data->command) {

			case (1):
			if (pwm_status == POWER_ON) {
				pwm_disable_all();
				off(DEBUGLED);
			} else {
				pwm_enable_all();
				on(DEBUGLED);
			}
			action = NONE;
			break;

			case (30):
			change_white(1);
			break;

			case (36):
			change_white(-1);
			break;

			case (4):
			change_white(-255);
			break;

			case (14):
			rgb_color.r=0; rgb_color.g=0; rgb_color.b=0;
			hsv_color = RgbToHsv(&rgb_color);
			update_color();
			break;

			case (40):
			change_hue(5.);
			action = NONE;
			break;

			case (41):
			change_hue(-5.);
			action = NONE;
			break;

			case (44):
			change_saturation(0.1);
			action = NONE;
			break;

			case (45):
			change_saturation(-0.1);
			action = NONE;
			break;

			case (9):
			change_value(0.1);
			action = NONE;
			break;

			case (5):
			change_value(-0.1);
			action = NONE;
			break;

			case (7):
			duration += 10;
			break;

			case (8):
			duration -= 10;
			break;

			case (16):
			colors_gen(RED, &rgb_color, &hsv_color);
			update_color();
			action = NONE;
			break;
			case (17):
			colors_gen(GREEN, &rgb_color, &hsv_color);
			update_color();
			action = NONE;
			break;
			case (18):
			colors_gen(BLUE, &rgb_color, &hsv_color);
			update_color();
			action = NONE;
			break;
			case (19):
			colors_gen(CYAN, &rgb_color, &hsv_color);
			update_color();
			action = NONE;
			break;
			case (20):
			colors_gen(MAGENTA, &rgb_color, &hsv_color);
			update_color();
			action = NONE;
			break;
			case (21):
			colors_gen(YELLOW, &rgb_color, &hsv_color);
			update_color();
			action = NONE;
			break;
			case (22):
			colors_gen(WHITE, &rgb_color, &hsv_color);
			update_color();
			action = NONE;
			break;
			case (23):
			colors_gen(BROWN, &rgb_color, &hsv_color);
			update_color();
			action = NONE;
			break;
			case (24):
			colors_gen(RANDOM, &rgb_color, &hsv_color);
			update_color();
			action = NONE;
			break;

			case (15):
			action = (action == HUE_FADE) ? NONE : HUE_FADE;
			break;

			default:
				break;
			}
		} else {
			switch (irmp_data->command) { // if you press the button longer
			case (30):
			change_white(5);
			break;
			case (36):
			change_white(-5);
			break;
			case (40):
			change_hue(0.5);
			break;
			case (41):
			change_hue(-0.5);
			break;
			case (44):
			change_saturation(0.01);
			break;
			case (45):
			change_saturation(-0.01);
			break;
			case (9):
			change_value(0.01);
			break;
			case (5):
			change_value(-0.01);
			break;
			case (7):
			duration += 5;
			break;
			case (8):
			duration -= 5;
			break;
			default:
				break;
			}
		}
	} //end remote switch

	switch (action) {
		case (HUE_FADE):
   			if (duration <= 0)
    				duration = 0;
			if ((millis - last_millis) > duration) {
				change_hue(1.);
				last_millis = millis;
			}
		break;

		default:
		break;
	} // action switch
}