2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for CreateBitmap
5 * PROGRAMMERS: Timo Kreuzer
12 #define DEFAULT_BITMAP 21
14 void Test_CreateBitmap_Params()
18 /* All of these should get us the default bitmap */
19 hbmp
= CreateBitmap(0, 0, 0, 0, NULL
);
20 ok(hbmp
== GetStockObject(21), "should get the default bitmap\n");
21 hbmp
= CreateBitmap(1, 0, 0, 0, NULL
);
22 ok(hbmp
== GetStockObject(21), "should get the default bitmap\n");
23 hbmp
= CreateBitmap(0, 1, 0, 0, NULL
);
24 ok(hbmp
== GetStockObject(21), "should get the default bitmap\n");
25 hbmp
= CreateBitmap(0, 1, 1, 0, NULL
);
26 ok(hbmp
== GetStockObject(21), "should get the default bitmap\n");
27 hbmp
= CreateBitmap(0, 1, 63, 33, NULL
);
28 ok(hbmp
== GetStockObject(21), "should get the default bitmap\n");
29 hbmp
= CreateBitmap(0, -4, -32, 233, NULL
);
30 ok(hbmp
== GetStockObject(21), "should get the default bitmap\n");
33 hbmp
= CreateBitmap(1, -1, 1, 0, NULL
);
35 ok_err(ERROR_INVALID_PARAMETER
);
38 hbmp
= CreateBitmap(-1, 1, 1, 0, NULL
);
40 ok_err(ERROR_INVALID_PARAMETER
);
43 hbmp
= CreateBitmap(-1, 1, 1, 1, NULL
);
45 ok_err(ERROR_INVALID_PARAMETER
);
48 hbmp
= CreateBitmap(1, -1, 1, 1, NULL
);
50 ok_err(ERROR_INVALID_PARAMETER
);
52 /* Check if an overflow in cPlanes * cBitsPixel is handled */
54 hbmp
= CreateBitmap(1, 1, 2, 0x80000004, NULL
);
56 ok_err(ERROR_INVALID_PARAMETER
);
58 /* Check for maximum width */
59 hbmp
= CreateBitmap(0x7FFFFFF, 1, 1, 1, NULL
);
64 hbmp
= CreateBitmap(0x8000000, 1, 1, 1, NULL
);
66 ok_err(ERROR_INVALID_PARAMETER
);
68 /* Check for maximum height */
69 hbmp
= CreateBitmap(1, 0x1FFFFF00, 1, 1, NULL
);
70 //ok(hbmp != 0, "\n"); // fails on windows 2003
74 hbmp
= CreateBitmap(1, 0x1FFFFFFF, 1, 1, NULL
);
78 /* Check for overflow in width * height */
79 hbmp
= CreateBitmap(0x20000, 0x1FFFF, 1, 1, NULL
);
80 //ok(hbmp != 0, "\n"); // fails on windows 2003
84 hbmp
= CreateBitmap(0x20000, 0x20000, 1, 1, NULL
);
88 /* Check huge allocation */
90 hbmp
= CreateBitmap(0x2000, 0x20000, 32, 1, NULL
);
92 ok_err(ERROR_INVALID_PARAMETER
);
96 void Test_CreateBitmap()
100 ULONG cjWidthBytes
, cBitsPixel
, cExpectedBitsPixel
;
102 hbmp
= CreateBitmap(0, 0, 0, 0, NULL
);
103 ok(hbmp
!= 0, "should get a 1x1 bitmap\n");
104 ok(hbmp
== GetStockObject(DEFAULT_BITMAP
), "\n");
105 ok_int(GetObject(hbmp
, sizeof(bitmap
), &bitmap
), sizeof(BITMAP
));
106 ok_int(bitmap
.bmType
, 0);
107 ok_int(bitmap
.bmWidth
, 1);
108 ok_int(bitmap
.bmHeight
, 1);
109 ok_int(bitmap
.bmWidthBytes
, 2);
110 ok_int(bitmap
.bmPlanes
, 1);
111 ok_int(bitmap
.bmBitsPixel
, 1);
112 ok_ptr(bitmap
.bmBits
, 0);
115 hbmp
= CreateBitmap(1, 2, 1, 1, NULL
);
116 ok(hbmp
!= 0, "should get a 1x2 bitmap\n");
117 ok_int(GetObject(hbmp
, sizeof(bitmap
), &bitmap
), sizeof(BITMAP
));
118 ok_int(bitmap
.bmType
, 0);
119 ok_int(bitmap
.bmWidth
, 1);
120 ok_int(bitmap
.bmHeight
, 2);
121 ok_int(bitmap
.bmWidthBytes
, 2);
122 ok_int(bitmap
.bmPlanes
, 1);
123 ok_int(bitmap
.bmBitsPixel
, 1);
124 ok_ptr(bitmap
.bmBits
, 0);
127 for (cBitsPixel
= 0; cBitsPixel
<= 32; cBitsPixel
++)
129 /* CreateBitmap API accepts any number as BitsPixels param.
130 but it just can create 1, 4, 8, 16, 24, 32 bpp Bitmaps */
131 if (cBitsPixel
<= 1) cExpectedBitsPixel
= 1;
132 else if (cBitsPixel
<= 4) cExpectedBitsPixel
= 4;
133 else if (cBitsPixel
<= 8) cExpectedBitsPixel
= 8;
134 else if (cBitsPixel
<= 16) cExpectedBitsPixel
= 16;
135 else if (cBitsPixel
<= 24) cExpectedBitsPixel
= 24;
136 else if (cBitsPixel
<= 32) cExpectedBitsPixel
= 32;
138 hbmp
= CreateBitmap(1, 2, 1, cBitsPixel
, NULL
);
139 ok(hbmp
!= 0, "should get a 1x2 bitmap %ld\n", cBitsPixel
);
140 ok_int(GetObject(hbmp
, sizeof(bitmap
), &bitmap
), sizeof(BITMAP
));
142 /* calculate expected line width */
143 cjWidthBytes
= ((((ULONG
)bitmap
.bmWidth
) * ((ULONG
)bitmap
.bmBitsPixel
) + 15) & ~15) >> 3;
145 ok_int(bitmap
.bmType
, 0);
146 ok_int(bitmap
.bmWidth
, 1);
147 ok_int(bitmap
.bmHeight
, 2);
148 ok_int(bitmap
.bmPlanes
, 1);
149 ok_int(bitmap
.bmBitsPixel
, cExpectedBitsPixel
);
150 ok_int(bitmap
.bmWidthBytes
, cjWidthBytes
);
151 ok_ptr(bitmap
.bmBits
, 0);
156 hbmp
= CreateBitmap(1, 2, 1, 33, NULL
);
157 ok(hbmp
== 0, "Expected failure for 33 bpp\n");
163 START_TEST(CreateBitmap
)
165 //Test_CreateBitmap_Params();