示例#1
0
文件: GetObject.c 项目: GYGit/reactos
void
Test_DIBBrush(void)
{
    struct
    {
        BITMAPINFOHEADER bmiHeader;
        WORD wColors[4];
        BYTE jBuffer[16];
    } PackedDIB =
    {
        {sizeof(BITMAPINFOHEADER), 4, 4, 1, 8, BI_RGB, 0, 1, 1, 4, 0},
        {1, 7, 3, 1},
        {0,1,2,3,  1,2,3,0,  2,3,0,1,  3,0,1,2},
    };
    LOGBRUSH logbrush;
    HBRUSH hBrush;

    /* Create a DIB brush */
    hBrush = CreateDIBPatternBrushPt(&PackedDIB, DIB_PAL_COLORS);
    ok(hBrush != 0, "CreateSolidBrush failed, skipping tests.\n");
    if (!hBrush) return;

    FillMemory(&logbrush, sizeof(LOGBRUSH), 0x77);
    SetLastError(ERROR_SUCCESS);

    ok_long(GetObject(hBrush, sizeof(LOGBRUSH), &logbrush), sizeof(LOGBRUSH));
    ok_long(logbrush.lbStyle, BS_DIBPATTERN);
    ok_long(logbrush.lbColor, 0);
    ok_long(logbrush.lbHatch, (ULONG_PTR)&PackedDIB);

    ok_err(ERROR_SUCCESS);
    DeleteObject(hBrush);


    /* Create a DIB brush with undocumented iUsage 2 */
    hBrush = CreateDIBPatternBrushPt(&PackedDIB, 2);
    ok(hBrush != 0, "CreateSolidBrush failed, skipping tests.\n");
    if (!hBrush) return;

    FillMemory(&logbrush, sizeof(LOGBRUSH), 0x77);
    SetLastError(ERROR_SUCCESS);

    ok_long(GetObject(hBrush, sizeof(LOGBRUSH), &logbrush), sizeof(LOGBRUSH));
    ok_long(logbrush.lbStyle, BS_DIBPATTERN);
    ok_long(logbrush.lbColor, 0);
    ok_long(logbrush.lbHatch, (ULONG_PTR)&PackedDIB);

    ok_err(ERROR_SUCCESS);
    DeleteObject(hBrush);

}
示例#2
0
文件: brush.c 项目: GYGit/reactos
/*
 * @implemented
 */
HBRUSH WINAPI
CreateBrushIndirect(
    CONST LOGBRUSH *LogBrush)
{
    HBRUSH hBrush;

    switch (LogBrush->lbStyle)
    {
    case BS_DIBPATTERN8X8:
    case BS_DIBPATTERN:
        hBrush = CreateDIBPatternBrush((HGLOBAL)LogBrush->lbHatch,
                                       LogBrush->lbColor);
        break;

    case BS_DIBPATTERNPT:
        hBrush = CreateDIBPatternBrushPt((PVOID)LogBrush->lbHatch,
                                         LogBrush->lbColor);
        break;

    case BS_PATTERN:
        hBrush = NtGdiCreatePatternBrushInternal((HBITMAP)LogBrush->lbHatch,
                 FALSE,
                 FALSE);
        break;

    case BS_PATTERN8X8:
        hBrush = NtGdiCreatePatternBrushInternal((HBITMAP)LogBrush->lbHatch,
                 FALSE,
                 TRUE);
        break;

    case BS_SOLID:
/*        hBrush = hGetPEBHandle(hctBrushHandle, LogBrush->lbColor);
        if (!hBrush)*/
        hBrush = NtGdiCreateSolidBrush(LogBrush->lbColor, 0);
        break;

    case BS_HATCHED:
        hBrush = NtGdiCreateHatchBrushInternal(LogBrush->lbHatch,
                                               LogBrush->lbColor,
                                               FALSE);
        break;

    case BS_NULL:
        hBrush = NtGdiGetStockObject(NULL_BRUSH);
        break;

    default:
        SetLastError(ERROR_INVALID_PARAMETER);
        hBrush = NULL;
        break;
    }

    return hBrush;
}
示例#3
0
long CxImage::Blt(HDC pDC, long x, long y)
{
	if((pDib==0)||(pDC==0)||(!info.bEnabled)) return 0;

    HBRUSH brImage = CreateDIBPatternBrushPt(pDib, DIB_RGB_COLORS);
    HBRUSH brOld = (HBRUSH) SelectObject(pDC, brImage);
    PatBlt(pDC, 0, 0, head.biWidth, head.biHeight, PATCOPY);
    SelectObject(pDC, brOld);
    DeleteObject(brImage);
	return 1;
}
示例#4
0
HBRUSH CreateAlphaBrush(ieBGRA clr)
{
	struct {
		BITMAPINFOHEADER hdr;
		ieBGRA	aPixels[8 * 8];
	} bmi;

	bmi.hdr.biSize = sizeof(bmi.hdr);
	bmi.hdr.biWidth = 1;
	bmi.hdr.biHeight = 1;
	bmi.hdr.biPlanes = 1;
	bmi.hdr.biBitCount = 32;
	bmi.hdr.biCompression = BI_RGB;
	bmi.hdr.biXPelsPerMeter = 0;
	bmi.hdr.biYPelsPerMeter = 0;
	bmi.hdr.biClrUsed = 0;
	bmi.hdr.biClrImportant = 0;

	for (int i = 0; i < 8 * 8; i++)
		bmi.aPixels[i] = clr;

	return CreateDIBPatternBrushPt(&bmi, DIB_RGB_COLORS);
}
示例#5
0
文件: dib.c 项目: aragaer/wine
static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sha1)
{
    DWORD dib_size = get_dib_size(bmi);
    HPEN solid_pen, dashed_pen, orig_pen;
    HBRUSH solid_brush, dib_brush, hatch_brush, orig_brush;
    INT i, y, hatch_style;
    HRGN hrgn, hrgn2;
    BYTE dib_brush_buf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD) + 16 * 16 * sizeof(DWORD)]; /* Enough for 16 x 16 at 32 bpp */
    BITMAPINFO *brush_bi = (BITMAPINFO*)dib_brush_buf;
    BYTE *brush_bits;
    BOOL dib_is_1bpp = (bmi->bmiHeader.biBitCount == 1);

    memset(bits, 0xcc, dib_size);
    compare_hash(bmi, bits, sha1, "empty");

    solid_pen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0xff));
    orig_pen = SelectObject(hdc, solid_pen);
    SetBrushOrgEx(hdc, 0, 0, NULL);

    /* horizontal and vertical lines */
    for(i = 1; i <= 16; i++)
    {
        SetROP2(hdc, i);
        MoveToEx(hdc, 10, i * 3, NULL);
        LineTo(hdc, 100, i * 3); /* l -> r */
        MoveToEx(hdc, 100, 50 + i * 3, NULL);
        LineTo(hdc, 10, 50 + i * 3); /* r -> l */
        MoveToEx(hdc, 120 + i * 3, 10, NULL);
        LineTo(hdc, 120 + i * 3, 100); /* t -> b */
        MoveToEx(hdc, 170 + i * 3, 100, NULL);
        LineTo(hdc, 170 + i * 3, 10); /* b -> t */
    }
    compare_hash(bmi, bits, sha1, "h and v solid lines");
    memset(bits, 0xcc, dib_size);

    /* diagonal lines */
    SetROP2(hdc, R2_COPYPEN);
    for(i = 0; i < 16; i++)
    {
        double s = sin(M_PI * i / 8.0);
        double c = cos(M_PI * i / 8.0);

        MoveToEx(hdc, 200.5 + 10 * c, 200.5 + 10 * s, NULL);
        LineTo(hdc, 200.5 + 100 * c, 200.5 + 100 * s);
    }
    compare_hash(bmi, bits, sha1, "diagonal solid lines");
    memset(bits, 0xcc, dib_size);

    for(i = 0; i < sizeof(bias_check) / sizeof(bias_check[0]); i++)
    {
        MoveToEx(hdc, bias_check[i].left, bias_check[i].top, NULL);
        LineTo(hdc, bias_check[i].right, bias_check[i].bottom);
    }
    compare_hash(bmi, bits, sha1, "more diagonal solid lines");
    memset(bits, 0xcc, dib_size);

    /* solid brush PatBlt */
    solid_brush = CreateSolidBrush(RGB(0x33, 0xaa, 0xff));
    orig_brush = SelectObject(hdc, solid_brush);

    for(i = 0, y = 10; i < 256; i++)
    {
        BOOL ret;

        ret = PatBlt(hdc, 10, y, 100, 10, rop3[i]);

        if(rop_uses_src(rop3[i]))
            ok(ret == FALSE, "got TRUE for %x\n", rop3[i]);
        else
        {
            ok(ret, "got FALSE for %x\n", rop3[i]);
            y += 20;
        }

    }
    compare_hash(bmi, bits, sha1, "solid patblt");
    memset(bits, 0xcc, dib_size);

    /* clipped lines */
    hrgn = CreateRectRgn(10, 10, 200, 20);
    hrgn2 = CreateRectRgn(100, 100, 200, 200);
    CombineRgn(hrgn, hrgn, hrgn2, RGN_OR);
    SetRectRgn(hrgn2, 290, 100, 300, 200);
    CombineRgn(hrgn, hrgn, hrgn2, RGN_OR);
    ExtSelectClipRgn(hdc, hrgn, RGN_COPY);
    DeleteObject(hrgn2);

    for(i = 0; i < sizeof(hline_clips)/sizeof(hline_clips[0]); i++)
    {
        MoveToEx(hdc, hline_clips[i].left, hline_clips[i].top, NULL);
        LineTo(hdc, hline_clips[i].right, hline_clips[i].bottom);
    }
    compare_hash(bmi, bits, sha1, "clipped solid hlines");
    memset(bits, 0xcc, dib_size);

    for(i = 0; i < sizeof(vline_clips)/sizeof(vline_clips[0]); i++)
    {
        MoveToEx(hdc, vline_clips[i].left, vline_clips[i].top, NULL);
        LineTo(hdc, vline_clips[i].right, vline_clips[i].bottom);
    }
    compare_hash(bmi, bits, sha1, "clipped solid vlines");
    memset(bits, 0xcc, dib_size);

    for(i = 0; i < sizeof(line_clips)/sizeof(line_clips[0]); i++)
    {
        MoveToEx(hdc, line_clips[i].left, line_clips[i].top, NULL);
        LineTo(hdc, line_clips[i].right, line_clips[i].bottom);
    }
    compare_hash(bmi, bits, sha1, "clipped solid diagonal lines");
    memset(bits, 0xcc, dib_size);

    /* clipped PatBlt */
    for(i = 0; i < sizeof(patblt_clips) / sizeof(patblt_clips[0]); i++)
    {
        PatBlt(hdc, patblt_clips[i].left, patblt_clips[i].top,
               patblt_clips[i].right - patblt_clips[i].left,
               patblt_clips[i].bottom - patblt_clips[i].top, PATCOPY);
    }
    compare_hash(bmi, bits, sha1, "clipped patblt");
    memset(bits, 0xcc, dib_size);

    /* clipped dashed lines */
    dashed_pen = CreatePen(PS_DASH, 1, RGB(0xff, 0, 0));
    SelectObject(hdc, dashed_pen);
    SetBkMode(hdc, TRANSPARENT);
    SetBkColor(hdc, RGB(0, 0xff, 0));

    for(i = 0; i < sizeof(hline_clips)/sizeof(hline_clips[0]); i++)
    {
        MoveToEx(hdc, hline_clips[i].left, hline_clips[i].top, NULL);
        LineTo(hdc, hline_clips[i].right, hline_clips[i].bottom);
    }
    compare_hash(bmi, bits, sha1, "clipped dashed hlines");
    memset(bits, 0xcc, dib_size);

    for(i = 0; i < sizeof(hline_clips)/sizeof(hline_clips[0]); i++)
    {
        MoveToEx(hdc, hline_clips[i].right - 1, hline_clips[i].bottom, NULL);
        LineTo(hdc, hline_clips[i].left - 1, hline_clips[i].top);
    }
    compare_hash(bmi, bits, sha1, "clipped dashed hlines r -> l");
    memset(bits, 0xcc, dib_size);

    for(i = 0; i < sizeof(vline_clips)/sizeof(vline_clips[0]); i++)
    {
        MoveToEx(hdc, vline_clips[i].left, vline_clips[i].top, NULL);
        LineTo(hdc, vline_clips[i].right, vline_clips[i].bottom);
    }
    compare_hash(bmi, bits, sha1, "clipped dashed vlines");
    memset(bits, 0xcc, dib_size);

    for(i = 0; i < sizeof(vline_clips)/sizeof(vline_clips[0]); i++)
    {
        MoveToEx(hdc, vline_clips[i].right, vline_clips[i].bottom - 1, NULL);
        LineTo(hdc, vline_clips[i].left, vline_clips[i].top - 1);
    }
    compare_hash(bmi, bits, sha1, "clipped dashed vlines b -> t");
    memset(bits, 0xcc, dib_size);

    for(i = 0; i < sizeof(line_clips)/sizeof(line_clips[0]); i++)
    {
        MoveToEx(hdc, line_clips[i].left, line_clips[i].top, NULL);
        LineTo(hdc, line_clips[i].right, line_clips[i].bottom);
    }
    compare_hash(bmi, bits, sha1, "clipped dashed diagonal lines");
    memset(bits, 0xcc, dib_size);

    SetBkMode(hdc, OPAQUE);

    for(i = 0; i < sizeof(line_clips)/sizeof(line_clips[0]); i++)
    {
        MoveToEx(hdc, line_clips[i].left, line_clips[i].top, NULL);
        LineTo(hdc, line_clips[i].right, line_clips[i].bottom);
    }
    compare_hash(bmi, bits, sha1, "clipped opaque dashed diagonal lines");
    memset(bits, 0xcc, dib_size);

    ExtSelectClipRgn(hdc, NULL, RGN_COPY);

    /* 8888 DIB pattern brush */

    brush_bi->bmiHeader = dib_brush_header_8888;
    brush_bits = (BYTE*)brush_bi + sizeof(BITMAPINFOHEADER);
    memset(brush_bits, 0, 16 * 16 * sizeof(DWORD));
    brush_bits[2] = 0xff;
    brush_bits[6] = 0xff;
    brush_bits[14] = 0xff;
    brush_bits[65] = 0xff;
    brush_bits[69] = 0xff;
    brush_bits[72] = 0xff;

    dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);

    SelectObject(hdc, dib_brush);
    SetBrushOrgEx(hdc, 1, 1, NULL);

    for(i = 0, y = 10; i < 256; i++)
    {
        BOOL ret;

        if(!rop_uses_src(rop3[i]))
        {
            ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
            ok(ret, "got FALSE for %x\n", rop3[i]);
            y += 25;
        }
    }
    compare_hash_broken_todo(bmi, bits, sha1, "top-down 8888 dib brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp);
    memset(bits, 0xcc, dib_size);

    SelectObject(hdc, orig_brush);
    DeleteObject(dib_brush);

    /* 8888 bottom-up DIB pattern brush */

    brush_bi->bmiHeader.biHeight = -brush_bi->bmiHeader.biHeight;

    dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);

    SelectObject(hdc, dib_brush);

    /* This used to set the x origin to 100 as well, but
       there's a Windows bug for 24 bpp where the brush's x offset
       is incorrectly calculated for rops that involve both D and P */
    SetBrushOrgEx(hdc, 4, 100, NULL);

    for(i = 0, y = 10; i < 256; i++)
    {
        BOOL ret;

        if(!rop_uses_src(rop3[i]))
        {
            ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
            ok(ret, "got FALSE for %x\n", rop3[i]);
            y += 25;
        }
    }
    compare_hash_broken_todo(bmi, bits, sha1, "bottom-up 8888 dib brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp);
    memset(bits, 0xcc, dib_size);

    SelectObject(hdc, orig_brush);
    DeleteObject(dib_brush);

    /* 24 bpp dib pattern brush */

    brush_bi->bmiHeader = dib_brush_header_24;
    brush_bits = (BYTE*)brush_bi + sizeof(BITMAPINFOHEADER);
    memset(brush_bits, 0, 16 * 16 * 3);
    brush_bits[0] = brush_bits[3] = brush_bits[6] = brush_bits[8] = 0xff;
    brush_bits[49] = brush_bits[52] = 0xff;

    dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);

    SelectObject(hdc, dib_brush);
    SetBrushOrgEx(hdc, 1, 1, NULL);

    for(i = 0, y = 10; i < 256; i++)
    {
        BOOL ret;

        if(!rop_uses_src(rop3[i]))
        {
            ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
            ok(ret, "got FALSE for %x\n", rop3[i]);
            y += 25;
        }
    }
    compare_hash_broken_todo(bmi, bits, sha1, "top-down 24 bpp brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp);
    memset(bits, 0xcc, dib_size);

    SelectObject(hdc, orig_brush);
    DeleteObject(dib_brush);

    /* 555 dib pattern brush */

    brush_bi->bmiHeader = dib_brush_header_555;
    brush_bits = (BYTE*)brush_bi + sizeof(BITMAPINFOHEADER);
    memset(brush_bits, 0, 16 * 16 * sizeof(WORD));
    brush_bits[0] = brush_bits[1] = 0xff;
    brush_bits[32] = brush_bits[34] = 0x7c;

    dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);

    SelectObject(hdc, dib_brush);
    SetBrushOrgEx(hdc, 1, 1, NULL);

    for(i = 0, y = 10; i < 256; i++)
    {
        BOOL ret;

        if(!rop_uses_src(rop3[i]))
        {
            ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
            ok(ret, "got FALSE for %x\n", rop3[i]);
            y += 25;
        }
    }
    compare_hash_broken_todo(bmi, bits, sha1, "top-down 555 dib brush patblt", dib_is_1bpp ? 1 : 0, dib_is_1bpp);
    memset(bits, 0xcc, dib_size);

    SelectObject(hdc, orig_brush);
    DeleteObject(dib_brush);

    SetBrushOrgEx(hdc, 0, 0, NULL);

    /* 8 bpp dib pattern brush */

    brush_bi->bmiHeader = dib_brush_header_8;
    brush_bi->bmiHeader.biClrUsed = 3;
    memset(brush_bi->bmiColors, 0, brush_bi->bmiHeader.biClrUsed * sizeof(RGBQUAD));
    brush_bi->bmiColors[0].rgbRed = 0xff;
    brush_bi->bmiColors[1].rgbRed = 0xff;
    brush_bi->bmiColors[1].rgbGreen = 0xff;
    brush_bi->bmiColors[1].rgbBlue = 0xff;

    brush_bits = (BYTE*)brush_bi + sizeof(BITMAPINFOHEADER) + brush_bi->bmiHeader.biClrUsed * sizeof(RGBQUAD);
    memset(brush_bits, 0, 16 * 16 * sizeof(BYTE));
    brush_bits[0] = brush_bits[1] = 1;
    brush_bits[16] = brush_bits[17] = 2;
    brush_bits[32] = brush_bits[33] = 6;

    dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);

    SelectObject(hdc, dib_brush);
    SetBrushOrgEx(hdc, 1, 1, NULL);

    for(i = 0, y = 10; i < 256; i++)
    {
        BOOL ret;

        if(!rop_uses_src(rop3[i]))
        {
            ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
            ok(ret, "got FALSE for %x\n", rop3[i]);
            y += 25;
        }
    }
    compare_hash_broken_todo(bmi, bits, sha1, "top-down 8 bpp dib brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp);
    memset(bits, 0xcc, dib_size);

    SelectObject(hdc, orig_brush);
    DeleteObject(dib_brush);

    /* 4 bpp dib pattern brush */

    brush_bi->bmiHeader = dib_brush_header_4;
    dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);

    SelectObject(hdc, dib_brush);
    SetBrushOrgEx(hdc, 1, 1, NULL);

    for(i = 0, y = 10; i < 256; i++)
    {
        BOOL ret;

        if(!rop_uses_src(rop3[i]))
        {
            ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
            ok(ret, "got FALSE for %x\n", rop3[i]);
            y += 25;
        }
    }
    compare_hash_broken_todo(bmi, bits, sha1, "top-down 4 bpp dib brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp);
    memset(bits, 0xcc, dib_size);

    SelectObject(hdc, orig_brush);
    DeleteObject(dib_brush);

    /* 1 bpp dib pattern brush */

    brush_bi->bmiHeader = dib_brush_header_1;
    brush_bi->bmiHeader.biClrUsed = 2;
    memset(brush_bits, 0, 16 * 4);
    brush_bits[0] = 0xf0;
    brush_bits[4] = 0xf0;
    brush_bits[8] = 0xf0;

    dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
    SelectObject(hdc, dib_brush);
    for(i = 0, y = 10; i < 256; i++)
    {
        BOOL ret;

        if(!rop_uses_src(rop3[i]))
        {
            ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
            ok(ret, "got FALSE for %x\n", rop3[i]);
            y += 25;
        }
    }

    compare_hash_broken_todo(bmi, bits, sha1, "top-down 1 bpp dib brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp);
    memset(bits, 0xcc, dib_size);

    SelectObject(hdc, orig_brush);
    SetBrushOrgEx(hdc, 0, 0, NULL);

    /* Rectangle */

    SelectObject(hdc, solid_pen);
    SelectObject(hdc, solid_brush);

    for(i = 0; i < sizeof(rectangles)/sizeof(rectangles[0]); i++)
    {
        Rectangle(hdc, rectangles[i].left, rectangles[i].top, rectangles[i].right, rectangles[i].bottom);
    }

    SelectObject(hdc, dashed_pen);
    for(i = 0; i < sizeof(rectangles)/sizeof(rectangles[0]); i++)
    {
        Rectangle(hdc, rectangles[i].left, rectangles[i].top + 150, rectangles[i].right, rectangles[i].bottom + 150);
    }

    compare_hash(bmi, bits, sha1, "rectangles");
    memset(bits, 0xcc, dib_size);
    SelectObject(hdc, solid_pen);

    /* PaintRgn */

    PaintRgn(hdc, hrgn);
    compare_hash(bmi, bits, sha1, "PaintRgn");
    memset(bits, 0xcc, dib_size);

    /* RTL rectangles */

    if( !pSetLayout )
    {
        win_skip("Don't have SetLayout\n");
        (*sha1)++;
    }
    else
    {
        pSetLayout(hdc, LAYOUT_RTL);
        PaintRgn(hdc, hrgn);
        PatBlt(hdc, 10, 250, 10, 10, PATCOPY);
        Rectangle(hdc, 100, 250, 110, 260);
        compare_hash(bmi, bits, sha1, "rtl");
        memset(bits, 0xcc, dib_size);

        pSetLayout(hdc, LAYOUT_LTR);
    }

    for(i = 0, y = 10; i < 256; i++)
    {
        BOOL ret;

        if(!rop_uses_src(rop3[i]))
        {
            for(hatch_style = HS_HORIZONTAL; hatch_style <= HS_DIAGCROSS; hatch_style++)
            {
                hatch_brush = CreateHatchBrush(hatch_style, RGB(0xff, 0, 0));
                SelectObject(hdc, hatch_brush);
                ret = PatBlt(hdc, 10 + i + 30 * hatch_style, y, 20, 20, rop3[i]);
                ok(ret, "got FALSE for %x\n", rop3[i]);
                SelectObject(hdc, orig_brush);
                DeleteObject(hatch_brush);
            }
            y += 25;
        }
    }

    compare_hash_broken_todo(bmi, bits, sha1, "hatch brushes", 1, FALSE); /* nt4 is different */
    memset(bits, 0xcc, dib_size);

    SelectObject(hdc, orig_brush);
    SelectObject(hdc, orig_pen);
    DeleteObject(hrgn);
    DeleteObject(dib_brush);
    DeleteObject(dashed_pen);
    DeleteObject(solid_brush);
    DeleteObject(solid_pen);
}
示例#6
0
void Demo_AreaFill(HDC hDC, const RECT * rcPaint, int width, int height)
{
	const COLORREF c0 = RGB(0x20, 0x20, 0x20);
	const COLORREF c1 = RGB(0xF0, 0xF0, 0x20);

	for (int i=0; i<4; i++)
		GradientRectangle(hDC, 1000+1100*i, 500, 2000+1100*i, 1500, c0, c1, i*450);

	for (i=0; i<4; i++)
		SymGradientRectangle(hDC, 1000+1100*i, 1600, 2000+1100*i, 2600, c0, c1, i*450);

	for (i=0; i<4; i++)
		CornerGradientRectangle(hDC, 1000+1100*i, 2700, 2000+1100*i, 3700, c0, c1, i);

	CenterGradientRectangle(hDC, 5600, 1500, 6600, 2500, c0, c1);
	CenterGradientRectangle(hDC, 5600, 2600, 6600, 3600, c1, c0);

	//  Buttons
	RoundRectButton(hDC, 0,    4000,  800, 4800,   0, 100, RGB(0x20, 0x20, 0x20), RGB(0xF0, 0xF0, 0x20));
	RoundRectButton(hDC, 1000, 4000, 1800, 4800, 400, 100, RGB(0xF0, 0x20, 0x20), RGB(0x20, 0xF0, 0x20));
	RoundRectButton(hDC, 2000, 4000, 2800, 4800, 800, 100, RGB(0xFF, 0xFF, 0x20), RGB(0x20, 0x20, 0xF0));
	
	   GradientRectangle(hDC, 0, 5000, 2000, 6000, RGB(0xFF, 0x0, 0), RGB(0, 0, 0xFF), 0);
	HLSGradientRectangle(hDC, 0, 6200, 2000, 7200, RGB(0xFF, 0x0, 0), RGB(0, 0, 0xFF), 200);

	RadialGradientFill(hDC, 3200, 6300, 3200    , 6300   ,  1000, RGB(0xFF, 0xFF, 0xFF), RGB(0, 0, 0xFF), 8);
	RadialGradientFill(hDC, 5300, 6300, 5300-300, 6300-600, 1000, RGB(0xFF, 0xFF, 0xFF), RGB(0, 0, 0xFF), 16);
	RadialGradientFill(hDC, 7400, 6300, 7400-300, 6300+300, 1000, RGB(0xFF, 0xFF, 0xFF), RGB(0, 0, 0xFF), 256);

	{
		RECT r = { 7000, 500, 8500, 500+1500 };

		KGDIObject blue(hDC, CreatePen(PS_SOLID, 1 * ONEINCH/72, RGB(0, 0, 0xFF)));
		KGDIObject yellow(hDC, CreateSolidBrush(RGB(0xFF, 0xFF, 0)));
	
		Rectangle(hDC, 7000, 500, 8500, 500+1500);
		
		BrickPatternFill(hDC, 7000,  500, 8500,	 500+1500, 150, 150);
		BrickPatternFill(hDC, 7000, 2100, 8500, 2100+1500, 100, 100);
	}

	KLogFont logfont(- 8 * ONEINCH / 72, "Tahoma");
	KGDIObject font(hDC, logfont.CreateFont());

	{
		SelectObject(hDC, GetStockObject(NULL_PEN));
	
		typedef enum { GAP = 1200 };

		for (int hs= HS_HORIZONTAL; hs<=HS_DIAGCROSS; hs++)
		{
			HBRUSH hBrush = CreateHatchBrush(hs, RGB(0, 0, 0xFF));
			HGDIOBJ hOld  = SelectObject(hDC, hBrush);

			SetBkColor(hDC, RGB(0xFF, 0xFF, 0));
			Rectangle(hDC, hs*GAP, 8000, hs*GAP+890, 8890);

			SetBkColor(hDC, RGB(0xFF, 0xFF, 0xFF));
		
			SetTextAlign(hDC, TA_CENTER);
			TextOut(hDC, hs*GAP+880/2, 8980, HS_Names[hs-HS_HORIZONTAL], _tcslen(HS_Names[hs-HS_HORIZONTAL]));

			SelectObject(hDC, hOld);
			DeleteObject(hBrush);
		}
	}

	{
		HINSTANCE hCards = LoadLibrary("cards.dll");

		for (int i=0; i<3; i++)
	{
		HBRUSH hBrush;
		int    width, height;

		switch ( i )
		{
			case 0:
				{
					HBITMAP hBitmap = LoadBitmap(hCards, MAKEINTRESOURCE(52));
					BITMAP  bmp;

					GetObject(hBitmap, sizeof(bmp), & bmp);
					width = bmp.bmWidth; height = bmp.bmHeight;

					hBrush = CreatePatternBrush(hBitmap);
					DeleteObject(hBitmap);
				}
				break;

			case 1:
				{
					HRSRC hResource = FindResource(hCards, MAKEINTRESOURCE(52-14), RT_BITMAP);
					HGLOBAL hGlobal = LoadResource(hCards, hResource);
	
					hBrush  = CreateDIBPatternBrushPt(LockResource(hGlobal), DIB_RGB_COLORS);
					width   = ((BITMAPCOREHEADER *) hGlobal)->bcWidth; // old DIB format
					height  = ((BITMAPCOREHEADER *) hGlobal)->bcHeight;// old DIB format
				}
				break;

			case 2:
				{
					HRSRC hResource = FindResource(hCards, MAKEINTRESOURCE(52-28), RT_BITMAP);
					HGLOBAL hGlobal = LoadResource(hCards, hResource);

					hBrush  = CreateDIBPatternBrush(hGlobal, DIB_RGB_COLORS);
					width   = ((BITMAPCOREHEADER *) hGlobal)->bcWidth;  // old DIB format
					height  = ((BITMAPCOREHEADER *) hGlobal)->bcHeight; // old DIB format
				}
		}
		
		HGDIOBJ hOld  = SelectObject(hDC, hBrush);

		POINT P = { i*1400+200 + width*10*i/4, 10000 + height*10*i/4 };
		LPtoDP(hDC, &P, 1);
		SetBrushOrgEx(hDC, P.x, P.y, NULL); // make sure cards aligned with rectangle
	
		Rectangle(hDC, i*1400+200, 10000, i*1400+200+width*30/2+1, 10000+height*30/2+1);
	
		SelectObject(hDC, hOld);
		DeleteObject(hBrush);

	}
	}

}
示例#7
0
文件: brush.c 项目: AmesianX/RosWine
static void test_palette_brush(void)
{
    char buffer[sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD) + 16 * 16];
    BITMAPINFO *info = (BITMAPINFO *)buffer;
    WORD *indices = (WORD *)info->bmiColors;
    char pal_buffer[sizeof(LOGPALETTE) + 256 * sizeof(PALETTEENTRY)];
    LOGPALETTE *pal = (LOGPALETTE *)pal_buffer;
    HDC hdc = CreateCompatibleDC( 0 );
    DWORD *dib_bits;
    HBITMAP dib;
    HBRUSH brush;
    int i;
    HPALETTE palette, palette2;

    memset( info, 0, sizeof(*info) );
    info->bmiHeader.biSize        = sizeof(info->bmiHeader);
    info->bmiHeader.biWidth       = 16;
    info->bmiHeader.biHeight      = 16;
    info->bmiHeader.biPlanes      = 1;
    info->bmiHeader.biBitCount    = 32;
    info->bmiHeader.biCompression = BI_RGB;
    dib = CreateDIBSection( NULL, info, DIB_RGB_COLORS, (void**)&dib_bits, NULL, 0 );
    ok( dib != NULL, "CreateDIBSection failed\n" );

    info->bmiHeader.biBitCount = 8;
    for (i = 0; i < 256; i++) indices[i] = 255 - i;
    for (i = 0; i < 256; i++) ((BYTE *)(indices + 256))[i] = i;
    brush = CreateDIBPatternBrushPt( info, DIB_PAL_COLORS );
    ok( brush != NULL, "CreateDIBPatternBrushPt failed\n" );

    pal->palVersion = 0x300;
    pal->palNumEntries = 256;
    for (i = 0; i < 256; i++)
    {
        pal->palPalEntry[i].peRed = i * 2;
        pal->palPalEntry[i].peGreen = i * 2;
        pal->palPalEntry[i].peBlue = i * 2;
        pal->palPalEntry[i].peFlags = 0;
    }
    palette = CreatePalette( pal );

    ok( SelectObject( hdc, dib ) != NULL, "SelectObject failed\n" );
    ok( SelectPalette( hdc, palette, 0 ) != NULL, "SelectPalette failed\n" );
    ok( SelectObject( hdc, brush ) != NULL, "SelectObject failed\n" );
    memset( dib_bits, 0xaa, 16 * 16 * 4 );
    PatBlt( hdc, 0, 0, 16, 16, PATCOPY );
    for (i = 0; i < 256; i++)
    {
        DWORD expect = (pal->palPalEntry[255 - i].peRed << 16 |
                        pal->palPalEntry[255 - i].peGreen << 8 |
                        pal->palPalEntry[255 - i].peBlue);
        ok( dib_bits[i] == expect, "wrong bits %x/%x at %u,%u\n", dib_bits[i], expect, i % 16, i / 16 );
    }

    for (i = 0; i < 256; i++) pal->palPalEntry[i].peRed = i * 3;
    palette2 = CreatePalette( pal );
    ok( SelectPalette( hdc, palette2, 0 ) != NULL, "SelectPalette failed\n" );
    memset( dib_bits, 0xaa, 16 * 16 * 4 );
    PatBlt( hdc, 0, 0, 16, 16, PATCOPY );
    for (i = 0; i < 256; i++)
    {
        DWORD expect = (pal->palPalEntry[255 - i].peRed << 16 |
                        pal->palPalEntry[255 - i].peGreen << 8 |
                        pal->palPalEntry[255 - i].peBlue);
        ok( dib_bits[i] == expect, "wrong bits %x/%x at %u,%u\n", dib_bits[i], expect, i % 16, i / 16 );
    }
    DeleteDC( hdc );
    DeleteObject( dib );
    DeleteObject( brush );
    DeleteObject( palette );
    DeleteObject( palette2 );
}
示例#8
0
文件: brush.c 项目: AmesianX/RosWine
static void test_pattern_brush(void)
{
    char buffer[sizeof(BITMAPINFOHEADER) + 2 * sizeof(RGBQUAD) + 32 * 32 / 8];
    BITMAPINFO *info = (BITMAPINFO *)buffer;
    HBRUSH brush;
    HBITMAP bitmap;
    LOGBRUSH br;
    INT ret;
    void *bits;
    DIBSECTION dib;
    HGLOBAL mem;

    bitmap = CreateBitmap( 20, 20, 1, 1, NULL );
    ok( bitmap != NULL, "CreateBitmap failed\n" );
    brush = CreatePatternBrush( bitmap );
    ok( brush != NULL, "CreatePatternBrush failed\n" );
    memset( &br, 0x55, sizeof(br) );
    ret = GetObjectW( brush, sizeof(br), &br );
    ok( ret == sizeof(br), "wrong size %u\n", ret );
    ok( br.lbStyle == BS_PATTERN, "wrong style %u\n", br.lbStyle );
    ok( br.lbColor == 0, "wrong color %u\n", br.lbColor );
    ok( (HBITMAP)br.lbHatch == bitmap, "wrong handle %p/%p\n", (HBITMAP)br.lbHatch, bitmap );
    DeleteObject( brush );

    br.lbStyle = BS_PATTERN8X8;
    br.lbColor = 0x12345;
    br.lbHatch = (ULONG_PTR)bitmap;
    brush = CreateBrushIndirect( &br );
    ok( brush != NULL, "CreatePatternBrush failed\n" );
    memset( &br, 0x55, sizeof(br) );
    ret = GetObjectW( brush, sizeof(br), &br );
    ok( ret == sizeof(br), "wrong size %u\n", ret );
    ok( br.lbStyle == BS_PATTERN, "wrong style %u\n", br.lbStyle );
    ok( br.lbColor == 0, "wrong color %u\n", br.lbColor );
    ok( (HBITMAP)br.lbHatch == bitmap, "wrong handle %p/%p\n", (HBITMAP)br.lbHatch, bitmap );
    ret = GetObjectW( bitmap, sizeof(dib), &dib );
    ok( ret == sizeof(dib.dsBm), "wrong size %u\n", ret );
    DeleteObject( bitmap );
    ret = GetObjectW( bitmap, sizeof(dib), &dib );
    ok( ret == 0, "wrong size %u\n", ret );
    DeleteObject( brush );

    memset( info, 0, sizeof(buffer) );
    info->bmiHeader.biSize = sizeof(info->bmiHeader);
    info->bmiHeader.biHeight = 32;
    info->bmiHeader.biWidth = 32;
    info->bmiHeader.biBitCount = 1;
    info->bmiHeader.biPlanes = 1;
    info->bmiHeader.biCompression = BI_RGB;
    bitmap = CreateDIBSection( 0, info, DIB_RGB_COLORS, (void**)&bits, NULL, 0 );
    ok( bitmap != NULL, "CreateDIBSection failed\n" );

    /* MSDN says a DIB section is not allowed, but it works fine */
    brush = CreatePatternBrush( bitmap );
    ok( brush != NULL, "CreatePatternBrush failed\n" );
    memset( &br, 0x55, sizeof(br) );
    ret = GetObjectW( brush, sizeof(br), &br );
    ok( ret == sizeof(br), "wrong size %u\n", ret );
    ok( br.lbStyle == BS_PATTERN, "wrong style %u\n", br.lbStyle );
    ok( br.lbColor == 0, "wrong color %u\n", br.lbColor );
    ok( (HBITMAP)br.lbHatch == bitmap, "wrong handle %p/%p\n", (HBITMAP)br.lbHatch, bitmap );
    ret = GetObjectW( bitmap, sizeof(dib), &dib );
    ok( ret == sizeof(dib), "wrong size %u\n", ret );
    DeleteObject( brush );
    DeleteObject( bitmap );

    brush = CreateDIBPatternBrushPt( info, DIB_RGB_COLORS );
    ok( brush != NULL, "CreatePatternBrush failed\n" );
    memset( &br, 0x55, sizeof(br) );
    ret = GetObjectW( brush, sizeof(br), &br );
    ok( ret == sizeof(br), "wrong size %u\n", ret );
    ok( br.lbStyle == BS_DIBPATTERN, "wrong style %u\n", br.lbStyle );
    ok( br.lbColor == 0, "wrong color %u\n", br.lbColor );
    ok( (BITMAPINFO *)br.lbHatch == info || broken(!br.lbHatch), /* nt4 */
        "wrong handle %p/%p\n", (BITMAPINFO *)br.lbHatch, info );
    DeleteObject( brush );

    br.lbStyle = BS_DIBPATTERNPT;
    br.lbColor = DIB_PAL_COLORS;
    br.lbHatch = (ULONG_PTR)info;
    brush = CreateBrushIndirect( &br );
    ok( brush != NULL, "CreatePatternBrush failed\n" );
    memset( &br, 0x55, sizeof(br) );
    ret = GetObjectW( brush, sizeof(br), &br );
    ok( ret == sizeof(br), "wrong size %u\n", ret );
    ok( br.lbStyle == BS_DIBPATTERN, "wrong style %u\n", br.lbStyle );
    ok( br.lbColor == 0, "wrong color %u\n", br.lbColor );
    ok( (BITMAPINFO *)br.lbHatch == info || broken(!br.lbHatch), /* nt4 */
        "wrong handle %p/%p\n", (BITMAPINFO *)br.lbHatch, info );

    mem = GlobalAlloc( GMEM_MOVEABLE, sizeof(buffer) );
    memcpy( GlobalLock( mem ), buffer, sizeof(buffer) );

    br.lbStyle = BS_DIBPATTERN;
    br.lbColor = DIB_PAL_COLORS;
    br.lbHatch = (ULONG_PTR)mem;
    brush = CreateBrushIndirect( &br );
    ok( brush != NULL, "CreatePatternBrush failed\n" );
    memset( &br, 0x55, sizeof(br) );
    ret = GetObjectW( brush, sizeof(br), &br );
    ok( ret == sizeof(br), "wrong size %u\n", ret );
    ok( br.lbStyle == BS_DIBPATTERN, "wrong style %u\n", br.lbStyle );
    ok( br.lbColor == 0, "wrong color %u\n", br.lbColor );
    ok( (HGLOBAL)br.lbHatch != mem, "wrong handle %p/%p\n", (HGLOBAL)br.lbHatch, mem );
    bits = GlobalLock( mem );
    ok( (HGLOBAL)br.lbHatch == bits || broken(!br.lbHatch), /* nt4 */
        "wrong handle %p/%p\n", (HGLOBAL)br.lbHatch, bits );
    ret = GlobalFlags( mem );
    ok( ret == 2, "wrong flags %x\n", ret );
    DeleteObject( brush );
    ret = GlobalFlags( mem );
    ok( ret == 2, "wrong flags %x\n", ret );

    brush = CreateDIBPatternBrushPt( info, DIB_PAL_COLORS );
    ok( brush != 0, "CreateDIBPatternBrushPt failed\n" );
    DeleteObject( brush );
    brush = CreateDIBPatternBrushPt( info, DIB_PAL_COLORS + 1 );
    ok( brush != 0, "CreateDIBPatternBrushPt failed\n" );
    DeleteObject( brush );
    brush = CreateDIBPatternBrushPt( info, DIB_PAL_COLORS + 2 );
    ok( !brush, "CreateDIBPatternBrushPt succeeded\n" );
    brush = CreateDIBPatternBrushPt( info, DIB_PAL_COLORS + 3 );
    ok( !brush, "CreateDIBPatternBrushPt succeeded\n" );

    info->bmiHeader.biBitCount = 8;
    info->bmiHeader.biCompression = BI_RLE8;
    brush = CreateDIBPatternBrushPt( info, DIB_RGB_COLORS );
    ok( !brush, "CreateDIBPatternBrushPt succeeded\n" );

    info->bmiHeader.biBitCount = 4;
    info->bmiHeader.biCompression = BI_RLE4;
    brush = CreateDIBPatternBrushPt( info, DIB_RGB_COLORS );
    ok( !brush, "CreateDIBPatternBrushPt succeeded\n" );

    br.lbStyle = BS_DIBPATTERN8X8;
    br.lbColor = DIB_RGB_COLORS;
    br.lbHatch = (ULONG_PTR)mem;
    brush = CreateBrushIndirect( &br );
    ok( !brush, "CreatePatternBrush succeeded\n" );

    br.lbStyle = BS_MONOPATTERN;
    br.lbColor = DIB_RGB_COLORS;
    br.lbHatch = (ULONG_PTR)mem;
    brush = CreateBrushIndirect( &br );
    ok( !brush, "CreatePatternBrush succeeded\n" );

    br.lbStyle = BS_INDEXED;
    br.lbColor = DIB_RGB_COLORS;
    br.lbHatch = (ULONG_PTR)mem;
    brush = CreateBrushIndirect( &br );
    ok( !brush, "CreatePatternBrush succeeded\n" );

    GlobalFree( mem );
}
示例#9
0
文件: xlate.c 项目: GYGit/reactos
void
Test_SrcMono1(ULONG iBmpFormat, HBITMAP hbmpDst, PVOID pvBits)
{
    COLORREF c, expected;
    HBRUSH hbr;
    RECT rect;
    struct
    {
        BITMAPINFOHEADER bmiHeader;
        ULONG bmiColors[2];
        BYTE aj[32];
    } bmi;

    SelectObject(hdcSrc, hbmp1bpp_a);
    SelectObject(hdcDst, hbmpDst);

    /* Set default dc fore and back colors */
    SetTextColor(hdcSrc, 0x000000);
    SetBkColor(hdcSrc, 0xffffff);
    SetTextColor(hdcDst, 0x000000);
    SetBkColor(hdcDst, 0xffffff);

    /* Do a bitblt operation */
    ok(BitBlt(hdcDst, 0, 0, 2, 2, hdcSrc, 0, 0, SRCCOPY), "(%ld): BitBlt failed", iBmpFormat);

    /* Test background color */
    c = GetPixel(hdcDst, 0, 0);
    expected = 0xffffff;
    ok(c == expected, "(%ld): wrong color, expected %lx, got %lx\n", iBmpFormat, expected, c);

    /* Test foreground color */
    c = GetPixel(hdcDst, 1, 0);
    expected = 0x000000;
    ok(c == expected, "(%ld): wrong color, expected %lx, got %lx\n", iBmpFormat, expected, c);

    if (pvBits)
    {
        c = GetDIBPixel(iBmpFormat, pvBits, 0);
        expected = iXlateFromRGB(iBmpFormat,  GetBkColor(hdcSrc));
        ok(c == expected, "(%ld): wrong color, expected %lx, got %lx\n", iBmpFormat, expected, c);

        c = GetDIBPixel(iBmpFormat, pvBits, 1);
        expected = iXlateFromRGB(iBmpFormat, GetTextColor(hdcSrc));
        ok(c == expected, "(%ld): wrong color, expected %lx, got %lx\n", iBmpFormat, expected, c);
    }

    /* Set different dc fore and back colors */
    SetTextColor(hdcSrc, 0xf00f0f);
    SetBkColor(hdcSrc, 0xf0ff0f);
    SetTextColor(hdcDst, 0xefFee5);
    SetBkColor(hdcDst, 0x100121);

    /* Make sure this alone didn't affect the resulting colors */
    c = GetPixel(hdcDst, 0, 0);
    expected = 0xffffff;
    ok(c == expected, "(%ld): wrong color, expected %lx, got %lx\n", iBmpFormat, expected, c);
    c = GetPixel(hdcDst, 1, 0);
    expected = 0x000000;
    ok(c == expected, "(%ld): wrong color, expected %lx, got %lx\n", iBmpFormat, expected, c);

    /* Repeat the bitblt operation */
    ok(BitBlt(hdcDst, 0, 0, 2, 2, hdcSrc, 0, 0, SRCCOPY), "(%ld): BitBlt failed", iBmpFormat);

    /* Test background color */
    c = GetPixel(hdcDst, 0, 0);
    expected = GetClosestColor(iBmpFormat, GetBkColor(hdcDst), 0xffffff);
    ok(c == expected, "(%ld): wrong color, expected %lx, got %lx\n", iBmpFormat, expected, c);

    /* Test foreground color */
    c = GetPixel(hdcDst, 1, 0);
    expected = GetClosestColor(iBmpFormat, GetTextColor(hdcDst), 0);
    ok(c == expected, "(%ld): wrong color, expected %lx, got %lx\n", iBmpFormat, expected, c);

    if (pvBits)
    {
        c = GetDIBPixel(iBmpFormat, pvBits, 0);
        expected = iXlateFromRGB(iBmpFormat, GetBkColor(hdcDst));
        ok(c == expected, "(%ld): wrong color, expected %lx, got %lx\n", iBmpFormat, expected, c);

        c = GetDIBPixel(iBmpFormat, pvBits, 1);
        expected = iXlateFromRGB(iBmpFormat, GetTextColor(hdcDst));
        ok(c == expected, "(%ld): wrong color, expected %lx, got %lx\n", iBmpFormat, expected, c);
    }

    /* Set inverted fore and back colors */
    SetTextColor(hdcSrc, 0);
    SetBkColor(hdcSrc, 0xffffff);
    SetTextColor(hdcDst, 0xffffff);
    SetBkColor(hdcDst, 0x000000);

    /* Repeat the bitblt operation */
    ok(BitBlt(hdcDst, 0, 0, 2, 2, hdcSrc, 0, 0, SRCCOPY), "(%ld): BitBlt failed", iBmpFormat);

    /* Test background color */
    c = GetPixel(hdcDst, 0, 0);
    expected = GetClosestColor(iBmpFormat, GetBkColor(hdcDst), 0xffffff);
    ok(c == expected, "(%ld): wrong color, expected %lx, got %lx\n", iBmpFormat, expected, c);

    /* Test foreground color */
    c = GetPixel(hdcDst, 1, 0);
    expected = GetClosestColor(iBmpFormat, GetTextColor(hdcDst), 0);
    ok(c == expected, "(%ld): wrong color, expected %lx, got %lx\n", iBmpFormat, expected, c);

    if (pvBits)
    {
        c = GetDIBPixel(iBmpFormat, pvBits, 0);
        expected = iXlateFromRGB(iBmpFormat, GetBkColor(hdcDst));
        ok(c == expected, "(%ld): wrong color, expected %lx, got %lx\n", iBmpFormat, expected, c);

        c = GetDIBPixel(iBmpFormat, pvBits, 1);
        expected = iXlateFromRGB(iBmpFormat, GetTextColor(hdcDst));
        ok(c == expected, "(%ld): wrong color, expected %lx, got %lx\n", iBmpFormat, expected, c);
    }


/* Hatch brush ****************************************************************/

    /* Set dc fore and back colors */
    SetTextColor(hdcDst, 0x102030);
    SetBkColor(hdcDst, 0xeeccdd);
    SetBkMode(hdcDst, OPAQUE);

    /* Create a hatch brush */
    hbr = CreateHatchBrush(HS_DIAGCROSS, 0x123456);

    /* Fill the destination bitmap */
    rect.left = rect.top = 0;
    rect.bottom = rect.right = 4;
    ok(FillRect(hdcDst, &rect, hbr), "FillRect failed\n");

    /* Test the fore color of the hatch brush */
    c = GetPixel(hdcDst, 0, 0);
    expected = GetClosestColor(iBmpFormat, 0x123456, 0);
    ok(c == expected, "(%ld): wrong color, expected %lx, got %lx\n", iBmpFormat, expected, c);

    /* Test the back color of the hatch brush */
    c = GetPixel(hdcDst, 1, 0);
    expected = GetClosestColor(iBmpFormat, GetBkColor(hdcDst), 0xffffff);
    ok(c == expected, "(%ld): wrong color, expected %lx, got %lx\n", iBmpFormat, expected, c);

    if (pvBits)
    {
        c = GetDIBPixel(iBmpFormat, pvBits, 0);
        expected = iXlateFromRGB(iBmpFormat, 0x123456);
        ok(c == expected, "(%ld): wrong color, expected %lx, got %lx\n", iBmpFormat, expected, c);

        c = GetDIBPixel(iBmpFormat, pvBits, 1);
        expected = iXlateFromRGB(iBmpFormat, GetBkColor(hdcDst));
        ok(c == expected, "(%ld): wrong color, expected %lx, got %lx\n", iBmpFormat, expected, c);
    }

    DeleteObject(hbr);

/* DIB brush ******************************************************************/

    bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    bmi.bmiHeader.biWidth = 8;
    bmi.bmiHeader.biHeight = 8;
    bmi.bmiHeader.biPlanes = 1;
    bmi.bmiHeader.biBitCount = 1;
    bmi.bmiHeader.biCompression = BI_RGB;
    bmi.bmiHeader.biSizeImage = 0;
    bmi.bmiHeader.biXPelsPerMeter = 1;
    bmi.bmiHeader.biYPelsPerMeter = 1;
    bmi.bmiHeader.biClrUsed = 2;
    bmi.bmiHeader.biClrImportant = 2;
    bmi.bmiColors[0] = 0xeeeeee;
    bmi.bmiColors[1] = 0x111111;
    memset(bmi.aj, 0xaaaa, sizeof(bmi.aj));
    hbr = CreateDIBPatternBrushPt(&bmi, DIB_RGB_COLORS);
    ok(hbr != 0, "CreateDIBPatternBrushPt failed\n");

    rect.left = rect.top = 0;
    rect.bottom = rect.right = 4;
    ok(FillRect(hdcDst, &rect, hbr),"FillRect failed\n");

    /* Test color 1 of the dib brush */
    c = GetPixel(hdcDst, 0, 0);
    expected = GetClosestColor(iBmpFormat, bmi.bmiColors[1], 0);
    ok(c == expected, "(%ld): wrong color, expected %lx, got %lx\n", iBmpFormat, expected, c);

    /* Test color 0 of the dib brush */
    c = GetPixel(hdcDst, 1, 0);
    expected = GetClosestColor(iBmpFormat, bmi.bmiColors[0], 0xffffff);
    ok(c == expected, "(%ld): wrong color, expected %lx, got %lx\n", iBmpFormat, expected, c);

    if (pvBits)
    {
        c = GetDIBPixel(iBmpFormat, pvBits, 0);
        expected = iXlateFromRGB(iBmpFormat, bmi.bmiColors[1]);
        ok(c == expected, "(%ld): wrong color, expected %lx, got %lx\n", iBmpFormat, expected, c);

        c = GetDIBPixel(iBmpFormat, pvBits, 1);
        expected = iXlateFromRGB(iBmpFormat, bmi.bmiColors[0]);
        ok(c == expected, "(%ld): wrong color, expected %lx, got %lx\n", iBmpFormat, expected, c);
    }

    DeleteObject(hbr);


}