Difference between GdkPixbuf and GdkPixmap



Basicly I'm developing a GtkDrawingArea based application. As far as I
understand, a GdkPixbuf is stored on the client, and a Pixmap on the
server.

Of course there are many more differences, but technically that's all
I need to know.


What I did first in this application was to load pictures onto
GdkPixbuf with gdk_pixbuf_new_from_file, and call gdk_draw_pixbuf to
draw this to the GtkPixmap target area. (pixbuf to pixmap)

Of course, though it worked good enough at first, I was intrigated and
I tested this through XDMCP to connect to a distant Xserver to see how
it would be reacting.

The results were pretty slow. Good looking[1], but slow. I suppose
this is caused by the the client->server traffic for the pixbuf to be
drawn each frame.

From the GDK Reference Manual, gdk_draw_pixbuf:
«On older X servers, rendering pixbufs with an alpha channel involves
round trips to the X server, and may be somewhat slow.»


What I did then was to store the Pixbuf as a pixmap with
gdk_pixbuf_render_pixmap_and_mask, just after having load it with
gdk_pixbuf_new_from_file (no change on the loading process)

The blit then would be done with gdk_draw_drawable (pixmap to pixmap)

And the result is pretty good enough through XDMCP. So I suppose this
solve my speed issue.


But of course it's not perfect. In fact the GtkPixmap resulting from
the gdk_pixbuf_render_pixmap_and_mask lose the alpha channel
informations. Or maybe I do something wrong.


Though gdk_pixbuf_render_pixmap_and_mask takes an alpha_threshold
parameter representing a «treshold value for opacity values» it
doesn't look the same when using the resulting pixmap with
gdk_draw_drawable[2]

I tried with multiple alpha_threshold values but I'm not satisfied at all.

What am I missing ? Is there a way to transform a pixbuf to a pixmap
without losing the alpha channel?

gdk_pixbuf_render_pixmap_and_mask returns a GdkPixmap and a GdkBitmap;
the mask; from a GdkPixbuf. I don't need any pixbuf at all, but that's
the only convenient way I found to load any picture format (png, svg,
etc.) easily from a filename (gdk_pixbuf_new_from_file)

[1] Good, but slow: http://boby.joe.free.fr/files/pixbuf-to-drawable.png
[2] Fast, but ugly:
http://boby.joe.free.fr/files/pixbuf-to-pixmap-to-drawable.png

PS: I think it's not necessary to send links to the program itself,
because it's big, messy, not well documented, etc. but feel free to
request it. It's open-source so there's no problem to get it.



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