Re: efficient drawing of complex data



On Thu, 2003-03-13 at 07:49, Markus Lausser wrote:
Hello again.

Problem: I have a GtkDrawingArea, the contents consists of rectangular
areas which are painted pixel by pixel (cause i have to calculate the
correct color for every single pixel). What is the fastet way to paint
this?  Right now my solution is:

1. a rgb buffer for the rectangular areas, filling it pixel by pixel.
2. draw these areas in a GdkPixmap using gdk_draw_rgb_image(pixmap, ...)
3. finally showing this pixmap on screen using
   gdk_draw_pixmap(drawingarea->window)

Is it faster to paint every pixel directly in the GdkPixmap? What
about the color allocation for every pixel?

No, this will be much slower. GdkRGB is the right approach.

Is it faster to draw the areas directly on screen skipping the
GdkPixmap (there might be thousands of rectangular areas).

If you are creating and destroying a GdkPixmap for each
small area, that might be a bit inefficient. A single big
pixmap won't slow things down significantly.

Note that with GTK+-2.x you might be using _two_ pixmaps if you 
aren't careful ... during the ::expose signal drawing to
drawingarea->window is redirected to an offscreen pixmap that 
is then copied to the screen at the end of the handler.

(See docs for gdk_window_begin_paint_region(), 
gtk_widget_set_double_buffered() for more information about
this topic.)

Regards,
                                         Owen





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