Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!spool.mu.edu!uwm.edu!linac!att!ucbvax!bloom-beacon!dont-send-mail-to-path-lines From: mouse@lightning.mcrcim.mcgill.EDU (der Mouse) Newsgroups: comp.windows.x Subject: Re: Color maps.... Message-ID: <9103280703.AA16051@lightning.McRCIM.McGill.EDU> Date: 28 Mar 91 07:03:05 GMT Sender: tytso@athena.mit.edu (Theodore Y. Ts'o) Organization: The Internet Lines: 49 > I am very new to the world of X programming so pardon me if I sound > stupid or that I didn't read the books thorough enough... This is a relatively frequent question, but you shouldn't have much trouble with it. You are already past the first hurdle most people seem to get stuck on. Fortunately, your problem is solvable. > The problem is, when I need to do logics with the colors, like > xoring, anding etc (e.g. white on blue gives yellow..etc), since I am > not using the default colorcells, I can't get the correct color for > the modes. I don't know what you're doing with 16 colors, when there are only three color channels, if you expect to work with primary colors this way, but that's your business.... > It's not as simple as blue (0001) on white (1111) xor gives yellow > (1110) because there's no way to know what color cells are allocated > (or is there?) Well, you know what cells are allocated because they're returned by the allocation call. > and even if we know, there's no systemetic scheme to do the logics. Right. You have to get lucky and get cells that happen to have the relationships you want. Now, what's the solution I implicitly promised above? Simply this: you tell the server to give you cells that are related the way you want. To do this, you have to allocate read/write cells instead of read-only cells (minor wart, but more or less unavoidable). What you actually want is to have a group of color cells that have all but four bits equal, then those four bits give you the sixteen combinations you want. The routine to allocate colormap cells this way is XAllocColorCells; you would want to call it with nplanes=4 and npixels=1. If it's important that all four bits be adjacent (which I gather in your case it is not), you can set contig True; otherwise, set it False. Of course, you can't blindly use GXxor even in this case; you need to take care to avoid clearing the "common" bits. You can do this by setting the plane-mask in the GC or by being careful to set the foreground and background values to something appropriate for the operation in question, take your pick.... der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu