Important: The information in this document is obsolete and should not be used for new development.
CopyMaskYou can use the
CopyMaskprocedure 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);
- The source
- The mask
- The destination
- The source rectangle.
- The mask rectangle. This must be the same size as the rectangle passed in the
- The destination rectangle.
CopyMaskprocedure copies the source bitmap or pixel map that you specify in the
srcBitsparameter to a destination bitmap or pixel map that you specify in the
dstBitsparameter--but only where the bits of the mask bitmap or pixel map that you specify in the
maskBitsparameter are set to 1. When copying images between color graphics ports, you must coerce each
CGrafPortrecord to a
GrafPortrecord, dereference the
portBitsfields of each, and then pass these "bitmaps" in the
dstBitsparameters. If your application copies a pixel image from a color graphics port called
MyColorPort, for example, you could specify
dstRectparameters, 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 the
dstRectparameters, 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 the
maskBitsparameter 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 the
maskBitsparameter is applied as a filter between the source and destination pixel maps that you specify in the
dstBitsparameters. 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
SPECIAL CONSIDERATIONSCalls to
CopyMaskare 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 to
CopyMaskprocedure may move or purge memory blocks in the application heap. Your application should not call this procedure at interrupt time.
SEE ALSOYou can use the bitmap returned by the
CalcMaskprocedure, 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 the
CalcCMaskprocedure, 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.
CopyDeepMaskprocedure (described next) combines the functions of the