Re: the problem of transparency



Dear every professional Linux engineer:
    We are developing a project with gtk of Linux but It is very hard for us
to deal transparency problem.
    The following is  about the detail of the problem.
    We want loading two JPG files, one of both is background picture ,
and the other is transparecy picture over the background  picture . Can you
tell us the method of realizing it with gtk of imlib.
    We are using the following method to deal it but failed

 GdkImlibImage *im;
 GdkImColor color;
 int r ,g ,b;
 gdk_imlib_get_image_shape(im,&color);
 r = color.r
 g = color.g
 b = color.b
 color.r = 255;
 color.g = 255;
 color.b = 255;
gdk_imlib_set_image_shape(im,&color);

the picture of im can not be changed to be transparency.
We feel very upset and please tell us how to slove the problem.

I can't recall if imlib returns a bitmap, but a bitmap is the key to your
problem.

Once you have a bitmap, create a GdkBitmap!  Then create a GtkDrawingArea.

What you'll do is first `clear' the GtkDrawingArea by simply drawing your
background image from the GdkPixmap.

        gdk_draw_pixmap(...);

Then (and this will require the use of a GC, create a new GdkGC) draw the
foreground image with transparency.

        gdk_gc_set_clip_mask(gc_fg, mask);
        gdk_gc_set_clip_origin(gc_fg, x, y);

        gdk_draw_pixmap(...);

The coordinates passed to gdk_gc_set_clip_origin() must match those you
specified for the foreground pixmap in gdk_draw_pixmap().

So to review:

Create a GtkDrawingArea widget to draw on to, next:

You'll need a GdkPixmap of the background image, a GdkPixmap and GdkBitmap
(the mask) of the foreground image.  Also a special GC that you keep track
of when drawing the foreground image (for transparency).

Xlib/Gdk *DOES* support transparency, it's just ignorance that some people
think it dosen't.

Note, you can draw the background image with the regular GC.

--
Sincerely,                  ,"-_                         \|/
-Capt. Taura M.             ,   O=__                    --X--
..__                         ,_JNMNNEO=_                 /|\
OMNOUMmnne.                  {OMMNNNEEEEOO=_
UOOOBIOOOEOMMn.               'LONMMMMNNEEEOOO=.__..,,..
UUOOEUUOOOOOOOObe              '"=OMMMMWNEEEOOOOO,"=OEEEOO=,._
OOUUUIEEIOONNOIUbe.                "7OMMMMNNNNNWWEEEEOOOOOO"   "'.
EEBNNMMMNWNWWEEIMMNe.             __  7EMMMNNNNNWWWEEEEEEEOO.     " .
NNMMMMWWWMMMWEINMMMNn            "=BBEEEEMMMMMMMMNNNWWWEEOOOOO=._     .
                  http://furry.ao.net/~learfox/





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