Xref: utzoo comp.sys.mac.programmer:13170 comp.graphics:10367 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!rice!uw-beaver!mit-eddie!bbn!bbn.com!mesard From: mesard@bbn.com (Wayne Mesard) Newsgroups: comp.sys.mac.programmer,comp.graphics Subject: color bitplanes on a Mac? Message-ID: <53503@bbn.COM> Date: 14 Mar 90 18:07:20 GMT Sender: news@bbn.COM Reply-To: mesard@BBN.COM (Wayne Mesard) Organization: Bolt Beranek and Newman Inc., Cambridge MA Lines: 58 Summary: -------- I want to use bitplanes on a MacII. How to do this isn't at all clear to me. I'm hoping that I'm revealing some profound ignorance on my part about Mac color or graphics or both and that someone can set me straight. Painfully verbose elaboration: --------- ------- ------------ I'm just getting into my first color Mac application. I hope someone can straighten me out on something: Suppose I want to draw N (where N <= 7) objects in a window. The objects may overlap, and can be drawn and erased in an arbitrary order. Now, in a conventional 8-bit color lookup table (CLUT) system, I would use a technique known as bitplaning: Assign each object to a bit in the 8 bit color table index and construct the color table in such a way that the rendered color reflects the high bit of the index. For example, if I have 5 objects, I'll need 5 bitplanes (i.e. a CLUT of size 2^5 == 32): Index In binary Color ----- --------- ----- 0 00000000 black 1 00000001 blue 2-3 0000001x salmon 4-7 000001xx green 8-15 00001xxx orange 16-31 0001xxxx magenta So, to draw object 3 (green), simply do a binary Or with 4 on each pixel value. Pixels that were black, blue or salmon will appear green. Pixels that were orange and magenta will appear unchanged. To erase, simply Xor the image. Details left as an exercise for the reader. [I've oversimplified a lot here, but that's the basic idea.] My problem [finally] is that transfer modes described in Inside Mac volume V all operate on the _RGB_ values of the pixel, as opposed to the _index_ values. I really expected the patXor mode to do what I wanted, but it seems that they really mean it when they say if "used on a colored destination, the color of the [result] isn't defined." Two possible solutions that come to mind are: 1) using the addOver and subOver drawing modes. 2) add a SearchProc for the device. But these are just stabs in the dark. A Right solution doesn't leap out at me. Bitplaning is such an immensely useful thing, that I can't believe that the Mac doesn't provide something similar without resorting to all kinds of contortions and ugly hacks. I've been all through the relevant chapters of IM-V, and I've come up empty-handed. Can anyone point me in the right direction? Thanks in advance. -- void Wayne_Mesard(); Mesard@BBN.COM Bolt Beranek and Newman, Cambridge, MA