home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / mac / programm / 20253 < prev    next >
Encoding:
Internet Message Format  |  1992-12-23  |  2.3 KB

  1. Path: sparky!uunet!spool.mu.edu!olivea!pagesat!spssig.spss.com!uchinews!dent.uchicago.edu!greg
  2. From: greg@dent.uchicago.edu (Greg Kuperberg)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: Looking at a bit in a bitmap truly bytes. Help!
  5. Message-ID: <1992Dec23.155102.4442@midway.uchicago.edu>
  6. Date: 23 Dec 92 15:51:02 GMT
  7. References: <1992Dec22.004631.14531@midway.uchicago.edu> <1992Dec22.205409.28125@kth.se>
  8. Sender: news@uchinews.uchicago.edu (News System)
  9. Organization: Dept. of Mathematics, U. of Chicago
  10. Lines: 41
  11.  
  12. In article <1992Dec22.205409.28125@kth.se> d88-jwa@hemul.nada.kth.se (Jon Wtte) writes:
  13. >What's non-oo about chasing down the mask? Don't you store objects
  14. >of icons in a decent data structure, check which one was clicked
  15. >and call the GetMask method of it? 
  16.  
  17. You shouldn't be surprised that I store the icon with a CIconHandle.
  18. It's a good thing it's a cicn and not an ICON, because then it would
  19. just be a Handle and I'd have no idea where the mask is.
  20.  
  21. By the way, I was pleasantly surprised that if you have cicn's,
  22. there is no need to have a duplicate lists of ICON's.
  23.  
  24. >Or even better, have the Icon object know how to check its own mask.
  25.  
  26. The point is not that I'd like to have my own nifty objects that
  27. obediently inspect themselves.  When it's important to wrap some
  28. variables in an object I'll do it.
  29.  
  30. Rather, I'd like to respect the Toolbox's informal notion of objects.
  31. I know when I change my data structures.  I don't know when Apple is
  32. going to change theirs.
  33.  
  34. >What I would do is open a new port, SetPortBits to
  35. >a known scratch space one longword long, and move
  36. >the origin and clip so that you know what's going on,
  37. >and draw the icon MASK into that port, then DisposePort
  38. >the port.
  39.  
  40. Here are some suggests that have variously come from
  41. you, me, Jamie McCarthy, and Matthew Russotto:
  42.  
  43. 1) Grab the baseAddr and read the raw bytes.
  44. 2) SetPortBits to the mask and use GetPixel.
  45. 3) SetPortBits to the mask and do a teeny weeny CopyBits to scratch space.
  46. 4) SetPortBits to scratch and do a teeny weeny CopyBits from the mask.
  47. 5) Use BitMapToRgn if it exists and then use PtInRgn.
  48.  
  49. What I ended up doing was writing a routine that does 1) and I called
  50. it PtInBitMap.  If the folks at Apple are reading this they should
  51. try to throw such a routine into the Toolbox at some point.  I don't
  52. understand how Quickdraw could have PtInRect but not PtInBitMap.
  53.