CalcMask
CalcMask Calculate a mask for use in CopyMask
#include <Quickdraw.h> Quickdraw
void CalcMask(srcPtr, destPtr, srcRowBytes,destRowBytes, height, wrdsWide);
Ptr srcPtr ; address within a BitMap of place to start calculating
Ptr destPtr ; address within a BitMap of where to store 1s and 0s
short srcRowBytes ; source bitmap rowBytes
short destRowBytes ; destination bitmap rowBytes
short height ; height of src and dest rectangle, in pixels
short wrdsWide ; width of src and dest rectangle, in 16-bit words
CalcMask examines a portion of a bitmap and creates a mask that can be used
with CopyMask. It finds the outermost outline of any figure in the bitmap (as
in the lasso tool of many paint programs) and creates a mask having 1s in the
places where paint would "leak" were you to pour it inside the figure.
srcPtr is the address of a 16-bit word inside of a bitMap data area.
CalcMask will use this as if it were the upper left corner of an
implied " rectangle", as defined by height and wrdsWide. It will
examine this rectangle in creating the mask.
destPtr is the address of a 16-bit word inside of a bitMap data area.
CalcMask will use this as if it were the upper left corner of an
implied rectangle defined by height and wrdsWide. It will fill all or
part of this " rectangle" with 1s.
Note: srcPtr should not be the same as destPtr, since CalcMask
clears the data in destPtr when it starts.
srcRowBytes and . . .
destRowBytes are the widths of the BitMap into which srcPtr and destPtr,
respectively point, Ie, the function will add this value to its current
address pointer to move "down" in the bitMap.
height is the height, in pixels, of both the source data area and the
destination area.
wrdsWide is the width, in 16-bit words, of both the source and destination
data area.
Returns: none

Notes: Use CalcMask to build an mask that can be used in conjunction with
CopyMask to implement the "lasso" tool of many paint programs.
The easiest way to work with this function is to create one or more
BitMaps the size and shape of your work area or your window. See
SeedFill for an example of this memory-intensive technique.
Assume you have a Rect, r, in local coordinates and you wish to create a
mask for figure(s) inside that rectangle. One way to use this function is:
Determine the value of srcPtr; it will be offset from the start of
thePort-> portBits.baseAddr by an even number of bytes, calculated as
follows:
topOffset = r.top * thePort->portBits.rowBytes;
leftOffset = (r.left / 16 ) * 2;
srcPtr = thePort->portBits.baseAddr + topOffset + leftOffset;
Allocate an offscreen destination BitMap (see CopyBits and
SetPortBits). Use the baseAddr of that bitmap as your destPtr.
Obtain srcRowBytes and destRowBytes directly from the respective
BitMap structures.
height is simply r.bottom - r.top
wrdsWide is ( ((r.right-r.left)-1)/16 )+1;
After calling CalcMask, you can copy the screen data by using the
destination BitMap in a call to CopyMask.
This same system of pointers-into- bitMaps and manual-calculation-for-
things Quickdraw- should-do is used in SeedFill.
Note: When running on 256K ROMs, you may wish to use the more
flexible CalcCMask function in which the parameters are more
straightforward.