예제 #1
0
Glib::RefPtr<Gdk::Pixbuf> createNegativePixbuf(Glib::RefPtr<Gdk::Pixbuf> p_pixbuf){
	Glib::RefPtr<Gdk::Pixbuf> l_pixbuf;

	l_pixbuf = p_pixbuf->copy();
	p_pixbuf->saturate_and_pixelate(l_pixbuf, 0, true);

	return l_pixbuf;
}
예제 #2
0
void main_window::new_image(const Glib::RefPtr<const Gdk::Pixbuf>& p) {
    picture = p->copy();
    processed_picture = picture->copy();
    color replace_false = make_color(0, 0, 0);
    color replace_true = make_color(255, 0, 0);
    color low = make_color(opts.ch1_low(), opts.ch2_low(), opts.ch3_low());
    color high = make_color(opts.ch1_high(), opts.ch2_high(), opts.ch3_high());
    threshold_image(processed_picture, low, high, replace_false, replace_true, opts.color_space());
    image.set(picture);
    processed_image.set(processed_picture);
}
예제 #3
0
void Module_Rectifier::display( const colorspaces::Image& image)
{
	colorspaces::ImageRGB8 img_rgb8(image);//conversion will happen if needed
	Glib::RefPtr<Gdk::Pixbuf> imgBuff = 
	Gdk::Pixbuf::create_from_data((const guint8*)img_rgb8.data,
		Gdk::COLORSPACE_RGB,
		false,
		8,
		img_rgb8.width,
		img_rgb8.height,
		img_rgb8.step);


	/* Image */
	gtkimage_notrectified->clear(); /**/
	gtkimage_notrectified->set(imgBuff);
	mybuffer = imgBuff->get_pixels();
	
	/* Rectified Image */
	imgRectifiedBuff = imgBuff->copy();
	gtkimage_rectified->clear(); /**/
	gtkimage_rectified->set(imgRectifiedBuff);
	mybuffer_rectified = imgRectifiedBuff->get_pixels();


	/* if the user have selected 4 points on each image the application rectify the second image */
	if ((counter_points_image == NUM_POINTS) and (counter_points_image_rectified == NUM_POINTS)){

		/* Calculate the solution matrix */
		if (flag_resolved == false){
			solve_equation_system();
			flag_resolved = true;
		}
  
		/* Build the rectified image */
		build_rectified_image(mybuffer, mybuffer_rectified);

	}

	/* Draw selected points */
	drawSelectedPoints(counter_points_image, points_image, mybuffer);
	drawSelectedPoints(counter_points_image_rectified, points_image_rectified, mybuffer_rectified);

   
}
예제 #4
0
int main(int argc, char **argv)
{
  Glib::thread_init();
  Gtk::Main tk(argc, argv);

  if (!gtk_gl_init_check (&argc, &argv) ||
      !gdk_gl_init_check (&argc, &argv) ) {
    std::cerr << "Failed to initialize GL\n";
    return 1;
  }

  CommandLineOptions opts (argc, argv);

  Platform::setBinaryPath (argv[0]);

  Model *model = new Model();

  try {
    Gio::File::create_for_path(Glib::get_user_config_dir() + "/repsnapper")->make_directory_with_parents();
  } catch(Gio::Error e) {
    switch(e.code()) {
    case Gio::Error::EXISTS:
      // Directory has already been created.  Normal.
      break;

    default:
      Gtk::MessageDialog dialog("Couldn't create user config directory!", false,
                                Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE);
      dialog.set_secondary_text(e.what());
      dialog.run();
      return 1;
    }
  }
      
  Glib::RefPtr<Gio::File> conf = Gio::File::create_for_path(Glib::get_user_config_dir() + "/repsnapper/repsnapper.conf");
  try {
    Glib::RefPtr<Gio::File> global = find_global_config();
    if(!global) {
      // Don't leave an empty config file behind
      conf->remove();
      Gtk::MessageDialog dialog("Couldn't find global configuration!", false,
                                Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE);
      dialog.set_secondary_text("It is likely that repsnapper is not correctly installed.");
      dialog.run();
      return 1;
    }
    
    global->copy(conf);
  } catch(Gio::Error e) {
    switch(e.code()) {
    case Gio::Error::EXISTS:
      // The user already has a config.  This is the normal case.
      break;

    case Gio::Error::PERMISSION_DENIED:
    {
      // Fall back to global config
      Gtk::MessageDialog dialog("Unable to create user config", false,
                                Gtk::MESSAGE_WARNING, Gtk::BUTTONS_CLOSE);
      dialog.set_secondary_text(e.what() + "\nFalling back to global config. Settings will not be saved.");
      dialog.run();
      conf = find_global_config();
      if(!conf) {
        Gtk::MessageDialog dialog("Couldn't find global configuration!", false,
                                  Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE);
        dialog.set_secondary_text("It is likely that repsnapper is not correctly installed.");
        dialog.run();
        return 1;
      }
      break;
    }

    default:
    {
      Gtk::MessageDialog dialog("Failed to locate config", false,
                                Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE);
      dialog.set_secondary_text(e.what());
      dialog.run();
      return 1;
    }
    }
  }

  // TODO: Error detection
  model->LoadConfig(conf);

  if (!opts.use_gui) {
    if (opts.stl_input_path.size() > 0) {
      model->ReadStl(Gio::File::create_for_path(opts.stl_input_path));

      if (opts.settings_path.size() > 0)
        model->LoadConfig(Gio::File::create_for_path(opts.settings_path));

      model->ConvertToGCode();

      if (opts.gcode_output_path.size() > 0)
        model->WriteGCode(Gio::File::create_for_path(opts.gcode_output_path));
    }
    return 0;
  }

  View::create(model);

  for (uint i = 0; i < opts.files.size(); i++)
    model->ReadStl(Gio::File::create_for_path(opts.files[i]));

  tk.run();

  return 0;
}
예제 #5
0
int main(int argc, char **argv)
{
  Glib::thread_init();
  // gdk_threads_init(); // locks everything at least on freebsd
  Gtk::Main tk(argc, argv);

  gchar *locale_dir;

#ifdef G_OS_WIN32
  char *inst_dir;
  inst_dir = g_win32_get_package_installation_directory_of_module (NULL);
  locale_dir = g_build_filename (inst_dir, "share", "locale", NULL);
  g_free (inst_dir);
#else
  locale_dir = g_strdup (LOCALEDIR);
#endif
  bindtextdomain (GETTEXT_PACKAGE, locale_dir);
  textdomain (GETTEXT_PACKAGE);

  //cerr << locale_dir<< endl;
  g_free(locale_dir);
  locale_dir = NULL;

  if (!gtk_gl_init_check (&argc, &argv) ||
      !gdk_gl_init_check (&argc, &argv) ) {
    std::cerr << "Failed to initialize GL\n";
    return 1;
  }

  CommandLineOptions opts (argc, argv);

  Platform::setBinaryPath (argv[0]);

  Model *model = new Model();

  try {
    std::string user_config_dir = Glib::build_filename (Glib::get_user_config_dir(), "repsnapper");
    Gio::File::create_for_path(user_config_dir)->make_directory_with_parents();
  } catch(Gio::Error e) {
    switch(e.code()) {
    case Gio::Error::EXISTS:
      // Directory has already been created.  Normal.
      break;

    default:
      Gtk::MessageDialog dialog (_("Couldn't create user config directory!"),
				 false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE);
      dialog.set_secondary_text(e.what());
      dialog.run();
      return 1;
    }
  }

  std::vector<std::string> user_config_bits(3);
  user_config_bits[0] = Glib::get_user_config_dir();
  user_config_bits[1] = "repsnapper";
  user_config_bits[2] = "repsnapper.conf";

  std::string user_config_file = Glib::build_filename (user_config_bits);
  Glib::RefPtr<Gio::File> conf = Gio::File::create_for_path(user_config_file);

  try {
    Glib::RefPtr<Gio::File> global = find_global_config();
    if(!global) {
      // Don't leave an empty config file behind
      conf->remove();
      Gtk::MessageDialog dialog (_("Couldn't find global configuration!"),
				 false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE);
      dialog.set_secondary_text (_("It is likely that repsnapper is not correctly installed."));
      dialog.run();
      return 1;
    }
    
    global->copy(conf);
  } catch(Gio::Error e) {
    switch(e.code()) {
    case Gio::Error::EXISTS:
      // The user already has a config.  This is the normal case.
      break;

    case Gio::Error::PERMISSION_DENIED:
    {
      // Fall back to global config
      Gtk::MessageDialog dialog (_("Unable to create user config"), false,
                                Gtk::MESSAGE_WARNING, Gtk::BUTTONS_CLOSE);
      dialog.set_secondary_text(e.what() + _("\nFalling back to global config. Settings will not be saved."));
      dialog.run();
      conf = find_global_config();
      if(!conf) {
        Gtk::MessageDialog dialog (_("Couldn't find global configuration!"), false,
                                  Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE);
        dialog.set_secondary_text (_("It is likely that repsnapper is not correctly installed."));
        dialog.run();
        return 1;
      }
      break;
    }

    default:
    {
      Gtk::MessageDialog dialog (_("Failed to locate config"), false,
				 Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE);
      dialog.set_secondary_text(e.what());
      dialog.run();
      return 1;
    }
    }
  }

  if (opts.settings_path.size() > 0)
    model->LoadConfig(Gio::File::create_for_path(opts.settings_path));
  else {
      // TODO: Error detection
    model->LoadConfig(conf);
  }

  bool nonprintingmode = false;
  if (opts.stl_input_path.size() > 0) {
    model->Read(Gio::File::create_for_path(opts.stl_input_path));
  }

  if (opts.gcode_output_path.size() > 0) {
    nonprintingmode = true;
  }

  if (!opts.use_gui) {
      if (opts.settings_path.size() > 0)
        model->LoadConfig(Gio::File::create_for_path(opts.settings_path));

      ViewProgress vprog(new Gtk::HBox(),new Gtk::ProgressBar(),new Gtk::Label());
      vprog.set_terminal_output(true);
      model->SetViewProgress(&vprog);
      model->statusbar=NULL;
      if (opts.gcode_output_path.size() > 0) {
	model->ConvertToGCode();
        model->WriteGCode(Gio::File::create_for_path(opts.gcode_output_path));
      }
      else if (opts.svg_output_path.size() > 0) {
	model->SliceToSVG(Gio::File::create_for_path(opts.svg_output_path),
			  opts.svg_single_output);
      }
      else if (opts.binary_output_path.size() > 0) {
	model->SaveStl(Gio::File::create_for_path(opts.binary_output_path));
      }
      else cerr << _("No output file given") << endl;
    return 0;
  }

  View* mainwin = View::create(model);

  mainwin->setNonPrintingMode(nonprintingmode, opts.gcode_output_path);

  mainwin->set_icon_name("gtk-convert");
  mainwin->set_title("Repsnapper");

  for (uint i = 0; i < opts.files.size(); i++)
    model->Read(Gio::File::create_for_path(opts.files[i]));

  tk.run();

  delete mainwin;
  delete model;

  return 0;
}
예제 #6
0
void PhotoPreview::SetImage(Glib::RefPtr<Gdk::Pixbuf> Image) {
	this->Image=Image->copy();
	Redraw();
	IsSilhouette=false;
}
예제 #7
0
void gui::ToolBox::onCopyClicked() {
	if (imageCurrent_.get_storage_type() == Gtk::IMAGE_EMPTY)
		return;
	Glib::RefPtr<const Gdk::Pixbuf> pixbuf = imageOriginal_.get_pixbuf();
	imageCurrent_.set(pixbuf->copy());
}