您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ CombineRgn函数代码示例

51自学网 2021-06-01 20:12:39
  C++
这篇教程C++ CombineRgn函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中CombineRgn函数的典型用法代码示例。如果您正苦于以下问题:C++ CombineRgn函数的具体用法?C++ CombineRgn怎么用?C++ CombineRgn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了CombineRgn函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: bitmap2region

// Windows uses regions only to specify the clip mask of a window therefore// we must convert our bitmap to a region.// Much of this code is "borrowed" from the Windows version of GTK// (also LGPLed).  Their code was based on code originally written by// Jean-Edouard Lachand-Robert.  Ain't open source great?//// Modified by me to use an Fl_Bitmap, to not hog memory, to not leak memory// (I hope) and to allow bitmaps of arbitrary dimensions. -CETstatic HRGN bitmap2region(Fl_Bitmap* bitmap){    HRGN hRgn = 0;    /* For better performances, we will use the ExtCreateRegion()     * function to create the region. This function take a RGNDATA     * structure on entry. We will add rectangles by amount of     * ALLOC_UNIT number in this structure.     */    #define ALLOC_UNIT  100    DWORD maxRects = ALLOC_UNIT;    RGNDATA* pData = (RGNDATA*)malloc(sizeof(RGNDATAHEADER)+(sizeof(RECT)*maxRects));    pData->rdh.dwSize = sizeof(RGNDATAHEADER);    pData->rdh.iType = RDH_RECTANGLES;    pData->rdh.nCount = pData->rdh.nRgnSize = 0;    SetRect(&pData->rdh.rcBound, MAXLONG, MAXLONG, 0, 0);                                 // number of bytes per line of pixels    const int bpl = (bitmap->width()+7)/8;    BYTE* p8 = (BYTE*)bitmap->array;    BYTE* p;    for (int y = 0; y < bitmap->height(); y++)    {        /* Scan each bitmap row from left to right*/        for (int x = 0; x < bitmap->width(); x++)        {            /* Search for a continuous range of "non transparent pixels"*/            int x0 = x;            while (x < bitmap->width())            {                p = p8 + x / 8;                                 /* This pixel is "transparent"*/                if (!((*p) & bit(x))) break;                x++;            }            if (x > x0)            {                RECT* pr;                /* Add the pixels (x0, y) to (x, y+1) as a new rectangle                 * in the region                 */                if (pData->rdh.nCount >= maxRects)                {                    maxRects += ALLOC_UNIT;                    pData = (RGNDATA*)realloc(pData, sizeof(RGNDATAHEADER)                        + (sizeof(RECT)*maxRects));                }                pr = (RECT*)&pData->Buffer;                SetRect(&pr[pData->rdh.nCount], x0, y, x, y+1);                if (x0 < pData->rdh.rcBound.left)                    pData->rdh.rcBound.left = x0;                if (y < pData->rdh.rcBound.top)                    pData->rdh.rcBound.top = y;                if (x > pData->rdh.rcBound.right)                    pData->rdh.rcBound.right = x;                if (y+1 > pData->rdh.rcBound.bottom)                    pData->rdh.rcBound.bottom = y+1;                pData->rdh.nCount++;                /* On Windows98, ExtCreateRegion() may fail if the                 * number of rectangles is too large (ie: >                 * 4000). Therefore, we have to create the region by                 * multiple steps.                 */                if (pData->rdh.nCount == 2000)                {                    HRGN h = ExtCreateRegion(NULL, sizeof(RGNDATAHEADER)                        + (sizeof(RECT)*maxRects), pData);                    if (hRgn)                    {                        CombineRgn(hRgn, hRgn, h, RGN_OR);                        DeleteObject(h);                    } else hRgn = h;                    pData->rdh.nCount = 0;                    SetRect(&pData->rdh.rcBound, MAXLONG, MAXLONG, 0, 0);                }            }        }        /* Go to next row */        p8 += bpl;    }    /* Create or extend the region with the remaining rectangles*/    HRGN h = ExtCreateRegion(NULL, sizeof(RGNDATAHEADER)        + (sizeof(RECT)*maxRects), pData);    if (hRgn)    {        CombineRgn(hRgn, hRgn, h, RGN_OR);        DeleteObject(h);    } else hRgn = h;//.........这里部分代码省略.........
开发者ID:edeproject,项目名称:svn,代码行数:101,


示例2: CreateRgnFromBitmap

HRGN CreateRgnFromBitmap(CDC *pDC, int iWidth, int iHeight, COLORREF color){	const DWORD RDHDR = sizeof(RGNDATAHEADER);	const DWORD MAXBUF = 40;		// size of one block in RECTs									// (i.e. MAXBUF*sizeof(RECT) in bytes)	LPRECT	pRects;	DWORD	cBlocks = 0;			// number of allocated blocks	INT		i, j;					// current position in mask image	INT		first = 0;				// left position of current scan line									// where mask was found	bool	wasfirst = false;		// set when if mask was found in current scan line	bool	ismask;					// set when current color is mask color	// allocate memory for region data	RGNDATAHEADER* pRgnData = (RGNDATAHEADER*)new BYTE[ RDHDR + ++cBlocks * MAXBUF * sizeof(RECT) ];	memset( pRgnData, 0, RDHDR + cBlocks * MAXBUF * sizeof(RECT) );	// fill it by default	pRgnData->dwSize	= RDHDR;	pRgnData->iType		= RDH_RECTANGLES;	pRgnData->nCount	= 0;	for ( i = 0; i < iHeight; i++ )		for ( j = 0; j < iWidth; j++ ){			// get color			ismask=(pDC->GetPixel(j,iHeight-i-1)!=color);			// place part of scan line as RECT region if transparent color found after mask color or			// mask color found at the end of mask image			if (wasfirst && ((ismask && (j==(iWidth-1)))||(ismask ^ (j<iWidth)))){				// get offset to RECT array if RGNDATA buffer				pRects = (LPRECT)((LPBYTE)pRgnData + RDHDR);				// save current RECT				pRects[ pRgnData->nCount++ ] = CRect( first, iHeight - i - 1, j+(j==(iWidth-1)), iHeight - i );				// if buffer full reallocate it				if ( pRgnData->nCount >= cBlocks * MAXBUF ){					LPBYTE pRgnDataNew = new BYTE[ RDHDR + ++cBlocks * MAXBUF * sizeof(RECT) ];					memcpy( pRgnDataNew, pRgnData, RDHDR + (cBlocks - 1) * MAXBUF * sizeof(RECT) );					delete[] pRgnData;					pRgnData = (RGNDATAHEADER*)pRgnDataNew;				}				wasfirst = false;			} else if ( !wasfirst && ismask ){		// set wasfirst when mask is found				first = j;				wasfirst = true;			}		}	// create region	/*	Under WinNT the ExtCreateRegion returns NULL (by [email
C++ ComboBox_AddString函数代码示例
C++ Com_sprintf函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。