📄 reg06.c
字号:
/*************************************************************************/
/* */
/* Copyright (c) 1997 - 1999 Accelerated Technology, Inc. */
/* */
/* PROPRIETARY RIGHTS of Accelerated Technology are involved in the */
/* subject matter of this material. All manufacturing, reproduction, */
/* use, and sales rights pertaining to this subject matter are governed */
/* by the license agreement. The recipient of this software implicitly */
/* accepts the terms of the license. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* FILE NAME VERSION */
/* */
/* REG06.c 1.9 */
/* */
/* COMPONENT */
/* */
/* All */
/* */
/* DESCRIPTION */
/* */
/* This file contains the IntersectRegion function. */
/* */
/* AUTHOR */
/* */
/* Giac Dinh, Accelerated Technology, Inc. */
/* */
/* DATA STRUCTURES */
/* */
/* None */
/* */
/* FUNCTIONS */
/* */
/* None */
/* */
/* DEPENDENCIES */
/* */
/* None */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* */
/*************************************************************************/
#include "meta_wnd.h"
#include "metconst.h" /* MetaWINDOW Constant & Stucture Definitions */
#include "metports.h" /* MetaWINDOW Port & Bitmap Definitions */
#include "grafdata.h"
#include "metmacs3.h"
/* Function IntersectRegion() creates a region that is the mutual intersection
of REGION1 and REGION2. If an error occurs during IntersectRegion() (e.g.
insufficient memory), a QueryError() status is posted and a NULL pointer
is returned.
Memory for the new region definition is allocated dynamically using the
MetaWINDOW GrafAlloc() function. When finished using the region, the program
should call GrafFree() with the region pointer to release the memory occupied
by the region definition. */
region *IntersectRegion( region *rgn1, region *rgn2 )
{
unsigned int mwMergeRegion (int numRects1, rect *rectList1,
int numRects2, rect *rectList2,
int sizeRGN, region *destRGN, int rgnOP );
void *GrafAlloc(int memSize);
rect *ptrList1;
rect *ptrList2;
int numList1;
int numList2;
region *ptrRgn;
unsigned int sizRgn;
short grafErrValue;
ptrList1 = rgn1->rgnList;
/* Calculate number of rects in list 1 */
numList1 = (rgn1->rgnSize - sizeof(region) - 2*sizeof(rect)) >> 3;
ptrList2 = rgn2->rgnList;
/* Calculate number of rects in list 2 */
numList2 = (rgn2->rgnSize - sizeof(region) - 2*sizeof(rect)) >> 3;
/* Determine how much memory is needed for new region */
sizRgn = mwMergeRegion(numList1,ptrList1,numList2,ptrList2,0,0,1);
ptrRgn = (region *) GrafAlloc (sizRgn);
if(ptrRgn == 0)
{
grafErrValue = c_UnionReg + c_OutofMem;
nuGrafErr(grafErrValue);
return(0);
}
mwMergeRegion(numList1,ptrList1,numList2,ptrList2,sizRgn, ptrRgn,1);
return(ptrRgn);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -