Path: utzoo!utgpu!watserv1!watmath!att!pacbell!pacbell.com!ucsd!swrinde!zaphod.mps.ohio-state.edu!uwm.edu!psuvax1!swatsun!jackiw From: jackiw@cs.swarthmore.edu (Nick Jackiw) Newsgroups: comp.sys.mac.programmer Subject: Re: CalcMask Message-ID: <49QP9FC@cs.swarthmore.edu> Date: 31 Aug 90 17:26:21 GMT References: <1990Aug31.154627.14859@midway.uchicago.edu> Reply-To: jackiw@cs.swarthmore.edu (Nick Jackiw) Organization: Visual Geometry Project, Swarthmore College, PA Lines: 49 gft_james@gsbacd.uchicago.edu writes: > > PROCEDURE CalcMask (srcPtr,dstPtr: Ptr; srcRow, dstRow, height, > words: INTEGER); > > This sounds like exactly what I need, but I can't for the life of me figger out > [what the arguments should be] "The SeedFill+CalcMask procedures operate on a portion of a bitmap. In both routines, srcPtr and dstPtr point to [the bits themselves, not the bitmap. e. g. srcPtr:=yourBitMap.baseAddr]. SrcRow and dstRow specify the row width in bytes (i. e. the rowBytes field of the BitMap record) ... . Height and words determine the number of bits to be filled or calculated; words is the width of the rectangle in words and height is the height off the rectangle in pixels." [IV-24] Thus, in two equi-sized and bounded bitmaps, aBits and bBits, to calculate in bBits an image of the portion of aBits stored in aRect, do: const pixPerByte=8; {Assume B&W} var aRect:Rect; aBits, bBits:BitMap; srcPtr,dstPtr:ptr; offset:longint; begin {Assume aBits, aRect, and bBits are all appropriately initialized} {aRect must delimit an area which begins and ends on word boundaries} {in the bitmaps.} {The bits we want to mask begin somewhere at or past aBits.baseaddr.} offset:=aBits.rowBytes*(aRect.top-aBits.bounds.top); {Move some rows down} offset:=offset+(aRect.left-aBits.bounds.left) div pixPerByte; {Move over} CalcMask(ptr(ord(aBits.baseAddr)+offset), ptr(ord(bBits.baseAddr)+offset), aBits.rowBytes,bBits.rowBytes, (aRect.bottom-aRect.top), (aRect.right-aRect.left) div (2*pixPerByte)); end; Hint: Without Inside Mac IV, life itself would be impossible. -- +-------------------+-jackiw@cs.swarthmore.edu / !rutgers!bpa!swatsun!jackiw-+ | nicholas jackiw | jackiw%campus.swarthmore.edu@swarthmr.bitnet | +-------------------+-VGP/MathDept/Swarthmore College, Swarthmore, PA 19081--+ "Ah...I've got this CHRONIC pain." _True Believer_