2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for CreateDIBPatternBrush
5 * PROGRAMMERS: Timo Kreuzer
13 /* New color use parameter. See support.microsoft.com/kb/kbview/108497 */
14 #define DIB_PAL_INDICES 2
16 void Test_CreateDIBPatternBrush()
21 void Test_CreateDIBPatternBrushPt()
25 BITMAPINFOHEADER bmiHeader
;
30 {sizeof(BITMAPINFOHEADER
), 4, -4, 1, 8, BI_RGB
, 0, 1, 1, 4, 0},
32 {0,1,2,3, 1,2,3,0, 2,3,0,1, 3,0,1,2},
39 ok_hdl(CreateDIBPatternBrushPt(NULL
, 0), NULL
);
40 ok_hdl(CreateDIBPatternBrushPt(NULL
, DIB_PAL_COLORS
), NULL
);
41 ok_hdl(CreateDIBPatternBrushPt(NULL
, 2), NULL
);
42 ok_hdl(CreateDIBPatternBrushPt(NULL
, 3), NULL
);
45 hbr
= CreateDIBPatternBrushPt(&PackedDIB
, 0);
46 ok(hbr
!= 0, "Expected success\n");
48 hbr
= CreateDIBPatternBrushPt(&PackedDIB
, 2);
49 ok(hbr
!= 0, "Expected success\n");
53 hbr
= CreateDIBPatternBrushPt(&PackedDIB
, 3);
54 ok(hbr
== 0, "Expected failure\n");
55 ok_err(ERROR_INVALID_PARAMETER
);
57 hbr
= CreateDIBPatternBrushPt(&PackedDIB
, 10);
58 ok(hbr
== 0, "Expected failure\n");
59 ok_err(ERROR_INVALID_PARAMETER
);
61 /* Create a DIB brush with palette indices */
62 hbr
= CreateDIBPatternBrushPt(&PackedDIB
, DIB_PAL_COLORS
);
63 ok(hbr
!= 0, "CreateDIBPatternBrushPt failed, skipping tests.\n");
66 /* Check the logbrush */
67 ok(GetObject(hbr
, sizeof(logbrush
), &logbrush
), "GetObject() failed\n");
68 ok_int(logbrush
.lbStyle
, BS_DIBPATTERN
);
69 ok_hex(logbrush
.lbColor
, 0);
70 ok(logbrush
.lbHatch
== (ULONG_PTR
)&PackedDIB
,
71 "invalid lbHatch. Got %p, expected %p\n", (PVOID
)logbrush
.lbHatch
, &PackedDIB
);
73 /* Select the brush into the dc */
74 hbrOld
= SelectObject(ghdcDIB32
, hbr
);
76 /* Copy it on the dib section */
77 ok_long(PatBlt(ghdcDIB32
, 0, 0, 4, 4, PATCOPY
), 1);
78 ok_long((*gpDIB32
)[0][0], 0x000000); // 0
79 ok_long((*gpDIB32
)[0][1], 0x800000); // 1
80 ok_long((*gpDIB32
)[0][2], 0x008000); // 2
81 ok_long((*gpDIB32
)[0][3], 0xc0c0c0); // 7
83 /* Select a logical palette into the DC */
84 hpalOld
= SelectPalette(ghdcDIB32
, ghpal
, FALSE
);
85 ok(hpalOld
!= 0, "Expected success, error %ld\n", GetLastError());
87 /* Copy it on the dib section */
88 ok_long(PatBlt(ghdcDIB32
, 0, 0, 4, 4, PATCOPY
), 1);
89 ok_long((*gpDIB32
)[0][0], 0x102030); // 0
90 ok_long((*gpDIB32
)[0][1], 0x203040); // 1
91 ok_long((*gpDIB32
)[0][2], 0x304050); // 2
92 ok_long((*gpDIB32
)[0][3], 0x8090a0); // 7
94 /* Select back old palette and destroy the DIB data */
95 SelectPalette(ghdcDIB32
, hpalOld
, FALSE
);
96 memset(gpDIB32
, 0x77, sizeof(*gpDIB32
));
98 /* Copy it on the dib section */
99 ok_long(PatBlt(ghdcDIB32
, 0, 0, 4, 4, PATCOPY
), 1);
100 ok_long((*gpDIB32
)[0][0], 0x000000); // 0
101 ok_long((*gpDIB32
)[0][1], 0x800000); // 1
102 ok_long((*gpDIB32
)[0][2], 0x008000); // 2
103 ok_long((*gpDIB32
)[0][3], 0xc0c0c0); // 7
105 SelectObject(ghdcDIB32
, hbrOld
);
108 /* Set some different values */
109 PackedDIB
.ajBuffer
[0] = 3;
110 PackedDIB
.ajBuffer
[1] = 2;
111 PackedDIB
.ajBuffer
[2] = 1;
112 PackedDIB
.ajBuffer
[3] = 0;
114 /* Create a DIB brush with DIB_PAL_INDICES */
115 hbr
= CreateDIBPatternBrushPt(&PackedDIB
, DIB_PAL_INDICES
);
116 ok(hbr
!= 0, "CreateSolidBrush failed, skipping tests.\n");
119 /* Check the logbrush */
120 ok(GetObject(hbr
, sizeof(logbrush
), &logbrush
), "GetObject() failed\n");
121 ok_int(logbrush
.lbStyle
, BS_DIBPATTERN
);
122 ok_hex(logbrush
.lbColor
, 0);
123 ok(logbrush
.lbHatch
== (ULONG_PTR
)&PackedDIB
,
124 "invalid lbHatch. Got %p, expected %p\n", (PVOID
)logbrush
.lbHatch
, &PackedDIB
);
126 /* Select the brush into the dc */
127 hbrOld
= SelectObject(ghdcDIB32
, hbr
);
128 ok(hbrOld
!= 0, "CreateSolidBrush failed, skipping tests.\n");
130 /* Copy it on a dib section */
131 memset(gpDIB32
, 0x77, sizeof(*gpDIB32
));
132 ok_long(PatBlt(ghdcDIB32
, 0, 0, 4, 4, PATCOPY
), 1);
133 ok_long((*gpDIB32
)[0][0], 0x77777777);
134 ok_long((*gpDIB32
)[0][1], 0x77777777);
135 ok_long((*gpDIB32
)[0][2], 0x77777777);
136 ok_long((*gpDIB32
)[0][3], 0x77777777);
138 /* Select a logical palette into the DC */
139 hpalOld
= SelectPalette(ghdcDIB32
, ghpal
, FALSE
);
140 ok(hpalOld
!= 0, "Expected success, error %ld\n", GetLastError());
142 /* Copy it on a dib section */
143 ok_long(PatBlt(ghdcDIB32
, 0, 0, 4, 4, PATCOPY
), 1);
144 ok_long((*gpDIB32
)[0][0], 0x77777777);
145 ok_long((*gpDIB32
)[0][1], 0x77777777);
146 ok_long((*gpDIB32
)[0][2], 0x77777777);
147 ok_long((*gpDIB32
)[0][3], 0x77777777);
149 SelectPalette(ghdcDIB32
, hpalOld
, FALSE
);
150 SelectObject(ghdcDIB32
, hbrOld
);
155 void Test_CreateDIBPatternBrushPt_RLE8()
159 BITMAPINFOHEADER bmiHeader
;
164 {sizeof(BITMAPINFOHEADER
), 4, 4, 1, 8, BI_RLE8
, 20, 1, 1, 4, 0},
166 {4,0, 0,2,0,1,0,2,3,1, 2,1, 2,2, 1,3,1,0,1,2, },
170 HDC hdc
= CreateCompatibleDC(0);
171 HBITMAP hbmp
= CreateDIBitmap(hdc
, &PackedDIB
.bmiHeader
, CBM_INIT
, &PackedDIB
.ajBuffer
, (PVOID
)&PackedDIB
, DIB_PAL_COLORS
);
172 ok(hbmp
!= 0, "CreateDIBitmap failed, skipping tests.\n");
174 /* Create a DIB brush with palette indices */
175 hbr
= CreateDIBPatternBrushPt(&PackedDIB
, DIB_PAL_COLORS
);
176 ok(hbr
== 0, "CreateDIBPatternBrushPt should fail.\n");
182 START_TEST(CreateDIBPatternBrush
)
186 Test_CreateDIBPatternBrush();
187 Test_CreateDIBPatternBrushPt();
188 //Test_CreateDIBPatternBrushPt_RLE8(); broken