Re: how Gtk::DrawingArea multithread drawing video and draw text, line , or rect...



my main function :


#include <gtkmm.h>
#include <libglademm/xml.h>
#include "callbacks.h"
#include "capture.h"
#include "utils.h"


const char *device="/dev/video0";
int width=640;
int height=480;

int gdrawtext;
int gdrawline;
int gdrawrect;
int gdrawcircle;
int gdrawbox;
int streaming;

extern rgb24_frame_t *rgb24frame;

Glib::RefPtr<Gnome::Glade::Xml> xml;
Gtk::DrawingArea *drawingarea;

/*start the frame capture thread*/
inline void start_capture_thread(){
    capture_start(device,width,height,-1);
}
/*start the frame display thread*/
inline void display_frame(){

    drawingarea->get_window()->draw_rgb_image(
                    drawingarea->get_style()->get_bg_gc(Gtk::STATE_NORMAL),
                    0,0,width,height,Gdk::RGB_DITHER_NONE,rgb24frame->rgb24,width*3);               
}

int main(int argc, char *argv[]){

    Gtk::Window *window;
    //Gtk::DrawingArea *drawingarea;

    Glib::thread_init();
    Gtk::Main main(argc,argv);
    xml=Gnome::Glade::Xml::create(" ultrasound.glade");
    xml->get_widget("ultrasound",window);
    xml->get_widget("drawingarea_video",drawingarea);

    register_signal_handler();
    Glib::Thread::create(sigc::ptr_fun(&start_capture_thread),true);
   

    Glib::Dispatcher patcher;
    patcher.connect(sigc::ptr_fun(&display_frame));
   

    main.run(*window);

}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]