Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!cica!gatech!ncsuvx!ecemwl!jnh From: jnh@ecemwl.ncsu.edu (Joseph N. Hall) Newsgroups: comp.sys.mac.programmer Subject: Re: Offscreen Bitmap / MultiFinder Message-ID: <3427@ncsuvx.ncsu.edu> Date: 18 Jul 89 17:50:57 GMT References: <14226@swan.ulowell.edu> Sender: news@ncsuvx.ncsu.edu Reply-To: jnh@ecemwl.UUCP (Joseph N. Hall) Organization: North Carolina State University Lines: 43 In article <14226@swan.ulowell.edu> jkeegan@hawk.ulowell.edu (Jeff Keegan) writes: >This is actually a two part question (I'm getting lazy).. > >One -> I want to have a window with a scroll bar that scrolls a large bitmap > horizontally. I want to create an off-screen bitmap (actually an > off-screen GrafPtr with it's own bitmap) and draw to that, then do > a copybits to the screen after receiving an update event or after > doing a scrollrect. Well, you CAN allocate your own GrafPtr if you want, but you can also use your window's GrafPtr ... Is this the best way to do it? It's certainly the best way to handle update events if you have trouble redrawing your window quickly. It also looks better. The NeXT maintains a full offscreen bitmap for each open window and handles all of this stuff automatically, by the way ... And how exactly do > I obtain the offscreen bitmap? I imagine that I must have to allocate > enough memory for the bitmap (with NewPtr most likely) and have the > baseAddr field of the bitmap point at that.. But how do I determine > exactly how bit that NewPtr value must be? I know that I want my > big-bitmap to have 7200 pixels across and a "n" pixels down.. Well, first of all, look up SetPortBits in IM vol. 1. You can use the window's own GrafPtr; just save the value of its portBits and then SetPortBits(yourBits). How do you MAKE your own offscreen bitmap? Well, it needs to be large enough to accomodate the existing window, and THEN it needs to be an even number of bytes wide. Thus rowBytes should equal ((horiz. pixels - 1) / 16) * 2 + 2. The total size (in bytes) of the bitmap will be rowBytes * vert. pixels. For simplicity, set bounds.left = bounds.top = 0, and bounds.right = horix. pixels, bounds.bottom = vert. pixels. This procedure is explained, although not exhaustively, in one of the early Tech Notes (sorry, don't remember the number). HIGHLY recommended reading, although you may be able to get this working without it. By the way, remember to scroll BOTH your bitmap and your window, if you're using the bitmap to "back up" the window's contents ...