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