alan@cogswell.Jpl.Nasa.Gov (Alan S. Mazer) (01/24/91)
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); There are many functions for combining pixels, but most of them don't seem to be too useful. Right now I do this in the client, but for large sets of pixels this is a pain. Please use e-mail for comments; I don't have time to read news anymore. Too busy trying to get decent overlaying :-). -- -- Alan # My aptitude test in high school suggested that ..!ames!elroy!alan # I should become a forest ranger. Take my alan@elroy.jpl.nasa.gov # opinions on computers with a grain of salt.
ekberg@asl.dl.nec.COM (Tom Ekberg) (02/19/91)
> 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); Try XCopyPlane. I think it does exactly what you want. If the bit in the bitmap is 0 then it draws the background color; if it is one then it draws the foreground color. -- tom, ekberg@aslss02.asl.dl.nec.com (x3503)
mouse@lightning.mcrcim.mcgill.EDU (02/22/91)
>> 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; What I took the original posting to be asking for was something which would do the given computation *for each pixel*. That is, given two drawables, each (say) 8 bits deep, it would do the equivalent of a copy of area 1 onto area 2, except that pixels in area 1 that had value 0 would leave the corresponding pixels in area 2 unchanged, instead of copying the 0. (As I said, though, I would want the 0 to be variable.) My guess is that this would be simple to implement (in the server, as an extension, say) but without hardware assist, it would be difficult to make it run reasonably fast. Of course, I haven't looked at it in any detail, so I could well be wrong. der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu
cjmchale@cs.tcd.ie (Ciaran McHale) (02/22/91)
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