Re: One Last Time: Transparent XPMs



On Tue, 2003-02-18 at 11:18, Mayank Lahiri wrote:
Hi!

I have a query, and I've noticed from the archives that it's never really 
been dealt with. I've also done extensive research in the API reference, 
all the examples I could find online, and all I can say is that this is a 
topic that has not been dealt with properly (hmm...I smell a contribution 
to the docs sometime soon...)

I was wondering if anyone could help with the following issues:

(Platform: Linux, gtk+ 2.0, C/C++ please)

By "transparent" I mean that you have an image in which one particular 
color is said to be "transparent" and any pixels of that color are not 
drawn. Instead, pixels of any other images below the current image being 
drawn are shown. Essentially, the transparent mechanism I'm talking 
about is the one in transparent .GIFs. I do *NOT* blending two images to 
give one a "translucent" look (isn't that an 'alpha channel'?)

You are correct.  Although in the final analysis, we can easily convert
an xpm to an image with an alpha channel.  The alpha channel will only
have 2 values:  0 or 255.  On or off.  From GTK's point of view, we can
do everything with GdkPixbuf, and I think that's where the optimization
is going into.



1) Pixmaps and Pixbufs: seem to be for the same purpose. Whats the 
difference between them? Which one is preferable  (i.e., low-level) (I see 
that the gdk_draw_pixmap function has been deprecated)? Which one is faster,
 and which one can handle transparent XPMs more efficiently?

I'd say pixmaps with bitmap masks are more efficient, even though
they've been depricated.  That's because we know they are server-side
operations that the Xserver can do very quickly.  Alpha-blending can be
done server-side with the XRender extension, so it may be fast too, when
XRender is present. I'm not familiar with how GdkPixbuf does it's stuff.


2) TRANSPARENCY: The standard approach seems to be to set a clipping 
region for each XPM drawn on screen. Isn't this grossly inefficient, say
for example in a sprite-based game? Is there any other more efficient way 
to do it?

No, masking has always been the fastest way.  It's how sprites have
always been done.  There's no other way to do it.  And in X, we know the
server can do it very efficiently.  Masks are also used for things like
shaping the windows and so forth (like the edges of the window in the
bluecurve theme).

Now with GdkPixbuf, gtk has to maintain a client-side image that we can
composite onto.  So that's probably even more inefficient.  At least
that's how I understand it.


3) Could anyone supply a simple C/C++ program to do the following:

  a. Load two transparent XPMs (called A and B) from disk files
  b. Create a window with only a drawing_area widget
  c. Draw the first image (A) *WITHOUT* transparency in the drawing area
  d. Draw the second image (B) *WITH* transparency right over the first image.

4) Would it be simpler/more efficient to implement an old-style RAW 
(or even PCX) image drawing routine that has one color hard-coded to transparency, 
and is wildly efficient? I like the sound of this....

I don't know.  Remember that with X, anytime you do image manipulation
client-side, you have to push all those pixels over to the X server to
display them.  With GtkPixmap and masking, it's all done on the server.

Anyway, I really  don't know anything that will help you.  I'll let the
other gurus fill in the details.

Michael



Any help would be GREATLY appreciated!

Thanks,
Mayank.

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
-- 
Michael L Torrie <torriem cs byu edu>



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