[Gtk-sharp-list] Using images with transparency

White Spirit wspirit at homechoice.co.uk
Thu Nov 9 01:47:58 EST 2006


I need to superimpose an image with a transparent background on top of 
another image.  The idea is to have a 2D map within a game that is made 
up of tiles upon which images of the player character's tiles can be 
superimposed so that the character image doesn't obliterates the map but 
is put on top, much like a sprite works (but without the animation).

I've tried using a pixmap to place a pixbuf image in the pixmap and then 
a test image with a transparent background in the pixmap afterwards, but 
the test image simply overwrites the original.  An except from my 
program is included at the bottom.

Can anyone please help me with this?


Code:

// This draws a map comprised of j * i grass1 tiles from a pixbuf

for (int i = 0; i < map.length; i++)
   {
   for (int j = 0; j < map.breadth; j++)
    {
    pixMap.DrawPixbuf (d.Style.BlackGC, grass1, 0, 0, j * 50, i * 50, 
50, 50, Gdk.RgbDither.None, 0, 0);
    }
  }

// This is meant to superimpose the test player character tile with 
transparent background in the upper left hand corner

pixMap.DrawPixbuf (d.Style.BlackGC, test, 0, 0, 0, 0, 50, 50, 
Gdk.RgbDither.None, 0, 0);


More information about the Gtk-sharp-list mailing list