[comp.sys.amiga.programmer] Printing and the Layers Library... HELP!

baxter_a@wehi.dn.mu.oz (04/16/91)

I want to handle preferences printer output from a vector drawing
program. I need to support _real_ printers, so 300dpi is expected.
Therefore (I think) I need to send the picture in strips, using
a shorter rasport (right?).
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?

Regards Alan

peter@cbmvax.commodore.com (Peter Cherna) (04/16/91)

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."