home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / next / programm / 5378 < prev    next >
Encoding:
Internet Message Format  |  1992-07-30  |  2.6 KB

  1. Path: sparky!uunet!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!unido!prim!dave
  2. From: prim!dave@germany.eu.net (Dave Griffiths)
  3. Newsgroups: comp.sys.next.programmer
  4. Subject: Bitmap Wizard
  5. Message-ID: <1992Jul31.161845.368@prim>
  6. Date: 31 Jul 92 16:18:45 GMT
  7. Organization: Primitive Software Ltd.
  8. Lines: 52
  9.  
  10. I'm posting this for a friend:
  11.  
  12.  
  13. Hi there!
  14.  
  15. I am having a problem with reading and writing bitmap images, and
  16. thought I would poll the assembled gurus out there.
  17.  
  18. Some background:
  19.  
  20. I am writing a Pinball game which has a TIFF file background onto
  21. which objects such as flippers, balls, bumpers and lights are
  22. composited.  These objects are initially drawn into NXImages and
  23. then composited where needed onto the view containing the background.
  24.  
  25. I need to do "hit detection" to determine when the ball has hit an
  26. object, and the fastest and easiest way of doing that appears to be to
  27. have a "shadow" pinball table onto which I draw shadows of things that
  28. the ball can hit.  The background of this shadow table is white, and
  29. walls (which balls just bounce off) are light grey.  Reactive objects
  30. like bumpers and flippers are dark grey.  Whenever I draw an object on
  31. the table (say redrawing a flipped flipper) I redraw its shadow (a
  32. simple dark grey outline) on the shadow table.  Thus whenever I move
  33. the ball(s) I read from the point on the shadow table just ahead of
  34. them, and if it is a wall I do a bounce, if it is a flipper etc. (dark
  35. grey) I work out which object it is, then send a message to that
  36. object saying it has been hit etc.
  37.  
  38. So what I am saying is that I need to be able to create a bitmap which
  39. I can composite onto, and from which I can read pixel values, very
  40. very fast.  Reading pixel values fast means I need to know where in
  41. memory the bitmap is stored.
  42.  
  43. Now, to use the NeXT composite methods I need to use NXImages or
  44. Views.  If I want to alter a bitmap image it MUST be an
  45. NXCachedImageRep because if I try to alter a NXBitmapImageRep it just
  46. changes a cached copy, and seeing as I don't know where the cached
  47. copy is, I can't read pixels back from it.  Also, with
  48. NXCachedImageReps I cannot find out where the bitmap is stored in
  49. memory (I can get the offscreen window it is stored in).
  50.  
  51. Help, I don't know what to do; I can lockFocus on the
  52. NXCachedImageRep, and copy the bit into a newly allocated
  53. NXBitmapImageRep, get the address of *that* bitmap and read the pixel,
  54. but that takes forever.  Has anyone (Ali Ozer?) got any ideas?
  55.  
  56. Thanks in advance,
  57.  
  58. Tim Bissel.
  59.  
  60. PS.  This is being posted for me by a friend, but you can reply to him,
  61.      post replies or try mailing me at ...unido!portland!tim
  62.