From: | |
Date: | 01 Feb 2001 at 19:32:14 |
Subject: | Re: Clipping graphics output |
Czesc Serge!
Dnia 01-Lut-01, Serge Tumanyan napisa�:
>Does anybody knows how to force the functions of graphic library to render
>only inside the RastPort? The simple example of what I mean
>is the following: if I open the window, and render outside its bounds, the
>result would be perfect, the rendering will be clipped on the
>bounds. But if I create a RastPort and make InitRastPort() and render
>in it, result would not be so perfect, if I go out the bounds, the innocent
>memory would be trashed, and the output would not be clipped.
>What am I doing wrong?
You have not layer attached to your's rastport. Try below code:
struct Layer_Info *layerinfo;
struct RastPort rastport = { 0 };
InitRastPort( &rastport );
if( rastport.BitMap = AllocBitMap( width, height, depth, 0, NULL ) )
{
if( layerinfo = NewLayerInfo() )
{
if( rastport.Layer = CreateUpfrontLayer( layerinfo, rastport.BitMap, 0,
0, width-1, height-1, LAYERSMART, NULL ) )
{
#define USE_REGIONS
struct Region *region;
if( region = NewRegion() )
{
struct Rectangle rect;
rect.MinX = 0;
rect.MinY = 0;
rect.MaxX = width - 1;
rect.MaxY = height - 1;
if( OrRectRegion( region, &rect ) )
{
oldregion = InstallClipRegion( rastport.Layer, region );
#endif /* USE_REGIONS */
/*
* Render wherever you want in rastport.
* Don't touch bitmap or clip it by hand!
*/
#ifdef USE_REGIONS
InstallClipRegion( rastport.Layer, oldregion );
}
DisposeRegion( region );
}
#endif /* USE_REGIONS */
DeleteLayer( layerinfo, rastport.Layer );
}
DisposeLayerInfo( layerinfo );
}
FreeBitMap( rastport.BitMap );
}
Try it with USE_REGIONS and without USE_REGION definition.
Instead using layers.library functions you can clip it by hand.
Regards!
Przemyslaw 'SENSEI' Gruchala
code/gfx2d/gfx3d/webmaster
Amiga 1200
Apollo 1240/33 MHz, 18 MB RAM, BTC 33.6 bps
HDD 3.2 GB, HDD 520 MB, CD x12
------------------------ Yahoo! Groups Sponsor ---------------------~-~>
eGroups is now Yahoo! Groups
Click here for more details
http://click.egroups.com/1/11231/0/_/451227/_/981056387/
---------------------------------------------------------------------_->