Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!sdd.hp.com!think.com!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!tcdcs!bofin!cjmchale From: cjmchale@cs.tcd.ie (Ciaran McHale) Newsgroups: comp.windows.x Subject: Re: overlay function in X Message-ID: <1991Feb22.144752.17371@cs.tcd.ie> Date: 22 Feb 91 14:47:52 GMT References: <9102220729.AA00513@lightning.McRCIM.McGill.EDU> Organization: DSG, Dept. of Comp. Sci., Trinity College, Dublin. Lines: 65 In <9102220729.AA00513@lightning.McRCIM.McGill.EDU> mouse@lightning.mcrcim.mcgill.EDU writes: >>> In case there's anyone out there who cares, something I would really >>> like in X is an overlay function of the sort > >>> pixel_out = (pixel_1 == 0 ? pixel_2 : pixel_1); > >Me too, though I'd prefer for the 0 to be variable. > >> Try XCopyPlane. I think it does exactly what you want. > >No, what that does is > > pixel_out = ((pixel_1 & bit) == 0) ? color_A : color_B; Consider the case where you want to display a satellite image in a window and overlay some contour lines on it. This can be achieved by the following: #define Bitmap Pixmap Window win; /* window to display stuff in */ Pixmap image_pixmap; /* for satellite image */ Bitmap contour_bitmap; /* for contour lines */ GC gc; ... /* initialisation; create the Window, Pixmap, Bitmap and GC */ ... /* draw the satellite image into image_pixmap */ ... /* draw the contour lines into contour_bitmap */ /* expose handling code */ /* redraw the satellite image to the window */ XSetClipMask(dpy, gc, None); /* no clipmask */ XCopyArea(dpy, image_pixmap, win, gc, ...); /* overlay the contour lines on top of the satellite image */ XSetClipMask(dpy, gc, contour_bitmap); XCopyPlane(dpy, contour_bitmap, win, gc, ..., 1L); The above code gives an overlay because the clipmask of (the GC used in) XCopyPlane() is the same as its source pixmap. Things to watch out for: 1. Set the foreground of gc to be the colour that you want the contour lines to be drawn in. 2. You'll need a different GC for drawing the contour lines into the contour_bitmap since this is a different depth than the image_pixmap/window (unless you're on a monochrome display). Disclaimer: I haven't tried any of this. But from my understanding of Xlib I think it should work. Ciaran. -- Ciaran McHale "Verbosity says it all" ____ Department of Computer Science, Trinity College, Dublin 2, Ireland. \ / Telephone: +353-1-772941 ext 1538 FAX: +353-1-772204 \/ Telex: 93782 TCD EI email: cjmchale@cs.tcd.ie