Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!rutgers!cbmvax!peter From: peter@cbmvax.commodore.com (Peter Cherna) Newsgroups: comp.sys.amiga.programmer Subject: Re: Printing and the Layers Library... HELP! Message-ID: <20688@cbmvax.commodore.com> Date: 16 Apr 91 16:05:43 GMT References: <1991Apr15.202049.24563@wehi.dn.mu.oz> Reply-To: peter@cbmvax.commodore.com (Peter Cherna) Organization: Commodore-Amiga, Inc. West Chester, PA. Lines: 63 In article <1991Apr15.202049.24563@wehi.dn.mu.oz> baxter_a@wehi.dn.mu.oz writes: >Rather than handle all the extra clipping this involves myself, is >it possible to use the layers library to protect memory outside the >rastport strip being rendered to from being written into by the >drawing routines? Here's some untested code to work from: #define STRIP_WIDTH whatever #define STRIP_HEIGHT whatever #define DEPTH whatever struct BitMap stripBitMap; struct Layer_Info *strip_layerinfo; struct Layer *strip_layer; ULONG ok = TRUE; /* Start with a bitmap */ InitBitMap( &stripBitMap, DEPTH, STRIP_WIDTH, STRIP_HEIGHT ); /* Allocate bitmap planes */ for ( d = 0; d < DEPTH; d++ ) { if ( !( stripBitMap.Planes[d] = AllocRaster( STRIP_WIDTH, STRIP_HEIGHT ) ) ) { ok = FALSE; break; } } /* A Layer_Info is somewhat like an underlying screen */ if (ok) { ok = ( strip_layerinfo = NewLayerInfo() ); } /* A Layer is what underlies a window. It needs to be associated with * a Layer_Info, and its RastPort provides clipping. */ if (ok) { /* Layer flags don't matter much since we're not going to change * the layers (move, size, etc.). We're just using one for clipping. */ ok = ( strip_layer = CreateUpfrontLayer( strip_layerinfo, &stripBitMap 0, 0, STRIP_WIDTH, STRIP_HEIGHT, LAYERSIMPLE | LAYERBACKDROP, NULL ) ); } if (ok) { /* We're in fine shape now. Render away... */ render( layer->rp ); } /* Free up and exit (exercise for the reader) */ Peter -- Peter Cherna, Operating Systems Development Group, Commodore-Amiga, Inc. {uunet|rutgers}!cbmvax!peter peter@cbmvax.commodore.com My opinions do not necessarily represent the opinions of my employer. "If all you have is a hammer, everything looks like a nail."