Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Imaging With QuickDraw /
Chapter 4 - Color QuickDraw / Color QuickDraw Reference
Color QuickDraw Routines / Calculating Color Fills


CalcCMask

To determine where filling will not occur when filling from the outside of a rectangle, you can use the CalcCMask procedure, which indicates pixels that match, or are surrounded by pixels that match, a particular color.

PROCEDURE CalcCMask (srcBits,dstBits: BitMap; 
                     srcRect,dstRect: Rect; 
                     seedRGB: RGBColor; matchProc: ProcPtr;
                     matchData: LongInt); 
srcBits
The source image. If the image is in a pixel map, you must coerce its PixMap record to a BitMap record.
dstBits
The destination image, a BitMap record.
srcRect
The rectangle of the source image.
dstRect
The rectangle of the destination image.
seedRGB
An RGBColor record specifying the color for pixels that should not be filled.
matchProc
An optional matching procedure.
matchData
Data for the optional matching procedure.
DESCRIPTION
The CalcCMask procedure generates a mask showing where pixels in an image cannot be filled from any of the outer edges of the rectangle you specify. The CalcCMask procedure returns this mask in the dstBits parameter. This mask is a bitmap filled with 1's only where the pixels in the source image cannot be filled. You can then use this mask with the CopyBits, CopyMask, and CopyDeepMask procedures.

You specify a source image in the srcBits parameter, and in the srcRect parameter you specify a rectangle within that source image. Starting from the edges of this rectangle, CalcCMask calculates which pixels cannot be filled. By default, CalcCMask returns 1's in the mask to indicate which pixels have the exact color that you specify in the seedRGB parameter, as well as which pixels are enclosed by shapes whose outlines consist entirely of pixels with this color.

For instance, if the source image in srcBits contains a dark blue rectangle on a red background, and your application sets seedRGB equal to dark blue, then CalcCMask returns a mask with 1's in the positions corresponding to the edges and interior of the rectangle, and 0's outside of the rectangle.

If you set the matchProc and matchData parameters to 0, CalcCMask uses the exact color specified in the RGBColor record that you supply in the seedRGB parameter. You can customize CalcCMask by writing your own color search function and pointing to it in the matchProc procedure; your color search function might, for example, search for colors that approximate the color specified in the RGBColor record. As with SeedCFill, you can then use the matchData parameter in any manner useful for your application.

The CalcCMask procedure does not scale--the source and destination rectangles must be the same size. Calls to CalcCMask are not clipped to the current port and are not stored into QuickDraw pictures.

SEE ALSO
See "Application-Defined Routine" on page 4-92 for a description of how to customize the CalcCMask procedure.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996