ADC Home > Reference Library > Technical Q&As > Carbon > Graphics & Imaging >
Not Recommended Document
Important: The information in this document is Not Recommended and should not be used for new development.
Current information on this Reference Library topic can be found here:
Technical Q&A QD27
Problems Creating a Mask for a Picture
|
Q: I want to create a mask for a picture, such that the mask is 0
wherever the picture's pixels are pure white, and 1 everywhere else. My first try was to
simply use CopyBits to copy the rectangle enclosing the PICT onto a same-sized
rect in a 1-bit-deep offscreen world. This didn't work, however, as the yellows
get transformed to 0, which is not what I want. I tried various transfer modes
with CopyBits (from 0 to 100) to no avail. The SeedCFill and the CalcCMask
routines don't seem to be what I want either, because it appears that their
masks have to be keyed off a certain point or side(s). I can take the brute
force approach and go through the pixels of the PICT one by one, checking to
see if they're white and setting the mask accordingly, but this seems insane.
Is there a good method for doing this?
A: The way to do this is to install a custom color search procedure,
then call CopyBits to copy into the 1-bit GWorld and let the search proc determine the
color to use. The search proc would simply look at the color asked for and return white if
it's white or black if it's nonwhite.
See "Color Manager" in Inside Macintosh: Advanced Color Imaging
(forthcoming in print from Addison-Wesley).
|
[Sep 15 1995]