コード例 #1
0
ファイル: Label.cpp プロジェクト: DamianSuess/LiteStep
HRGN Label::CreateBackgroundRegion()
{
    HRGN region = NULL;
    
    if (mBackgroundImage)
    {
        // Draw the background into a memory bitmap, then create a region from
        // non-transparent pixels in that bitmap.
        HDC windowDC = GetDC(mWindow);
        
        HDC bufferDC = CreateCompatibleDC(windowDC);
        HBITMAP bufferBitmap = CreateCompatibleBitmap(windowDC, mWidth, mHeight);
        HBITMAP oldBufferBitmap = SelectBitmap(bufferDC, bufferBitmap);
        
        DrawBackground(bufferDC);
        SelectBitmap(bufferDC, oldBufferBitmap);
        region = BitmapToRegion(bufferBitmap, RGB(255, 0, 255), 0, 0, 0);
        
        DeleteDC(bufferDC);
        DeleteBitmap(bufferBitmap);
        
        ReleaseDC(mWindow, windowDC);
    }
    else
    {
        // If there is no background image, the window is always rectangular
        region = CreateRectRgn(0, 0, mWidth, mHeight);
    }
    
    return region;
}
コード例 #2
0
ファイル: AnimateButton.cpp プロジェクト: latelan/BlueClick
void CAnimateButton::PrepareBitmap(HBITMAP hBitmap)
{
	int nStates = 4;

	//取得图像所处区域及计算各状态按钮窗口区域
	m_arBmpRgn.SetSize(nStates);
	m_arBmpRgn.SetSize(nStates);

	CRect rcTmp;
	for(int i = 0; i < nStates; i ++)
	{
		m_arBmpRgn[i] = BitmapToRegion(hBitmap, nStates, i);
	}

	CBitmap* pBmpWhole = CBitmap::FromHandle(hBitmap);
	BITMAP bmp;
	pBmpWhole->GetBitmap(&bmp);

	m_aniBtnWidth = bmp.bmWidth / nStates;
	m_aniBtnHeight = bmp.bmHeight;

	m_pMemDC = new CDC;
	CDC* pDC = GetDC();
	m_pMemDC->CreateCompatibleDC(pDC);
	m_pMemDC->SelectObject(pBmpWhole);
	ReleaseDC(pDC);

 	CRgn RgnWnd;
 	RgnWnd.CreateRectRgn(0, 0, m_aniBtnWidth, m_aniBtnHeight);
 	SetWindowRgn(HRGN(RgnWnd), FALSE);
	//调整大小(这样在DrawItem里面才可能限定画的范围)
	SetWindowPos(NULL, 0, 0, m_aniBtnWidth, m_aniBtnHeight, SWP_NOMOVE);
}
コード例 #3
0
ファイル: region.c プロジェクト: mirror/xserver
int
ProcXFixesCreateRegionFromBitmap(ClientPtr client)
{
    RegionPtr pRegion;
    PixmapPtr pPixmap;
    int rc;

    REQUEST(xXFixesCreateRegionFromBitmapReq);

    REQUEST_SIZE_MATCH(xXFixesCreateRegionFromBitmapReq);
    LEGAL_NEW_RESOURCE(stuff->region, client);

    rc = dixLookupResourceByType((void **) &pPixmap, stuff->bitmap, RT_PIXMAP,
                                 client, DixReadAccess);
    if (rc != Success) {
        client->errorValue = stuff->bitmap;
        return rc;
    }
    if (pPixmap->drawable.depth != 1)
        return BadMatch;

    pRegion = BitmapToRegion(pPixmap->drawable.pScreen, pPixmap);

    if (!pRegion)
        return BadAlloc;

    if (!AddResource(stuff->region, RegionResType, (void *) pRegion))
        return BadAlloc;

    return Success;
}
コード例 #4
0
ファイル: mipict.c プロジェクト: balagopalraj/clearlinux
int
miChangePictureClip(PicturePtr pPicture, int type, void *value, int n)
{
    ScreenPtr pScreen = pPicture->pDrawable->pScreen;
    PictureScreenPtr ps = GetPictureScreen(pScreen);
    RegionPtr clientClip;

    switch (type) {
    case CT_PIXMAP:
        /* convert the pixmap to a region */
        clientClip = BitmapToRegion(pScreen, (PixmapPtr) value);
        if (!clientClip)
            return BadAlloc;
        (*pScreen->DestroyPixmap) ((PixmapPtr) value);
        break;
    case CT_REGION:
        clientClip = value;
        break;
    case CT_NONE:
        clientClip = 0;
        break;
    default:
        clientClip = RegionFromRects(n, (xRectangle *) value, type);
        if (!clientClip)
            return BadAlloc;
        free(value);
        break;
    }
    (*ps->DestroyPictureClip) (pPicture);
    pPicture->clientClip = clientClip;
    pPicture->stateChanges |= CPClipMask;
    return Success;
}
コード例 #5
0
ファイル: region.c プロジェクト: eriytt/xserver-xsdl
int
ProcXFixesCreateRegionFromPicture (ClientPtr client)
{
    RegionPtr	pRegion;
    PicturePtr	pPicture;
    REQUEST (xXFixesCreateRegionFromPictureReq);

    REQUEST_SIZE_MATCH (xXFixesCreateRegionFromPictureReq);
    LEGAL_NEW_RESOURCE (stuff->region, client);

    VERIFY_PICTURE(pPicture, stuff->picture, client, DixGetAttrAccess);
    
    switch (pPicture->clientClipType) {
    case CT_PIXMAP:
	pRegion = BitmapToRegion(pPicture->pDrawable->pScreen,
				   (PixmapPtr) pPicture->clientClip);
	if (!pRegion)
	    return BadAlloc;
	break;
    case CT_REGION:
	pRegion = XFixesRegionCopy ((RegionPtr) pPicture->clientClip);
	if (!pRegion)
	    return BadAlloc;
	break;
    default:
	return BadImplementation;   /* assume sane server bits */
    }
    
    if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
	return BadAlloc;
    
    return Success;
}
コード例 #6
0
void CXTPPopupControl::UpdateBitmapRegion()
{
	if (!GetSafeHwnd())
		return;

	m_bLayered = FALSE;

	if (m_nBackgroundBitmap <= 0)
	{
		SetWindowRgn(NULL, FALSE);
		return;
	}

	CXTPImageManagerIcon* pImage = m_pImageManager->GetImage(m_nBackgroundBitmap, 0);
	if (!pImage)
	{
		SetWindowRgn(NULL, FALSE);
		return;
	}

	if (pImage->IsAlpha())
	{
		SetWindowRgn(NULL, FALSE);

		SetRegionAlphaLayer(pImage);
	}
	else
	{
		HRGN hRgn = BitmapToRegion(pImage);
		if (!hRgn)
			return;

		SetWindowRgn(hRgn, FALSE);
	}
}
コード例 #7
0
ファイル: migc.c プロジェクト: mirror/xserver
void
miChangeClip(GCPtr pGC, int type, void *pvalue, int nrects)
{
    (*pGC->funcs->DestroyClip) (pGC);
    if (type == CT_PIXMAP) {
        /* convert the pixmap to a region */
        pGC->clientClip = BitmapToRegion(pGC->pScreen, (PixmapPtr) pvalue);
        (*pGC->pScreen->DestroyPixmap) (pvalue);
    }
    else if (type == CT_REGION) {
        /* stuff the region in the GC */
        pGC->clientClip = pvalue;
    }
    else if (type != CT_NONE) {
        pGC->clientClip = RegionFromRects(nrects, (xRectangle *) pvalue, type);
        free(pvalue);
    }
    pGC->stateChanges |= GCClipMask;
}
コード例 #8
0
BOOL CSuperProgressCtrl::Create(CWnd* pParent, int x, int y,
							HBITMAP hbmArea, UINT nID)
{
	// Local Variables
	BITMAP bm;
	BOOL bRet;
	HRGN hRgn;

	// Get the dimensions of the given bitmap
	if(GetObject((HGDIOBJ)hbmArea, sizeof(BITMAP), (void*)&bm) == 0)
		return FALSE;
	// Create the window
	bRet = CWnd::Create(s_Class, NULL, WS_VISIBLE | WS_CHILD,
		CRect(x, y, x+bm.bmWidth-1, y+bm.bmHeight-1), pParent,
		nID, NULL);
	// Set the various member variables
	m_nMin = 0;			// Default minimum is 0
	m_nMax = 100;		// Default maximum is 100
	m_nPosition = 0;	// Initial position is at 0
	m_nStep = 10;		// Default step is 10
	m_Colour1 = RGB(0,0,255);	// Default start colour is blue
	m_Colour2 = RGB(255,0,0);	// Default end colour is red
	m_Background = GetSysColor(COLOR_3DFACE);	// Dialog Background
	m_nFillStyle = SP_FILL_HORZGRAD;	// Horizontal Gradient
	// If the window was created successfully, set the window region
	if(bRet)
	{
		m_hbmArea = hbmArea;
		m_hRegion = BitmapToRegion(hbmArea, RGB(255,255,255), 0x000000);
		hRgn = InflateRegion(m_hRegion, 1, 1);
		SetWindowRgn(m_hWnd, hRgn, TRUE);
		// We don't need to delete the region,
		// Windows does it for us when the
		// window is destroyed
	}
	// Return the status of the window creation
	return bRet;
}
コード例 #9
0
ファイル: region.c プロジェクト: eriytt/xserver-xsdl
int
ProcXFixesCreateRegionFromGC (ClientPtr client)
{
    RegionPtr	pRegion, pClip;
    GCPtr	pGC;
    int 	rc;
    REQUEST (xXFixesCreateRegionFromGCReq);

    REQUEST_SIZE_MATCH (xXFixesCreateRegionFromGCReq);
    LEGAL_NEW_RESOURCE (stuff->region, client);

    rc = dixLookupGC(&pGC, stuff->gc, client, DixGetAttrAccess);
    if (rc != Success)
	return rc;
    
    switch (pGC->clientClipType) {
    case CT_PIXMAP:
	pRegion = BitmapToRegion(pGC->pScreen, (PixmapPtr) pGC->clientClip);
	if (!pRegion)
	    return BadAlloc;
	break;
    case CT_REGION:
	pClip = (RegionPtr) pGC->clientClip;
	pRegion = XFixesRegionCopy (pClip);
	if (!pRegion)
	    return BadAlloc;
	break;
    default:
	return BadImplementation;   /* assume sane server bits */
    }
    
    if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
	return BadAlloc;
    
    return Success;
}
コード例 #10
0
ファイル: shape.c プロジェクト: coffee8651/turbovnc
static int
ProcShapeMask(ClientPtr client)
{
    WindowPtr pWin;
    ScreenPtr pScreen;

    REQUEST(xShapeMaskReq);
    RegionPtr srcRgn;
    RegionPtr *destRgn;
    PixmapPtr pPixmap;
    CreateDftPtr createDefault;
    int rc;

    REQUEST_SIZE_MATCH(xShapeMaskReq);
    UpdateCurrentTime();
    rc = dixLookupWindow(&pWin, stuff->dest, client, DixSetAttrAccess);
    if (rc != Success)
        return rc;
    switch (stuff->destKind) {
    case ShapeBounding:
        createDefault = CreateBoundingShape;
        break;
    case ShapeClip:
        createDefault = CreateClipShape;
        break;
    case ShapeInput:
        createDefault = CreateBoundingShape;
        break;
    default:
        client->errorValue = stuff->destKind;
        return BadValue;
    }
    pScreen = pWin->drawable.pScreen;
    if (stuff->src == None)
        srcRgn = 0;
    else {
        rc = dixLookupResourceByType((pointer *) &pPixmap, stuff->src,
                                     RT_PIXMAP, client, DixReadAccess);
        if (rc != Success)
            return rc;
        if (pPixmap->drawable.pScreen != pScreen ||
            pPixmap->drawable.depth != 1)
            return BadMatch;
        srcRgn = BitmapToRegion(pScreen, pPixmap);
        if (!srcRgn)
            return BadAlloc;
    }

    if (!pWin->optional)
        MakeWindowOptional(pWin);
    switch (stuff->destKind) {
    case ShapeBounding:
        destRgn = &pWin->optional->boundingShape;
        break;
    case ShapeClip:
        destRgn = &pWin->optional->clipShape;
        break;
    case ShapeInput:
        destRgn = &pWin->optional->inputShape;
        break;
    default:
        return BadValue;
    }

    return RegionOperate(client, pWin, (int) stuff->destKind,
                         destRgn, srcRgn, (int) stuff->op,
                         stuff->xOff, stuff->yOff, createDefault);
}