One Last Time: Transparent XPMs



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'?)


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?

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?

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....

Any help would be GREATLY appreciated!

Thanks,
Mayank.




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