当前位置: 首页>>代码示例>>C++>>正文


C++ CreatePatternBrush函数代码示例

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


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

示例1: setClipping

void EmfPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap & pix, const QPointF &)
{
	setClipping();

#ifdef Q_WS_WIN
	HBITMAP hBmp = pix.toWinHBITMAP();
	HBRUSH wbrush = CreatePatternBrush(hBmp);

	QMatrix m = painter()->worldMatrix();
	QRectF dr = m.mapRect(r);

	RECT rect;
	rect.left = qRound(dr.left());
	rect.top = qRound(dr.top());
	rect.right = qRound(dr.right());
	rect.bottom = qRound(dr.bottom());

	FillRect(metaDC, &rect, wbrush);

	DeleteObject(hBmp);
	DeleteObject(wbrush);
#else
	int width = qRound(r.width());
	int height = qRound(r.height());

	QPixmap pixmap(width, height);
	QPainter p(&pixmap);
	p.drawTiledPixmap(0, 0, width, height, pix);
	p.end();

	drawPixmap(r, pixmap, QRectF());
#endif

	resetClipping();
}
开发者ID:jkriege2,项目名称:JKQtPlotter,代码行数:35,代码来源:EmfEngine.cpp

示例2: DrawXorBar

void WINAPI DrawXorBar(HDC hdc, int x1, int y1, int width, int height)
{
    static WORD _dotPatternBmp[8] = 
    { 
    0x00aa, 0x0055, 0x00aa, 0x0055, 
    0x00aa, 0x0055, 0x00aa, 0x0055
    };

    HBITMAP hbitmap;
    HBRUSH hbrush,hbrushOld;

    hbitmap = CreateBitmap(8,8,1,1,_dotPatternBmp);
    hbrush = CreatePatternBrush(hbitmap);

    SetBrushOrgEx(hdc,x1,y1,0);

    hbrushOld = (HBRUSH)SelectObject(hdc,hbrush);

    PatBlt(hdc,x1,y1,width,height,PATINVERT);

    SelectObject(hdc,hbrushOld);

    DeleteObject(hbrush);
    DeleteObject(hbitmap);
} 
开发者ID:sunmingbao,项目名称:xb-ether-tester,代码行数:25,代码来源:splitters.c

示例3: GetModuleFileName

void CChineseChessDlg::DrawChessImage(int x, int y, HDC dc)
{
	HBITMAP hbmp;
	char name[3];
	char path[255];
	GetModuleFileName(NULL,path,255);
	(_tcsrchr(path,_T('\\')))[1] = 0;
	strcat(path,_T("\\Sourse\\"));
	if (chess[y][x].chessType != 0)
	{
		if (chess[y][x].isSelect)
		{
			strcat(path,_T("x"));
		}
		itoa(chess[y][x].chessType,name,10);
		strcat(path,name);
		strcat(path,_T(".bmp"));
		hbmp = (HBITMAP)LoadImage(AfxGetInstanceHandle(),path,
			IMAGE_BITMAP,50,50,LR_LOADFROMFILE);
		HBRUSH brush = CreatePatternBrush(hbmp); 
		HGDIOBJ hOld = SelectObject(dc,brush);
		RECT rec;
		rec.left = x * 50 ;
		rec.top = y * 50 ;
		rec.bottom = rec.top + 50;
		rec.right = rec.left + 50;
		FillRect(dc,&rec,brush);

		//╩ж╦╢т╜охв╢л╛
		SelectObject(dc, hOld);

		DeleteObject(brush);
		DeleteObject(hOld);
	}
}
开发者ID:wakaoyun,项目名称:dengqibin,代码行数:35,代码来源:Chinese+ChessDlg.cpp

示例4: GetWindowRect

int CTabCtrl2::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CTabCtrl::OnCreate(lpCreateStruct) == -1)
		return -1;

	CRect rc;
	GetWindowRect(rc);
	CDC* dc = GetDC();

	HDC hDCMem = CreateCompatibleDC(dc->GetSafeHdc());
	HBITMAP hBmp = CreateCompatibleBitmap(dc->GetSafeHdc(), rc.right - rc.left, rc.bottom - rc.top);
	HGDIOBJ hBmpOld = SelectObject(hDCMem, hBmp);

	SendMessage(WM_PRINTCLIENT, (WPARAM)hDCMem, (LPARAM)(PRF_ERASEBKGND | PRF_CLIENT | PRF_NONCLIENT));

	hBgBrush = CreatePatternBrush(hBmp);

	SelectObject(hDCMem, hBmpOld);

	DeleteObject(hBmp);
	DeleteDC(hDCMem);
	ReleaseDC(dc);	

	return 0;
}
开发者ID:MFDonadeli,项目名称:PMA,代码行数:25,代码来源:RCGen.cpp

示例5: MonSelDrawDisabledRect

static BOOL
MonSelDrawDisabledRect(IN OUT PMONITORSELWND infoPtr,
                       IN HDC hDC,
                       IN const RECT *prc)
{
    BOOL Ret = FALSE;

    if (infoPtr->hbrDisabled == NULL)
    {
        static const DWORD Pattern[4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA};

        if (infoPtr->hbmDisabledPattern == NULL)
        {
            infoPtr->hbmDisabledPattern = CreateBitmap(8,
                                          8,
                                          1,
                                          1,
                                          Pattern);
        }

        if (infoPtr->hbmDisabledPattern != NULL)
            infoPtr->hbrDisabled = CreatePatternBrush(infoPtr->hbmDisabledPattern);
    }

    if (infoPtr->hbrDisabled != NULL)
    {
        /* FIXME: Implement */
    }

    return Ret;
}
开发者ID:Strongc,项目名称:reactos,代码行数:31,代码来源:monslctl.c

示例6: update_wallpaper

/***********************************************************************
 *           update_wallpaper
 */
BOOL update_wallpaper( const WCHAR *wallpaper, const WCHAR *pattern )
{
    int pat[8];

    if (hbrushPattern) DeleteObject( hbrushPattern );
    hbrushPattern = 0;
    memset( pat, 0, sizeof(pat) );
    if (pattern)
    {
        char buffer[64];
        WideCharToMultiByte( CP_ACP, 0, pattern, -1, buffer, sizeof(buffer), NULL, NULL );
        if (sscanf( buffer, " %d %d %d %d %d %d %d %d",
                    &pat[0], &pat[1], &pat[2], &pat[3],
                    &pat[4], &pat[5], &pat[6], &pat[7] ))
        {
            WORD ptrn[8];
            HBITMAP hbitmap;
            int i;

            for (i = 0; i < 8; i++) ptrn[i] = pat[i] & 0xffff;
            hbitmap = CreateBitmap( 8, 8, 1, 1, ptrn );
            hbrushPattern = CreatePatternBrush( hbitmap );
            DeleteObject( hbitmap );
        }
    }
    init_wallpaper( wallpaper );
    RedrawWindow( GetDesktopWindow(), 0, 0, RDW_INVALIDATE | RDW_ERASE | RDW_NOCHILDREN );
    return TRUE;
}
开发者ID:Kelimion,项目名称:wine,代码行数:32,代码来源:desktop.c

示例7: DESKTOP_SetPattern

/***********************************************************************
 *           DESKTOP_SetPattern
 *
 * Set the desktop pattern.
 */
BOOL DESKTOP_SetPattern( LPCWSTR pattern )
{
    int pat[8];

    if (hbrushPattern) DeleteObject( hbrushPattern );
    hbrushPattern = 0;
    memset( pat, 0, sizeof(pat) );
    if (pattern)
    {
        char buffer[64];
        WideCharToMultiByte( CP_ACP, 0, pattern, -1, buffer, sizeof(buffer), NULL, NULL );
        if (sscanf( buffer, " %d %d %d %d %d %d %d %d",
                    &pat[0], &pat[1], &pat[2], &pat[3],
                    &pat[4], &pat[5], &pat[6], &pat[7] ))
        {
            WORD ptrn[8];
            HBITMAP hbitmap;
            int i;

            for (i = 0; i < 8; i++) ptrn[i] = pat[i] & 0xffff;
            hbitmap = CreateBitmap( 8, 8, 1, 1, ptrn );
            hbrushPattern = CreatePatternBrush( hbitmap );
            DeleteObject( hbitmap );
        }
    }
    return TRUE;
}
开发者ID:MichaelMcDonnell,项目名称:wine,代码行数:32,代码来源:desktop.c

示例8: CreateBitmap

static TroughClientData *TroughClientDataInit(Tcl_Interp *interp)
{
    TroughClientData *cd = (TroughClientData*)ckalloc(sizeof(*cd));
    cd->PatternBitmap = CreateBitmap(8, 8, 1, 1, Pattern);
    cd->PatternBrush  = CreatePatternBrush(cd->PatternBitmap);
    Ttk_RegisterCleanup(interp, cd, TroughClientDataDeleteProc);
    return cd;
}
开发者ID:aosm,项目名称:tcl,代码行数:8,代码来源:ttkWinTheme.c

示例9: wWinMain

int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
                     _In_opt_ HINSTANCE hPrevInstance,
                     _In_ LPWSTR    lpCmdLine,
                     _In_ int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    // TODO: Place code here.

    // Initialize global strings
    LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
    LoadStringW(hInstance, IDC_SAPPER, szWindowClass, MAX_LOADSTRING);
	HBITMAP hBmp = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BITMAPBACK));

	HBRUSH hBrush = CreatePatternBrush(hBmp);

	BombField::setBmpEmpty(LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BITMAPBUT)));
	BombField::setBmp0(LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BITMAP0)));
	BombField::setBmpFlag(LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BITMAPFLAG)));
	BombField::setBmpQm(LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BITMAPQM)));
	BombField::setBmpBomb(LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BITMAPBOMB)));
	BombField::setBmp1(LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BITMAP1)));
	BombField::setBmp2(LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BITMAP2)));
	BombField::setBmp3(LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BITMAP3)));
	BombField::setBmp4(LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BITMAP4)));
	BombField::setBmp5(LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BITMAP5)));
	BombField::setBmp6(LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BITMAP6)));
	BombField::setBmp7(LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BITMAP7)));
	BombField::setBmp8(LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BITMAP8)));
	BombField::setBmpExploded(LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BITMAPEXPL)));

	if (!MyRegisterClass(hInstance, hBrush))
		return FALSE;

    // Perform application initialization:
    if (!InitInstance (hInstance, nCmdShow))
    {
        return FALSE;
    }

    HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_SAPPER));

    MSG msg;

    // Main message loop:
    while (GetMessage(&msg, nullptr, 0, 0))
    {
        if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    return (int) msg.wParam;
}
开发者ID:GeorgeMyzor,项目名称:Sapper,代码行数:57,代码来源:Sapper.cpp

示例10: WinMain

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR szCmd, int nShow)
{
	HWND hwnd;
	MSG msg;
	WNDCLASSEX wcls;
	HBITMAP hbitmap = LoadBitmap(GetModuleHandle(NULL), TEXT("background"));
	HBRUSH hbrush = CreatePatternBrush(hbitmap);
	DeleteObject(hbitmap);

	wcls.cbSize = sizeof(wcls);
	wcls.style = CS_HREDRAW | CS_VREDRAW;
	wcls.lpfnWndProc = WndProc;
	wcls.hInstance = hInst;
	wcls.cbWndExtra = 0;
	wcls.cbClsExtra = 0;
	wcls.hbrBackground = hbrush/*(HBRUSH)GetStockObject(NULL_BRUSH)*/;
	wcls.hIcon = LoadIcon(NULL, IDI_APPLICATION);
	wcls.hIconSm = NULL;
	wcls.hCursor = LoadCursor(NULL, IDC_ARROW);
	wcls.lpszClassName = szAppName;
	wcls.lpszMenuName = NULL;

	if (!RegisterClassEx(&wcls)){
		MessageBox(NULL, TEXT("注册类出错!"), TEXT("错误"), MB_ICONERROR);
		return 0;
	}

	wcls.cbWndExtra = sizeof(BOOL);
	wcls.lpfnWndProc = ButtonProc;
	wcls.lpszClassName = TEXT("mybutton");
	wcls.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH);


	if (!RegisterClassEx(&wcls)){
		MessageBox(NULL, TEXT("注册类出错!"), TEXT("错误"), MB_ICONERROR);
		return 0;
	}

	hwnd = CreateWindow(szAppName,
		szAppName,
		WS_OVERLAPPED | WS_CAPTION | \
		WS_SYSMENU | WS_MINIMIZEBOX,
		CW_USEDEFAULT, CW_USEDEFAULT,
		CW_USEDEFAULT, CW_USEDEFAULT,
		NULL, NULL, hInst, NULL);

	ShowWindow(hwnd, nShow);
	UpdateWindow(hwnd);

	while (GetMessage(&msg, NULL, 0, 0)){
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
	DeleteObject(hbrush);
	return msg.wParam;
}
开发者ID:HIPIAOYI,项目名称:DouDiZhu,代码行数:56,代码来源:winmain.cpp

示例11: DrawPreview

static void DrawPreview(HWND hwnd, HDC hdc)
{
	BITMAPINFO bi;
	bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
	bi.bmiHeader.biWidth = 8;
	bi.bmiHeader.biHeight = -8;
	bi.bmiHeader.biPlanes = 1;
	bi.bmiHeader.biBitCount = 32;
	bi.bmiHeader.biCompression = BI_RGB;
	HBITMAP hBmpBrush = CreateDIBSection(0, &bi, DIB_RGB_COLORS, 0, 0, 0);
	HDC dcBmp = CreateCompatibleDC(0);
	HBITMAP hBmpSave = (HBITMAP)SelectObject(dcBmp, hBmpBrush);
	HBRUSH hbr = CreateSolidBrush(RGB(0xcc, 0xcc, 0xcc));

	RECT rc;
	SetRect(&rc, 0, 0, 8, 8);
	FillRect(dcBmp, &rc, hbr);
	DeleteObject(hbr);
	hbr = CreateSolidBrush(RGB(0xff, 0xff, 0xff));
	SetRect(&rc, 4, 0, 8, 4);
	FillRect(dcBmp, &rc, hbr);
	SetRect(&rc, 0, 4, 4, 8);
	FillRect(dcBmp, &rc, hbr);
	DeleteObject(hbr);
	SelectObject(dcBmp, hBmpSave);
	DeleteDC(dcBmp);

	GetClientRect(hwnd, &rc);
	hbr = CreatePatternBrush(hBmpBrush);
	SetBrushOrgEx(hdc, 1, 1, 0);
	FillRect(hdc, &rc, hbr);
	DeleteObject(hbr);
	DeleteObject(hBmpBrush);

	if (gPreviewOk)
	{
		int width = min(rc.right, wndPreview->getContent()->getWidth());
		int height = min(rc.bottom, wndPreview->getContent()->getHeight());
		int left = (rc.right - width) / 2;
		int top = (rc.bottom - height) / 2;


		BLENDFUNCTION bf;
		bf.BlendOp = AC_SRC_OVER;
		bf.BlendFlags = 0;
		bf.SourceConstantAlpha = 255;
		bf.AlphaFormat = AC_SRC_ALPHA;
		AlphaBlend(hdc, left, top, width, height,
			wndPreview->getContent()->getDC(),
			0, 0, width, height, bf);

	}

	FrameRect(hdc, &rc, GetStockBrush(LTGRAY_BRUSH));
}
开发者ID:0xmono,项目名称:miranda-ng,代码行数:55,代码来源:opt_skins.cpp

示例12: drawPatternSimple

static void drawPatternSimple(HDC hdc, const RECT& destRect, HBITMAP hbmp, const POINT& phase)
{
    OwnPtr<HBRUSH> hBrush = adoptPtr(CreatePatternBrush(hbmp));
    if (!hBrush)
        return;

    POINT oldOrg;
    SetBrushOrgEx(hdc, destRect.left - phase.x, destRect.top - phase.y, &oldOrg);
    FillRect(hdc, &destRect, hBrush.get());
    SetBrushOrgEx(hdc, oldOrg.x, oldOrg.y, 0);
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:11,代码来源:SharedBitmap.cpp

示例13: MyCreateSolidBrush

STATICFN HBRUSH NEAR MyCreateSolidBrush(
    DWORD rgb)
{
    HDC hdc;
    HDC hdcMem;
    HBRUSH hbr;
    HBRUSH hbrOld;
    HBITMAP hbmPat;
    HBITMAP hbmOld;

    /*
     * First, create a brush for the given RGB value.
     */
    hbr = CreateSolidBrush(rgb);

    /*
     * Create a temporary memory DC.
     */
    hdc = GetDC(ghwndMain);
    hdcMem = CreateCompatibleDC(hdc);

    /*
     * Create a temporary bitmap.
     */
    hbmPat = MyCreateBitmap(hdc, 8, 8, gnColorPalColors);
    ReleaseDC(ghwndMain, hdc);

    /*
     * Draw the (possibly) dithered pattern on the temporary bitmap.
     */
    hbmOld = SelectObject(hdcMem, hbmPat);
    hbrOld = SelectObject(hdcMem, hbr);
    PatBlt(hdcMem, 0, 0, 8, 8, PATCOPY);
    SelectObject(hdcMem, hbrOld);
    SelectObject(hdcMem, hbmOld);
    DeleteDC(hdcMem);

    /*
     * Delete the first brush.
     */
    DeleteObject(hbr);

    /*
     * Now create a pattern brush out of the (dithered) bitmap.
     */
    hbr = CreatePatternBrush(hbmPat);

    DeleteObject(hbmPat);

    /*
     * Return the pattern brush.
     */
    return hbr;
}
开发者ID:mingpen,项目名称:OpenNT,代码行数:54,代码来源:colorwp.c

示例14: CreatePatternBrushFromFile

HBRUSH CreatePatternBrushFromFile(LPCTSTR pszFile)
{
    HBRUSH hbr = NULL;
    HBITMAP hbm = (HBITMAP)LoadImage(g_hinst, pszFile,
                   IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
    if (hbm) {
        hbr = CreatePatternBrush(hbm);
        DeleteObject(hbm);
    }
    return hbr;
}
开发者ID:AnarNFT,项目名称:books-code,代码行数:11,代码来源:095_tiling.cpp

示例15: Test_MaskBlt_Brush

void Test_MaskBlt_Brush()
{
    HDC hdcDst, hdcSrc;
    struct
    {
        BITMAPINFOHEADER bmiHeader;
        ULONG aulColors[2];
    } bmiData = {{sizeof(BITMAPINFOHEADER), 16, 16, 1, 1, BI_RGB, 0, 10, 10, 2,0}, {0, 0xFFFFFF}};
    PBITMAPINFO pbmi = (PBITMAPINFO)&bmiData;
    HBITMAP hbmDst, hbmSrc, hbmMsk;
    PULONG pulBitsDst, pulBitsSrc, pulBitsMsk;
    BOOL ret;
    HBRUSH hbr;

    /* Create a dest dc and bitmap */
    hdcDst = CreateCompatibleDC(NULL);
    hbmDst = CreateDIBSection(hdcDst, pbmi, DIB_RGB_COLORS, (PVOID*)&pulBitsDst, NULL, 0);
    SelectObject(hdcDst, hbmDst);

    /* Create a source dc and bitmap */
    hdcSrc = CreateCompatibleDC(NULL);
    hbmSrc = CreateDIBSection(hdcSrc, pbmi, DIB_RGB_COLORS, (PVOID*)&pulBitsSrc, NULL, 0);
    SelectObject(hdcSrc, hbmSrc);

    hbr = CreateHatchBrush(HS_CROSS, 0);
    ok(hbr != 0, "failed to create brush\n");
    ok(SelectObject(hdcDst, hbr) != 0, "failed to select brush\n");

    /* Do the masking (SRCCOPY / NOOP) */
    pulBitsDst[0] = 0x00000000;
    pulBitsSrc[0] = 0xFFFFFFFF;
    ret = MaskBlt(hdcDst, 0, 0, 8, 1, hdcSrc, 0, 0, NULL, 0, 0, MAKEROP4(SRCCOPY, 0xAA0000));
    ok(ret == 1, "MaskBlt failed (%d)\n", ret);
    ok(pulBitsDst[0] == 0, "pulBitsDst[0] == 0x%lx\n", pulBitsDst[0]);

    /* Create a 1 bpp pattern brush */
    pbmi->bmiHeader.biWidth = 8;
    hbmMsk = CreateDIBSection(hdcDst, pbmi, DIB_RGB_COLORS, (PVOID*)&pulBitsMsk, NULL, 0);
    ok(hbmMsk != 0, "CreateDIBSection failed\n");
    hbr = CreatePatternBrush(hbmMsk);
    ok(hbr != 0, "CreatePatternBrush failed\n");
    ok(SelectObject(hdcDst, hbr) != 0, "failed to select brush\n");

    /* Do the masking (SRCCOPY / NOOP) */
    pulBitsDst[0] = 0x00000000;
    pulBitsSrc[0] = 0xFFFFFFFF;
    pulBitsMsk[0] = 0xCCAAFF00;
    ret = MaskBlt(hdcDst, 0, 0, 16, 1, hdcSrc, 0, 0, NULL, 0, 0, MAKEROP4(SRCCOPY, 0xAA0000));
    ok(ret == 1, "MaskBlt failed (%d)\n", ret);
    ok(pulBitsDst[0] == 0, "pulBitsDst[0] == 0x%lx\n", pulBitsDst[0]);

}
开发者ID:GYGit,项目名称:reactos,代码行数:52,代码来源:MaskBlt.c


注:本文中的CreatePatternBrush函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。