Re: [gtk-list] Two more Gtk questions (fast frame rates and thread safety)




Rob Browning <rlb@cs.utexas.edu> writes:

> First of all, we need to display small image streams at high frame
> rates.  Currently we use a motif DrawingArea widget with a fixed 3/3/2
> colormap where we know the mapping from indexes to colors.  We then
> use XPutImage with a properly constructed image pixel index array to
> display each image.  (This implementation is reasonably fast, but does
> have the restriction (because of the 3/3/2 trick) that it only works
> on some 8-bit visuals).  What would be the best way(s) to handle this
> in gtk?

In gtk, you can use gdk_image_new to create an image that is (pretty
transparently) either a normal image or an XShm shared memory image.
You then draw it to the screen with gdk_draw_image. (In some cases,
it may look better to draw to the image to a pixmap and copy to the
screen, since less time is spent actually changing the screen.) You
do have to handle the details of creating the image data yourself,
using whatever kind of color map you set up. This isn't blazingly
fast, but you should be able to get 10-15 frames a second for a 
256x256 image. (Depending greatly on your hardware.)

You can look at the source code for the GIMP, or gsumi 
(http://www.msc.cornell.edu/~otaylor/gsumi/) if you want an example.
gsumi might be a bit simpler.

> [ description of clever approach to threading approach with Motif omitted ]

Sounds like the same thing should work fine. On the other hand, if
you want to modify the gtk source to be truly thread safe, then 
you'll probably make lots of people quite happy. (It looked a bit
difficult, though, when I took a look at it.)

Regards,
                                        Owen



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