winedib.drv: Add support for 4bpp.
[wine/dibeng-hd.git] / dlls / winedib.drv / tests / dib.c
blob8ac8954719ac37db38a36745a6389f0657c6062c
1 /*
2 * DIB Engine Tests
4 * Copyright 2008 Huw Davies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "wingdi.h"
26 #include "winuser.h"
27 #include "wincrypt.h"
29 #include "wine/test.h"
31 static HCRYPTPROV crypt_prov;
33 static inline DWORD get_stride(BITMAPINFO *bmi)
35 return ((bmi->bmiHeader.biBitCount * bmi->bmiHeader.biWidth + 31) >> 3) & ~3;
38 static inline DWORD get_dib_size(BITMAPINFO *bmi)
40 return get_stride(bmi) * abs(bmi->bmiHeader.biHeight);
43 static char *hash_dib(BITMAPINFO *bmi, void *bits)
45 DWORD dib_size = get_dib_size(bmi);
46 HCRYPTHASH hash;
47 char *buf;
48 BYTE hash_buf[20];
49 DWORD hash_size = sizeof(hash_buf);
50 int i;
51 static const char *hex = "0123456789abcdef";
53 if(!crypt_prov) return NULL;
55 if(!CryptCreateHash(crypt_prov, CALG_SHA1, 0, 0, &hash)) return NULL;
57 CryptHashData(hash, bits, dib_size, 0);
59 CryptGetHashParam(hash, HP_HASHVAL, NULL, &hash_size, 0);
60 if(hash_size != sizeof(hash_buf)) return NULL;
62 CryptGetHashParam(hash, HP_HASHVAL, hash_buf, &hash_size, 0);
63 CryptDestroyHash(hash);
65 buf = HeapAlloc(GetProcessHeap(), 0, hash_size * 2 + 1);
67 for(i = 0; i < hash_size; i++)
69 buf[i * 2] = hex[hash_buf[i] >> 4];
70 buf[i * 2 + 1] = hex[hash_buf[i] & 0xf];
72 buf[i * 2] = '\0';
74 return buf;
77 static const char *sha1_graphics_a8r8g8b8[] =
79 "95cb7f0f4368270ae675522c797e6f6ab588ef7b",
80 "2d9183f4c588ce7ebdce837dd34b6b9f4331378a",
81 "0cd0d61e8be5c929f3eff128cff165f40ac8547e",
82 "984547a084edcf57c12e3fa3d4afe0e4bff4a1f0",
83 "2e2d96ff6d91e5872fa7e28818a8ebbbbe3b1b0c",
84 "fec2fe8417e20ca0298ba1de62663ad67197432f",
85 "add45a809b7222e2aef33e7ccc1635218b570c0d",
86 "ed4ed3c7a434210c48abfa3a8e65eeadf81ae15e",
87 "e101e3a5bbdcb829422ef6e90ad0a7f19e9fec27",
88 "6e58c93280761828c6b39eec336a137b853f4bee",
89 "0bf80f2c9c22f1e719a0e70bd04d2d3dd2d4025c",
90 "2877e81b495e8bc9cddd6d516b4bb3ee179c886c",
91 "14efc4b458cf2684f95a1a3d01bb5810f372aff7",
92 "95cb7f0f4368270ae675522c797e6f6ab588ef7b",
93 "2258c3b3500a3a748ed150c65ce92b75acc83b20",
94 "225a666a44c11d29d0ae2fcc79cece32a9236d12",
95 "a298c1a8360ed96518f6589d70971495ae1dfb82",
96 "a8b305f8df0cefddd54b8fe3b59f1422acf0e43f",
97 "dc8eb6ddc6383013a8a57a6967b538cd2722e804",
98 NULL
101 static const char *sha1_graphics_r8g8b8[] =
103 "89a55b8437e04e45a0f4e4006032693e3cf7e018",
104 "a608985d40c1515f364d5b7d63769c84d72b377c",
105 "8570ebe8521b90dbdf008c3a7e56d2821728da64",
106 "a1fdfa4f9bf0ee98a12888a403b8340bc0456549",
107 "bd82e8d32e16bf7b81e8f36d9c9de142d15ab917",
108 "5e3515c56a5531accfeab0be6a8c9c743614eebc",
109 "4be17ae19582246b2d45e0ed8827d01334eb3d82",
110 "97e1cc12b0395db79e61e8ac474a82423e4dd2be",
111 "daa05e9b3f6f0a57aa9e52088220f794836807f1",
112 "c438c8d9d09fbfab54608eab2d456afd2d62b2a6",
113 "d79b7672abbbdb115d8e13083410fcae79c71969",
114 "2d16e940f822cc3eff7d1f0213f90c9b79d6f82f",
115 "7a4302fffb9023ac548add1da89922b92c8eaf92",
116 "89a55b8437e04e45a0f4e4006032693e3cf7e018",
117 "1340b5b111bffac9af2fcc6bf3b808ad7a61153e",
118 "f8227278afaa26e02a0296f6e6e184d07c2d5548",
119 "fbcb08a3435d36c78d5d6e233b15b4de094b8719",
120 "25c5392d274bc428b8f0202ad1700ae514a68a9e",
121 "868bcecb95b24fcaa22aeb06b68199bc1147bad7",
122 NULL
125 static const char *sha1_graphics_r5g5b5[] =
127 "7e3f989ce484ca33da1285d16c249a1cca615f8a",
128 "78d1ffc49f3e8a22a47a6127fa85b6709eb43d93",
129 "a9b85400e42dbd520f7eaf5a9dac7fddafbf2a98",
130 "f00e76cb9fcbb93b7e5e0157c3edca8bbf993be1",
131 "3bd9c9b32be36276882e8272f05cbf8a59ac500b",
132 "49f1be21ccba14e7353dfb9b497ce0a4502a0a99",
133 "5b22dcb4a56cd7705ed208fefc4b8257b64032de",
134 "79e9bbadbe2bfd8286efe32cfb6dc15ed954774b",
135 "f6f8f7bf472f21094b11590315d0c75209b651d8",
136 "16cd82b3b79fd31a88c42b77f586aea1370b3279",
137 "9333e99c5392fbb8d9a9097d59c097ae416633fb",
138 "704850dd6cc451177cd687197a073355b722a75e",
139 "9fec3a301e3a76ac5a87b7043d590bcfcf2e990f",
140 "7e3f989ce484ca33da1285d16c249a1cca615f8a",
141 "8492821c8385727a1fbd0f59046f793e4a96073e",
142 "f444946ea1b0f3486f139a073f9dec1a14f27d8e",
143 "6a0499f50a6443166ecd94a22a24ef7f0b85bbb2",
144 "ccb37978304f4ff575ced0267111a23854f94cdb",
145 "451edcd867c79a2893c8fc7886aecf67a97baae7",
146 NULL
149 static const char *sha1_graphics_a8b8g8r8[] =
151 "95cb7f0f4368270ae675522c797e6f6ab588ef7b",
152 "e383c1071e40e6b430dce07362b4f8f08d1a2664",
153 "baa7320a6d3a022a437fc83de4b87043550431bc",
154 "984547a084edcf57c12e3fa3d4afe0e4bff4a1f0",
155 "bae34003c7c98f48ca3745d42bc4e8e16ca6dc83",
156 "9191f0c7efe75bdc56583e4084da831608426915",
157 "e027dcc94aae26b56474c68b14e29bbde881e460",
158 "71cdf94baffc177fb021627b71f6e8289e2e9243",
159 "e101e3a5bbdcb829422ef6e90ad0a7f19e9fec27",
160 "ea64721a62d38c6a293120eb9dcfbfe3e0b8a68d",
161 "87a536ea8c7c3274fcab204ef6f729c4cfc756ef",
162 "2ddffa82b883fa337fa7ba4f407c367f7a4620cb",
163 "eb8234894c1d94a2b547ab1c853e9ed23fadfc80",
164 "95cb7f0f4368270ae675522c797e6f6ab588ef7b",
165 "fb079298dd9442a7ba2b4d1c6da2261e8f9193f1",
166 "6ddd366e3b64c6cc89936fe4cf182e18953bd162",
167 "4770abc73f51a0ff7dbc8a2a4c1c7c59a0a06df4",
168 "b69724f3335c51eb932bdc920434771e04d14855",
169 "dc8eb6ddc6383013a8a57a6967b538cd2722e804",
170 NULL
173 static const char *sha1_graphics_a5r9g9b9[] =
175 "95cb7f0f4368270ae675522c797e6f6ab588ef7b",
176 "7068a270d021bae6b818ee7fee380a195fa9a313",
177 "e7f686e271af7cbf4b102a85eb6a5f63cd8878ce",
178 "984547a084edcf57c12e3fa3d4afe0e4bff4a1f0",
179 "dfc4eb6831c242b264517c4e1c2c4650e200239f",
180 "fec2fe8417e20ca0298ba1de62663ad67197432f",
181 "2dd24904813503f7fbc36e1b9a5d198ca78c47a8",
182 "0026235d4a23454471cdb4f6ef95716221541932",
183 "e101e3a5bbdcb829422ef6e90ad0a7f19e9fec27",
184 "49ced2410172c99978f4fda1c4f177447fcc700e",
185 "0bf80f2c9c22f1e719a0e70bd04d2d3dd2d4025c",
186 "2877e81b495e8bc9cddd6d516b4bb3ee179c886c",
187 "734dc770f6f09563fd0284f9be16cdd587f5d503",
188 "95cb7f0f4368270ae675522c797e6f6ab588ef7b",
189 "e77dd688f82143b87e37cc42cb428a75ba00dbd5",
190 "30359c04c4075a9207ead667181ea9123f6f6439",
191 "a298c1a8360ed96518f6589d70971495ae1dfb82",
192 "8e782acd734e091f2bdf303a10c4302c133c040c",
193 "dc8eb6ddc6383013a8a57a6967b538cd2722e804",
194 NULL
197 static const char *sha1_graphics_r5g6b5[] =
199 "7e3f989ce484ca33da1285d16c249a1cca615f8a",
200 "78d1ffc49f3e8a22a47a6127fa85b6709eb43d93",
201 "a9b85400e42dbd520f7eaf5a9dac7fddafbf2a98",
202 "f00e76cb9fcbb93b7e5e0157c3edca8bbf993be1",
203 "3bd9c9b32be36276882e8272f05cbf8a59ac500b",
204 "49f1be21ccba14e7353dfb9b497ce0a4502a0a99",
205 "5b22dcb4a56cd7705ed208fefc4b8257b64032de",
206 "79e9bbadbe2bfd8286efe32cfb6dc15ed954774b",
207 "f6f8f7bf472f21094b11590315d0c75209b651d8",
208 "16cd82b3b79fd31a88c42b77f586aea1370b3279",
209 "9333e99c5392fbb8d9a9097d59c097ae416633fb",
210 "704850dd6cc451177cd687197a073355b722a75e",
211 "9fec3a301e3a76ac5a87b7043d590bcfcf2e990f",
212 "7e3f989ce484ca33da1285d16c249a1cca615f8a",
213 "8492821c8385727a1fbd0f59046f793e4a96073e",
214 "f444946ea1b0f3486f139a073f9dec1a14f27d8e",
215 "6a0499f50a6443166ecd94a22a24ef7f0b85bbb2",
216 "ccb37978304f4ff575ced0267111a23854f94cdb",
217 "451edcd867c79a2893c8fc7886aecf67a97baae7",
218 NULL
221 static const char *sha1_graphics_r4g5b4[] =
223 "7e3f989ce484ca33da1285d16c249a1cca615f8a",
224 "919ba89672b906b052df5c225ddbaf8e6474390f",
225 "d0cdad9dd3668bb3c3c48699cb97623a99e62ae1",
226 "f00e76cb9fcbb93b7e5e0157c3edca8bbf993be1",
227 "1c0a5b7e02e464e77b173909bf52b0475bf23a59",
228 "49f1be21ccba14e7353dfb9b497ce0a4502a0a99",
229 "30a3133fbb6f5cc60aacd348148aa44b0121bd0b",
230 "ec68b7751e2d19e01aa2515e0f5539d971b81255",
231 "f6f8f7bf472f21094b11590315d0c75209b651d8",
232 "87156a3f8f142258b52806f42735f4c7cf21b7f1",
233 "9333e99c5392fbb8d9a9097d59c097ae416633fb",
234 "704850dd6cc451177cd687197a073355b722a75e",
235 "ff1972911441802da0a361abec3b113ef60613ef",
236 "7e3f989ce484ca33da1285d16c249a1cca615f8a",
237 "5993b550845cc2510cefa6325dfd29a7569847e8",
238 "f145873125f7e1ef0b80cf6c1a898c0f2b71f4a0",
239 "6a0499f50a6443166ecd94a22a24ef7f0b85bbb2",
240 "c2509287ce5e765261941346f55c99224bec5d17",
241 "451edcd867c79a2893c8fc7886aecf67a97baae7",
242 NULL
245 static const char *sha1_graphics_8[] =
247 "76c12085cc663150d792db4a63d32f4bcf005695",
248 "49f8e672f1d2c77007196ec96f184e7a40ee6fdc",
249 "ee9cbd1a485b469bfb04782bfe7182fcf6d2d25e",
250 "bc31e57d62e5fffc45db48f7c0bca525ad54c544",
251 "6d6630d434beacc32dc785520a98d120dc5314e9",
252 "a2572ac555b4615e22d08f6bb921924ad99ebbb8",
253 "dd41e413044a8fd1b8a4d3c0d34817ded0109e57",
254 "bc31e57d62e5fffc45db48f7c0bca525ad54c544",
255 "6d6630d434beacc32dc785520a98d120dc5314e9",
256 "a2572ac555b4615e22d08f6bb921924ad99ebbb8",
257 "dd41e413044a8fd1b8a4d3c0d34817ded0109e57",
258 "6267cc2712f89b1940098c345b81e20d630af242",
259 "7850b8bc680072607f6aa483b00f3b51c61a084b",
260 "76c12085cc663150d792db4a63d32f4bcf005695",
261 "bf5ca681587c1f85e540c69f592aa38a0fdacd3d",
262 "6267cc2712f89b1940098c345b81e20d630af242",
263 "7850b8bc680072607f6aa483b00f3b51c61a084b",
264 "76c12085cc663150d792db4a63d32f4bcf005695",
265 "bf5ca681587c1f85e540c69f592aa38a0fdacd3d",
266 NULL
269 static const char *sha1_graphics_4[] =
271 "b8f5f858da37fd16f13658bcd8b01e0aa267d93b",
272 "0cb0755deb9f203d41e526704508712731d4775f",
273 "fdc7f47c61706208aa354a7978b35552aad2c7a2",
274 "ac7f98e13a8e0e51edbb789b3a6dbd9ccf8774b7",
275 "aeeda45bb572aef5cb3e76a329c8e25470adc763",
276 "71423336495d7ca61ef688c695da3c0bf938fbb6",
277 "eaebe115722689ab5cdc968613d6ed1dd60cd792",
278 "ac7f98e13a8e0e51edbb789b3a6dbd9ccf8774b7",
279 "aeeda45bb572aef5cb3e76a329c8e25470adc763",
280 "71423336495d7ca61ef688c695da3c0bf938fbb6",
281 "eaebe115722689ab5cdc968613d6ed1dd60cd792",
282 "facbe32a70a05ab5607e16c5767290b02c92a28c",
283 "1f60c6493cf11837eb76fb46ef95fef4ceefc419",
284 "b8f5f858da37fd16f13658bcd8b01e0aa267d93b",
285 "c58da8612b8f17c3f332d9c03856a25734999b65",
286 "facbe32a70a05ab5607e16c5767290b02c92a28c",
287 "1f60c6493cf11837eb76fb46ef95fef4ceefc419",
288 "b8f5f858da37fd16f13658bcd8b01e0aa267d93b",
289 "c58da8612b8f17c3f332d9c03856a25734999b65",
290 NULL
293 static void compare_hash(BITMAPINFO *bmi, BYTE *bits, const char ***sha1)
295 char *hash = hash_dib(bmi, bits);
297 if(!hash)
299 skip("SHA1 hashing unavailable on this platform\n");
300 return;
303 if(**sha1)
305 ok(!strcmp(hash, **sha1), "expected hash %s got %s\n", **sha1, hash);
306 (*sha1)++;
308 else trace("\"%s\",\n", hash);
310 HeapFree(GetProcessHeap(), 0, hash);
313 static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sha1)
315 HPEN solid_pen, orig_pen;
316 DWORD dib_size = get_dib_size(bmi);
317 INT i;
319 solid_pen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0xff));
320 orig_pen = SelectObject(hdc, solid_pen);
322 memset(bits, 0xcc, dib_size);
323 compare_hash(bmi, bits, sha1);
325 /* solid lines */
327 MoveToEx(hdc, 60, 10, NULL);
328 LineTo(hdc, 60, 20); /* vline t -> b */
330 MoveToEx(hdc, 10, 70, NULL);
331 LineTo(hdc, 100, 70); /* hline l -> r */
333 MoveToEx(hdc, 100, 73, NULL);
334 LineTo(hdc, 10, 73); /* hline r -> l */
336 MoveToEx(hdc, 1, 70, NULL);
337 LineTo(hdc, 1, 10); /* vline b -> t */
339 MoveToEx(hdc, 110, 20, NULL);
340 LineTo(hdc, 120, 43); /* diag tl -> br */
342 compare_hash(bmi, bits, sha1);
344 memset(bits, 0xcc, dib_size);
345 MoveToEx(hdc, 120, 43, NULL);
346 LineTo(hdc, 110, 20); /* diag br -> tl */
348 compare_hash(bmi, bits, sha1);
350 /* Try the 16 ROP2s */
351 for(i = 0; i < 16; i++)
353 memset(bits, 0xcc, dib_size);
354 SetROP2(hdc, i+1);
355 MoveToEx(hdc, 10, 20, NULL);
356 LineTo(hdc, 110, 20);
357 compare_hash(bmi, bits, sha1);
360 SetROP2(hdc, R2_COPYPEN);
362 SelectObject(hdc, orig_pen);
363 DeleteObject(solid_pen);
366 static void test_simple_graphics(void)
368 char bmibuf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)];
369 BITMAPINFO *pbmi = (BITMAPINFO *)bmibuf;
370 DWORD *bit_fields = (DWORD*)(bmibuf + sizeof(BITMAPINFOHEADER));
371 HDC hdc, mem_dc;
372 BYTE *bits;
373 HBITMAP hdib, orig_bm;
374 const char **sha1;
376 hdc = GetDC(0);
378 /* a8r8g8b8 */
379 trace("8888\n");
380 memset(pbmi, 0, sizeof(bmibuf));
381 pbmi->bmiHeader.biSize = sizeof(pbmi->bmiHeader);
382 pbmi->bmiHeader.biHeight = 100;
383 pbmi->bmiHeader.biWidth = 512;
384 pbmi->bmiHeader.biBitCount = 32;
385 pbmi->bmiHeader.biPlanes = 1;
386 pbmi->bmiHeader.biCompression = BI_RGB;
388 hdib = CreateDIBSection(0, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
389 ok(hdib != NULL, "ret NULL\n");
390 mem_dc = CreateCompatibleDC(hdc);
391 orig_bm = SelectObject(mem_dc, hdib);
393 sha1 = sha1_graphics_a8r8g8b8;
394 draw_graphics(mem_dc, pbmi, bits, &sha1);
396 SelectObject(mem_dc, orig_bm);
397 DeleteObject(hdib);
398 DeleteDC(mem_dc);
401 /* r8g8b8 */
402 trace("888\n");
403 pbmi->bmiHeader.biBitCount = 24;
404 hdib = CreateDIBSection(0, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
405 ok(hdib != NULL, "ret NULL\n");
406 mem_dc = CreateCompatibleDC(hdc);
407 orig_bm = SelectObject(mem_dc, hdib);
409 sha1 = sha1_graphics_r8g8b8;
410 draw_graphics(mem_dc, pbmi, bits, &sha1);
412 SelectObject(mem_dc, orig_bm);
413 DeleteObject(hdib);
414 DeleteDC(mem_dc);
416 /* r5g5b5 */
417 trace("555\n");
418 pbmi->bmiHeader.biBitCount = 16;
419 hdib = CreateDIBSection(0, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
420 ok(hdib != NULL, "ret NULL\n");
421 mem_dc = CreateCompatibleDC(hdc);
422 orig_bm = SelectObject(mem_dc, hdib);
424 sha1 = sha1_graphics_r5g5b5;
425 draw_graphics(mem_dc, pbmi, bits, &sha1);
427 SelectObject(mem_dc, orig_bm);
428 DeleteObject(hdib);
429 DeleteDC(mem_dc);
431 /* a8r8g8b8 - bitfields. Should be the same as the regular 32 bit case.*/
432 trace("8888 - bitfields\n");
433 pbmi->bmiHeader.biBitCount = 32;
434 pbmi->bmiHeader.biCompression = BI_BITFIELDS;
435 bit_fields[0] = 0xff0000;
436 bit_fields[1] = 0x00ff00;
437 bit_fields[2] = 0x0000ff;
439 hdib = CreateDIBSection(0, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
440 ok(hdib != NULL, "ret NULL\n");
441 mem_dc = CreateCompatibleDC(hdc);
442 orig_bm = SelectObject(mem_dc, hdib);
444 sha1 = sha1_graphics_a8r8g8b8;
445 draw_graphics(mem_dc, pbmi, bits, &sha1);
447 SelectObject(mem_dc, orig_bm);
448 DeleteObject(hdib);
449 DeleteDC(mem_dc);
451 /* a8b8g8r8 - bitfields */
452 trace("8b8g8r8 - bitfields\n");
453 bit_fields[0] = 0x0000ff;
454 bit_fields[1] = 0x00ff00;
455 bit_fields[2] = 0xff0000;
457 hdib = CreateDIBSection(0, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
458 ok(hdib != NULL, "ret NULL\n");
459 mem_dc = CreateCompatibleDC(hdc);
460 orig_bm = SelectObject(mem_dc, hdib);
462 sha1 = sha1_graphics_a8b8g8r8;
463 draw_graphics(mem_dc, pbmi, bits, &sha1);
465 SelectObject(mem_dc, orig_bm);
466 DeleteObject(hdib);
467 DeleteDC(mem_dc);
469 /* a5r9g9b9 - bitfields */
470 trace("5999 - bitfields\n");
471 bit_fields[0] = 0x07fc0000;
472 bit_fields[1] = 0x0003fe00;
473 bit_fields[2] = 0x000001ff;
475 hdib = CreateDIBSection(0, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
476 ok(hdib != NULL, "ret NULL\n");
477 mem_dc = CreateCompatibleDC(hdc);
478 orig_bm = SelectObject(mem_dc, hdib);
480 sha1 = sha1_graphics_a5r9g9b9;
481 draw_graphics(mem_dc, pbmi, bits, &sha1);
483 SelectObject(mem_dc, orig_bm);
484 DeleteObject(hdib);
485 DeleteDC(mem_dc);
487 /* r5g6b5 - bitfields. This one is optimized, so test independently. */
488 trace("565 - bitfields\n");
489 pbmi->bmiHeader.biBitCount = 16;
490 bit_fields[0] = 0xf800;
491 bit_fields[1] = 0x07e0;
492 bit_fields[2] = 0x001f;
494 hdib = CreateDIBSection(0, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
495 ok(hdib != NULL, "ret NULL\n");
496 mem_dc = CreateCompatibleDC(hdc);
497 orig_bm = SelectObject(mem_dc, hdib);
499 sha1 = sha1_graphics_r5g6b5;
500 draw_graphics(mem_dc, pbmi, bits, &sha1);
502 SelectObject(mem_dc, orig_bm);
503 DeleteObject(hdib);
504 DeleteDC(mem_dc);
507 /* r5g5b5 - bitfields. Should be the same as the regular 16 bit case. */
508 trace("555 - bitfields\n");
509 pbmi->bmiHeader.biBitCount = 16;
510 bit_fields[0] = 0x7c00;
511 bit_fields[1] = 0x03e0;
512 bit_fields[2] = 0x001f;
514 hdib = CreateDIBSection(0, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
515 ok(hdib != NULL, "ret NULL\n");
516 mem_dc = CreateCompatibleDC(hdc);
517 orig_bm = SelectObject(mem_dc, hdib);
519 sha1 = sha1_graphics_r5g5b5;
520 draw_graphics(mem_dc, pbmi, bits, &sha1);
522 SelectObject(mem_dc, orig_bm);
523 DeleteObject(hdib);
524 DeleteDC(mem_dc);
526 /* r4g5b4 - bitfields */
527 trace("454 - bitfields\n");
528 pbmi->bmiHeader.biBitCount = 16;
529 bit_fields[0] = 0x1e00;
530 bit_fields[1] = 0x01f0;
531 bit_fields[2] = 0x000f;
533 hdib = CreateDIBSection(0, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
534 ok(hdib != NULL, "ret NULL\n");
535 mem_dc = CreateCompatibleDC(hdc);
536 orig_bm = SelectObject(mem_dc, hdib);
538 sha1 = sha1_graphics_r4g5b4;
539 draw_graphics(mem_dc, pbmi, bits, &sha1);
541 SelectObject(mem_dc, orig_bm);
542 DeleteObject(hdib);
543 DeleteDC(mem_dc);
545 /* 8 bit */
546 trace("8\n");
547 pbmi->bmiHeader.biBitCount = 8;
548 pbmi->bmiHeader.biCompression = BI_RGB;
549 pbmi->bmiHeader.biClrUsed = 5;
550 pbmi->bmiColors[0].rgbRed = 0xff;
551 pbmi->bmiColors[0].rgbGreen = 0xff;
552 pbmi->bmiColors[0].rgbBlue = 0xff;
553 pbmi->bmiColors[1].rgbRed = 0;
554 pbmi->bmiColors[1].rgbGreen = 0;
555 pbmi->bmiColors[1].rgbBlue = 0;
556 pbmi->bmiColors[2].rgbRed = 0xff;
557 pbmi->bmiColors[2].rgbGreen = 0;
558 pbmi->bmiColors[2].rgbBlue = 0;
559 pbmi->bmiColors[3].rgbRed = 0;
560 pbmi->bmiColors[3].rgbGreen = 0xff;
561 pbmi->bmiColors[3].rgbBlue = 0;
562 pbmi->bmiColors[4].rgbRed = 0;
563 pbmi->bmiColors[4].rgbGreen = 0;
564 pbmi->bmiColors[4].rgbBlue = 0xff;
566 hdib = CreateDIBSection(0, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
567 ok(hdib != NULL, "ret NULL\n");
568 mem_dc = CreateCompatibleDC(hdc);
569 orig_bm = SelectObject(mem_dc, hdib);
571 sha1 = sha1_graphics_8;
572 draw_graphics(mem_dc, pbmi, bits, &sha1);
574 SelectObject(mem_dc, orig_bm);
575 DeleteObject(hdib);
576 DeleteDC(mem_dc);
578 /* 4 bit */
579 trace("4\n");
580 pbmi->bmiHeader.biBitCount = 4;
582 hdib = CreateDIBSection(0, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
583 ok(hdib != NULL, "ret NULL\n");
584 mem_dc = CreateCompatibleDC(hdc);
585 orig_bm = SelectObject(mem_dc, hdib);
587 sha1 = sha1_graphics_4;
588 draw_graphics(mem_dc, pbmi, bits, &sha1);
590 SelectObject(mem_dc, orig_bm);
591 DeleteObject(hdib);
592 DeleteDC(mem_dc);
596 START_TEST(dib)
598 CryptAcquireContextW(&crypt_prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
600 test_simple_graphics();
602 CryptReleaseContext(crypt_prov, 0);