Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!nosc!ucsd!ucbvax!hplabs!well!wdh From: wdh@well.UUCP (Bill Hofmann) Newsgroups: comp.sys.mac.programmer Subject: Re: how do I find bit-depth of a window? Summary: Read Vol 5: Graphic devices (GetMaxDevice, gdHandles) Keywords: QuickDraw BitMap PixMap Message-ID: <6641@well.UUCP> Date: 27 Jul 88 16:15:09 GMT References: <2127@uhccux.uhcc.hawaii.edu> Reply-To: wdh@well.UUCP (Bill Hofmann) Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 40 >#1: Given a window, and a Rect in that window's coordinates, how can I tell >if that rectangle's contents are currently displayed on a single monitor >with one-bit color, addressable as an old-style BitMap? First, convert the rect to global coords (by being sure the window is the current port, then, by doing LocalToGlobal on the topLeft and botRight points of the Rect. Then, do a GetMaxDevice(&yourRect), which will return the deepest device that intersects your rect (it returns a GDHandle). E.g.: if (deepest = GetMaxDevice(&yourRect)) /* in case NO device matches */ { if ((*(*deepest)->gdPMap)->pixelSize == 1) /* use the pixmap's baseAddr */ ; } >#2: If that rectangle is indeed addressable as a BitMap, but the window >overlaps several monitors, how do I find the address for the Rect in >question? Once you've done the above, you've got the pixmap for the 1 bit device that your window rect is on. Somewhere in the depths of Vol 5 they mention which device the portBits points to-but it is pretty much ignored by color QD, as I recall. I think it's the first device on the list that the window's in, or maybe the main device, but don't quote me. So once you've found the device, you've got the pixmap, and thus you have your address (somewhere in NuBus space) and you have *your* rect (in global coords) and from the device, you can get the rect *it* represents ((*deepest)->gdRect), then you can intersect the two, and use your head to figure the address, given the rowBytes and etc. Beware: if you muck with the gdRect, you can really screw things up (speaking from experience). Note esp. that rowBytes MUST be used, not other indicators of screen width. So how is it that MacDTS refuses to answer technical questions 3 weeks before MacWorld? Seems like an ill-guided policy to me (I've got at least one fairly burning question in the queue...). -Bill Hofmann