Important: The information in this document is obsolete and should not be used for new development.
CopyMask
You can use theCopyMask
procedure 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
BitMap
record.maskBits
- The mask
BitMap
record.dstBits
- The destination
BitMap
record.srcRect
- The source rectangle.
maskRect
- The mask rectangle. This must be the same size as the rectangle passed in the
srcRect
parameter.dstRect
- The destination rectangle.
DESCRIPTION
TheCopyMask
procedure copies the source bitmap or pixel map that you specify in thesrcBits
parameter to a destination bitmap or pixel map that you specify in thedstBits
parameter--but only where the bits of the mask bitmap or pixel map that you specify in themaskBits
parameter are set to 1. When copying images between color graphics ports, you must coerce eachCGrafPort
record to aGrafPort
record, dereference theportBits
fields of each, and then pass these "bitmaps" in thesrcBits
anddstBits
parameters. If your application copies a pixel image from a color graphics port calledMyColorPort
, for example, you could specifyGrafPtr(MyColorPort)^.portBits
in thesrcBits
parameter.Using the
srcRect
anddstRect
parameters, you can specify identically or differently sized source and destination rectangles; for differently sized rectangles,CopyMask
scales the source image to fit the destination. When you specify rectangles in thesrcRect
anddstRect
parameters, use the local coordinate systems of, respectively, the source and destination graphics ports.The rectangle you pass in the
maskRect
parameter selects the portion of the bitmap or pixel map that you specify in themaskBits
parameter 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 themaskBits
parameter is applied as a filter between the source and destination pixel maps that you specify in thesrcBits
anddstBits
parameters. 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
PixMap
record.SPECIAL CONSIDERATIONS
Calls toCopyMask
are not recorded in pictures and do not print.See the list of special considerations for the
CopyBits
procedure beginning on page 3-113; these considerations also apply toCopyMask
.The
CopyMask
procedure 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 theCalcMask
procedure, 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 theCalcCMask
procedure, described in the chapter "Color QuickDraw."The chapter "Color QuickDraw" describes in more detail how to use
CopyMask
in 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
CopyDeepMask
procedure (described next) combines the functions of theCopyMask
andCopyBits
procedures.