Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. #include <string>
  2. #include <sstream>
  3. #include <iostream>
  4. #include <fstream>
  5. #include <initializer_list>
  6. #include <limits>
  7. #include "ImageProcessingController.cpp"
  8. #include "ConsoleTextView.cpp"
  9. #include "GraphicalView.cpp"
  10. #include "AlignModel.cpp"
  11.  
  12. using std::string;
  13. using std::stringstream;
  14. using std::cout;
  15. using std::cerr;
  16. using std::endl;
  17. using std::numeric_limits;
  18.  
  19. #include <gtkmm.h>
  20.  
  21.  
  22. class DrawingArea : public Gtk::DrawingArea
  23. {
  24. public:
  25. DrawingArea();
  26.  
  27. protected:
  28. // Override default signal handler:
  29. virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
  30. private:
  31. // 1.Pgm image
  32. Glib::RefPtr<Gdk::Pixbuf> image1;
  33. // 2.Pgm image
  34. Glib::RefPtr<Gdk::Pixbuf> image2;
  35. //Pixel buffer for display
  36. Glib::RefPtr<Gdk::Pixbuf> display;
  37. // Scale of the image
  38. double scale;
  39. };
  40.  
  41. DrawingArea::DrawingArea()
  42. {
  43. // Load the images
  44. image1 = Gdk::Pixbuf::create_from_file("first.pgm");
  45. image2 = Gdk::Pixbuf::create_from_file("second.pgm");
  46. //create a 720x640 rgb Pixbuf
  47. display = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB,0,8,720,640);
  48. }
  49. // Call when the display need to be updated
  50. bool DrawingArea::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
  51. {
  52. //copy the two images to the display Pixbuf with this function:
  53. //void Gdk::Pixbuf::copy_area (int src_x,int src_y,int width,int height,const Glib::RefPtr< Gdk::Pixbuf >& dest_pixbuf,int dest_x,int dest_y)
  54. image1->copy_area(0,0,360,640,display,0,0);
  55. image2->copy_area(0,0,360,640,display,360,0);
  56. // Place the display Pixbuf at the center of the window
  57. Gdk::Cairo::set_source_pixbuf(cr, display, 0,0);
  58. // Update the whole drawing area
  59. cr->rectangle(0, 0, display->get_width(), display->get_height());
  60. // Fill the area with the image
  61. cr->fill();
  62. // The event has been handled.
  63. return true;
  64. }
  65.  
  66. int main(int argc, char** argv) {
  67. Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "betontaplfa");
  68. Gtk::Window window;
  69.  
  70. // Create the drawing
  71. DrawingArea Dwg;
  72. // Insert the drawing in the window
  73. window.add(Dwg);
  74. // Resize the window
  75. window.resize(720,640);
  76. // Set the window title
  77. window.set_title("Pgm");
  78. // Show the drawing
  79. Dwg.show();
  80.  
  81. // Start main loop
  82. return app->run(window);
  83. }
  84.  
  85.  
  86.  
  87. // int main(int argc, char **argv) {
  88. // ConsoleTextView* console_view = new ConsoleTextView();
  89. // GraphicalView* graphical_view = new GraphicalView();
  90. // AlignModel* align_model = new AlignModel();
  91.  
  92. // ImageProcessingController controller(align_model, console_view, graphical_view);
  93. // controller.RetrieveAndExecute(argc, argv);
  94. // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement