1c2c66affSColin Finck /*
2c2c66affSColin Finck * PROJECT: ReactOS api tests
3c2c66affSColin Finck * LICENSE: GPL - See COPYING in the top level directory
4c2c66affSColin Finck * PURPOSE: Test for SetDIBitsToDevice
5c2c66affSColin Finck * PROGRAMMERS: Timo Kreuzer
6c2c66affSColin Finck */
7c2c66affSColin Finck
8aee83c35SAmine Khaldi #include "precomp.h"
9c2c66affSColin Finck
10c2c66affSColin Finck #include "init.h"
11c2c66affSColin Finck
12c2c66affSColin Finck static void
Test_SetDIBitsToDevice_Params()13c2c66affSColin Finck Test_SetDIBitsToDevice_Params()
14c2c66affSColin Finck {
15c2c66affSColin Finck UCHAR ajBmiBuffer[sizeof(BITMAPINFO) + 4];
16c2c66affSColin Finck PBITMAPINFO pbmi = (PBITMAPINFO)ajBmiBuffer;
17c2c66affSColin Finck ULONG aulBits[16];
18c2c66affSColin Finck INT ret;
19c2c66affSColin Finck
20c2c66affSColin Finck /* Setup the bitmap info */
21c2c66affSColin Finck pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
22c2c66affSColin Finck pbmi->bmiHeader.biWidth = 2;
23c2c66affSColin Finck pbmi->bmiHeader.biHeight = -4;
24c2c66affSColin Finck pbmi->bmiHeader.biPlanes = 1;
25c2c66affSColin Finck pbmi->bmiHeader.biBitCount = 32;
26c2c66affSColin Finck pbmi->bmiHeader.biCompression = BI_RGB;
27c2c66affSColin Finck pbmi->bmiHeader.biSizeImage = 0;
28c2c66affSColin Finck pbmi->bmiHeader.biXPelsPerMeter = 0;
29c2c66affSColin Finck pbmi->bmiHeader.biYPelsPerMeter = 0;
30c2c66affSColin Finck pbmi->bmiHeader.biClrUsed = 0;
31c2c66affSColin Finck pbmi->bmiHeader.biClrImportant = 0;
32c2c66affSColin Finck
33c2c66affSColin Finck /* Test a normal operation */
34c2c66affSColin Finck SetLastError(0xdeadc0de);
35c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
36c2c66affSColin Finck 0, // XDest,
37c2c66affSColin Finck 0, // YDest,
38c2c66affSColin Finck 2, // dwWidth,
39c2c66affSColin Finck 2, // dwHeight,
40c2c66affSColin Finck 0, // XSrc,
41c2c66affSColin Finck 0, // YSrc,
42c2c66affSColin Finck 0, // uStartScan,
43c2c66affSColin Finck 2, // cScanLines,
44c2c66affSColin Finck aulBits, // lpvBits,
45c2c66affSColin Finck pbmi,
46c2c66affSColin Finck DIB_RGB_COLORS);
47c2c66affSColin Finck ok_dec(ret, 2);
48c2c66affSColin Finck ok_err(0xdeadc0de);
49c2c66affSColin Finck
50c2c66affSColin Finck /* Test hdc == NULL */
51c2c66affSColin Finck SetLastError(0xdeadc0de);
52c2c66affSColin Finck ret = SetDIBitsToDevice(NULL,
53c2c66affSColin Finck 0, // XDest,
54c2c66affSColin Finck 0, // YDest,
55c2c66affSColin Finck 2, // dwWidth,
56c2c66affSColin Finck 2, // dwHeight,
57c2c66affSColin Finck 0, // XSrc,
58c2c66affSColin Finck 0, // YSrc,
59c2c66affSColin Finck 0, // uStartScan,
60c2c66affSColin Finck 2, // cScanLines,
61c2c66affSColin Finck aulBits, // lpvBits,
62c2c66affSColin Finck pbmi,
63c2c66affSColin Finck DIB_RGB_COLORS);
64c2c66affSColin Finck ok_dec(ret, 0);
65c2c66affSColin Finck ok_err(ERROR_INVALID_HANDLE);
66c2c66affSColin Finck
67c2c66affSColin Finck /* Test truncated hdc */
68c2c66affSColin Finck SetLastError(0xdeadc0de);
69c2c66affSColin Finck ret = SetDIBitsToDevice((HDC)((ULONG_PTR)ghdcDIB32 & 0xFFFF),
70c2c66affSColin Finck 0, // XDest,
71c2c66affSColin Finck 0, // YDest,
72c2c66affSColin Finck 2, // dwWidth,
73c2c66affSColin Finck 2, // dwHeight,
74c2c66affSColin Finck 0, // XSrc,
75c2c66affSColin Finck 0, // YSrc,
76c2c66affSColin Finck 0, // uStartScan,
77c2c66affSColin Finck 2, // cScanLines,
78c2c66affSColin Finck aulBits, // lpvBits,
79c2c66affSColin Finck pbmi,
80c2c66affSColin Finck DIB_RGB_COLORS);
81c2c66affSColin Finck ok_dec(ret, 0);
82c2c66affSColin Finck ok_err(ERROR_INVALID_HANDLE);
83c2c66affSColin Finck
84c2c66affSColin Finck /* Test invalid ColorUse */
85c2c66affSColin Finck SetLastError(0xdeadc0de);
86c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
87c2c66affSColin Finck 0, // XDest,
88c2c66affSColin Finck 0, // YDest,
89c2c66affSColin Finck 2, // dwWidth,
90c2c66affSColin Finck 2, // dwHeight,
91c2c66affSColin Finck 0, // XSrc,
92c2c66affSColin Finck 0, // YSrc,
93c2c66affSColin Finck 0, // uStartScan,
94c2c66affSColin Finck 2, // cScanLines,
95c2c66affSColin Finck aulBits, // lpvBits,
96c2c66affSColin Finck pbmi,
97c2c66affSColin Finck 7);
98c2c66affSColin Finck ok_dec(ret, 0);
99c2c66affSColin Finck ok_err(0xdeadc0de);
100c2c66affSColin Finck
101c2c66affSColin Finck /* test unaligned buffer */
102c2c66affSColin Finck SetLastError(0xdeadc0de);
103c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
104c2c66affSColin Finck 0, // XDest,
105c2c66affSColin Finck 0, // YDest,
106c2c66affSColin Finck 2, // dwWidth,
107c2c66affSColin Finck 2, // dwHeight,
108c2c66affSColin Finck 0, // XSrc,
109c2c66affSColin Finck 0, // YSrc,
110c2c66affSColin Finck 0, // uStartScan,
111c2c66affSColin Finck 2, // cScanLines,
112c2c66affSColin Finck (BYTE*)aulBits + 1, // lpvBits,
113c2c66affSColin Finck pbmi,
114c2c66affSColin Finck DIB_RGB_COLORS);
115c2c66affSColin Finck ok_dec(ret, 2);
116c2c66affSColin Finck ok_err(0xdeadc0de);
117c2c66affSColin Finck
118c2c66affSColin Finck /* test unaligned and huge scanline buffer */
119c2c66affSColin Finck SetLastError(0xdeadc0de);
120c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
121c2c66affSColin Finck 0, // XDest,
122c2c66affSColin Finck 0, // YDest,
123c2c66affSColin Finck 2, // dwWidth,
124c2c66affSColin Finck 2, // dwHeight,
125c2c66affSColin Finck 0, // XSrc,
126c2c66affSColin Finck 0, // YSrc,
127c2c66affSColin Finck 0, // uStartScan,
128c2c66affSColin Finck 20000000, // cScanLines,
129c2c66affSColin Finck (BYTE*)aulBits + 1, // lpvBits,
130c2c66affSColin Finck pbmi,
131c2c66affSColin Finck DIB_RGB_COLORS);
132*ebb7c052SDoug Lyons ok_dec(ret, 0);
133c2c66affSColin Finck ok_err(0xdeadc0de);
134c2c66affSColin Finck
135c2c66affSColin Finck /* test unaligned illegal buffer */
136c2c66affSColin Finck SetLastError(0xdeadc0de);
137c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
138c2c66affSColin Finck 0, // XDest,
139c2c66affSColin Finck 0, // YDest,
140c2c66affSColin Finck 2, // dwWidth,
141c2c66affSColin Finck 2, // dwHeight,
142c2c66affSColin Finck 0, // XSrc,
143c2c66affSColin Finck 0, // YSrc,
144c2c66affSColin Finck 0, // uStartScan,
145c2c66affSColin Finck 2, // cScanLines,
146c2c66affSColin Finck (BYTE*)0x7fffffff, // lpvBits,
147c2c66affSColin Finck pbmi,
148c2c66affSColin Finck DIB_RGB_COLORS);
149*ebb7c052SDoug Lyons ok_dec(ret, 0);
150c2c66affSColin Finck ok_err(0xdeadc0de);
151c2c66affSColin Finck
152c2c66affSColin Finck /* Test negative XDest */
153c2c66affSColin Finck SetLastError(0xdeadc0de);
154c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
155c2c66affSColin Finck -100, // XDest,
156c2c66affSColin Finck 0, // YDest,
157c2c66affSColin Finck 2, // dwWidth,
158c2c66affSColin Finck 2, // dwHeight,
159c2c66affSColin Finck 0, // XSrc,
160c2c66affSColin Finck 0, // YSrc,
161c2c66affSColin Finck 0, // uStartScan,
162c2c66affSColin Finck 2, // cScanLines,
163c2c66affSColin Finck aulBits, // lpvBits,
164c2c66affSColin Finck pbmi,
165c2c66affSColin Finck DIB_RGB_COLORS);
166c2c66affSColin Finck ok_dec(ret, 2);
167c2c66affSColin Finck ok_err(0xdeadc0de);
168c2c66affSColin Finck
169c2c66affSColin Finck /* Test huge XDest */
170c2c66affSColin Finck SetLastError(0xdeadc0de);
171c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
172c2c66affSColin Finck LONG_MAX, // XDest,
173c2c66affSColin Finck 0, // YDest,
174c2c66affSColin Finck 2, // dwWidth,
175c2c66affSColin Finck 2, // dwHeight,
176c2c66affSColin Finck 0, // XSrc,
177c2c66affSColin Finck 0, // YSrc,
178c2c66affSColin Finck 0, // uStartScan,
179c2c66affSColin Finck 2, // cScanLines,
180c2c66affSColin Finck aulBits, // lpvBits,
181c2c66affSColin Finck pbmi,
182c2c66affSColin Finck DIB_RGB_COLORS);
183c2c66affSColin Finck ok_dec(ret, 2);
184c2c66affSColin Finck ok_err(0xdeadc0de);
185c2c66affSColin Finck
186c2c66affSColin Finck /* Test XSrc outside of the DIB */
187c2c66affSColin Finck SetLastError(0xdeadc0de);
188c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
189c2c66affSColin Finck 0, // XDest,
190c2c66affSColin Finck 0, // YDest,
191c2c66affSColin Finck 2, // dwWidth,
192c2c66affSColin Finck 2, // dwHeight,
193c2c66affSColin Finck 100, // XSrc,
194c2c66affSColin Finck 0, // YSrc,
195c2c66affSColin Finck 0, // uStartScan,
196c2c66affSColin Finck 2, // cScanLines,
197c2c66affSColin Finck aulBits, // lpvBits,
198c2c66affSColin Finck pbmi,
199c2c66affSColin Finck DIB_RGB_COLORS);
200c2c66affSColin Finck ok_dec(ret, 2);
201c2c66affSColin Finck ok_err(0xdeadc0de);
202c2c66affSColin Finck
203c2c66affSColin Finck /* Test YSrc outside of the DIB */
204c2c66affSColin Finck SetLastError(0xdeadc0de);
205c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
206c2c66affSColin Finck 0, // XDest,
207c2c66affSColin Finck 0, // YDest,
208c2c66affSColin Finck 2, // dwWidth,
209c2c66affSColin Finck 2, // dwHeight,
210c2c66affSColin Finck 0, // XSrc,
211c2c66affSColin Finck 100, // YSrc,
212c2c66affSColin Finck 0, // uStartScan,
213c2c66affSColin Finck 2, // cScanLines,
214c2c66affSColin Finck aulBits, // lpvBits,
215c2c66affSColin Finck pbmi,
216c2c66affSColin Finck DIB_RGB_COLORS);
217c2c66affSColin Finck ok_dec(ret, 2);
218c2c66affSColin Finck ok_err(0xdeadc0de);
219c2c66affSColin Finck
220c2c66affSColin Finck /* Test uStartScan outside of the DIB */
221c2c66affSColin Finck SetLastError(0xdeadc0de);
222c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
223c2c66affSColin Finck 0, // XDest,
224c2c66affSColin Finck 0, // YDest,
225c2c66affSColin Finck 2, // dwWidth,
226c2c66affSColin Finck 2, // dwHeight,
227c2c66affSColin Finck 0, // XSrc,
228c2c66affSColin Finck 0, // YSrc,
229c2c66affSColin Finck 100, // uStartScan,
230c2c66affSColin Finck 5, // cScanLines,
231c2c66affSColin Finck aulBits, // lpvBits,
232c2c66affSColin Finck pbmi,
233c2c66affSColin Finck DIB_RGB_COLORS);
234c2c66affSColin Finck ok_dec(ret, 5);
235c2c66affSColin Finck ok_err(0xdeadc0de);
236c2c66affSColin Finck
237c2c66affSColin Finck /* Test cScanLines larger than the DIB */
238c2c66affSColin Finck SetLastError(0xdeadc0de);
239c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
240c2c66affSColin Finck 0, // XDest,
241c2c66affSColin Finck 0, // YDest,
242c2c66affSColin Finck 2, // dwWidth,
243c2c66affSColin Finck 2, // dwHeight,
244c2c66affSColin Finck 0, // XSrc,
245c2c66affSColin Finck 0, // YSrc,
246c2c66affSColin Finck 0, // uStartScan,
247c2c66affSColin Finck 7, // cScanLines,
248c2c66affSColin Finck aulBits, // lpvBits,
249c2c66affSColin Finck pbmi,
250c2c66affSColin Finck DIB_RGB_COLORS);
251*ebb7c052SDoug Lyons ok_dec(ret, 7);
252c2c66affSColin Finck ok_err(0xdeadc0de);
253c2c66affSColin Finck
254c2c66affSColin Finck /* Test large cScanlines */
255c2c66affSColin Finck SetLastError(0xdeadc0de);
256c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
257c2c66affSColin Finck 0, // XDest,
258c2c66affSColin Finck 0, // YDest,
259c2c66affSColin Finck 2, // dwWidth,
260c2c66affSColin Finck 2, // dwHeight,
261c2c66affSColin Finck 0, // XSrc,
262c2c66affSColin Finck 0, // YSrc,
263c2c66affSColin Finck 0, // uStartScan,
264c2c66affSColin Finck 2000, // cScanLines,
265c2c66affSColin Finck aulBits, // lpvBits,
266c2c66affSColin Finck pbmi,
267c2c66affSColin Finck DIB_RGB_COLORS);
268*ebb7c052SDoug Lyons ok_dec(ret, 0);
269c2c66affSColin Finck ok_err(0xdeadc0de);
270c2c66affSColin Finck
271c2c66affSColin Finck /* Test uStartScan and cScanLines larger than the DIB */
272c2c66affSColin Finck SetLastError(0xdeadc0de);
273c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
274c2c66affSColin Finck 0, // XDest,
275c2c66affSColin Finck 0, // YDest,
276c2c66affSColin Finck 2, // dwWidth,
277c2c66affSColin Finck 2, // dwHeight,
278c2c66affSColin Finck 0, // XSrc,
279c2c66affSColin Finck 0, // YSrc,
280c2c66affSColin Finck 100, // uStartScan,
281c2c66affSColin Finck 7, // cScanLines,
282c2c66affSColin Finck aulBits, // lpvBits,
283c2c66affSColin Finck pbmi,
284c2c66affSColin Finck DIB_RGB_COLORS);
285c2c66affSColin Finck ok_dec(ret, 7);
286c2c66affSColin Finck ok_err(0xdeadc0de);
287c2c66affSColin Finck
288c2c66affSColin Finck /* Test lpvBits == NULL */
289c2c66affSColin Finck SetLastError(0xdeadc0de);
290c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
291c2c66affSColin Finck 0, // XDest,
292c2c66affSColin Finck 0, // YDest,
293c2c66affSColin Finck 2, // dwWidth,
294c2c66affSColin Finck 2, // dwHeight,
295c2c66affSColin Finck 0, // XSrc,
296c2c66affSColin Finck 0, // YSrc,
297c2c66affSColin Finck 0, // uStartScan,
298c2c66affSColin Finck 2, // cScanLines,
299c2c66affSColin Finck NULL, // lpvBits,
300c2c66affSColin Finck pbmi,
301c2c66affSColin Finck DIB_RGB_COLORS);
302c2c66affSColin Finck ok_dec(ret, 0);
303c2c66affSColin Finck ok_err(0xdeadc0de);
304c2c66affSColin Finck
305c2c66affSColin Finck /* Test pbmi == NULL */
306c2c66affSColin Finck SetLastError(0xdeadc0de);
307c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
308c2c66affSColin Finck 0, // XDest,
309c2c66affSColin Finck 0, // YDest,
310c2c66affSColin Finck 2, // dwWidth,
311c2c66affSColin Finck 2, // dwHeight,
312c2c66affSColin Finck 0, // XSrc,
313c2c66affSColin Finck 0, // YSrc,
314c2c66affSColin Finck 0, // uStartScan,
315c2c66affSColin Finck 2, // cScanLines,
316c2c66affSColin Finck aulBits, // lpvBits,
317c2c66affSColin Finck NULL,
318c2c66affSColin Finck DIB_RGB_COLORS);
319c2c66affSColin Finck ok_dec(ret, 0);
320c2c66affSColin Finck ok_err(0xdeadc0de);
321c2c66affSColin Finck
322c2c66affSColin Finck /* Test huge positive DIB height, result is limited to dwHeight */
323c2c66affSColin Finck pbmi->bmiHeader.biHeight = 10000;
324c2c66affSColin Finck SetLastError(0xdeadc0de);
325c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
326c2c66affSColin Finck 0, // XDest,
327c2c66affSColin Finck 1, // YDest,
328c2c66affSColin Finck 2, // dwWidth,
329c2c66affSColin Finck 3, // dwHeight,
330c2c66affSColin Finck 0, // XSrc,
331c2c66affSColin Finck 1, // YSrc,
332c2c66affSColin Finck 0, // uStartScan,
333c2c66affSColin Finck 7, // cScanLines,
334c2c66affSColin Finck aulBits, // lpvBits,
335c2c66affSColin Finck pbmi,
336c2c66affSColin Finck DIB_RGB_COLORS);
337c2c66affSColin Finck ok_dec(ret, 4);
338c2c66affSColin Finck ok_err(0xdeadc0de);
339c2c66affSColin Finck
340c2c66affSColin Finck /* Test huge negative DIB height */
341c2c66affSColin Finck pbmi->bmiHeader.biHeight = -10000;
342c2c66affSColin Finck SetLastError(0xdeadc0de);
343c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
344c2c66affSColin Finck 0, // XDest,
345c2c66affSColin Finck 0, // YDest,
346c2c66affSColin Finck 2, // dwWidth,
347c2c66affSColin Finck 2, // dwHeight,
348c2c66affSColin Finck 0, // XSrc,
349c2c66affSColin Finck 0, // YSrc,
350c2c66affSColin Finck 0, // uStartScan,
351c2c66affSColin Finck 7, // cScanLines,
352c2c66affSColin Finck aulBits, // lpvBits,
353c2c66affSColin Finck pbmi,
354c2c66affSColin Finck DIB_RGB_COLORS);
355c2c66affSColin Finck ok_dec(ret, 7);
356c2c66affSColin Finck ok_err(0xdeadc0de);
357c2c66affSColin Finck
358c2c66affSColin Finck /* Test what happens when we cause an integer overflow */
359c2c66affSColin Finck pbmi->bmiHeader.biHeight = LONG_MIN;
360c2c66affSColin Finck SetLastError(0xdeadc0de);
361c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
362c2c66affSColin Finck 0, // XDest,
363c2c66affSColin Finck 0, // YDest,
364c2c66affSColin Finck 2, // dwWidth,
365c2c66affSColin Finck 2, // dwHeight,
366c2c66affSColin Finck 0, // XSrc,
367c2c66affSColin Finck 0, // YSrc,
368c2c66affSColin Finck 0, // uStartScan,
369c2c66affSColin Finck 2, // cScanLines,
370c2c66affSColin Finck aulBits, // lpvBits,
371c2c66affSColin Finck pbmi,
372c2c66affSColin Finck DIB_RGB_COLORS);
373c2c66affSColin Finck ok_dec(ret, 2);
374c2c66affSColin Finck ok_err(0xdeadc0de);
375c2c66affSColin Finck
376c2c66affSColin Finck /* Now also test a huge value of uStartScan */
377c2c66affSColin Finck SetLastError(0xdeadc0de);
378c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
379c2c66affSColin Finck 0, // XDest,
380c2c66affSColin Finck 0, // YDest,
381c2c66affSColin Finck 2, // dwWidth,
382c2c66affSColin Finck 2, // dwHeight,
383c2c66affSColin Finck 0, // XSrc,
384c2c66affSColin Finck 0, // YSrc,
385c2c66affSColin Finck abs(pbmi->bmiHeader.biHeight) - 3, // uStartScan,
386c2c66affSColin Finck 9, // cScanLines,
387c2c66affSColin Finck aulBits, // lpvBits,
388c2c66affSColin Finck pbmi,
389c2c66affSColin Finck DIB_RGB_COLORS);
390c2c66affSColin Finck ok_dec(ret, 3);
391c2c66affSColin Finck ok_err(0xdeadc0de);
392c2c66affSColin Finck
393c2c66affSColin Finck /* Now also test a huge value of uStartScan */
394c2c66affSColin Finck pbmi->bmiHeader.biHeight = LONG_MIN + 1;
395c2c66affSColin Finck SetLastError(0xdeadc0de);
396c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
397c2c66affSColin Finck 0, // XDest,
398c2c66affSColin Finck 0, // YDest,
399c2c66affSColin Finck 2, // dwWidth,
400c2c66affSColin Finck 2, // dwHeight,
401c2c66affSColin Finck 0, // XSrc,
402c2c66affSColin Finck 0, // YSrc,
403c2c66affSColin Finck abs(pbmi->bmiHeader.biHeight) - 3, // uStartScan,
404c2c66affSColin Finck 9, // cScanLines,
405c2c66affSColin Finck aulBits, // lpvBits,
406c2c66affSColin Finck pbmi,
407c2c66affSColin Finck DIB_RGB_COLORS);
408c2c66affSColin Finck ok_dec(ret, 5);
409c2c66affSColin Finck ok_err(0xdeadc0de);
410c2c66affSColin Finck
411c2c66affSColin Finck /* Now also test a huge value of uStartScan */
412c2c66affSColin Finck pbmi->bmiHeader.biHeight = LONG_MIN + 7;
413c2c66affSColin Finck SetLastError(0xdeadc0de);
414c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
415c2c66affSColin Finck 0, // XDest,
416c2c66affSColin Finck 0, // YDest,
417c2c66affSColin Finck 2, // dwWidth,
418c2c66affSColin Finck 2, // dwHeight,
419c2c66affSColin Finck 0, // XSrc,
420c2c66affSColin Finck 0, // YSrc,
421c2c66affSColin Finck abs(pbmi->bmiHeader.biHeight) - 3, // uStartScan,
422c2c66affSColin Finck 32, // cScanLines,
423c2c66affSColin Finck aulBits, // lpvBits,
424c2c66affSColin Finck pbmi,
425c2c66affSColin Finck DIB_RGB_COLORS);
426c2c66affSColin Finck ok_dec(ret, 17);
427c2c66affSColin Finck ok_err(0xdeadc0de);
428c2c66affSColin Finck
429c2c66affSColin Finck /* Test invalid bitmap info header */
430c2c66affSColin Finck pbmi->bmiHeader.biSize = 0;
431c2c66affSColin Finck SetLastError(0xdeadc0de);
432c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
433c2c66affSColin Finck 0, // XDest,
434c2c66affSColin Finck 0, // YDest,
435c2c66affSColin Finck 2, // dwWidth,
436c2c66affSColin Finck 2, // dwHeight,
437c2c66affSColin Finck 0, // XSrc,
438c2c66affSColin Finck 0, // YSrc,
439c2c66affSColin Finck 0, // uStartScan,
440c2c66affSColin Finck 2, // cScanLines,
441c2c66affSColin Finck aulBits, // lpvBits,
442c2c66affSColin Finck pbmi,
443c2c66affSColin Finck DIB_RGB_COLORS);
444c2c66affSColin Finck ok_dec(ret, 0);
445c2c66affSColin Finck ok_err(0xdeadc0de);
446c2c66affSColin Finck
447c2c66affSColin Finck }
448c2c66affSColin Finck
449c2c66affSColin Finck
450c2c66affSColin Finck static void
Test_SetDIBitsToDevice()451c2c66affSColin Finck Test_SetDIBitsToDevice()
452c2c66affSColin Finck {
453c2c66affSColin Finck UCHAR ajBmiBuffer[sizeof(BITMAPINFO) + 4];
454c2c66affSColin Finck PBITMAPINFO pbmi = (PBITMAPINFO)ajBmiBuffer;
455c2c66affSColin Finck ULONG aulBits[16];
456c2c66affSColin Finck INT ret;
457c2c66affSColin Finck
458c2c66affSColin Finck /* Setup the bitmap info */
459c2c66affSColin Finck pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
460c2c66affSColin Finck pbmi->bmiHeader.biWidth = 2;
461c2c66affSColin Finck pbmi->bmiHeader.biHeight = -2;
462c2c66affSColin Finck pbmi->bmiHeader.biPlanes = 1;
463c2c66affSColin Finck pbmi->bmiHeader.biBitCount = 32;
464c2c66affSColin Finck pbmi->bmiHeader.biCompression = BI_RGB;
465c2c66affSColin Finck pbmi->bmiHeader.biSizeImage = 0;
466c2c66affSColin Finck pbmi->bmiHeader.biXPelsPerMeter = 0;
467c2c66affSColin Finck pbmi->bmiHeader.biYPelsPerMeter = 0;
468c2c66affSColin Finck pbmi->bmiHeader.biClrUsed = 0;
469c2c66affSColin Finck pbmi->bmiHeader.biClrImportant = 0;
470c2c66affSColin Finck
471c2c66affSColin Finck /* Set pixels */
472c2c66affSColin Finck aulBits[0] = 0x11000000;
473c2c66affSColin Finck aulBits[1] = 0x00000011;
474c2c66affSColin Finck aulBits[2] = 0xFF000000;
475c2c66affSColin Finck aulBits[3] = 0x000000FF;
476c2c66affSColin Finck
477c2c66affSColin Finck
478c2c66affSColin Finck memset(gpDIB32, 0, sizeof(*gpDIB32));
479c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
480c2c66affSColin Finck 0, // XDest,
481c2c66affSColin Finck 0, // YDest,
482c2c66affSColin Finck 2, // dwWidth,
483c2c66affSColin Finck 2, // dwHeight,
484c2c66affSColin Finck 0, // XSrc,
485c2c66affSColin Finck 0, // YSrc,
486c2c66affSColin Finck 0, // uStartScan,
487c2c66affSColin Finck 2, // cScanLines,
488c2c66affSColin Finck aulBits, // lpvBits,
489c2c66affSColin Finck pbmi,
490c2c66affSColin Finck DIB_RGB_COLORS);
491c2c66affSColin Finck
492c2c66affSColin Finck ok_dec(ret, 2);
493c2c66affSColin Finck ok_hex((*gpDIB32)[0][0], 0x11000000);
494c2c66affSColin Finck ok_hex((*gpDIB32)[0][1], 0x00000011);
495c2c66affSColin Finck ok_hex((*gpDIB32)[0][2], 0x00000000);
496c2c66affSColin Finck ok_hex((*gpDIB32)[0][3], 0x00000000);
497c2c66affSColin Finck ok_hex((*gpDIB32)[1][0], 0xFF000000);
498c2c66affSColin Finck ok_hex((*gpDIB32)[1][1], 0x000000FF);
499c2c66affSColin Finck ok_hex((*gpDIB32)[1][2], 0x00000000);
500c2c66affSColin Finck ok_hex((*gpDIB32)[1][3], 0x00000000);
501c2c66affSColin Finck
502c2c66affSColin Finck memset(gpDIB32, 0, sizeof(*gpDIB32));
503c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
504c2c66affSColin Finck 0, // XDest,
505c2c66affSColin Finck 1, // YDest,
506c2c66affSColin Finck 2, // dwWidth,
507c2c66affSColin Finck 2, // dwHeight,
508c2c66affSColin Finck 0, // XSrc,
509c2c66affSColin Finck 0, // YSrc,
510c2c66affSColin Finck 0, // uStartScan,
511c2c66affSColin Finck 2, // cScanLines,
512c2c66affSColin Finck aulBits, // lpvBits,
513c2c66affSColin Finck pbmi,
514c2c66affSColin Finck DIB_RGB_COLORS);
515c2c66affSColin Finck
516c2c66affSColin Finck ok_dec(ret, 2);
517c2c66affSColin Finck ok_hex((*gpDIB32)[0][0], 0x00000000);
518c2c66affSColin Finck ok_hex((*gpDIB32)[0][1], 0x00000000);
519c2c66affSColin Finck ok_hex((*gpDIB32)[0][2], 0x00000000);
520c2c66affSColin Finck ok_hex((*gpDIB32)[0][3], 0x00000000);
521c2c66affSColin Finck ok_hex((*gpDIB32)[1][0], 0x11000000);
522c2c66affSColin Finck ok_hex((*gpDIB32)[1][1], 0x00000011);
523c2c66affSColin Finck ok_hex((*gpDIB32)[1][2], 0x00000000);
524c2c66affSColin Finck ok_hex((*gpDIB32)[1][3], 0x00000000);
525c2c66affSColin Finck ok_hex((*gpDIB32)[2][0], 0xFF000000);
526c2c66affSColin Finck ok_hex((*gpDIB32)[2][1], 0x000000FF);
527c2c66affSColin Finck ok_hex((*gpDIB32)[2][2], 0x00000000);
528c2c66affSColin Finck ok_hex((*gpDIB32)[2][3], 0x00000000);
529c2c66affSColin Finck
530c2c66affSColin Finck memset(gpDIB32, 0, sizeof(*gpDIB32));
531c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
532c2c66affSColin Finck 0, // XDest,
533c2c66affSColin Finck 0, // YDest,
534c2c66affSColin Finck 2, // dwWidth,
535c2c66affSColin Finck 2, // dwHeight,
536c2c66affSColin Finck 0, // XSrc,
537c2c66affSColin Finck 0, // YSrc,
538c2c66affSColin Finck 0, // uStartScan,
539c2c66affSColin Finck 1, // cScanLines,
540c2c66affSColin Finck aulBits, // lpvBits,
541c2c66affSColin Finck pbmi,
542c2c66affSColin Finck DIB_RGB_COLORS);
543c2c66affSColin Finck
544c2c66affSColin Finck ok_dec(ret, 1);
545*ebb7c052SDoug Lyons ok_hex((*gpDIB32)[0][0], 0x00000000);
546*ebb7c052SDoug Lyons ok_hex((*gpDIB32)[0][1], 0x00000000);
547c2c66affSColin Finck ok_hex((*gpDIB32)[0][2], 0x00000000);
548c2c66affSColin Finck ok_hex((*gpDIB32)[0][3], 0x00000000);
549c2c66affSColin Finck todo_ros ok_hex((*gpDIB32)[1][0], 0x11000000);
550c2c66affSColin Finck todo_ros ok_hex((*gpDIB32)[1][1], 0x00000011);
551c2c66affSColin Finck ok_hex((*gpDIB32)[1][2], 0x00000000);
552c2c66affSColin Finck ok_hex((*gpDIB32)[1][3], 0x00000000);
553c2c66affSColin Finck #if 0
554c2c66affSColin Finck
555c2c66affSColin Finck memset(gpDIB32, 0, sizeof(*gpDIB32));
556c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
557c2c66affSColin Finck 0, // XDest,
558c2c66affSColin Finck 0, // YDest,
559c2c66affSColin Finck 2, // dwWidth,
560c2c66affSColin Finck 2, // dwHeight,
561c2c66affSColin Finck 0, // XSrc,
562c2c66affSColin Finck 0, // YSrc,
563c2c66affSColin Finck 1, // uStartScan,
564c2c66affSColin Finck 1, // cScanLines,
565c2c66affSColin Finck aulBits, // lpvBits,
566c2c66affSColin Finck pbmi,
567c2c66affSColin Finck DIB_RGB_COLORS);
568c2c66affSColin Finck
569c2c66affSColin Finck ok_dec(ret, 1);
570c2c66affSColin Finck todo_ros ok_hex(pulDIB32Bits[0], 0x11000000);
571c2c66affSColin Finck todo_ros ok_hex(pulDIB32Bits[1], 0x00000011);
572c2c66affSColin Finck ok_hex(pulDIB32Bits[2], 0x00000000);
573c2c66affSColin Finck ok_hex(pulDIB32Bits[3], 0x00000000);
574c2c66affSColin Finck todo_ros ok_hex(pulDIB32Bits[4], 0x00000000);
575c2c66affSColin Finck todo_ros ok_hex(pulDIB32Bits[5], 0x00000000);
576c2c66affSColin Finck ok_hex(pulDIB32Bits[6], 0x00000000);
577c2c66affSColin Finck ok_hex(pulDIB32Bits[7], 0x00000000);
578c2c66affSColin Finck
579c2c66affSColin Finck /*****************/
580c2c66affSColin Finck
581c2c66affSColin Finck /* Use bottom-up bitmap */
582c2c66affSColin Finck pbmi->bmiHeader.biHeight = 2;
583c2c66affSColin Finck
584c2c66affSColin Finck memset(gpDIB32, 0, sizeof(*gpDIB32));
585c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
586c2c66affSColin Finck 0, // XDest,
587c2c66affSColin Finck 0, // YDest,
588c2c66affSColin Finck 2, // dwWidth,
589c2c66affSColin Finck 2, // dwHeight,
590c2c66affSColin Finck 0, // XSrc,
591c2c66affSColin Finck 0, // YSrc,
592c2c66affSColin Finck 0, // uStartScan,
593c2c66affSColin Finck 2, // cScanLines,
594c2c66affSColin Finck aulBits, // lpvBits,
595c2c66affSColin Finck pbmi,
596c2c66affSColin Finck DIB_RGB_COLORS);
597c2c66affSColin Finck
598c2c66affSColin Finck ok_dec(ret, 2);
599c2c66affSColin Finck ok_hex(pulDIB32Bits[0], 0xFF000000);
600c2c66affSColin Finck ok_hex(pulDIB32Bits[1], 0x000000FF);
601c2c66affSColin Finck ok_hex(pulDIB32Bits[2], 0x00000000);
602c2c66affSColin Finck ok_hex(pulDIB32Bits[3], 0x00000000);
603c2c66affSColin Finck ok_hex(pulDIB32Bits[4], 0x11000000);
604c2c66affSColin Finck ok_hex(pulDIB32Bits[5], 0x00000011);
605c2c66affSColin Finck ok_hex(pulDIB32Bits[6], 0x00000000);
606c2c66affSColin Finck ok_hex(pulDIB32Bits[7], 0x00000000);
607c2c66affSColin Finck
608c2c66affSColin Finck memset(gpDIB32, 0, sizeof(*gpDIB32));
609c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
610c2c66affSColin Finck 0, // XDest,
611c2c66affSColin Finck 1, // YDest,
612c2c66affSColin Finck 2, // dwWidth,
613c2c66affSColin Finck 2, // dwHeight,
614c2c66affSColin Finck 0, // XSrc,
615c2c66affSColin Finck 0, // YSrc,
616c2c66affSColin Finck 0, // uStartScan,
617c2c66affSColin Finck 2, // cScanLines,
618c2c66affSColin Finck aulBits, // lpvBits,
619c2c66affSColin Finck pbmi,
620c2c66affSColin Finck DIB_RGB_COLORS);
621c2c66affSColin Finck
622c2c66affSColin Finck ok_dec(ret, 2);
623c2c66affSColin Finck ok_hex(pulDIB32Bits[0], 0x00000000);
624c2c66affSColin Finck ok_hex(pulDIB32Bits[1], 0x00000000);
625c2c66affSColin Finck ok_hex(pulDIB32Bits[2], 0x00000000);
626c2c66affSColin Finck ok_hex(pulDIB32Bits[3], 0x00000000);
627c2c66affSColin Finck ok_hex(pulDIB32Bits[4], 0xFF000000);
628c2c66affSColin Finck ok_hex(pulDIB32Bits[5], 0x000000FF);
629c2c66affSColin Finck ok_hex(pulDIB32Bits[6], 0x00000000);
630c2c66affSColin Finck ok_hex(pulDIB32Bits[7], 0x00000000);
631c2c66affSColin Finck ok_hex(pulDIB32Bits[8], 0x11000000);
632c2c66affSColin Finck ok_hex(pulDIB32Bits[9], 0x00000011);
633c2c66affSColin Finck ok_hex(pulDIB32Bits[10], 0x00000000);
634c2c66affSColin Finck ok_hex(pulDIB32Bits[11], 0x00000000);
635c2c66affSColin Finck
636c2c66affSColin Finck memset(gpDIB32, 0, sizeof(*gpDIB32));
637c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
638c2c66affSColin Finck 0, // XDest,
639c2c66affSColin Finck 0, // YDest,
640c2c66affSColin Finck 2, // dwWidth,
641c2c66affSColin Finck 2, // dwHeight,
642c2c66affSColin Finck 0, // XSrc,
643c2c66affSColin Finck 0, // YSrc,
644c2c66affSColin Finck 0, // uStartScan,
645c2c66affSColin Finck 1, // cScanLines,
646c2c66affSColin Finck aulBits, // lpvBits,
647c2c66affSColin Finck pbmi,
648c2c66affSColin Finck DIB_RGB_COLORS);
649c2c66affSColin Finck
650c2c66affSColin Finck ok_dec(ret, 1);
651c2c66affSColin Finck todo_ros ok_hex(pulDIB32Bits[0], 0x00000000);
652c2c66affSColin Finck todo_ros ok_hex(pulDIB32Bits[1], 0x00000000);
653c2c66affSColin Finck ok_hex(pulDIB32Bits[2], 0x00000000);
654c2c66affSColin Finck ok_hex(pulDIB32Bits[3], 0x00000000);
655c2c66affSColin Finck todo_ros ok_hex(pulDIB32Bits[4], 0x11000000);
656c2c66affSColin Finck todo_ros ok_hex(pulDIB32Bits[5], 0x00000011);
657c2c66affSColin Finck ok_hex(pulDIB32Bits[6], 0x00000000);
658c2c66affSColin Finck ok_hex(pulDIB32Bits[7], 0x00000000);
659c2c66affSColin Finck
660c2c66affSColin Finck
661c2c66affSColin Finck memset(gpDIB32, 0, sizeof(*gpDIB32));
662c2c66affSColin Finck ret = SetDIBitsToDevice(ghdcDIB32,
663c2c66affSColin Finck 0, // XDest,
664c2c66affSColin Finck 0, // YDest,
665c2c66affSColin Finck 2, // dwWidth,
666c2c66affSColin Finck 2, // dwHeight,
667c2c66affSColin Finck 0, // XSrc,
668c2c66affSColin Finck 0, // YSrc,
669c2c66affSColin Finck 1, // uStartScan,
670c2c66affSColin Finck 1, // cScanLines,
671c2c66affSColin Finck aulBits, // lpvBits,
672c2c66affSColin Finck pbmi,
673c2c66affSColin Finck DIB_RGB_COLORS);
674c2c66affSColin Finck
675c2c66affSColin Finck ok_dec(ret, 1);
676c2c66affSColin Finck todo_ros ok_hex(pulDIB32Bits[0], 0x11000000);
677c2c66affSColin Finck todo_ros ok_hex(pulDIB32Bits[1], 0x00000011);
678c2c66affSColin Finck ok_hex(pulDIB32Bits[2], 0x00000000);
679c2c66affSColin Finck ok_hex(pulDIB32Bits[3], 0x00000000);
680c2c66affSColin Finck todo_ros ok_hex(pulDIB32Bits[4], 0x00000000);
681c2c66affSColin Finck todo_ros ok_hex(pulDIB32Bits[5], 0x00000000);
682c2c66affSColin Finck ok_hex(pulDIB32Bits[6], 0x00000000);
683c2c66affSColin Finck ok_hex(pulDIB32Bits[7], 0x00000000);
684c2c66affSColin Finck #endif
685c2c66affSColin Finck }
686c2c66affSColin Finck
687c2c66affSColin Finck
START_TEST(SetDIBitsToDevice)688c2c66affSColin Finck START_TEST(SetDIBitsToDevice)
689c2c66affSColin Finck {
690c2c66affSColin Finck InitStuff();
691c2c66affSColin Finck
692c2c66affSColin Finck Test_SetDIBitsToDevice_Params();
693c2c66affSColin Finck Test_SetDIBitsToDevice();
694c2c66affSColin Finck
695c2c66affSColin Finck
696c2c66affSColin Finck }
697