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 void Test_CreateDIBPatternBrush()
18 void Test_CreateDIBPatternBrushPt()
22 BITMAPINFOHEADER bmiHeader
;
27 {sizeof(BITMAPINFOHEADER
), 4, -4, 1, 8, BI_RGB
, 0, 1, 1, 4, 0},
29 {0,1,2,3, 1,2,3,0, 2,3,0,1, 3,0,1,2},
35 ok_hdl(CreateDIBPatternBrushPt(NULL
, 0), NULL
);
36 ok_hdl(CreateDIBPatternBrushPt(NULL
, DIB_PAL_COLORS
), NULL
);
37 ok_hdl(CreateDIBPatternBrushPt(NULL
, 2), NULL
);
38 ok_hdl(CreateDIBPatternBrushPt(NULL
, 3), NULL
);
41 hbr
= CreateDIBPatternBrushPt(&PackedDIB
, 0);
42 ok(hbr
!= 0, "Expected success\n");
44 hbr
= CreateDIBPatternBrushPt(&PackedDIB
, 2);
45 ok(hbr
!= 0, "Expected success\n");
49 hbr
= CreateDIBPatternBrushPt(&PackedDIB
, 3);
50 ok(hbr
== 0, "Expected failure\n");
51 ok_err(ERROR_INVALID_PARAMETER
);
53 hbr
= CreateDIBPatternBrushPt(&PackedDIB
, 10);
54 ok(hbr
== 0, "Expected failure\n");
55 ok_err(ERROR_INVALID_PARAMETER
);
57 /* Create a DIB brush with palette indices */
58 hbr
= CreateDIBPatternBrushPt(&PackedDIB
, DIB_PAL_COLORS
);
59 ok(hbr
!= 0, "CreateDIBPatternBrushPt failed, skipping tests.\n");
62 /* Select the brush into the dc */
63 hbrOld
= SelectObject(ghdcDIB32
, hbr
);
65 /* Copy it on the dib section */
66 ok_long(PatBlt(ghdcDIB32
, 0, 0, 4, 4, PATCOPY
), 1);
67 ok_long(pulDIB32Bits
[0], 0x000000); // 0
68 ok_long(pulDIB32Bits
[1], 0x800000); // 1
69 ok_long(pulDIB32Bits
[2], 0x008000); // 2
70 ok_long(pulDIB32Bits
[3], 0xc0c0c0); // 7
72 /* Select a logical palette into the DC */
73 hpalOld
= SelectPalette(ghdcDIB32
, ghpal
, FALSE
);
74 ok(hpalOld
!= 0, "Expected success, error %ld\n", GetLastError());
76 /* Copy it on the dib section */
77 ok_long(PatBlt(ghdcDIB32
, 0, 0, 4, 4, PATCOPY
), 1);
78 ok_long(pulDIB32Bits
[0], 0x102030); // 0
79 ok_long(pulDIB32Bits
[1], 0x203040); // 1
80 ok_long(pulDIB32Bits
[2], 0x304050); // 2
81 ok_long(pulDIB32Bits
[3], 0x8090a0); // 7
83 /* Select back old palette and destroy the DIB data */
84 SelectPalette(ghdcDIB32
, hpalOld
, FALSE
);
85 memset(&PackedDIB
.ajBuffer
, 0x77, 4);
87 /* Copy it on the dib section */
88 ok_long(PatBlt(ghdcDIB32
, 0, 0, 4, 4, PATCOPY
), 1);
89 ok_long(pulDIB32Bits
[0], 0x000000); // 0
90 ok_long(pulDIB32Bits
[1], 0x800000); // 1
91 ok_long(pulDIB32Bits
[2], 0x008000); // 2
92 ok_long(pulDIB32Bits
[3], 0xc0c0c0); // 7
94 SelectObject(ghdcDIB32
, hbrOld
);
97 /* Set some different values */
98 PackedDIB
.ajBuffer
[0] = 3;
99 PackedDIB
.ajBuffer
[1] = 2;
100 PackedDIB
.ajBuffer
[2] = 1;
101 PackedDIB
.ajBuffer
[3] = 0;
103 /* Create a DIB brush with unkdocumented iUsage == 2 */
104 hbr
= CreateDIBPatternBrushPt(&PackedDIB
, 2);
105 ok(hbr
!= 0, "CreateSolidBrush failed, skipping tests.\n");
108 /* Select the brush into the dc */
109 hbrOld
= SelectObject(ghdcDIB32
, hbr
);
110 ok(hbrOld
!= 0, "CreateSolidBrush failed, skipping tests.\n");
112 /* Copy it on a dib section */
113 memset(pulDIB32Bits
, 0x77, 64);
114 ok_long(PatBlt(ghdcDIB32
, 0, 0, 4, 4, PATCOPY
), 1);
115 ok_long(pulDIB32Bits
[0], 0x77777777);
116 ok_long(pulDIB32Bits
[1], 0x77777777);
117 ok_long(pulDIB32Bits
[2], 0x77777777);
118 ok_long(pulDIB32Bits
[3], 0x77777777);
120 /* Select a logical palette into the DC */
121 hpalOld
= SelectPalette(ghdcDIB32
, ghpal
, FALSE
);
122 ok(hpalOld
!= 0, "Expected success, error %ld\n", GetLastError());
124 /* Copy it on a dib section */
125 ok_long(PatBlt(ghdcDIB32
, 0, 0, 4, 4, PATCOPY
), 1);
126 ok_long(pulDIB32Bits
[0], 0x77777777);
127 ok_long(pulDIB32Bits
[1], 0x77777777);
128 ok_long(pulDIB32Bits
[2], 0x77777777);
129 ok_long(pulDIB32Bits
[3], 0x77777777);
131 SelectPalette(ghdcDIB32
, hpalOld
, FALSE
);
132 SelectObject(ghdcDIB32
, hbrOld
);
137 void Test_CreateDIBPatternBrushPt_RLE8()
141 BITMAPINFOHEADER bmiHeader
;
146 {sizeof(BITMAPINFOHEADER
), 4, 4, 1, 8, BI_RLE8
, 20, 1, 1, 4, 0},
148 {4,0, 0,2,0,1,0,2,3,1, 2,1, 2,2, 1,3,1,0,1,2, },
152 HDC hdc
= CreateCompatibleDC(0);
153 HBITMAP hbmp
= CreateDIBitmap(hdc
, &PackedDIB
.bmiHeader
, CBM_INIT
, &PackedDIB
.ajBuffer
, (PVOID
)&PackedDIB
, DIB_PAL_COLORS
);
154 ok(hbmp
!= 0, "CreateDIBitmap failed, skipping tests.\n");
156 /* Create a DIB brush with palette indices */
157 hbr
= CreateDIBPatternBrushPt(&PackedDIB
, DIB_PAL_COLORS
);
158 ok(hbr
!= 0, "CreateDIBPatternBrushPt failed, skipping tests.\n");
165 START_TEST(CreateDIBPatternBrush
)
169 Test_CreateDIBPatternBrush();
170 Test_CreateDIBPatternBrushPt();
171 Test_CreateDIBPatternBrushPt_RLE8();