Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!gatech!bbn!ulowell!hawk!jkeegan From: jkeegan@hawk.ulowell.edu (Jeff Keegan) Newsgroups: comp.sys.mac.programmer Subject: Slightly more elaborate offscreen bitmap prob. Message-ID: <14324@swan.ulowell.edu> Date: 24 Jul 89 07:52:41 GMT Sender: news@swan.ulowell.edu Reply-To: jkeegan@hawk.ulowell.edu (Jeff Keegan) Organization: University of Lowell, CS Dept Lines: 71 I took the advice given to me by many people, and read tech. note #41 on drawing to offscreen bitmaps. It had exactly the information I was looking for. Thanks to all who replied.. However I've run into a slightly different problem now and I'm beginning to wonder if the way I want to tackle the problem can be done. Let me explain.. I'm writing a program that will have as part of it a "time line". For various reasons I have decided that I want to save it as a very long (wide) offscreen bitmap (7200 pixels), and when an update event comes along I read my scrollbar and calculate which part of the offscreen bitmap I want to copy to my screen. This SEEMS to work fine at first. I have (for the sake of debugging) drawn offscreen to my offscreen bitmap multiples of 25 up to 7200. Scrolling shows that the bitmap is fine up to around 600 pixels, and then becomes garbage. Here is the code I use to create the offscreen bitmap : Rect meterRect; GrafPtr offScreenMeter; ... SetRect(&meterRect,0,0,METER_WIDTH,METER_HEIGHT); offScreenMeter = (GrafPtr)NewPtr(sizeof(GrafPort)); OpenPort(offScreenMeter); offScreenMeter->portRect = meterRect; offScreenMeter->portBits.bounds = meterRect; offScreenMeter->portBits.rowBytes = (((offScreenMeter->portBits.bounds.right - offScreenMeter->portBits.bounds.left) + 15) >> 4) << 1; offScreenMeter->portBits.baseAddr = NewPtr(offScreenMeter->portBits.rowBytes * (long)(offScreenMeter->portBits.bounds.bottom - offScreenMeter->portBits.bounds.top)); This creates it. I draw to it with : int i; char numstring[20]; SetPort(offScreenMeter); EraseRect(&offScreenMeter->portRect); for (i=0; i<= METER_WIDTH; i+=25) { MoveTo(i-2,METER_HEIGHT-9); sprintf(numstring,"%d",i); DrawString(CtoPstr(numstring)); } I have a scroll bar with min 0, max METER_WIDTH - WINDOW_WIDTH. When I have to update the screen, I do a copybits with a destination rectangle in the window, and a source rectangle local to the offscreen bitmap (controlValue,0,controlValue+WINDOW_WIDTH,METER_HEIGHT). It works fine for the first 600 pixels or so, then garbage. I think that somehow it's being clipped by the regions of the screen (cliprgn, visrgn, etc) but I have no idea how to get around this (I use a whole offscreen grafptr, not just a bitmap). Is this method I want to do not possible? Was it never intended to have 7200 pixel offscreen bitmaps? It would be real convenient for my project if it could be done this way. Any replies would be appreciated. ..Jeff Keegan ------------------------------------------------------------------------------- | Jeff Keegan | I clutch the wire fence until my fingers bleed | | jkeegan@hawk.ulowell.edu | A wound that will not heal | |----------------------------| A heart that cannot feel | | This space intentionally | Hoping that the horror will receed | | left blank | Hoping that tomorrow we'll all be freed -RUSH | -------------------------------------------------------------------------------