[comp.sys.mac.programmer] Rgns from icons

heddle@clas01.cebaf.gov (David Heddle) (05/27/91)

Dear friends:

Does anyone have code for generating a rgn from an icon (bw and color).
I guess one uses the icon mask, but I don't know how to convert a 
bit map into a region. Presumably this is also how the lasso works
in a bit map painting program.

cheers,

dph

peirce@outpost.UUCP (Michael Peirce) (05/28/91)

In article <1991May27.132246.17040@murdoch.acc.Virginia.EDU>, heddle@clas01.cebaf.gov (David Heddle) writes:
> Dear friends:
> 
> Does anyone have code for generating a rgn from an icon (bw and color).
> I guess one uses the icon mask, but I don't know how to convert a 
> bit map into a region. Presumably this is also how the lasso works
> in a bit map painting program.

The following is a code fragment from some of my own code.  It uses
BitMapToRegion to convert the mask of a CICN into a region.  You used
to have to license this routine for some reason, but I *think* it's
built into System 7.


    oldSpotRgn := NewRgn;
    FailNIL(oldSpotRgn);
	
    HLock(Handle(fCICN));
    WITH fCICN^^ DO BEGIN
        iconBMap.baseAddr := @iconMaskData;
        FailOSErr(BitMapToRegionhccc(oldSpotRgn,iconBMap));

--  Michael Peirce         --   outpost!peirce@claris.com
--  Peirce Software        --   Suite 301, 719 Hibiscus Place
--  Macintosh Programming  --   San Jose, California 95117
--           & Consulting  --   (408) 244-6554, AppleLink: PEIRCE