Re: problem displaying rgb images on window



your problem is that the gtk_widget_show_all() routine is responsible for
rendering widgets, not updating the display with the latest version of
whatever underlying pixmap is to be rendered to the screen.

you should implement a new paradigm for rendering your images, thus:

1) all pixmap rendering should happen through the expose event callback
for the drawing area (widget made at startup) responsbile for displaying
the image.

2) the routine responsible for converting the data to an image should
create the new pixmap and make this new pixmap available to the expose
event for rendering, followed by a call to gtk_widget_queue_draw_area() to
force the expose event to be called.

an example of this logic could be:

GdkPixmap *dispPmap;
GtkWidget *DrawingArea;

gboolean pmap_expose(GtkWidget *widget, GdkEventExpose *event, gpointer none)
{
  gdk_draw_drawable(widget->window, widget->style->fg_gc[GTK_WIDGET_STATE
(widget)], dispPmap, event->area.x, event->area.y, event->area.x,
event->area.y, event->area.width, event->area.height);
  return TRUE;
}

void makeDrawing()
{
 static GdkPixmap *pixbuf;
 while(!feof(fp))
 {
  decode();
  convert_yuv_to_rgb();

  if(pixbuf)
    g_object_unref(pixbuf);
  pixbuf =
gdk_pixbuf_new_from_data(rgb_buffer,0,0,8,width,height,width,NULL,NULL);
  dispPmap = pixbuf;
  gtk_widget_queue_draw_area(DrawingArea, 0, 0,
DrawingArea->allocation.width, DrawingArea->allocation.height);
  while (gtk_events_pending())
    gtk_main_iteration();
 }  // end while
 g_object_unref(pixbuf);
 pixmap=NULL;
}

in this manner, a single call to makeDrawing() from anywhere (internal to
the program, or as a result of a user request) will end up doing what you
want.

richard

Hi,
I am writing an application using GTK+ (version 2.10.0) for x86 pc.
Iam decoding an mp4 video stream and displaying the RGB data on the
window.
This is in a loop.

while(!feof(fp))
{

decode(); //decodes one frame of mp4 data to yuv format
convert_yuv_to_rgb(); //converts one frame of decoded  yuv data to rgb
format

/* Iam using the following code to render the rgb data on display window
*/

pixbuf =
gdk_pixbuf_new_from_data(rgb_buffer,0,0,8,width,height,width,NULL,NULL);
gtk_image_set_from_pixbuf(image_display,pixbuf);
gtk_widget_show_all(display_window); //image_display is contained in this
window
g_object_unref(pixbuf);

}

Now my problem is that the decoding and conversion is happening at a very
high rate but the display changes only once in a while and out of 370
frames
decoded only abt 8 to 10 are displayed. I also observed that clicking on
the
application or any button increases the number of frames displayed.
Please let me know the solution to this or if there is any better way to
display rgb images on the window.

Thanks
_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list






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