Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!crdgw1!uakari.primate.wisc.edu!sdd.hp.com!spool.mu.edu!think.com!mintaka!bloom-beacon!dont-send-mail-to-path-lines From: mouse@lightning.mcrcim.mcgill.EDU (der Mouse) Newsgroups: comp.windows.x Subject: Re: NEEDED: Color "OR" operation Message-ID: <9105160408.AA05642@lightning.McRCIM.McGill.EDU> Date: 16 May 91 04:08:50 GMT Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 73 > I need the ability to specify a color dominance in graphics > operations in X. More or less a graphics "OR" routine. I need an > efficient means of doing this with XPutImage (I DO NOT want to copy > back the pixmap section and do the "OR" locally since that would > involve multiple transfers, very inefficient). The situation is > this: I have a bitmap (1 plane pixmap) locally, and I wish to place > it onto a server (color or bw) and I want to be able to specify this > behavior: > source dest result > ------ ---- ------ > fg fg fg > fg bg fg > bg fg fg > bg bg bg I thought the source was only 1 bit deep...should the left column be 1s and 0s perhaps? > bg represents the background (or actually, any) color (index) > fg represents the foreground (or color to dominate) color (index) > Is there some efficient means of implementing this? For arbitrary indices? No; you need two copy calls in the general case. (Or, you need to use one of the tricks below, like the stipple trick.) If you are allocating the colors yourself, you need only two of them, and your Visual is appropriate, you can use XAllocColorPlanes to request one bitplane and one pixel, set the window's backing-pixel to the pixel value and the backing-planes to the plane bitmask, then set your GC's planemasks to write to only the plane in question, and pretend you're on a monochrome server where you can get any effect you want by using one of GXand, GXor, GXnand, or GXnor. Another possibility is to set the GC's stipple to the bitmap, the fill-style to FillStippled, the foreground to fg, and do a FillRectangle operation. Another possibility is to set the GC's clip-mask to the bitmap, the foreground to fg, and do a FillRectangle; however, I *think* the MIT server turns clip-masks into lists of rectangles, and if the picture doesn't decompose nicely into rectangles this will (a) eat up server memory and (b) draw comparatively slowly. It will also cost some setup time while the server scans the bitmap and sets up the rectangles. And what the MIT server does, many other servers pick up. (I'm sure I'll be corrected if I misread that code....) > Is there a way of mapping all pixels of a certain color within a > region to be another color (on the server)? Not within the core protocol, at least without making assumptions about the presence of other colors. > Is there a friendly way of allocating a color to be at indices 0 and > 1 without screwing up the global color map? No. But the AllocColorPlanes operation I outlined above will almost always succeed, and it gives you most of the benefits you'd have if you could ensure your colors were at 0 and 1. (Assuming a dynamic visual. You naturally will have to live with the color indices you get if you have to use a static visual.) > Will R5 take care of this :) ? I'd be surprised if R5 changes anything bearing on my comments above, except perhaps the bit about the (in)efficiency of clip-masks. der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu