e4da9ee91adb84f67d93f1e0bb435b9bbc9d5d84
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for CreateBitmap
5 * PROGRAMMERS: Timo Kreuzer
11 #define DEFAULT_BITMAP 21
13 void Test_CreateBitmap_Params()
17 /* All of these should get us the default bitmap */
18 hbmp
= CreateBitmap(0, 0, 0, 0, NULL
);
19 ok(hbmp
== GetStockObject(21), "should get the default bitmap\n");
20 hbmp
= CreateBitmap(1, 0, 0, 0, NULL
);
21 ok(hbmp
== GetStockObject(21), "should get the default bitmap\n");
22 hbmp
= CreateBitmap(0, 1, 0, 0, NULL
);
23 ok(hbmp
== GetStockObject(21), "should get the default bitmap\n");
24 hbmp
= CreateBitmap(0, 1, 1, 0, NULL
);
25 ok(hbmp
== GetStockObject(21), "should get the default bitmap\n");
26 hbmp
= CreateBitmap(0, 1, 63, 33, NULL
);
27 ok(hbmp
== GetStockObject(21), "should get the default bitmap\n");
28 hbmp
= CreateBitmap(0, -4, -32, 233, NULL
);
29 ok(hbmp
== GetStockObject(21), "should get the default bitmap\n");
32 hbmp
= CreateBitmap(1, -1, 1, 0, NULL
);
34 ok_err(ERROR_INVALID_PARAMETER
);
37 hbmp
= CreateBitmap(-1, 1, 1, 0, NULL
);
39 ok_err(ERROR_INVALID_PARAMETER
);
42 hbmp
= CreateBitmap(-1, 1, 1, 1, NULL
);
44 ok_err(ERROR_INVALID_PARAMETER
);
47 hbmp
= CreateBitmap(1, -1, 1, 1, NULL
);
49 ok_err(ERROR_INVALID_PARAMETER
);
51 /* Check if an overflow in cPlanes * cBitsPixel is handled */
53 hbmp
= CreateBitmap(1, 1, 2, 0x80000004, NULL
);
55 ok_err(ERROR_INVALID_PARAMETER
);
57 /* Check for maximum width */
58 hbmp
= CreateBitmap(0x7FFFFFF, 1, 1, 1, NULL
);
63 hbmp
= CreateBitmap(0x8000000, 1, 1, 1, NULL
);
65 ok_err(ERROR_INVALID_PARAMETER
);
67 /* Check for maximum height */
68 hbmp
= CreateBitmap(1, 0x1FFFFF00, 1, 1, NULL
);
69 //ok(hbmp != 0, "\n"); // fails on windows 2003
73 hbmp
= CreateBitmap(1, 0x1FFFFFFF, 1, 1, NULL
);
77 /* Check for overflow in width * height */
78 hbmp
= CreateBitmap(0x20000, 0x1FFFF, 1, 1, NULL
);
79 //ok(hbmp != 0, "\n"); // fails on windows 2003
83 hbmp
= CreateBitmap(0x20000, 0x20000, 1, 1, NULL
);
87 /* Check huge allocation */
89 hbmp
= CreateBitmap(0x2000, 0x20000, 32, 1, NULL
);
91 ok_err(ERROR_INVALID_PARAMETER
);
95 void Test_CreateBitmap()
99 ULONG cjWidthBytes
, cBitsPixel
, cExpectedBitsPixel
;
101 hbmp
= CreateBitmap(0, 0, 0, 0, NULL
);
102 ok(hbmp
!= 0, "should get a 1x1 bitmap\n");
103 ok(hbmp
== GetStockObject(DEFAULT_BITMAP
), "\n");
104 ok_int(GetObject(hbmp
, sizeof(bitmap
), &bitmap
), sizeof(BITMAP
));
105 ok_int(bitmap
.bmType
, 0);
106 ok_int(bitmap
.bmWidth
, 1);
107 ok_int(bitmap
.bmHeight
, 1);
108 ok_int(bitmap
.bmWidthBytes
, 2);
109 ok_int(bitmap
.bmPlanes
, 1);
110 ok_int(bitmap
.bmBitsPixel
, 1);
111 ok_ptr(bitmap
.bmBits
, 0);
114 hbmp
= CreateBitmap(1, 2, 1, 1, NULL
);
115 ok(hbmp
!= 0, "should get a 1x2 bitmap\n");
116 ok_int(GetObject(hbmp
, sizeof(bitmap
), &bitmap
), sizeof(BITMAP
));
117 ok_int(bitmap
.bmType
, 0);
118 ok_int(bitmap
.bmWidth
, 1);
119 ok_int(bitmap
.bmHeight
, 2);
120 ok_int(bitmap
.bmWidthBytes
, 2);
121 ok_int(bitmap
.bmPlanes
, 1);
122 ok_int(bitmap
.bmBitsPixel
, 1);
123 ok_ptr(bitmap
.bmBits
, 0);
126 for (cBitsPixel
= 0; cBitsPixel
<= 32; cBitsPixel
++)
128 /* CreateBitmap API accepts any number as BitsPixels param.
129 but it just can create 1, 4, 8, 16, 24, 32 bpp Bitmaps */
130 if (cBitsPixel
<= 1) cExpectedBitsPixel
= 1;
131 else if (cBitsPixel
<= 4) cExpectedBitsPixel
= 4;
132 else if (cBitsPixel
<= 8) cExpectedBitsPixel
= 8;
133 else if (cBitsPixel
<= 16) cExpectedBitsPixel
= 16;
134 else if (cBitsPixel
<= 24) cExpectedBitsPixel
= 24;
135 else if (cBitsPixel
<= 32) cExpectedBitsPixel
= 32;
137 hbmp
= CreateBitmap(1, 2, 1, cBitsPixel
, NULL
);
138 ok(hbmp
!= 0, "should get a 1x2 bitmap %ld\n", cBitsPixel
);
139 ok_int(GetObject(hbmp
, sizeof(bitmap
), &bitmap
), sizeof(BITMAP
));
141 /* calculate expected line width */
142 cjWidthBytes
= ((((ULONG
)bitmap
.bmWidth
) * ((ULONG
)bitmap
.bmBitsPixel
) + 15) & ~15) >> 3;
144 ok_int(bitmap
.bmType
, 0);
145 ok_int(bitmap
.bmWidth
, 1);
146 ok_int(bitmap
.bmHeight
, 2);
147 ok_int(bitmap
.bmPlanes
, 1);
148 ok_int(bitmap
.bmBitsPixel
, cExpectedBitsPixel
);
149 ok_int(bitmap
.bmWidthBytes
, cjWidthBytes
);
150 ok_ptr(bitmap
.bmBits
, 0);
155 hbmp
= CreateBitmap(1, 2, 1, 33, NULL
);
156 ok(hbmp
== 0, "Expected failure for 33 bpp\n");
162 START_TEST(CreateBitmap
)
164 //Test_CreateBitmap_Params();