Path: utzoo!censor!geac!torsqnt!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!samsung!usc!apple!well!oster From: oster@well.sf.ca.us (David Phillip Oster) Newsgroups: comp.sys.mac.programmer Subject: Re: ARGH!! Trivial Question; Please Help Message-ID: <16616@well.sf.ca.us> Date: 11 Mar 90 13:08:53 GMT References: Reply-To: oster@well.UUCP (David Phillip Oster) Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 34 In article jackiw@cs.swarthmore.edu (Nick Jackiw) writes: _>I've been knocking myself out over a simple (stupid) question: _>I want to copyBits from one pixmap to another without using any cGrafPorts. _>How? _>IM V says "CopyBits now accepts either bitMaps or pixMaps as parameters." _>Obviously, CopyBits(pixMapHandle^^,pixMapHandle^^,...) isn't going to work; _>pixMapHandle^^ is not the same type as BitMap, and even if I coerce it _>into so believing, with CopyBits(BitMapHandle(PixMapHandle)^^,) I'm _>hacking off many of the fields of the pixMap (including important ones _>like pixelDepth) and I get stack overflows, bus errors, and other symptoms _>of the Wrong Approach. The correct call is: HLock(Handle(srcPixMapHandle)); HLock(Handle(destPixMapHandle)); CopyBits(BitMapHandle(srcPixMapHandle)^^, BitMapHandle(destPixMapHandle)^^, srcRect, destRect, srcCopy, NIL); HUnlock(Handle(srcPixMapHandle)); HUnlock(Handle(destPixMapHandle)); CopyBits will look at the rowBytes field and do the right thing. (or, it will look at the version field an do the right thing.) But, it will move memory, so you have to lock the pixMapHandles acorss the call. If you remember your Inside Mac Vol 1. Assem. Lang. Interface., large structures are passed by reference in pascal, so you are not chopping off anything important. The stucture of a pixmap was designed specifically to make this work. Note: this uses the inverse table of the current Graphic Device to do color table arbitration if the two pixmaps use different color tables. -- -- David Phillip Oster - Note new address. Old one has gone Bye Bye. -- oster@well.sf.ca.us = {backbone}!well!oster