[net.micro.mac] Problem with off-screen bitmaps.

larryh@tekcbi.UUCP (Larry Hutchinson) (10/13/86)

I swear that I have found a case where quickdraw does not ignore the visRgn
when drawing into an off-screen bitmap.

	( Before you say "ah, it's the old clipRgn problem or the
	old >3.5kBytes problem", let me assure you that it isn't. 
	The clipRgn of the window is set equal to the portRect and besides,
	the problem occurs before CopyBits is used. )

I have a program that installs an off-screen bitmap into a 
window, draws some stuff and then stamps it onto the window.
It worked fine for some time but then I discovered that it screws up under
certain conditions of window update &/or activation. I can easily generate
the case where it screws up and also where it doesn't.  Using TMON, I have
looked thru the entire grafPort and the ONLY difference between the two 
cases is the visRgn.  If I then use TMON to change the visRgn of the screwup 
case from the original complex value to the size of the portRect, then all 
is ok.  It's as if qd is not aware that the bitmap is off-screen.
Am I confusing qd somehow or what?

The offscreen bitmap is installed into thePort via the routine below.  If
the visRgn is wierd, then the FillRect(r,&white) will not fill (or only
partially depending on visRgn).

Setup:  Mac+, S3.2, F5.3 but it works the same with old roms and system.

Does anybody have any idea what I am doing wrong?

Larry Hutchinson, Tektronix, Inc. PO Box 500, MS 02-305, Beaverton, OR 97077
{ decvax,allegra }!tektronix!tekcbi!larryh


/*
 *	InstallBitMap(savebm,bm,r,width,height);
 *
 *	shortcut for installing bitmaps.
 *	Don't forget to DisposPtr after use is over.
 *	if savebm is null then the old bitmap will not be saved.
 *	Coordinate system offset is set to the same as the old bitmap.
 *	An implicit assumption is made that the new bitmap is smaller than
 *	or equal to the original portRect (which is not changed).
 *	rectangle is filled with white.
 */
 
InstallBitMap(savebm,bm,r,width,height)
	BitMap		*savebm,	/* place to save the original bitmap */
			*bm;		/* addr of the new bitmap */
	Rect		*r;		/* addr of rect to fill in */
	short		width,height;
{
	SetRect(r,0,0,width,height);
	SetRect(&bm->bounds,0,0,(width/16)*16,height);
	if(width&0xf)
		bm->bounds.right += 16;
	bm->rowBytes= bm->bounds.right/8;
	bm->baseAddr= NewPtr( (long) bm->rowBytes*height);
	if(savebm != NULL)
		*savebm= thePort->portBits;
	SetPortBits(bm);
	FillRect(r,&white);
}