Newbie Question
- From: Aaron Smith <aws4y virginia edu>
- To: gtk-app-devel-list gnome org
- Subject: Newbie Question
- Date: Wed, 17 Sep 2003 14:46:28 -0400
Hi all,
I am writing a GTK+ App that requires an image to be updates at intervals
I have the image widget in a window that is updated periodicly. Here is
the code:
GtkWidget *image;
GdkImage *test;
guint32 pixel;
GtkWidget *window;
GdkVisual *help;
int main()
{
.....
gtk_init(&argc,&argv); //Parses GTK+ init options
window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window),"Test"); //title the window
help=gdk_visual_get_best(); //get the visual
test=gdk_image_new(GDK_IMAGE_NORMAL,help,1024,1024); //create the gdk
image
image=gtk_image_new(test,NULL); //set up the image widget
gtk_container_add(GTK_CONTAINER(window),image); //add the image to the
window
gtk_signal_connect(GTK_OBJECT(window),
"delete_event",
GTK_SIGNAL_FUNC(delete_event_cb),
NULL); //exit main when the window closes.
//create the window widget
gtk_widget_show_all(window);
gtk_timeout_add(50,conac,NULL);
gtk_main();
return 0;
}
conac is the timeout I am adding is as follows
gint conac(gpointer data)
{
int i;
int a,b,c,d;
long *final;
gchar *tvarr;
final=calloc(LIN_ARR,sizeof(long)); //final image buffer
tvarr=(gchar *)calloc(LIN_ARR,sizeof(char)); //display buffer of
characters
expose(exptime,final,pci_fd,memfd,TRUE); //default leach expose function
max_min(tvarr,final,min,max); //from final make the display
buffer.
gtk_widget_hide(image);
gdk_image_destroy(test);
test=gdk_image_new(GDK_IMAGE_NORMAL,help,1024,1024); //create the gdk
image
//populate the Gdk image
for(a=0;a<1024;a++)
for(b=0;b<1024;b++)
{
pixel=tvarr[a*1024+b]<<help->red_shift|
tvarr[a*1024+b]<<help->green_shift|
tvarr[a*1024+b]<<help->blue_shift;
c=1023-a;
d=1023-b;
gdk_image_put_pixel(test,a,d,pixel);
}
gtk_container_remove(GTK_CONTAINER(window),image);
image=gtk_image_new(test,NULL);
gtk_container_add(GTK_CONTAINER(window),image);
gtk_widget_show(image);
return 1;
}
I am aware that the gtk_signal_connect() dosent work, I really dont
care, I would like to get the image update functin "conac" working (ie.
Updating the child widget image and displating it in the window)
Thanks in advance for the help,
Aaron Smith
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]