[comp.sys.mac.programmer] Drawing an ICN# or its mask

borcelf@jacobs.cs.orst.edu (Fernando Borcel) (01/12/89)

Here's a LSP example on drawing an ICN# or its mask (something that puzzled me
for awhile...)

---

var
     mybitMap: BitMap;   {Where the ICN# picture is saved}
     bounds: rect;       {Part of the icon to be drawn (ICON or Mask)}
     destRect: rect;     {Where the icon will be drawn in the window}
     mywindow: GrafPtr;  {The window where the drawing occurs}
     MyIcon: Handle;     {Handle to an ICN#}
     ...
     ...

     MyIcon:= getResource('ICN#', icnID);
     ...
     ...
     mybitMap.baseAddr := MyIcon^;   {MybitMap points now to MyIcon}
     mybitMap.rowbytes := 4;         {ICN#'s are 4 bytes wide}
     setpt(myBitMap.bounds.topleft, 0, 0);
     setpt(mybitMap.bounds.botright, 32, 64);

{use next two lines to draw icon}
     setrect(bounds, 0, 0, 32, 32);  {Upper part of MyIcon}
     copybits(mybitMap, mywindow^.portbits, bounds, destrect, srcCopy, nil);

{use next two lines to draw Mask on the Icon}
     setrect(MaskBounds, 0, 32, 32, 64); {Lower part of MyIcon}
     copybits(mybitMap, mywindow^.portbits, Maskbounds, destrect, Mask, nil);

     ...

---

Of course you'll have to keep track of all your Icon's locations yourself, but
other than that it's pretty straight-forward.  It worked for me...

	-Fernando

 
    ___                       __                |{tektronix,hp-pcd}!orstcs!
   /   _  _  _  _  _  _/ _   /_/  _  _  _  _ /  |  jacobs.cs.orst.edu!borcelf
  /- /_// // / _// // // /  /  )/ // //  /_//   | 
_/  /_ /  / //_// //_//_/  /__//_//  /_ /_ /_   |borcelf@jacobs.cs.orst.edu