[comp.sys.mac.programmer] Storing an icon as a region

markham@phi.cs.unc.edu (Andrew Markham) (08/01/89)

I would like to take an ICON resource, read it in and somehow store it as
a Region so that I can take advantage of the "Quickness" of regions in 
comparison to icons.  Basically I do the following:

/* this to get it initially */
GetIcon(theIcon,iconID);
SetRect(theRect,left,top,right,bottom);
PlotIcon(theRect,theIcon);

/* and this to move it around */
EraseRect(theRect);
OffsetRect(theRect, horiz, vert);
PlotIcon(theRect,theIcon);

in order to move the icon around on the screen.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

It just seems that it would be much faster to do this:

/* this to get it initially */
GetIcon(theIcon,iconID);
iconRgn:= NewRgn;
OpenRgn;
SetRect(theRect,left,top,right,bottom);
PlotIcon(theRect,theIcon); 		/* does this work? it didn't for me */
CloseRgn(iconRgn);

/* and this to move it around */
EraseRgn(iconRgn);
OffsetRgn(iconRgn,horiz,vert);
FrameRgn(iconRgn);




I would think this possible, but what am I doing wrong?

Is there a better way to do this?  It seems pretty cumbersome, but I found
no better "obvious" way.  Plus, I just started and haven't become accustomed
to regions, bitmaps, etc...

Please e-mail any advice.

Thank you,

Andrew W. Markham 			<markham@sunmail.cs.unc.edu>
Computer Science Department			UNC-CH
"Nobody in the world can cover my main man Michael Jordan. No, No, Nooobody."
					-Mars Blackmon

stores@unix.SRI.COM (Matt Mora) (08/01/89)

In article <9043@thorin.cs.unc.edu> markham@phi.cs.unc.edu (Andrew Markham) writes:
>I would like to take an ICON resource, read it in and somehow store it as
>a Region so that I can take advantage of the "Quickness" of regions in 
>comparison to icons.  Basically I do the following:

>/* this to get it initially */
>GetIcon(theIcon,iconID);
>iconRgn:= NewRgn;
>OpenRgn;
>SetRect(theRect,left,top,right,bottom);
>PlotIcon(theRect,theIcon); 		/* does this work? it didn't for me */
>CloseRgn(iconRgn);

I quote from IM "While a region is open, all calls to Line, LineTo, and the
 procedures
that draw framed shapes (except arcs) affect the outline of the region.
Only the line endpoints and shape boundaries affect the region
definition; the pen mode, pattern, and size do not affect it."

The call to PlotIcon will not be recorded in the rgn.

Apple has some code called "bitmaptoRgn" that will do what you want.

I'm not to sure of the name, and I think you have to license the code
from Apple.









-- 
___________________________________________________________
Matthew Mora
SRI International                       stores@unix.sri.com
___________________________________________________________