Important: The information in this document is obsolete and should not be used for new development.
CopyMask
You can use theCopyMaskprocedure to copy a bit or pixel image from one graphics port (or offscreen graphics world) into another graphics port only where the bits in a mask are set to 1.
PROCEDURE CopyMask (srcBits,maskBits,dstBits: BitMap; srcRect,maskRect,dstRect:\xDDRect);
srcBits- The source
BitMaprecord.maskBits- The mask
BitMaprecord.dstBits- The destination
BitMaprecord.srcRect- The source rectangle.
maskRect- The mask rectangle. This must be the same size as the rectangle passed in the
srcRectparameter.dstRect- The destination rectangle.
DESCRIPTION
TheCopyMaskprocedure copies the source bitmap or pixel map that you specify in thesrcBitsparameter to a destination bitmap or pixel map that you specify in thedstBitsparameter--but only where the bits of the mask bitmap or pixel map that you specify in themaskBitsparameter are set to 1. When copying images between color graphics ports, you must coerce eachCGrafPortrecord to aGrafPortrecord, dereference theportBitsfields of each, and then pass these "bitmaps" in thesrcBitsanddstBitsparameters. If your application copies a pixel image from a color graphics port calledMyColorPort, for example, you could specifyGrafPtr(MyColorPort)^.portBitsin thesrcBitsparameter.Using the
srcRectanddstRectparameters, you can specify identically or differently sized source and destination rectangles; for differently sized rectangles,CopyMaskscales the source image to fit the destination. When you specify rectangles in thesrcRectanddstRectparameters, use the local coordinate systems of, respectively, the source and destination graphics ports.The rectangle you pass in the
maskRectparameter selects the portion of the bitmap or pixel map that you specify in themaskBitsparameter to use as the mask.If you specify pixel maps to
CopyMask, they may range from 1 to 32 pixels in depth. The pixel depth of the mask that you specify in themaskBitsparameter is applied as a filter between the source and destination pixel maps that you specify in thesrcBitsanddstBitsparameters. A black mask pixel value means that the copy operation is to take the source pixel; a white value means that the copy operation is to take the destination pixel. Intermediate values specify a weighted average, which is calculated on a color component basis. For each pixel's color component value, the calculation is(1 - mask) source + (mask) destination
Thus high mask values for a pixel's color component reduce that component's contribution from the source
PixMaprecord.SPECIAL CONSIDERATIONS
Calls toCopyMaskare not recorded in pictures and do not print.See the list of special considerations for the
CopyBitsprocedure beginning on page 3-113; these considerations also apply toCopyMask.The
CopyMaskprocedure may move or purge memory blocks in the application heap. Your application should not call this procedure at interrupt time.SEE ALSO
You can use the bitmap returned by theCalcMaskprocedure, described on page 3-106, as the mask in order to implement a mask copy similar to that performed by the MacPaint lasso tool. In the same way, you could use the pixel map returned by theCalcCMaskprocedure, described in the chapter "Color QuickDraw."The chapter "Color QuickDraw" describes in more detail how to use
CopyMaskin a Color QuickDraw environment. Plate 3 at the front of this book illustrates how to use different colors in the mask to produce different effects in the destination pixel map; Listing 6-2 on page 6-10 in the chapter "Offscreen Graphics Worlds" shows the code that produced this plate. Plate 4 at the front of this book provides another illustration of the effects of the source and mask pixel maps on the destination pixel map.The
CopyDeepMaskprocedure (described next) combines the functions of theCopyMaskandCopyBitsprocedures.