Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <sstream>
- #include <iostream>
- #include <fstream>
- #include <initializer_list>
- #include <limits>
- #include "ImageProcessingController.cpp"
- #include "ConsoleTextView.cpp"
- #include "GraphicalView.cpp"
- #include "AlignModel.cpp"
- using std::string;
- using std::stringstream;
- using std::cout;
- using std::cerr;
- using std::endl;
- using std::numeric_limits;
- #include <gtkmm.h>
- class DrawingArea : public Gtk::DrawingArea
- {
- public:
- DrawingArea();
- protected:
- // Override default signal handler:
- virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
- private:
- // 1.Pgm image
- Glib::RefPtr<Gdk::Pixbuf> image1;
- // 2.Pgm image
- Glib::RefPtr<Gdk::Pixbuf> image2;
- //Pixel buffer for display
- Glib::RefPtr<Gdk::Pixbuf> display;
- // Scale of the image
- double scale;
- };
- DrawingArea::DrawingArea()
- {
- // Load the images
- image1 = Gdk::Pixbuf::create_from_file("first.pgm");
- image2 = Gdk::Pixbuf::create_from_file("second.pgm");
- //create a 720x640 rgb Pixbuf
- display = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB,0,8,720,640);
- }
- // Call when the display need to be updated
- bool DrawingArea::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
- {
- //copy the two images to the display Pixbuf with this function:
- //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)
- image1->copy_area(0,0,360,640,display,0,0);
- image2->copy_area(0,0,360,640,display,360,0);
- // Place the display Pixbuf at the center of the window
- Gdk::Cairo::set_source_pixbuf(cr, display, 0,0);
- // Update the whole drawing area
- cr->rectangle(0, 0, display->get_width(), display->get_height());
- // Fill the area with the image
- cr->fill();
- // The event has been handled.
- return true;
- }
- int main(int argc, char** argv) {
- Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "betontaplfa");
- Gtk::Window window;
- // Create the drawing
- DrawingArea Dwg;
- // Insert the drawing in the window
- window.add(Dwg);
- // Resize the window
- window.resize(720,640);
- // Set the window title
- window.set_title("Pgm");
- // Show the drawing
- Dwg.show();
- // Start main loop
- return app->run(window);
- }
- // int main(int argc, char **argv) {
- // ConsoleTextView* console_view = new ConsoleTextView();
- // GraphicalView* graphical_view = new GraphicalView();
- // AlignModel* align_model = new AlignModel();
- // ImageProcessingController controller(align_model, console_view, graphical_view);
- // controller.RetrieveAndExecute(argc, argv);
- // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement