Re: [gtk-list] Getting the mask out of a pixmap




On Sun, 2 May 1999, katre wrote:
> gdk_draw_pixmap (mask, gc, pixmap, 0, 0, width, height), I get a nasty looking
> error message, with a bunch of numbers tacked onto the end.  In fact, i get
> this message any time I try using a GdkBitmap as a GdkDrawable in a gdk_draw
> function.  So, what am I doing wrong, and how do I fix it?
> 

You can't do that because the destination bitmap has a different depth
than the source pixmap. Thus the pixels in these two are not comparable,
and there is no way to draw from one to the other.

Both the Gdk and Imlib functions for creating pixmaps from XPM data will
create the mask for you. Imlib will also create the mask when loading a
PNG with alpha transparency. Imlib is much faster with XPM's by the way if
that matters for your app.

Your XPM for this purpose should have a "None" color, like this:

static char * suggests_xpm[] = {
"16 16 4 1",
"       c None",
".      c #8E388A288E38",
"X      c #FFFFD75C1861",
"o      c #000000000000",
"                ",
"       .        ",
"      .X.       ",
"     .XXX.      ",
"     .XXX.      ",
"    .XXXXX.     ",
"    .XXoXX.     ",
"   .XXo.oXX.    ",
"  .XXXo.oXXX.   ",
"  .XXXo.oXXX.   ",
" .XXXXXoXXXXX.  ",
" .XXXXXXXXXXX.  ",
".XXXXXXoXXXXXX. ",
".XXXXXXXXXXXXX. ",
"ooooooooooooooo ",
"                "};

A good place to look for image loading examples is the GnomePixmap widget
(if you don't want to download gnome-libs, try www.gnome.org/lxr)
That widget loads every kind of image.

HTH, 
Havoc




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