Display images

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



Hi,  don't know if I can ask this question in this list but I'll made it..
if anyone can help me please replay asap.....

I am trying  to show the images that I get from my webcam on the screen...
I am using GTK GDK library... but I am having a strange problem: when I
call gtk_main() it goes to the routine that draw the RGB image, then I call
gtk_main_quit() and it exits of the routine, but in the next loop it repeat
the RGB routine twice before go out, then in the next one it repeat it
three times, in the next one four times, etc.... so in become slower in
every loop....here I send the code so you can see what I am doing wrong...
thanks in advance.

Edgar


**********************************************************************************

**********************************************************************************

LIBRARIES......

VARIABLES......

gboolean on_darea_expose (GtkWidget *widget,
                            GdkEventExpose *event,
                            gpointer user_data);

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

CAMERA PROPERTIES........

//------------------------------------------------------------------------------

                                   /* CREATE DISPLAY WINDOWS AND IMAGE AREA
*/
//------------------------------------------------------------------------------



gtk_init (&argc,
&argv);
// Initialize GTK functions.
gdk_init (&argc,
&argv);                                                                  //
Initialize GDK functions.
gdk_rgb_init();
// Initialize GDK_RGB functions.

window = gtk_window_new (GTK_WINDOW_TOPLEVEL);     // Create windows.

darea =
gtk_drawing_area_new();
// Create Image area.

//-------------------------------------------------------------------------

                                        /* CAPTURE LOOP */
//------------------------------------------------------------------------
while (1){

CAPTURING........

display();}

}

//------------------------------------------------------------------------
                                                           /* DISPLAY
IMAGES */
//------------------------------------------------------------------------

void display(window,darea)
  {
    gint x, y;

   gtk_drawing_area_size (GTK_DRAWING_AREA (darea), COLS,
ROWS);              // Set darea size.

   gtk_container_add (GTK_CONTAINER (window),
darea);                                          // Put darea in windows.


   gtk_signal_connect (GTK_OBJECT (darea),
"expose-event",                               // Put RGB image in darea.
                        GTK_SIGNAL_FUNC (on_darea_expose), NULL);

   gtk_widget_show_all
(window);
// Show windows in screen.



gtk_main();
// Go to main process (RGB).

    }


  gboolean on_darea_expose (GtkWidget *widget,
                   GdkEventExpose *event,
                   gpointer user_data)
  {


    gdk_draw_rgb_image (widget->window,
widget->style->fg_gc[GTK_STATE_NORMAL],
                        0, 0, COLS, ROWS,
                        GDK_RGB_DITHER_MAX, buf, COLS * 3);
   gtk_main_quit();

   }







[Index of Archives]     [Linux DVB]     [Video Disk Recorder]     [Asterisk]     [Photo]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Free Photo Albums]     [Fedora Users]     [Fedora Women]     [ALSA Users]     [ALSA Devel]     [Linux USB]

Powered by Linux