gdi32/tests: Avoid deleting invalid objects.
[wine] / dlls / gdi32 / tests / dib.c
1 /*
2  * DIB driver tests.
3  *
4  * Copyright 2011 Huw Davies
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include <math.h>
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "wingdi.h"
28 #include "winuser.h"
29 #include "wincrypt.h"
30 #include "mmsystem.h" /* DIBINDEX */
31
32 #include "wine/test.h"
33
34 static HCRYPTPROV crypt_prov;
35 static BOOL (WINAPI *pGdiAlphaBlend)(HDC,int,int,int,int,HDC,int,int,int,int,BLENDFUNCTION);
36 static BOOL (WINAPI *pGdiGradientFill)(HDC,TRIVERTEX*,ULONG,void*,ULONG,ULONG);
37 static DWORD (WINAPI *pSetLayout)(HDC hdc, DWORD layout);
38
39 static const DWORD rop3[256] =
40 {
41     0x000042, 0x010289, 0x020C89, 0x0300AA, 0x040C88, 0x0500A9, 0x060865, 0x0702C5,
42     0x080F08, 0x090245, 0x0A0329, 0x0B0B2A, 0x0C0324, 0x0D0B25, 0x0E08A5, 0x0F0001,
43     0x100C85, 0x1100A6, 0x120868, 0x1302C8, 0x140869, 0x1502C9, 0x165CCA, 0x171D54,
44     0x180D59, 0x191CC8, 0x1A06C5, 0x1B0768, 0x1C06CA, 0x1D0766, 0x1E01A5, 0x1F0385,
45     0x200F09, 0x210248, 0x220326, 0x230B24, 0x240D55, 0x251CC5, 0x2606C8, 0x271868,
46     0x280369, 0x2916CA, 0x2A0CC9, 0x2B1D58, 0x2C0784, 0x2D060A, 0x2E064A, 0x2F0E2A,
47     0x30032A, 0x310B28, 0x320688, 0x330008, 0x3406C4, 0x351864, 0x3601A8, 0x370388,
48     0x38078A, 0x390604, 0x3A0644, 0x3B0E24, 0x3C004A, 0x3D18A4, 0x3E1B24, 0x3F00EA,
49     0x400F0A, 0x410249, 0x420D5D, 0x431CC4, 0x440328, 0x450B29, 0x4606C6, 0x47076A,
50     0x480368, 0x4916C5, 0x4A0789, 0x4B0605, 0x4C0CC8, 0x4D1954, 0x4E0645, 0x4F0E25,
51     0x500325, 0x510B26, 0x5206C9, 0x530764, 0x5408A9, 0x550009, 0x5601A9, 0x570389,
52     0x580785, 0x590609, 0x5A0049, 0x5B18A9, 0x5C0649, 0x5D0E29, 0x5E1B29, 0x5F00E9,
53     0x600365, 0x6116C6, 0x620786, 0x630608, 0x640788, 0x650606, 0x660046, 0x6718A8,
54     0x6858A6, 0x690145, 0x6A01E9, 0x6B178A, 0x6C01E8, 0x6D1785, 0x6E1E28, 0x6F0C65,
55     0x700CC5, 0x711D5C, 0x720648, 0x730E28, 0x740646, 0x750E26, 0x761B28, 0x7700E6,
56     0x7801E5, 0x791786, 0x7A1E29, 0x7B0C68, 0x7C1E24, 0x7D0C69, 0x7E0955, 0x7F03C9,
57     0x8003E9, 0x810975, 0x820C49, 0x831E04, 0x840C48, 0x851E05, 0x8617A6, 0x8701C5,
58     0x8800C6, 0x891B08, 0x8A0E06, 0x8B0666, 0x8C0E08, 0x8D0668, 0x8E1D7C, 0x8F0CE5,
59     0x900C45, 0x911E08, 0x9217A9, 0x9301C4, 0x9417AA, 0x9501C9, 0x960169, 0x97588A,
60     0x981888, 0x990066, 0x9A0709, 0x9B07A8, 0x9C0704, 0x9D07A6, 0x9E16E6, 0x9F0345,
61     0xA000C9, 0xA11B05, 0xA20E09, 0xA30669, 0xA41885, 0xA50065, 0xA60706, 0xA707A5,
62     0xA803A9, 0xA90189, 0xAA0029, 0xAB0889, 0xAC0744, 0xAD06E9, 0xAE0B06, 0xAF0229,
63     0xB00E05, 0xB10665, 0xB21974, 0xB30CE8, 0xB4070A, 0xB507A9, 0xB616E9, 0xB70348,
64     0xB8074A, 0xB906E6, 0xBA0B09, 0xBB0226, 0xBC1CE4, 0xBD0D7D, 0xBE0269, 0xBF08C9,
65     0xC000CA, 0xC11B04, 0xC21884, 0xC3006A, 0xC40E04, 0xC50664, 0xC60708, 0xC707AA,
66     0xC803A8, 0xC90184, 0xCA0749, 0xCB06E4, 0xCC0020, 0xCD0888, 0xCE0B08, 0xCF0224,
67     0xD00E0A, 0xD1066A, 0xD20705, 0xD307A4, 0xD41D78, 0xD50CE9, 0xD616EA, 0xD70349,
68     0xD80745, 0xD906E8, 0xDA1CE9, 0xDB0D75, 0xDC0B04, 0xDD0228, 0xDE0268, 0xDF08C8,
69     0xE003A5, 0xE10185, 0xE20746, 0xE306EA, 0xE40748, 0xE506E5, 0xE61CE8, 0xE70D79,
70     0xE81D74, 0xE95CE6, 0xEA02E9, 0xEB0849, 0xEC02E8, 0xED0848, 0xEE0086, 0xEF0A08,
71     0xF00021, 0xF10885, 0xF20B05, 0xF3022A, 0xF40B0A, 0xF50225, 0xF60265, 0xF708C5,
72     0xF802E5, 0xF90845, 0xFA0089, 0xFB0A09, 0xFC008A, 0xFD0A0A, 0xFE02A9, 0xFF0062
73 };
74
75 static inline BOOL rop_uses_src(DWORD rop)
76 {
77     return (((rop & 0xcc0000) >> 2) != (rop & 0x330000));
78 }
79
80 static const char *sha1_graphics_a8r8g8b8[] =
81 {
82     "a3cadd34d95d3d5cc23344f69aab1c2e55935fcf",
83     "2426172d9e8fec27d9228088f382ef3c93717da9",
84     "9e8f27ca952cdba01dbf25d07c34e86a7820c012",
85     "664fac17803859a4015c6ae29e5538e314d5c827",
86     "17b2c177bdce5e94433574a928bda5c94a8cdfa5",
87     "fe6cc678fb13a3ead67839481bf22348adc69f52",
88     "d51bd330cec510cdccf5394328bd8e5411901e9e",
89     "df4aebf98d91f11be560dd232123b3ae327303d7",
90     "f2af53dd073a09b1031d0032d28da35c82adc566",
91     "eb5a963a6f7b25533ddfb8915e70865d037bd156",
92     "c387917268455017aa0b28bed73aa6554044bbb3",
93     "dcae44fee010dbf7a107797a503923fd8b1abe2e",
94     "6c530622a025d872a642e8f950867884d7b136cb",
95     "7c07d91b8f68fb31821701b3dcb96de018bf0c66",
96     "b2261353decda2712b83538ab434a49ce21f3172",
97     "35f731c0f6356b8f30651bb3cbe0d922c49deba5",
98     "9b9874c1c1d92afa554137e191d34ea33acc322f",
99     "c311dd74325e8cebfc8529a6d24a6fa4ecb7137e",
100     "d7398de15b2837a58a62a701ca1b3384625afec4",
101     "a78b28472bb7ff480ddedd06b9cf2daa775fa7ae",
102     "5246ef357e7317b9d141a3294d300c195da76cb7",
103     "87f6b6a19f021ca5912d285e14ce2ff9474d79f3",
104     "3d8244b665ecdb104087bad171b0b0f83545133c",
105     "e2a8eef4aeda3a0f6c950075acba38f1f9e0814d",
106     "8b66f14d51ecdeea12bc993302bb9b7d3ec085a1",
107     "7da9dd3d40d44d92deb9883fb7110443c2d5769a",
108     "e358efb1c11172e40855de620bdb8a8e545cd790",
109     "9e0c2596c6ecb4f1bc97b18ec3ca493d37626608",
110     "58806549380c964e7a53ad54821d2eb86fa5b9ce",
111     "7fc30d3058c235ce39088de0a598b8c7fe7ca61f",
112     "52a6c769c227f2bb1949097c4c87fed5ee0cbcb1",
113     "8a010d4c5af51fcc34d51be3197878782bdf63e7",
114     "c84c2c33e22eb7e5c4a2faad3b3b99a359d77528",
115     "41bcc1f57c60bdec3c4d1e749084a12867f91224",
116     "94645300d6eb51020a7ef8261dee2941cd51b5df",
117     "c56f5bdc9cac4f0bc81c33295d9aed8eaf4cb1f2",
118     "21cdfde38ac7edbb241ec83d82f31286e90c4629",
119     "1fd2f4dcb62f8522171872e43fd4a35041d68100",
120     "68c18db6abfda626cab12d198298d4c39264bfbc",
121     "6b59ae6c20749020ad43175e05110dc33b6a59b5",
122     "39c31de73aafcfcadf0bf414da4495be9de54417",
123     "132949f59bfeb88dc2047e6eaecb8512aea3d9ab",
124     "f6a6d765bf23726329f96020ba8c5e3c0897aafa",
125     "a7aa311cdc6137f15b9ef9cb1a92ac54ec02f058",
126     "e71d6bb9bd38eea5719f8ba57177997910e2d841",
127     "3d2ccbe51408232a04769546b1bdd74f84558a41",
128     "a1fe9aa885584a0f713d7c6f76c89830fbf28563",
129     "d7085333becdec7759a5229e5fe9ba1e11db0c22",
130     "aaf62842bb98d8a2945c4f643baf50afaeea9307",
131     "287b2f2f2fb5a1d7ee4a29b43342103d78a7a8ab",
132     "d7dd4700f49808541bba99244b7eb5840e0a2439",
133     "af99228aa4cfbd1f61bd824db046144a3c6c2ed7",
134     "568f87f0194ca19b69a5b2bcdef795d89c5721ce",
135     "50d19fe68b2ab4fdbb5d590cdca6dc84a95bab68",
136     "a1fde1094d2c19ddb20871842dae1da73618709e",
137     "e462052a03dbe4ec3814db7700e166d00d4d686f",
138     "a27917d4db49ce77989fae246015aeb2a28520ee",
139     "657514a4ca1f2b6ca7a125ad58dfed82099a37d1",
140     "5e0549fdcf0fc7c50054dccc51d37fc734ab8134",
141     "eca1998a4d79fb81b2a4103f79e3b846a864eaaf",
142     "e4acfcf2d001fbc431d9af59ab3d3ca7c2d965e5",
143     "2b3198bd5c0a87db5dab13df8bbe14363d02acec",
144     "f115ef8392ba82d8cd6e7a039320edcd812c1d28",
145     "aebb1b3baa4fd5213bf80a5ad7a50d54de8fdba4",
146     "f451a05f699ac3bbe155d059e7871a2636887b5f",
147     "5dca709c60e0cd50fa85274a2836aec9eb6168e3",
148     "dccaef62738ff90da4554a85d8cb846d6436799e",
149     "cc4e1372ddf6e303a7fd159090c9d3a1f8ec2a89",
150     NULL
151 };
152
153 static const char *sha1_graphics_a8r8g8b8_bitfields[] =
154 {
155     "a3cadd34d95d3d5cc23344f69aab1c2e55935fcf",
156     "2426172d9e8fec27d9228088f382ef3c93717da9",
157     "9e8f27ca952cdba01dbf25d07c34e86a7820c012",
158     "664fac17803859a4015c6ae29e5538e314d5c827",
159     "17b2c177bdce5e94433574a928bda5c94a8cdfa5",
160     "fe6cc678fb13a3ead67839481bf22348adc69f52",
161     "d51bd330cec510cdccf5394328bd8e5411901e9e",
162     "df4aebf98d91f11be560dd232123b3ae327303d7",
163     "f2af53dd073a09b1031d0032d28da35c82adc566",
164     "eb5a963a6f7b25533ddfb8915e70865d037bd156",
165     "c387917268455017aa0b28bed73aa6554044bbb3",
166     "dcae44fee010dbf7a107797a503923fd8b1abe2e",
167     "6c530622a025d872a642e8f950867884d7b136cb",
168     "7c07d91b8f68fb31821701b3dcb96de018bf0c66",
169     "b2261353decda2712b83538ab434a49ce21f3172",
170     "35f731c0f6356b8f30651bb3cbe0d922c49deba5",
171     "9b9874c1c1d92afa554137e191d34ea33acc322f",
172     "c311dd74325e8cebfc8529a6d24a6fa4ecb7137e",
173     "d7398de15b2837a58a62a701ca1b3384625afec4",
174     "a78b28472bb7ff480ddedd06b9cf2daa775fa7ae",
175     "5246ef357e7317b9d141a3294d300c195da76cb7",
176     "87f6b6a19f021ca5912d285e14ce2ff9474d79f3",
177     "3d8244b665ecdb104087bad171b0b0f83545133c",
178     "e2a8eef4aeda3a0f6c950075acba38f1f9e0814d",
179     "8b66f14d51ecdeea12bc993302bb9b7d3ec085a1",
180     "7da9dd3d40d44d92deb9883fb7110443c2d5769a",
181     "e358efb1c11172e40855de620bdb8a8e545cd790",
182     "9e0c2596c6ecb4f1bc97b18ec3ca493d37626608",
183     "58806549380c964e7a53ad54821d2eb86fa5b9ce",
184     "7fc30d3058c235ce39088de0a598b8c7fe7ca61f",
185     "52a6c769c227f2bb1949097c4c87fed5ee0cbcb1",
186     "8a010d4c5af51fcc34d51be3197878782bdf63e7",
187     "c84c2c33e22eb7e5c4a2faad3b3b99a359d77528",
188     "41bcc1f57c60bdec3c4d1e749084a12867f91224",
189     "94645300d6eb51020a7ef8261dee2941cd51b5df",
190     "c56f5bdc9cac4f0bc81c33295d9aed8eaf4cb1f2",
191     "21cdfde38ac7edbb241ec83d82f31286e90c4629",
192     "1fd2f4dcb62f8522171872e43fd4a35041d68100",
193     "68c18db6abfda626cab12d198298d4c39264bfbc",
194     "6b59ae6c20749020ad43175e05110dc33b6a59b5",
195     "39c31de73aafcfcadf0bf414da4495be9de54417",
196     "132949f59bfeb88dc2047e6eaecb8512aea3d9ab",
197     "f6a6d765bf23726329f96020ba8c5e3c0897aafa",
198     "a7aa311cdc6137f15b9ef9cb1a92ac54ec02f058",
199     "e71d6bb9bd38eea5719f8ba57177997910e2d841",
200     "3d2ccbe51408232a04769546b1bdd74f84558a41",
201     "a1fe9aa885584a0f713d7c6f76c89830fbf28563",
202     "d7085333becdec7759a5229e5fe9ba1e11db0c22",
203     "aaf62842bb98d8a2945c4f643baf50afaeea9307",
204     "287b2f2f2fb5a1d7ee4a29b43342103d78a7a8ab",
205     "d7dd4700f49808541bba99244b7eb5840e0a2439",
206     "af99228aa4cfbd1f61bd824db046144a3c6c2ed7",
207     "568f87f0194ca19b69a5b2bcdef795d89c5721ce",
208     "50d19fe68b2ab4fdbb5d590cdca6dc84a95bab68",
209     "a1fde1094d2c19ddb20871842dae1da73618709e",
210     "0cda6b3297003b3ccd6d5baa17e1ca9bb7c56f08",
211     "b2c8e1ebb9435031fe068442f479d1304096e79f",
212     "657514a4ca1f2b6ca7a125ad58dfed82099a37d1",
213     "5e0549fdcf0fc7c50054dccc51d37fc734ab8134",
214     "eca1998a4d79fb81b2a4103f79e3b846a864eaaf",
215     "e4acfcf2d001fbc431d9af59ab3d3ca7c2d965e5",
216     "e4f110504dd3e4e34f960a39ba91a91c67bf26af",
217     "f115ef8392ba82d8cd6e7a039320edcd812c1d28",
218     "aebb1b3baa4fd5213bf80a5ad7a50d54de8fdba4",
219     "f451a05f699ac3bbe155d059e7871a2636887b5f",
220     "5dca709c60e0cd50fa85274a2836aec9eb6168e3",
221     "dccaef62738ff90da4554a85d8cb846d6436799e",
222     "cc4e1372ddf6e303a7fd159090c9d3a1f8ec2a89",
223     NULL
224 };
225
226 static const char *sha1_graphics_a8b8g8r8[] =
227 {
228     "a3cadd34d95d3d5cc23344f69aab1c2e55935fcf",
229     "e0bc877697093ed440e125154e247ca9d65e933c",
230     "c6d7faf5a502299f99d59eef3f7650bd63dbe108",
231     "9d8c05c3ebd786e7d052418e905a80a64bf7853d",
232     "3da12af0a810fd993fa3dbe23328a4fcd2b6c92a",
233     "b91c8f21cc4d7994abc551feff5b6927d267a9db",
234     "d49dd2c6a37e975b6dc3d201ccc217a788b30284",
235     "ca6753f9eb44529cf8c67cd6abcd4ed1ef758904",
236     "18c3ae944e0afb6c43c21cde093ddb22a27611e4",
237     "b753ebb39d90210cc717f57b53dd439f7de6b077",
238     "38c017dd1fff26b492a57e09f3ce2c4370faf225",
239     "94368cea5033b435454daa56d55546310675131e",
240     "bf57a6a37fb107d29ed3d45695919887abcb7902",
241     "3db0f8bcca3d94920aa57be6321202b8c3c08822",
242     "1f1fc165a4dae7ba118ddccb58a279bfe3876b0a",
243     "8e09abb108e137c99527ab4c9bd07d95b9254bbb",
244     "b0178632775d29bec2b16de7b9b8287115c40d0f",
245     "ca7e859647b9498b53fdd92543ad8aea98ff46f3",
246     "3369889a67d6c79a24ee15f7d14374f9995215e4",
247     "473a1fd07df800c87a5d3286b642ace10c61c6af",
248     "10cd25a0ed5cd8f978d7d68236f81d949b938e84",
249     "b8951d2b20518fd129e5113a5f429626893913bf",
250     "e81fc45962f861d53f420e29cb5d33faf5adbec8",
251     "4851c5b7d5bc18590e787c0c218a592ef504e738",
252     "9aa506e3df33e0d5298755aa4144e10eb4b5adcf",
253     "abdf003699364fe45fab7dc61e67c606d0063b40",
254     "89abaadff4e68c738cf9251c51e3609564843381",
255     "f6aa3f907f620b9f3493f03cb3b4b292df3a9545",
256     "77d0ad32938147aa4038c1eced232b7b5a5f88f3",
257     "43d36e57b702ce56eb250bf53f1ecc4680990cfe",
258     "fd6e0ebb52710ebcdd8dd69931165c83c4930b41",
259     "71b9756fdfeedce1e6db201176d21a981b881662",
260     "5319528d9af750c172ae62ee85ddb2eaef73b193",
261     "b7ce8aa3c328eedaed7306234ed9bae67708e627",
262     "19b32a0daa91201725b5e13820c343d0a84ff698",
263     "abca6a80a99b05722d2d87ce2a8b94ef1ae549e1",
264     "2ba70994d0b4ce87fdf6fbc33ada11252178061e",
265     "7b4e1d47a03e2cec236d8fb6e2ae89d8ed078f79",
266     "075c4cb50e2cf96ab5d132c9f7bb1c1deb4735bd",
267     "8566c1110ab5cb8f754787b47923c8bff38f790c",
268     "89e90d6159d59886bbbf0c40a7cd01293c3cfda3",
269     "3a598f1eb35c1412b0c131e9d9e36a4aef9534d2",
270     "d01071c44259adc94b89978b7d51a058b6dad665",
271     "e6d33b106bcda374e662d338c57a457dbcaa108a",
272     "27ef47377e88f5ac5ad33b19eae27d56c456ac65",
273     "339908a568f384e1f384a3e1b0dd415779203b02",
274     "88fd743d00bd37d2ed722092146795b044d08a6e",
275     "c0537ec24147e74939219213d864ee113cad9967",
276     "118bf4c5bddc206ba737f7aa8b239940cd1aadc2",
277     "7cb51f6c5f1dae926601986c934533df5f8baa9f",
278     "86c84cc8306975edecc6d4a89a8aff29f59b55a7",
279     "af99228aa4cfbd1f61bd824db046144a3c6c2ed7",
280     "25675c30adfe24d6cae60793b156dfdaa36ac3ba",
281     "1cb1810b127f509117b38d62a15b67b2347b9145",
282     "f05b3294f25de5fa6d1114104bca97871052ea5a",
283     "87f57a31253a38dbf3dc3070473328fa04b68a48",
284     "db64cc4d830fc35ed170b53943e722b2342954d4",
285     "9988ceca44dafbee247aece1f027c06c27c01652",
286     "d80d45a97bc877b50ba2c3f720d5197f2f1c5fc5",
287     "b76e0724496e471b01ef8b34f8beba69f5bde261",
288     "34201d3d3583f89ce3267d3d0c4e01c64463de4b",
289     "693f5c5fbaeaadb5928d34b035499626fecb8394",
290     "8a9aa84c42dedc3e681191a1229846887ed262ec",
291     "66041875232f64dbfd2d18353aa28e43e8ccb6b5",
292     "707bc44fc9fed68ff1f537f0473e0cd825dd660f",
293     "f19f5d8e2c96328f06f3985d02ff474fa37b1ea8",
294     "175a7bcb73c74eceecc000657a0100bccf158ff4",
295     "d26eeb6b2d345b587d4305a1234ec0842a96d4b6",
296     NULL
297 };
298
299 static const char *sha1_graphics_r10g10b10[] =
300 {
301     "a3cadd34d95d3d5cc23344f69aab1c2e55935fcf",
302     "b340b5d4750dd3dcd95d73c41b2c3a17f799210b",
303     "b1db68f35022c5fd43519ec8e98047e16bc4fff8",
304     "6e1902eb24865e74066fa9f2a7a49e6f9154f62f",
305     "35df9f4b0965fedf7bca36aa4f17b0fa20e2cd03",
306     "5652e1feb7d4f22c8a2721fd141157e0b9ef965e",
307     "22d89d5933f8b9bd60e9b22e42e7f5659269b63d",
308     "0ad27de0c916c073d0d18484fff899bbdb258db7",
309     "7c05ee5a01dad1e187537701a95382f0a3ec28dc",
310     "b00f0b4448be722d1a19ffe33aaaac4df848d397",
311     "7e5ce5c05a54e83890f022ba4e9853e4b254bf0c",
312     "2986b431a0022153e5f875da77cc792e3825ebd5",
313     "ca4b25a5459885ce1e0a36844612087893d425b1",
314     "181bd4616796d89174cedc0332fb320b65aeb0e2",
315     "6c417b1798ee319eeb404efe4aa136ed7ed37966",
316     "9a9f83e2035aa591d18101c919d1fd5b3456b46c",
317     "74ce9f5658cd8aeae4601fe72fcef07d9f75ec26",
318     "536eaaa901d652805a8977ecb2dc73f651094c5b",
319     "b8b1ac11bcc7174c5b23c18cc7919d09a04255c2",
320     "92cddcabf5365eef1e037f488af52b31669d987f",
321     "2c9c4f27bade080a2cd6f9160422762e267c2f5f",
322     "c7ce29d189dc06ba57e64f0cc32202f5a25ba48d",
323     "717778cc9ab30bcfc026a4344ea1bdef870bd247",
324     "7ac4cb547c8f4ce5079c95afad9d0e2b0cd76a0e",
325     "d578210815e27fe210eb678a71e6d22ba4b4c196",
326     "c7a027c7079dfcc831ca8bc134a509958273073c",
327     "19cf978596195b848df8709aaf637f83f92b8336",
328     "798a835fe50156eeb478c0a6085b088f53409d52",
329     "86ddf268d854f37e5b478c48792b551b57635db6",
330     "8259d388e02542207b6a08d65d553871ce1c4a09",
331     "faea73ff9436223f8c4ee76ac9861a6609ac4ae4",
332     "66f8d78d4971934794478afee28b3a50e97f1b82",
333     "b8f16334bdced439e1c6fc69704bc95f7b46b147",
334     "63798fb175afef78fa8fe8133d9de97a0cc80651",
335     "5f629ab51719dd0ca5a67d880eb2631f5b598a7b",
336     "1ceb85697f649a62b1753438daa14944af7f450c",
337     "98ce4dbc04eb48fa0f96ef813db5b4dfa1b2dd39",
338     "3addb9ccd8f56fc0825f61b1b5af67d3297f4ded",
339     "f00bac7e18827cfb264fae2e8a0da17b9db18d52",
340     "63c1c6c63e82f3b8bd977a1381b248e05321394d",
341     "ada202d2f526f6995f83412479891c1764b66e5a",
342     "68348e8f54883f4fe295354b024e291c85f1038f",
343     "07f55f85a5bb70de5841ea4f62a9af3d29d3d94b",
344     "e9167564031ead3459eee6a3ebb2f58f100d931f",
345     "d39315a1399639f6d4305a342c9ccf02a463b0dd",
346     "46196f50297260df2863e2fa76d2dfcf72006c23",
347     "0790585dfaef94f912b1ee81477d4ac448708708",
348     "589fb8a85d924ad19ed78409ae89475ba479c30a",
349     "43d67bc61ef54014b022891e5c024fc24b1fe797",
350     "e8783644428b637adbe80bcd084a33428cb69983",
351     "fc0c32afb719295f28bcfef22803bef94f798e20",
352     "36f6db4fbe2a1630a7597d3a446f2902755c96ef",
353     "d3f08946300e1700865042aed121870e292d1095",
354     "467ff4af1e105855874f27fbf84d1d2b0417ab5d",
355     "fb0dcff8a67a88313557ee8b588aaa2004fe7b8b",
356     "8ea5d7e4bebc40a1d91b04b12e1c11a42c188095",
357     "317521e576801acaea62c76fe16813cdfe20f4ad",
358     "ce0fc29bb0281d6c955d64e239254ef9e6dbc06d",
359     "5ab49e7b61eddd3bab4182f362a38e1ab6a5a3b7",
360     "555b6f04ba8dec9e2a60693dcaac594227052727",
361     "c199b96a71c3aab2d49ccb5b6294bf14eb0dd1eb",
362     "4238fe9d296b5c72b0a8745cc761f308605b2094",
363     "943dc6033ab335a6a63e666f70a6bb3a0677e157",
364     "88b6427cf71a6b9a26bfd6026103d50f721651a9",
365     "88cfa7b7c1487f8eda05fce92b622942c9fb7ca4",
366     "64cf929548bc5324fb14b053077bf5bc4be3e15c",
367     "ad91dde8566dceaadc3523cdc8149cd7415a1b70",
368     "1936661eee8073068506131c9e89265b2f8403e8",
369     NULL
370 };
371
372 static const char *sha1_graphics_r6g6b6[] =
373 {
374     "a3cadd34d95d3d5cc23344f69aab1c2e55935fcf",
375     "a1adb32e70188a00f82fe58156b4da74f3ef7a0a",
376     "5b9dab3d8411afb25fbbeba0313db526815ac189",
377     "6415f551e28e1b38b2d721f0a9e003b7d215f6b2",
378     "2028d1b0d1acef35dc07027135023f35fb9746b9",
379     "378713720dcb5aadb730435ad0989a68ab189114",
380     "084152773feb01a85df6006f2f4f288a1442d37a",
381     "97b824953f60fc9a91028045baacbe7b7dc82b14",
382     "f33b1931f392bd09b3494efc23cf7d0ed3071014",
383     "287d755448e72e29e4812193e2b6f8098a214d82",
384     "4059d295aa05ace77853d7ee3d74305cdcbec9f5",
385     "2557ebd4fdacc0e5bcce3dae88a46dd247654ea1",
386     "e51bcf80211cd06e7d10225534b7a79b5454be27",
387     "9bf91a547f47b29bf370e9b60eae7cd6ce987617",
388     "0b94e0a5b739ab0020130646522e53da35a149ad",
389     "eab6e532845dfd5dc2701ef90669a5f7b63e9539",
390     "90deb2e2502186b3c62a58ec9b1c9d2b7b4089c1",
391     "a4e451f76a77bbc3e224a41e9b4fa78cb841a8af",
392     "084607a5c99a84140d93db57d1b0f3a0f51afdac",
393     "2128157e601ef0d6b3636b7387d3b28e876de728",
394     "8bdcdcd463f0052279d070ac763757f4db975483",
395     "9ea0ad22d7b61598fe36e9c942242e8e07e32edb",
396     "8b6452ebd1f6d189d10ee6647e7704821559cfcb",
397     "c39a25a61c4eade48dea62a97c9fb8714c06a8af",
398     "66b130f83381957cfc4763558c5f5cddf2e3b564",
399     "d548135ce2320499277ce12b80bc35004f8a9787",
400     "85a4f3f1b4b0a170198f1bb5d225fcf77887665e",
401     "1906ddfd829e735af49245171f8eb7673295d399",
402     "971a0b786d5bccb1bfb9cbb054740e4eb36f9b7a",
403     "e2896035f178b3d20e4f4d1accb1b3d1b4028865",
404     "defd95a10d44cad6e736542920b74efd53e9e7eb",
405     "eaccd012c0fc46e79cae1997ef101979e5654d8d",
406     "3f11a735e52030aa3d0f024d83803698293d10e5",
407     "82f45c5a34fbb9e36d947a876834d33a1f69719c",
408     "3d27002f4fe3c943468b7e3ef6985962c41ac8dc",
409     "3231c4d87faefb7ec5bd377613969c05b70343fc",
410     "00394e438e9edde978e88602c9ad2a572e965bf6",
411     "e760be69cb37c7be35d5968d7a294e1fd49d4f66",
412     "996fb708ddc4b94eb8d1585bd83a5c8a1e2633ba",
413     "caa39eb482e8fc2e00f1c6737735c023ac9363ef",
414     "c1250ff2b67e6d2a8baccc5c93f8f5ad933c5c4f",
415     "3d6cf3753390a05504b1f50302f767df443f0f40",
416     "b7cf1bafe002673ae58ff50feea61ee32a1ae10a",
417     "da9e896a3a98b330980152b2e4a43cb6e686c730",
418     "0a613357e1e8ec8ff1ad956e46e527a05cab8500",
419     "bdd8ed3ca3ad107b43731ec253ecaa34750a10de",
420     "47499ad13b719de18c59c2bc9b38ed578db50b95",
421     "643e82ac67ab2b0c034a3fcfa498b072a5f2be5c",
422     "cd01f2c0a63b2229d4467d2f874d58edca32b3d4",
423     "94b54f1da5212b3f3a1195eda5ea927e160bc89d",
424     "49341c297a887186bd47d7465d827ab3147f05e3",
425     "325279e76367200d3fd7194d81c09fd139988ece",
426     "c3def160a1e847605ff0fc7edd30397fa90635a0",
427     "a9c2158329c207638cfd2c82cd8a6218efdb28d2",
428     "7f0c4e6874f0c36cee64ff5dec76258ca8822cb2",
429     "aecb242c31f31a90f071b6455ea7d808d4ea22e3",
430     "77ea86e51a94b11a8081b29696cb4115687843e3",
431     "d67b897cad72d31e75359094007b1346fd8806ea",
432     "442bcf4d94a649c9406c3b0bf2f00cb7c6a4d1d4",
433     "3d0853f4f7580d7cd5148c21c34d878ecf39a5f3",
434     "1e5a4ef7f8634847a251d1fcce298c409fd13d87",
435     "481337fbedf181d4324bf7f8299b0327197ff468",
436     "9ab957870fa4e17aec6a79bc1a4fdb42a5ffcc30",
437     "b4b9f0bf127ef11f510f25684ae21d692609c85e",
438     "8e32ea3614c3b20899d748db48258761c7158d2b",
439     "5da35bad12e3e9b26a0444d30820099481281e45",
440     "94f004e98ae8035af948611770a4a2dd6643f510",
441     "045ddaf752e7ffc7ded792f36af3c7c0cfeeae42",
442     NULL
443 };
444
445 static const char *sha1_graphics_24[] =
446 {
447     "e993b15c9bd14fb45a15310450b7083c44e42665",
448     "edbd7bab3d957fbc85e89612197cf918f5f5af20",
449     "6a7efb3b6e0b49336df1bd2937ca09a11d976531",
450     "236eb5ca9da70ec7cc719cd2fd291bab14000257",
451     "f98023c7cd8c068f2d7a77ce3600004b90ea12d6",
452     "5c4cb9cea2226fc671bb4a11f8253343ee94bb4b",
453     "fd4be592483623dbc800fe28210a1f0daa71999b",
454     "788b8de98c47974fa9f232a6042ae4ca546ddb7d",
455     "a8772e6c44ba633fb384a7c4b50b435f1406107e",
456     "883bc8f305c602edca785e21cd00f488583fb13f",
457     "3bac4e80993f49dc3926e30524115fca9d7a8026",
458     "91369e35be29059a0665782541db4c8b324c6bb2",
459     "0fa8cf332a56bb6d7e14e85861fdd60f51d70501",
460     "593d694cdcc8349b3bfc8257041dbcb27e61da45",
461     "1036b91d93e31cd1d4740d0c8642e115e5a38188",
462     "1898073cdb35ca4d2b21bba933ac16a0b4297317",
463     "5068bff794553cf5a3145ae407c9a2984357844c",
464     "413a7989969c229dee4ab1798362f32f96cf0a10",
465     "0bb222e540b82720d4971e4a2fc626899af03e03",
466     "adc20832d8c43f1cf372d8392535492013cd2306",
467     "45649794dcbcabda487f66f7a80fc1bec79047a1",
468     "367c2dc1e91ff9ea0e984d6fb3000cfb4e0ae7e9",
469     "9c6afd47dd748a33c585e6655fd4ec1c28976a47",
470     "b4df692ac70a5f9f303270df4641ab014c6cbf46",
471     "8bc3128ba47891366fd7b02fde7ca19100e64b9f",
472     "e649e00efe7fea1eb8b17f7867fe089e5270c44b",
473     "a0bffbbfb0adf6f188479c88da04e25d76ab4822",
474     "92a1ab214dd8027c407814420449119466c92840",
475     "b58f19c1800344a2b8e017eb784705bdb2bd8450",
476     "5747a6d5c6ce79731c55e8cf33f7da3025cd35fd",
477     "955390669afed2369b15b32fa519f2f921cdf1a0",
478     "201906f7d763b930a98c97f8eeab417f2b65e723",
479     "5313357d50c40c05a3b3a83d0d2013a138c955a1",
480     "701c5af1d0c28294ce7d804b5697643c430d22a0",
481     "b0a959745b2db1d9f449e68e4479a4f36301879c",
482     "63f764b9bd2f4876ab1ee0f3c0eb55b5a7de5212",
483     "e171f6ec77bca91d6b8559911bce296c0bac469e",
484     "9725669042ef68acb408404d196496d10340bb5a",
485     "26e7e1c300ba0c5aaaef03eeb71d529f6def9289",
486     "b1f602d2a74095cc0115ae2ae07b642498e6c0fc",
487     "03d5eb8e3a6662e6dc183f88ee2f285065fc9c51",
488     "f4c312f9a37ddc54a27f6b1421dab1ce0cec0c27",
489     "0f79500eda467cd3cbc220abdd37b5dba695d654",
490     "8d4e3e9d81cc30aaad555ed9e27aed7c615de630",
491     "84c43a3cbd7d8c1ac9a0e9b6f07620158079b278",
492     "7d479beeb6758c164566638b5c873c188d6a91e7",
493     "80086808fca03e757d812e31d1ae576bf90dac9d",
494     "9560096f1b85ae6d939d736165c44df00a47c424",
495     "1015e0217ea13eaa62c7666b8b81aafd75f8f610",
496     "93e1aec608e037af3bfb7bd32dde446abe4eea11",
497     "b25ba91487ec945410deb2b51bc1156890c032a8",
498     "d347ca5c6c4b6a61389247c3b6f61564033e8c25",
499     "ee315634ed92da3a32c2675ecd1b369471c60936",
500     "6776e0612410e7e200c853721b4ab6ad8b6b81f5",
501     "620a5a520d81971a2d9c30b8d836ba696e11b8dd",
502     "354b92008a8409c62d0fa1dff1532c5943aa37a2",
503     "8dc9cb7deae5c24d1eae004d53893fa6caf4723c",
504     "cf311a96d41bd98fdbdfb5dfaac4ba1ba9b7d6da",
505     "bf5ec23456efe00e1e0931c17de9040ab2092858",
506     "0bbdf0a0489428f96e3c1d3e5305f9a893820852",
507     "9d86b1b2bbce90efd3c0b9fe20d23ffa3eeecd20",
508     "8f7a0af421101952e674f37154c1e8c4646ea2d2",
509     "e96b79bf88988b5694a04dfc3bd0029361b39801",
510     "d12284f58daabbd173dfae6c7e55fd5d822d89b4",
511     "09cb4ab070083144bed4271c0a2a34ccb6ed13c0",
512     "cc5ed4c9e925f0a457a7437fbb8054528cdd9469",
513     "c95afd0a020e68a76982fe8663b5d64113987233",
514     "48658ff76c137185c56a53f3ccf0e958d0296742",
515     NULL
516 };
517
518 static const char *sha1_graphics_r5g5b5[] =
519 {
520     "2a2ab8b3c019e70b788ade028b0e9e53ffc529ae",
521     "847005cf7371f511bcc837251cde07b1796f6113",
522     "a8f75743a930843ec14d516cd048b6e0468e5d89",
523     "d094f51ce9b9daa9c1d9594ea88be2a2db651459",
524     "cf3928e240c9149788e1635b115a4e5baea0dd8f",
525     "a9034a905daa91757b4f63345c0e40638cd53ca8",
526     "15ee915d989e49bb9bab5b834d8f355bd067cd8f",
527     "99474fecf11df7b7035c35be6b8b697be9889418",
528     "cbc2898717f97ebb07c0c7cc04abde936dc5b584",
529     "29c896b591fdf4ddd23e5c0da1818c37e4686d94",
530     "4b5b275d33c1ebfe5bdc61df2ad125e865b800fa",
531     "92df731fa1f89550d9d4f7ea36c13f2e57c4b02a",
532     "420e39ff3bdd04c4b6cc2c98e99cb7993c7a0de5",
533     "1fabf0fdd046857b1974e31c1c1764fa9d1a762f",
534     "449092689226a1172b6086ba1181d6b6d6499f26",
535     "1a92a60f190d33ef06d9decb56fd3fdd33f3af03",
536     "e61f5978c2e28c0c6d8f5eefe0f840c975586efc",
537     "897d16f4d6a6ddad685d23ed7828d4f676539b75",
538     "9d21bcfdeaf1ca5d47eb823bdefc24d7a95f4f56",
539     "6daaf945a955928c5c124c880522ca4634fb2343",
540     "12a288390d16e1efa99d4185301de48a4d433b14",
541     "ea92af2538b76f41a3a03eaa11ac395c9b6197c4",
542     "1d3af561605fd61433035600d8962cb8d266fdd0",
543     "3a50ce21b3563a604b4fc9f247a30f5a981f1ba6",
544     "d7d97e28ed316f6596c737eb83baa5948d86b673",
545     "ecc2991277d7314f55b00e0f284ae3703aeef81e",
546     "656bf3b7121bcd620a0a3ad488f0d66604824577",
547     "d7d8493b5fa7a3a8323d6ac84245093a79f052c1",
548     "df5dafe96e528c2cc7fd11e4934e298f53cec34b",
549     "a49530722328ae88fd765792ac0c657efbcce75d",
550     "aa46aa2226e3121eaefa9d0836418e0b69262d69",
551     "333f3f2cf3ff15736d59f92a33c45323d3987d6d",
552     "a6fd83542c3826132e88d3f5e304d604c0056fad",
553     "a8d6a5285a927ba3a3be34b06a06c70a20d4c1b3",
554     "e428d213ad02651287894f093413949dcb369208",
555     "7df915bedcc5951a1b6f828490f7dbb93212e835",
556     "645dc251d205139282b17eb7bece1055fff3bcd0",
557     "76215275593631f5900aad3616d725733dc39493",
558     "81655a550703849a616d4a16504bb9c6f999285f",
559     "573d65665d20f00d36d9782ae2b89772140524ab",
560     "619414c1b33ac60cb0c0de61df86245d472259b0",
561     "c3d4a1425e17de9e05e3f6dfc6a24c26bfd5ee12",
562     "2a66dae03890ff791eabb982949435adb19af02b",
563     "24ac219478ba406f30794550690486b14cbac5e8",
564     "2b28d20690dc92374ebecb5508f8fdc6c7581790",
565     "db8c34882ddd46716d14bbf569d530f80db65ed4",
566     "6c652ecce55e71fee16bc1c9b2c5ae4161bdd2ea",
567     "9b02173f424c098ea0f4cc5db9eb65f69263d127",
568     "a92942269911a88793b3460b6f2a2cd56e48eec1",
569     "059db9f0426b371e464ef3d30f1a4f4aa599e101",
570     "a52d6ceee5c2a04b4e059c0d49337a997cc17e40",
571     "aa4a0a4b7f2697aaf270c89874631974bd9d7183",
572     "585061e403d9cac1603a38af420efe87338f381a",
573     "8f447a3820c83662086dfa836da2205b0130fd5f",
574     "3772003c7fb420003512d0c437b3659d96d89ce4",
575     "dab47c9dc149e570045d699598b14a613bf319b3",
576     "2daca4d26a086ed34894693be0b0374402232809",
577     "e313ae8f7261b88999757ed0c6f26df85b4f01a5",
578     "47d0bab8664ae0aaa927495d07bb3537cce35f16",
579     "295ec16530126046790fb734e99f86f5b3b74ed8",
580     "d98b0561010606b55a1b9b85fbc93640f681d256",
581     "1c1499051860b7caa25173b328ca9c862f01dd1a",
582     "a655512753bc90e6d4eb3848f69e96db1ad348e5",
583     "2230f36f12d4becb242e2962fa1b3694db2496ca",
584     "d81e41a765d7a2d68073f5fde3f74f09df84001d",
585     "0de013c2c6aba9f99cbcf5f8cfd3212ded7ae72a",
586     "5950f7d00cd8692872377df0e869a7d5ea5e4420",
587     "fedc67d1b0797be5f40cd45280844f2b61d29b0a",
588     "7de23c68ca224818fdf127c5e96729dcd0de2b8b",
589     "a848b1b0293b05b3f9358a3ffcb21a2e5fdecf05",
590     "1a0fd0df17fa4c455a4a91cad30b5242f77fd233",
591     "af45bf81d119be5cf6845ad41191ba52637e65e9",
592     NULL
593 };
594
595 static const char *sha1_graphics_r4g4b4[] =
596 {
597     "2a2ab8b3c019e70b788ade028b0e9e53ffc529ae",
598     "cfa0ab83ee93283ad914c3748f0532da1697af1d",
599     "8bd18697d1ef27492805667a0bc956343ac08667",
600     "e8501c830321584474654f90e40eaf27dc21e6a8",
601     "d95ab10fcfb8447b41742e89f1ae8cd297a32fc4",
602     "821177710961d2cb5f7e7dfc0e06e767b6042753",
603     "667124365ffadeea1d8791bedda77a0c7b898de8",
604     "c9f23e684b600dea17575b4b17175fbd9106c3a9",
605     "7678876e50eae35d1eaa096aae25afaa0b864bf3",
606     "fb52b0c373a5f2a60b981604b120962942d2447a",
607     "5ab8dd07436681d762fa04ad7c6d71291c488924",
608     "0167981d9e1490a2ebd396ff7582f0943aa8e1b8",
609     "115a6bd382410a4a1d3c1fa71d8bf02536863e38",
610     "65c6d1228e3b6d63d42647f14217bc1658b70d9a",
611     "25fcb75aa687aac35b8f72640889fe92413e00c5",
612     "3bddf9d53e89560b083302b146cd33791b13d941",
613     "a81504498c7a7bb46340ce74476a42f70f2730b1",
614     "e61a4f2657a444d8c49f84fb944f9f847667bf2b",
615     "32b6e0aa79b7e96cd0ab2da167f6463c011023a8",
616     "1d283aa4d2b2114f7809fe59357d590c7c779aa7",
617     "29640e2ddd2d3016da14507c3ce9b2ce32f39bb4",
618     "57ebf8becac1524543da120e88e9cc57ecfdec49",
619     "e68ef3ffd7401244cdea79781eab12d7a5e8ca18",
620     "d591232bbc2592462c819a9486750f64180518fd",
621     "0e183a4c30b3da345129cffe33fe0fc593d8666b",
622     "f14d9a4bd8a365b7c8f068a0dad481b6eb2b178b",
623     "8933450132bf949ba4bc28626968425b5ed2867d",
624     "9928a8f28a66c00069a124f7171b248817005763",
625     "e4a9dcc3e565cd3a6b7087dd1433f3898bb9cdb2",
626     "eca4f9b16b3bddfd0735fdd792e0ccaadfb9ba49",
627     "233e588cf660e2c9b552cf02065cf63fa6655864",
628     "0740ff74dcd259d9a644ba51ad77ff0d40348951",
629     "a3345acaf272f2e288626906e3056cd0ced70499",
630     "957a86fbe8a96dd068db65e4e624a52bcc84af46",
631     "13b0f240054dc57ba0e2dfde74048496304a2c7f",
632     "51ef267eb9c15487c9430f505e8a6c929eb2170c",
633     "1b593d8e031d3b37fecf6f1df5a8f96c8e8bfef8",
634     "9dd123938b0a02601d8d458ecbd6535ddefea724",
635     "815a1e4fc7f3a00c2990c150e87eba0b13f66811",
636     "75ae8c80af4356a1a5eebde6608fbc31e8a95372",
637     "b89ae8de2d975b8adb263ace66fd953d29165a8b",
638     "e901ab4b20bc87370609d7ba1f21aa08abd9eced",
639     "e9105c6ed8355519e0cf2d2217ed7af43cec8ba0",
640     "3cbf5fffdd73f9639f3eb34ec1ab3055bc8618fb",
641     "8e2e70ade90711c4ac01352aa0373fce36ff5dc0",
642     "8c40d6d8e0c696c31f04c896e492a2a38703d870",
643     "e13c821c236ea0b67cca64c9da7be15e88fc712f",
644     "9af4907a8144458a73dbb7471784f8c3d9aeffcf",
645     "e4731b63d41f6b51e30752ea52d85c4a2938731b",
646     "f0acb3cfcda62e95bee5f7bc8830ffeb3dd7e5a7",
647     "07b10c3f191d0a93e5e5694aae37dcad407e10f5",
648     "f7900e60347029876ba55e8f0c4c02e89deb36b6",
649     "7d80b8289da8a65931f03c74a9ef0aff5f8eb551",
650     "a7a986097e5b553c71bd93fd0ec6037e6bd0f2d1",
651     "7587a9c87cab1eca827807f351bb67ca184d1ac5",
652     "b53ef0b5c674822e784903a9dbdd3b386d9f2350",
653     "5505d2ed20dc61ffe48832ecf5329162a5ceb734",
654     "9f72be4467219a345b1164205d1fbfda2d64271e",
655     "13d1634e03bc49cfe14a32278d9b1f5ddbb9be10",
656     "a79e4cc419b9e1735e275e2823da52875536943a",
657     "b0182002cb1f4fba9df3c21a4d046ab41ce7e9be",
658     "3830cd728c1e72837310940bcdac4e294d6c9843",
659     "f571c7c4aac92491017963032194690c0fa06b42",
660     "6fd751b7328c02954bce98bed94b3ce3c73db118",
661     "91d50b5a604d6c38aa0d08b9af995490f8ec246b",
662     "8585783d0373e9696b508776b6e6b18a80b09888",
663     "b53cde47b0e28063770d3b1328c3cc2f774a6300",
664     NULL
665 };
666
667 static const char *sha1_graphics_8_color[] =
668 {
669     "41728d7ff2bb425b5fc06521adeabf6cc73136f3",
670     "e313bb57f699587b0bae2f17f5da5d977e6f2a61",
671     "49024d6cbdf1614327dfda9eda17675e76805f7e",
672     "63ba8ab7e7996857d52d4c2b995cfcd304daf25f",
673     "92295ae66712df050cfd6cc9fd2fd4101784c5fc",
674     "84d85009d35ae10abbc435f3913422544105cea2",
675     "eae349c2a481d6e8bfdf9a7f4f49384a14716a5f",
676     "6c51068ca1db36d948eaa34aed4a44d2cd1e8b32",
677     "f3aa8d89430748178952de56643069d80b40aad6",
678     "bd5fed74e2f1b097ef4c20bd30edfc6ee11eeccd",
679     "0546b87bf5fbe1b8168eed5d4a20649be92734a1",
680     "52b1363e821bf604d9df260bfa97e26d428c33fd",
681     "108732d9909ee5f3542a9b90b3ad96ec82446ab9",
682     "06c76c53dcf3ba5e213d483e27d841404c9aa90a",
683     "ae8fcdbdd44ba58e9bd46a4c56eb54f37483913c",
684     "89711289be6d5c55734878410e4923d5cca9aca9",
685     "8355caf57d51ad4e14275943088392e37dc75d33",
686     "5992b2e331a0e0f752598cc8d083cbecb5f4dde6",
687     "6f0570da9dea7f043f678088f8362ee458cd79fa",
688     "940db409d4c3e5640275724f9e5f7c1a0d2e21b2",
689     "242ce86967ea62fa69c1e6f597ccbcf2f0b1602c",
690     "5092b22af85a08f10a2899888bb9d552f25f828e",
691     "f5dafef807237fe72c74c0bbd47c382ace45bfde",
692     "e91973be2651eeef568700463652838d8cbba976",
693     "1df851515ecf46df5c2d3279535c1763f72353dd",
694     "b68922915ebc2797d58deecf983f7d0cf9a5efbd",
695     "359bd76088a965bb0cee7c44800bc46b2638807e",
696     "e14e5734b33057b890368f3e9d482d9e5a0358c5",
697     "64205ccaa277e64eeea0c20e99900ac79858ca2c",
698     "2cdee35d43d62da09b4ddfddbd0948ddbb9fc48e",
699     "91f988f575338505ba8a40727865a8d3f2298624",
700     "d2b4557492ebb2e0f640a0a2f6fc3bdc8d8f36f9",
701     "421e8b608378e4f17774dd32ea6446fa0fa16f91",
702     "3b7488731da48635d86be551ab7c8c0f91c78219",
703     "4fd49cb49853ef950fd0b7e2e35718a71c8374c7",
704     "e15a355fc09bfd22267917898e2266168ff410e3",
705     "b9688566bddf18586787c00e68724e51e97dfb72",
706     "5e38e03310f1c66f2052af2a745d8c60515707c5",
707     "f994fb5019bf4c1a96eccf89af599eae0aa6b412",
708     "3a71ad6fef147067641e49a5f69b2454e3a5010d",
709     "ea10eac72830dcae19bcb16a076c2b21d844b5b6",
710     "6376234f542467e5887adfece62f753e998dc19d",
711     "add949d009217ef2b847e34772ba363e4be7b1b8",
712     "28fcf9f7d098c05de632ae38b2fe33b9635ad445",
713     "0b58666deb3615e912896a764e5c6475989e95e4",
714     "bf460cc44c0edee851d72587c8425c3f06a62c55",
715     "ea74c00c45569007383b632d7f1d2adc82645717",
716     "5ac22e1a33b0204fdc7a68d54ee94648e96079a0",
717     "284abed096637c80bb50844e393da9dd4b3f19ac",
718     "9dc776c5ab8256b1301c7d1da60544a9410e6715",
719     "a433c41c05b6db008a4cb2c52a321d027c6be1fe",
720     "46f772c2832b3aad584674db666bd63e48b4f338",
721     "a9f9ca0049235db51ab7359a5fc3d21be42d2aac",
722     "f3dc739da41fb299637c8660e8c46917ddcf87a8",
723     "eae47bf865d932f22a6e59b6fe8d041f220e1fbc",
724     "9ae38bb94c7b4c0c6dfebbee23d1de4db9b77488",
725     "678979a45126a76eb629992cd64734862f53a555",
726     "2f7ba8803604c032cb1a1228bc021f0f1c03e245",
727     "9b1cc7b24f8ce15db2af7f4aa8cde8687784dfa2",
728     "cc4a4cea622d825700bccef7d90a5a447d9ca39d",
729     "e58d9c0acf0219d0839e1dbd162e08a765ed7f0f",
730     "34ca0f9660e1889f9f2c0deb80535d3c4f349fa4",
731     "2c07272462c68cf5944b03e2aa049475b99143c5",
732     "07ca369fb875d37b9cf855045f528af1827edec4",
733     "5e9e3e71b06c5efe20f93b3838e745b40b878471",
734     "153ae5c9fc2a31b38c4878b25d9026b9f51f132d",
735     "488341e88810d737de0b26de4e4d4fa0e78eb482",
736     "bd1e7f40e3971e2ff6c5561286901193a1557527",
737     "5a42b7eeff8198e7b005e4afa4282e6ffb939906",
738     "d7ffa3893c6fa937569791cf49986518a4a4d96e",
739     "26bc25a011e2b60961ee9d6c6141d928ae24389b",
740     "8771d5ff7b93b9dd9d077e672b342235dfb28472",
741     "6a1f6e1d494bf6b0ece7af5fa164ebaadb3a19bd",
742     NULL
743 };
744
745 static const char *sha1_graphics_8_grayscale[] =
746 {
747     "41728d7ff2bb425b5fc06521adeabf6cc73136f3",
748     "df35491dd5038187c05bac06921402ba6d7773a8",
749     "c8cd6d34e011d5f9ca4b1190eec3b416e5e68e53",
750     "66a686ac22cd0ec326f2c97ef473781cabe9690b",
751     "9bddef7b97b8b03569f07011e66ddd67fe82d787",
752     "2a4cea20974bcfb92cf40b05746fc7eb465c4b0f",
753     "0a87689ca33f888f05dbfa21ddec11c069990d8b",
754     "8d0a92e6333e1b99591962e2def9bc9121111cf5",
755     "409c9f29f6fa2e312c8e0b4b3c59acb4d84d8717",
756     "1fbc234c28a8140965ad0fe30b4b799f6681e864",
757     "1fc709d5d3e55d5f96c451c209cd73c59dbfe733",
758     "96b6a32e057d5faeae57086cbb62a8e7b3e6e86f",
759     "aa66ea7c9b7214339858b9fc9bd4720d05e8c843",
760     "114bb377b4e78a1978e1ac09388c48861b5223a3",
761     "8d0a92e6333e1b99591962e2def9bc9121111cf5",
762     "9dc511d6947fe816185cdff93bf0cfe0349b72b4",
763     "eb4c14ee66b012187f5fe6a2ec28b6be956567c8",
764     "216388ddf6b563dd2058a9df65b40b6f72df1715",
765     "ad11e4b6979cf055e3bf1868112a7bef207385a4",
766     "47f72be971bd2d3399dabd018201f4f5075e96fe",
767     "de09d41c9ae4338fbfcfe9f8ed71d343537a6f3d",
768     "f39ab890a2b99d0c31e6e047f2315244972f5ffd",
769     "6e7baf7d328bc2c55366e32967a0db4d2f43ab82",
770     "15b991814d84d6aa252696dd0c6150ef88a8db3f",
771     "1cb52f2a4d17b9b0d8375d016aa8cf0677fcd29a",
772     "9a6cfd68523e40ea1d52847d7747da912cfe2ca9",
773     "b6785a410048bb85e7ea3f0492459972103c935e",
774     "82e641ebe47d9f8cc229b82b8315e69e52f812b1",
775     "15db343049e3a9b31addc5d2ffebc3fe91b39c51",
776     "a895daf1f20371d4d1c3f93c070124cc13e341c3",
777     "3ddc872384ed8f9eaef472aa14a1d79a2c3f3b04",
778     "0000000000000000000000000000000000000000",
779     "bd7d8c1cb4b2adc31cf8c7d39a4fa1e3ac7f2545",
780     "33fc8618ce62f5cdd9e06ad61e296f718a99899e",
781     "dcaa7fe030ae4d3029e38ca584047eeb2d17fe10",
782     "6d41e6168662e75baacf74d911d7419d54c8d73c",
783     "2404952157ba1519094a2da6bfbf2b0f1356432d",
784     "24caede65b40815a60b83c4edfa06bdc542388cd",
785     "650a51bedd1af92469d2950eb95220db35f95c6e",
786     "3f43aa11e6fccb747cc13224583fb2f951fee08c",
787     "04cea9753b575ecce8e55357eddfcec10ddfbbea",
788     "6b6f4b97f05e015eb37a5f6aff637235feacd030",
789     "1bd06e4e11929e5e91c3c9f20def639b20e731e8",
790     "d63a6086547e90d2ba84aaebfeae24f3ba0c04f1",
791     "85425940daf119125deb52421b2057acebe6d1cf",
792     "a3db92382cf0a4c7cafe52c27b1f41520aaa677d",
793     "9869b6f088822fb423996f9968e5a931301fc2c3",
794     "cdf63ab4ab32c2e8e27527a9588d0fb525f1c945",
795     "a7f81cf3326fa3608acc13cfce2f573912e9d745",
796     "f2ea92f523f8918b1d514a2d9555dcb4750273b4",
797     "e9c16e43a8f589ae85289c5c3ffea6b22fba1806",
798     "84a4bc0c2c5d36d016da4df95a5d8d6c8ce3ba6f",
799     "f543efc84e638afbaa456e629100f0274de1a35b",
800     "1bd2587399006eed0d46beff397d32081f6bc58e",
801     "f8a571de89ed82ffb9cbc041ce1eacb064be2853",
802     "640a49455acabca6954a7fbb6af4e872af342d11",
803     "589e7911e09332ee090371deae17b0120ff990b5",
804     "a1a941fa270cda48c648553ed4b427e16e96f8e0",
805     "f30a8d9f73ca043c5bfc18d9595e299fc0a39eec",
806     "fb63bbb2f944fb63ed2d7399f07b168740c1034b",
807     "3685c9ae95118a83db3569832c29753276fa1264",
808     "09640bad951c33e7d70a1fced83b1869f65b3fc5",
809     "cb9ea8137eca1450e049879772f5c11a0e11ff0a",
810     "a4b04ed35484de0de61832a8a28bbc7def645622",
811     "515897610714251dd3b54f54fe76a9ed3fd12c53",
812     "0ca8775d9a61ccc251d1e6f2e3cfd26a24ae24a2",
813     "17ae603c199a5d6695d198a7f36e6d7263990951",
814     "1918a33f59d3500204ffc573318a39e9ff754221",
815     "5449d1aef0d2d6af9ac3fd7adb32c23ddc9be1e2",
816     "55d302ece31a9b7fc4be4a07a53767ba210273e7",
817     "a6a29836291f9dbca85e25cee60f62ef5faca6d7",
818     "3494a23633405e46af96cb57715617fef1ac252e",
819     "5a3ae1da30d83cc157e6a4a5617c85598309f4ac",
820     "edc1ad2704452354aa6f79fac244a55b6f509c2e",
821     "87eab8f81fb2a036080e099760f628037f9306e7",
822     "a3eac75d30f681b3898ee469d368960529634d7d",
823     "cd5caeabdb71241766d24f038cfc5f1e91e11256",
824     "e2b393dc3f5833f7868668ea31369e90348768cd",
825     NULL
826 };
827
828 static const char *sha1_graphics_8[] =
829 {
830     "41728d7ff2bb425b5fc06521adeabf6cc73136f3",
831     "512246d4886ab889a090b167ba194577cb95272e",
832     "921e852d4564cb9e5ac15ff68b5207bebea871d1",
833     "9636b0ebefc443ea11949ccd28f6ca454277dd41",
834     "aa9050da55e6b6957c60b7d603fce539cb5c0048",
835     "e2b93aca15fb1233ac09a713dced1f4cd950b1e4",
836     "3e3a603fc26cc305aa27f88da7d2a3b0073877d8",
837     "390b2bf70daba36310683f46af9cd50b9a061396",
838     "82d21737e9a7247397a6c983a9b6d9a0452dd74d",
839     "2a8460af91675e01cbe9384eb6cd3eb2cb420960",
840     "1af53b1218ee9844fcda891b836d42f6b2f66bd5",
841     "da1cc34a9d9b779fc7849e03e214096026506464",
842     "5ba8f99ca034666effa556748c49a0f5a015125f",
843     "b67ba2f55659c75ac72c1112494461bb3086e1a4",
844     "73e2859ce849f756f954718ce3c90f02e31712b6",
845     "b1dff0f5dd233b44ee568878c5d3f8ae1d80c6d9",
846     "1f27dc1a1316fb7a4a78fe40fcd4bdae3aaad218",
847     "6e375e1485a1e45ac6ab10af49645d5fb2e76dff",
848     "cfc67c325c7cdf96d90af9b3cceb8d0504cbb3b0",
849     "7262364067e03c7fa498af1d59d228d6c63b460e",
850     "5241241a355a667ef0834049adf4218e8b3f16b8",
851     "db22d666690948eb966f75b796c72c7150a5c4b9",
852     "af21fb2645b568b049549de375584c4aa3055143",
853     "1f13ea0034db4b0ffa4ddcff9664fd892058f9cd",
854     "3caf512cfddfd463d0750cfe3cadb58548eb2ae8",
855     "4e5e7d5fd64818b2b3d3e793c88f603b699d2f0f",
856     "c4efce8f7ed2d380ea5dc6fe1ef8448a27827532",
857     "bdc0a354635b879871077c5b712570e469863c99",
858     "d599bf210423fe3adbb4f1de87d9360de97827d0",
859     "bae7c8b789e4e9b336c03c4daee3bce63fe039d9",
860     "cc01f17928f7780cefd423ea653b072eea723a1b",
861     "c005662a47f14c2f1b7c7fb3b0ef0fc390c6ea6a",
862     "675cde16a6ad2bcd8d7e72780b07a0ccd8d0393a",
863     "ea39ac62ca2f815a1d029340c6465994b6f03cb0",
864     "9a603513cd81acf70cf8b27b0d544e7f672e9d40",
865     "f4a334e69535de74ee5ed54be93a75120a66e54a",
866     "559fd1d15447745527c61fe43a94c6708bff3e39",
867     "995f77f2f53398399f09d1365cb4dfd105764e5c",
868     "61907a6685bba93077da40cfb28cf2ab74552fd2",
869     "122015e5e17c1c317c6e51c0e207826b606a4077",
870     "c21851589a5f8a45ea5f9bb3e72f4f88d0a6697d",
871     "8c609921d4a3ed89a994a75482b27496bf103cf5",
872     "eb2ce16a6ae251f4965135ee776776b5fc02c42c",
873     "66493ee117719e172f327a426af601996025f28c",
874     "acead2745fec0b6c817fa601353bdf2d197b64f7",
875     "a6b858b2d125c159529d3f3ec45b31925a79acff",
876     "1f1379089d7c6e8d733aaa4eaffbe02db6255b61",
877     "d83adc669c0dea0dc4812b93f998514b6f02d805",
878     "9e8ceb7c3cd68e043b6d875c8c84a1e394962412",
879     "9e996fc74eeef53f0a6c31aabb2edce6e103f189",
880     "6b8abd1785304d6531c1e4cc65c1ffcdcb2196a5",
881     "7d1bfff706b0713e53209407889f83a0da26a81d",
882     "31e667c2dbb81dcf81d01cb88f794e88ddb90ff2",
883     "31e667c2dbb81dcf81d01cb88f794e88ddb90ff2",
884     "465d9cd0a77ab4fcf035aa67544b2a26269e0b09",
885     "600d6b2713d5e4c0d90c02660245ed26c7ae3033",
886     "d4f3a5ea033adc405c44e1ca137dc908c606dad6",
887     "7103d428ec9a959778120fd6f0dc62dd608ddd63",
888     "bd28d77cd85b20a2384d6b25082cfd884bba683e",
889     "7e591ec8ae9bb61c3a443c93f071cab2b8978394",
890     "f81c70b6ee2d4690f9f7c797c66582b176f8dcef",
891     "d3f359cac7318ce09e0531d51c8c2b316cf3a23b",
892     "293c41a7ed923a4617560481ae8815cebf83701a",
893     "ec06b56f3abe277be42650ebd49dabeaae9e756d",
894     "750c923785ba2afb9ce597516c072f90f014bf95",
895     "80089132f8a11d86e8038f2f8e12dfba46624ee5",
896     "bde5a62a065c027561226fbec5155e938ba7f6b3",
897     "a6311d74fc058079a327abb536e69353be719925",
898     "fbaa8848a1d3896469c37fd43ab44233f5b875a3",
899     "0000000000000000000000000000000000000000",
900     "c2ac98ef716fd8a5ac8f08ce66293d9a96344337",
901     NULL
902 };
903
904 static const char *sha1_graphics_4[] =
905 {
906     "fa867e2976a549ecd3b1fa67df54963232fcef8c",
907     "256d742b4da96b373b4fa5663d0ad3b5faab5c8e",
908     "d96d8f4232b930bccd53b903b5efaf8c0bdb16f4",
909     "9401799e6116c35e5f0e5bdca07ea25316757a72",
910     "482ae2b0ef1d64752b5ef11cc7f35a33eb55d07c",
911     "dcfb3e01100b41c0f75a1c5f84b6de6b90138281",
912     "2505598845fa026ea7187582461efbf06cb6904f",
913     "3981a19363beca8f28d32a5928ac296fd22a5296",
914     "01404024ebb2c266d17d734059524d874491650f",
915     "c87bbff3f83b8ec11bb03cfa9bc9ee5166c4c7ef",
916     "f35c5d62853be78c5d39fb2f45200dc262aa8e18",
917     "46e94a55f5f58a6b915078d8ffdc725f53aab516",
918     "665bbbc749a5ffeedc0d62aef0661a5ce845b017",
919     "1f26a01730f67d40ea711a50d9d801bac15a642e",
920     "3b53d24178cfacba53103a44dfd5d072b15a6781",
921     "c52cfd57f26037723d37192722fc3a217f280c9e",
922     "e34da6500cf2e424d980714d92737cf6c31a7bda",
923     "d17f4358ae529f920960ed89e535902ee13b0033",
924     "0f44e12ecd1ea7e39433890443626d4fc35204a4",
925     "eb38683e812fd13dca971ba8f4cfd2b6820d3524",
926     "73bbc83f88f1aaa6df0158b63e70bb3165163163",
927     "0dc2690a5c58a2907a8ab06693ebfab6698172eb",
928     "df5f0d6574bdf1781754b5b9f98232a77e439e33",
929     "39c16648cf6c261be71a33cec41867f28e119b94",
930     "26ad5116562e7b58c76a26eaf521e2e40899e944",
931     "1bcc54eaf8e3c2b7c59ecccb23c240181d7ba8b8",
932     "4f827ca6927f15191588456f985bf29d2a3b3c24",
933     "e7de769c3d12ea9dd223bef4881c578823bec67e",
934     "6fb102d020e5554116feefc8482104f3ae2036d2",
935     "ae546ffd30b837afc7dfcb5c9ce4f01d15b35ddc",
936     "20c9eb3276c08fdce35755e349bec94b04929812",
937     "628d837163a25c6520f19c0602383176dbad528e",
938     "b5a12cff7100290ad43f5ed17a321b42de048893",
939     "b672afbeeafb44194a821f0def81a8892872937e",
940     "db0124045882b598feea192186cf7eb7a0387866",
941     "602d91471378fe24a2d0248bd8a92b624f099fea",
942     "e772873b87a0f55ea51a3da323f64bf8814c6703",
943     "21aa1ff238a2d78efed1aa658ac8fe21b1e64daa",
944     "1a579cd280422131c35e907a023ee0e80749b5a4",
945     "bbf027f506cbb80d359bf4892fcb75f816f2e446",
946     "ed44bded6b17df7fe92b191fd810d1aafbd55f52",
947     "a49bcb1ace42d548254d9e96d22088b1fe2e75b4",
948     "e2a21a965dfd0bd09f9270917f681610efc18ce7",
949     "3e411b004a5be84451860c6da6a4a1a482b77862",
950     "3b3d2f18fdc75e938ca43cc2d0b41fa67c1c5d36",
951     "7811c536a6527112b438a6413f3927f2c79086a7",
952     "525ef3615040225752a2fe646ab99ee64e360630",
953     "46760975993f9881b7bbe94123173e6a683d3f25",
954     "df5feb905a31c288008cf5e82d73ac818a160d82",
955     "df5feb905a31c288008cf5e82d73ac818a160d82",
956     "d8af3868c66c7d6dac35ec8ee0317b38a6910bb1",
957     "ec8e2aebfb4a1c28ebcd0e053b9e4d8638b50951",
958     "1a23839d71d2379ed4e709a5ae6c14639fbe3ab8",
959     "09f8416a780d80be61cbda3d8a05aee418d0ea00",
960     "28a6b9f7927e99e53cf46f0333d29168cb10e920",
961     "029552113292cc110fd6b7888e766628950aaeef",
962     "297f6ad15200bffbf15198324ee8f27a61a6f2d4",
963     "70cfa427a1a0d6f2232b1fd544905d48af69cb98",
964     "287ea7db721e641439888cb9f4bac3a5f16124eb",
965     "dd9eaa5325cdf250e89162ac84207978ebb6458e",
966     "42466aab11852741d937c1ff6f3bb711e58415a6",
967     "0663cf6330591fcf744aba96664e05d90243d07a",
968     "3024fa38333f83a639b0f0e6ac6d4b9868231157",
969     "6fe7d0d17b892032cfd171c3d7c365f030b5be38",
970     "7ae780dcc7cf04dda50648bfc07cc6a7a2f2189e",
971     "0000000000000000000000000000000000000000",
972     "9ab46e0c42f82dc73df8a55cbf881abd72397cec",
973     NULL
974 };
975
976 static const char *sha1_graphics_4_grayscale[] =
977 {
978     "fa867e2976a549ecd3b1fa67df54963232fcef8c",
979     "6611ea6cb24bcf34c5f3688d57e2874aecb39c24",
980     "5ab1d3f8f5938c5d20a2fa3237e319077b21e716",
981     "1c201d149c0bd886ff8a427ad513f15a70991174",
982     "44646e67842a4d055bea1fad0434e6e4a0eb5465",
983     "315189097a02024d2eae61d524c4de07a396aee7",
984     "73ac786015dea36ac466a6524dba757d5d238ece",
985     "6e328cc4d53627f034b23706d8bf26afe18512ae",
986     "3c5b90cfeafdc1c99c8c62317d07276fdf66803e",
987     "95e6f509bb1cf9981efc47a0878ab0bd983eb349",
988     "2e1bc3b00e4ecc62b03785533dc0faeeda38d53f",
989     "6448226859cab61a61c95d3ed5ed5f216b1bb120",
990     "7f1cb06597b14edbea03b860aec3cebc4ebc3d62",
991     "ec3879342b5a44f6de6efe946243ae5ade00980d",
992     "6e328cc4d53627f034b23706d8bf26afe18512ae",
993     "51b50968a3a0570d5ed690fe44ba1a78a4d62ce2",
994     "d5bab61f78ac3355aa2e0776b2d5d9d71d61e77b",
995     "fa47c5195405f6a0eefba3e3a60ad463c7ee94c7",
996     "b2bda683edef912957845a33edc055902a801fed",
997     "b067f0421cb2c83b218b8ab6edbede2ff5723b57",
998     "c8de76f9c0900e5f86c7584fe94d5749376b7b49",
999     "43ee3e187dda14b86aef12371041ae70313b5a65",
1000     "7fab79b7f1a5cb2ec31ed8eeaf213b3d8dcde4d8",
1001     "d4930552a7845111ffd9db57260be1ab97967c06",
1002     "afdf41fca7951c6dd6193320de1295f2c68fe52a",
1003     "f2f1f331fe6b1b31d7c9ddd37793b375fc01d3d4",
1004     "f0af0f1edcb837bdf1535c1f5e9988c21ae9bfd1",
1005     "0000000000000000000000000000000000000000",
1006     "71c4577baaf35f12f6707b1e2f78a1e8c0d41d0b",
1007     "9b7d6b12385bb9e1cd881758aff342bd5427432b",
1008     "6fdd5aa022da2a8af6f1d02b6072ebc068b4b600",
1009     "643fab30f1a59dc37f1e0f1a6006076fbf90a5fe",
1010     "6edbc0b95e9ae3348ce7d12c44f9c8082b5f2aa9",
1011     "9c0da52c4ceaa8fdfcff7351328dd520bb57e985",
1012     "f8224430462f6a93f85ef33b8aa7299525990708",
1013     "1cf93cecc942b41ab8fae21ea18418a6d64873e5",
1014     "d58b8760ef01c12e691651c932d683c66fde3654",
1015     "94438c82b8812fe81a69d5d1429c5967cdbfed7a",
1016     "764ea26f10fe11f7bdb538a26fc33d44b3a95d6d",
1017     "94ad53c578f6034dfc5c666e363203cdfb00f2cc",
1018     "8cd7b0ba8426db344b4cb8820890603020ed65e9",
1019     "ad96132f25ca14e1aeb17c86f8d187febf6401c9",
1020     "027b05bc82ce4f897c4bf812610a641547368939",
1021     "3f131e855ba1611d8fb0f16a6979f8f56aacc7f3",
1022     "ae64d1dc52dcfa8c644f953c4601fa2fbefec37b",
1023     "2f3fb1bd8f416198d70e06f6d519571cd5eb4ef4",
1024     "cc96ccaf6b99f60a49b03017515f83cba22b4c40",
1025     "5eeb56afea8040a8fb18c11f29931b836474126d",
1026     "a3405c085fc2f2184bcd0d1edcdcc66927e33659",
1027     "f8681c09f1abfc38d31e47622cb8798cd896a00e",
1028     "b5ee51cfc73acb59a2f6124509ea236f8fc7f9f7",
1029     "d374d4d92c940ae42a9b42c14d744341b68a8c14",
1030     "43560b856907f552df3b9dd1f91e1aa8ab9ff17e",
1031     "8cefa6dcb658487d0715598d5d120677dbfdab42",
1032     "ada3b7c34946e584dcdf4203e07cfa3dad02bc63",
1033     "c2f61571b067a44b30f56b4658c9606f0edfc0f3",
1034     "58f400c9bb78e49a879276fb049edfc9c981740a",
1035     "cb3794f676d6e9502f27172ac7d79a12ca2ba32c",
1036     "aa89612798fbc4e11a73b6233c0ac4832e6af2f9",
1037     "c96a998be5c1d588ef1243cfd2610d056d16947e",
1038     "68bee638d59a373f33f308751471b3ef41849582",
1039     "be0501175cc3cbb61217fca76356f761117fb40f",
1040     "8fa37e26cdae406c2d1c81b1175dcf0311cf60c9",
1041     "3efe128a5bf250f2c460664e8f543f5ec54d5dc2",
1042     "2d5123e757cf00e423a89160d7dc4997c3688829",
1043     "0000000000000000000000000000000000000000",
1044     "36dfdad9f3f5cfde6add3cef23368c343d30469a",
1045     NULL
1046 };
1047
1048 static const char *sha1_graphics_1[] =
1049 {
1050     "23366004515f3bc46796ea505d748f8d0f97fbe1",
1051     "ad674a4104c6a1eacaee8f20effdfe31775b4409",
1052     "a7cc69f957d7b533a0a330859a143d701daac73c",
1053     "a955bf088c5edb129289ce65caace48ec95632e4",
1054     "5316d3c558c254479883133cf58cd07ab521d3f0",
1055     "fcbfdb5d60716ea05f2d1896fae7a6e7a8249d35",
1056     "2c140b39cc8d21358fded8959cd655f03d7f0f89",
1057     "121423a38b4ac4743bd516e0a7e88a3863796313",
1058     "7c17635c6c7f62dbf8fd4773d0c503358553d2c7",
1059     "21d5d9e47bb07de2cf7bc99b7725390d03a6cde6",
1060     "f69ee65ea25676429a28eea79b5b9cb9206b8d01",
1061     "39ff81f77ef4ee772367ed1a63785987c060126e",
1062     "4c686508a994ca4c7a0a73b8c0fe52423c180d9c",
1063     "b0cc1f5e244ae0c0835a9866a46abdfcd56d1cb1",
1064     "7ddf19df5bbdf4475b6ec1bc042425e382502864",
1065     "144c9a846e5e37ac6efd5ed3a97ec231479e8fca",
1066     "c5ffc59048bf786b5646ad6226cd8633965de9ef",
1067     "40fadc2d24c713b04ff96f7dc26e70e85f26c55e",
1068     "400a21caa01e015096ee1afcf1b54e7f8ec515bd",
1069     "0ff4b49797e30e3555aab45219adf449a9a560ff",
1070     "280327328ca940c212ce24fe72e0b00014072767",
1071     "144c9a846e5e37ac6efd5ed3a97ec231479e8fca",
1072     "b85463875f755b85f1464b1b6275912bcbad6c9f",
1073     "816f200969feecc788b61dfeecf05b1790984401",
1074     "a4964d8bbf80fe785f906bc0f7c5b113242a58fc",
1075     "a5d204cc7342d40b765ca042f8668e22601c4ff9",
1076     "adb2818f6d3845dd140bc0f9abdbaa89d2a8c3de",
1077     "0a76e0121facb103857130bc6e12185ad77fc3fa",
1078     "02aede714773d654d0fc2f640afaa133ec718ad5",
1079     "13cc63972aee4f6ae27091a8af18de01f1d3a5da",
1080     "3bb745ccb08402ce6fac6ee26fb8d7aad2dba27e",
1081     "b26699f62661e16a1dc452d24c88ce363a1f2998",
1082     "4d95c3d1e170f004c80aa8c52feafb8e0e90760e",
1083     "c14832e69ec3585c15987b3d69d5007236fa9814",
1084     "e44ea620b0c47125a34193537ab9d219a52ad028",
1085     "ef2db9fb75a672f69bab88e5d08fe64f50ec2bc4",
1086     "df81db2a9b3942a82e0dc5e57247b642f9b42702",
1087     "8819bf7a43295161fe045a42936000b3a51fe200",
1088     "e08dbc26469c229f75ccbf1a38a133401f270b84",
1089     "d1e6091caa4482d3142df3b958606c41ebf4698e",
1090     "07c1116d8286fb665a1005de220eadc3d5999aaf",
1091     "4afb0649488f6e6f7d3a2b8bf438d82f2c88f4d1",
1092     "f2fe295317e795a88edd0b2c52618b8cb0e7f2ce",
1093     "ffc78c075d4be66806f6c59180772d5eed963dc0",
1094     "c86eeaeed09871dee4b43722ba512d2d3af7f4d0",
1095     "24b1a6241c81dbb950cfbe5da6798fd59eb36266",
1096     "1007d3b531b4bc3553d4547bc88443fc1f497cf6",
1097     "b71ca46be287598f716bb04fac0a52ad139c70db",
1098     "6589e48498e30ab036fbfe94d73427b2b1238a69",
1099     "4dce919117d2e41df9f5d4d0de14f97ae650046d",
1100     "22c2e078f69d73b7a5cb3f7dcbb8fbaa007ef3ac",
1101     "be36cda370650e6d5fb0570aeb8ced491d0c2b1c",
1102     "4c34cb8e47f9ff4b4348aa2d40cce7cb54d65cb0",
1103     "18f4497e43903e8df5b27da4ceebf62b15550a87",
1104     "3fa3570a2ebd38042b90f24bd3496233bca5a23d",
1105     "2fcd25c2d19a01fa631fd19135d9f28b26b86259",
1106     "655cfadeb157233c804d42b58195569c8846e3c1",
1107     "65c8811c609203fd424f5ed5f92ca2268a1dca54",
1108     "a45b297d709e297584eb0f2985294ec0ab53d8ad",
1109     "0d180c37bc26d83a1a11f66168757f3de2493243",
1110     "b362ba4790def178c236c0ae7b0093dbba47cf24",
1111     "d1d2ecf71a37d9eda58fa09454aa871971428ace",
1112     "6672da4e016b6e9de0ca218f8307cce7d48d62c4",
1113     "ee22f43ea867228c6ff937d39e1826e285a107e8",
1114     "832c3c3afd056e5d1cdfb2f466f27225c4adcc6c",
1115     "a2a928de9007d765da496abec8c21b23601f8c45",
1116     "28ded40e72d4327b9413571476b167fb28a1f420",
1117     "23366004515f3bc46796ea505d748f8d0f97fbe1",
1118     "88763f8e8fcf4f78fa864325791a9dd35a0bd279",
1119     "013cee26bac8f815eadad4bfc012d9b5d01c3b7f",
1120     "44a28536466dc895feb824b23dfd4a47c6948af8",
1121     "f0316a5765a0404760e94cd05b7dc956cae07d26",
1122     "781d8c5cbc28591fd48fce06f984c502fdc6b363",
1123     "df510792a7790cc699532b1420d43c6d4da2ae2f",
1124     "55c26d22f11d80b73383fa57d0fac552d705b092",
1125     "14443b33a9879bf829ed3b06e1aef0d7dcf662cc",
1126     "53ab1fcccd09fa5cbff77497f36a70a3b3cb8b81",
1127     "4842a30dd7fdf38ddc3ddec85c08efe13a0e2e0b",
1128     "cc76db6da5ba1776f20240a5ad97a26a9cdf96b0",
1129     "014f477664a7f4ce4a948d6359a2707119afc8e2",
1130     "1ee4e951743efc8764249fbc7adecefbfec0428e",
1131     "9ab50a663b74577b656e9849484a909d7ac52eeb",
1132     "128eefd2ee043d59dc37918065f687e378e5ca95",
1133     "c642abc651f525332d9d635049646d309e877839",
1134     "8d34215487088b5d4ef63062270ce25c2862643d",
1135     "3dc3075b0c87fdcaabbbae8928303fb2358c15c2",
1136     "bbae6f0659e095a42b420082079663f937065813",
1137     "ca711c69165e1fa5be72993b9a7870ef6d485249",
1138     NULL
1139 };
1140
1141 static const RECT graphics_bounds[] =
1142 {
1143     { 0, 0, 0, 0 },
1144     { 10, 3, 219, 101 },
1145     { 100, 100, 301, 301 },
1146     { 0, 0, 201, 201 },
1147     { 10, 10, 110, 320 },
1148     { 10, 99, 300, 200 },
1149     { 99, 12, 201, 200 },
1150     { 90, 110, 300, 200 },
1151     { 90, 90, 210, 200 },
1152     { 10, 99, 300, 200 },
1153     { 10, 99, 300, 200 },
1154     { 99, 12, 201, 200 },
1155     { 99, 11, 201, 200 },
1156     { 90, 110, 300, 200 },
1157     { 90, 110, 300, 200 },
1158     { 10, 10, 365, 405 },
1159     { 10, 10, 365, 405 },
1160     { 10, 10, 365, 405 },
1161     { 10, 10, 365, 405 },
1162     { 10, 10, 365, 405 },
1163     { 10, 10, 365, 405 },
1164     { 10, 10, 365, 405 },
1165     { 10, 10, 365, 405 },
1166     { 10, 10, 350, 251 },
1167     { 10, 10, 300, 200 },
1168     { 300, 10, 9, 260 },
1169     { 10, 10, 435, 405 },
1170     { 10, 10, 120, 120 },
1171     { 10, 10, 110, 110 },
1172     { 10, 10, 120, 110 },
1173     { 10, 10, 110, 120 },
1174     { 10, 10, 120, 120 },
1175     { 10, 10, 110, 110 },
1176     { 10, 10, 120, 110 },
1177     { 10, 10, 110, 120 },
1178     { 100, 100, 356, 356 },
1179     { 100, 100, 356, 356 },
1180     { 50, 50, 306, 306 },
1181     { 100, 100, 356, 356 },
1182     { 100, 100, 356, 356 },
1183     { 100, 100, 356, 356 },
1184     { 100, 100, 356, 356 },
1185     { 100, 100, 356, 356 },
1186     { 100, 100, 356, 356 },
1187     { 100, 100, 356, 356 },
1188     { 100, 100, 356, 356 },
1189     { 100, 100, 356, 356 },
1190     { 100, 100, 356, 356 },
1191     { 100, 100, 356, 356 },
1192     { 10, 10, 416, 26 },
1193     { 10, 8, 60, 104 },
1194     { 0, 10, 511, 306 },
1195     { 0, 10, 512, 306 },
1196     { 1, 1, 300, 512 },
1197     { 0, 0, 500, 512 },
1198     { 5, 5, 206, 206 },
1199     { 45, 45, 256, 256 },
1200     { 86, 86, 215, 215 },
1201     { 45, 45, 256, 256 },
1202     { 8, 0, 392, 231 },
1203     { 8, 0, 392, 231 },
1204     { 0, 0, 60, 20 },
1205     { 0, 0, 512, 512 },
1206     { -1, -1, -1, -1 }  /* the end */
1207 };
1208
1209 static const char **current_sha1;
1210 static const RECT *current_bounds;
1211 static const char *dst_format;
1212
1213 static inline DWORD get_stride(BITMAPINFO *bmi)
1214 {
1215     return ((bmi->bmiHeader.biBitCount * bmi->bmiHeader.biWidth + 31) >> 3) & ~3;
1216 }
1217
1218 static inline DWORD get_dib_size(BITMAPINFO *bmi)
1219 {
1220     return get_stride(bmi) * abs(bmi->bmiHeader.biHeight);
1221 }
1222
1223 static char *hash_dib(BITMAPINFO *bmi, void *bits)
1224 {
1225     DWORD dib_size = get_dib_size(bmi);
1226     HCRYPTHASH hash;
1227     char *buf;
1228     BYTE hash_buf[20];
1229     DWORD hash_size = sizeof(hash_buf);
1230     int i;
1231     static const char *hex = "0123456789abcdef";
1232
1233     if(!crypt_prov) return NULL;
1234
1235     if(!CryptCreateHash(crypt_prov, CALG_SHA1, 0, 0, &hash)) return NULL;
1236
1237     CryptHashData(hash, bits, dib_size, 0);
1238
1239     CryptGetHashParam(hash, HP_HASHVAL, NULL, &hash_size, 0);
1240     if(hash_size != sizeof(hash_buf)) return NULL;
1241
1242     CryptGetHashParam(hash, HP_HASHVAL, hash_buf, &hash_size, 0);
1243     CryptDestroyHash(hash);
1244
1245     buf = HeapAlloc(GetProcessHeap(), 0, hash_size * 2 + 1);
1246
1247     for(i = 0; i < hash_size; i++)
1248     {
1249         buf[i * 2] = hex[hash_buf[i] >> 4];
1250         buf[i * 2 + 1] = hex[hash_buf[i] & 0xf];
1251     }
1252     buf[i * 2] = '\0';
1253
1254     return buf;
1255 }
1256
1257 static void reset_bounds( HDC hdc )
1258 {
1259     current_bounds = graphics_bounds;
1260     SetBoundsRect( hdc, NULL, DCB_RESET | DCB_ENABLE );
1261 }
1262
1263 static void compare_bounds( HDC hdc, const char *info )
1264 {
1265     RECT rect;
1266
1267     GetBoundsRect( hdc, &rect, DCB_RESET );
1268
1269     if (current_bounds->left == -1 &&
1270         current_bounds->top == -1 &&
1271         current_bounds->right == -1 &&
1272         current_bounds->bottom == -1)
1273     {
1274         ok( 0, "missing bounds, got { %d, %d, %d, %d },\n", rect.left, rect.top, rect.right, rect.bottom );
1275         return;
1276     }
1277
1278     ok( !memcmp( current_bounds, &rect, sizeof(RECT) ),
1279         "%s: %s: expected bounds %d,%d,%d,%d got %d,%d,%d,%d\n", dst_format, info,
1280         current_bounds->left, current_bounds->top, current_bounds->right, current_bounds->bottom,
1281         rect.left, rect.top, rect.right, rect.bottom );
1282     current_bounds++;
1283 }
1284
1285 static void skip_compare( int count )
1286 {
1287     current_sha1 += count;
1288     current_bounds++;
1289 }
1290
1291 static void compare_hash_broken_todo(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char *info, int num_broken, BOOL todo)
1292 {
1293     char *hash = hash_dib(bmi, bits);
1294     BOOL ok_cond;
1295     int i;
1296
1297     /* reset the bits for the next test */
1298     memset( bits, 0xcc, get_dib_size(bmi) );
1299
1300     if(!hash)
1301     {
1302         skip("SHA1 hashing unavailable on this platform\n");
1303         return;
1304     }
1305
1306     for(i = 0; i <= num_broken; i++)
1307     {
1308         if(current_sha1[i] == NULL)
1309         {
1310             ok(current_sha1[i] != NULL, "missing hash, got \"%s\",\n", hash);
1311             return;
1312         }
1313     }
1314
1315     ok_cond = !strcmp(hash, *current_sha1);
1316
1317     for(i = 1; i <= num_broken; i++)
1318         ok_cond = ok_cond || broken( !strcmp(hash, current_sha1[i]) );
1319
1320     if(todo)
1321         todo_wine ok( ok_cond, "%s: %s: expected hash %s got %s\n",
1322                       dst_format, info, *current_sha1, hash );
1323     else
1324         ok( ok_cond, "%s: %s: expected hash %s got %s\n",
1325             dst_format, info, *current_sha1, hash );
1326
1327     current_sha1 += num_broken + 1;
1328
1329     HeapFree(GetProcessHeap(), 0, hash);
1330
1331     compare_bounds( hdc, info );
1332 }
1333
1334 static void compare_hash(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char *info)
1335 {
1336     compare_hash_broken_todo(hdc, bmi, bits, info, 0, FALSE);
1337 }
1338
1339 static const RECT bias_check[] =
1340 {
1341     {100, 100, 200, 150},
1342     {100, 100, 150, 200},
1343     {100, 100,  50, 200},
1344     {100, 100,   0, 150},
1345     {100, 100,   0,  50},
1346     {100, 100,  50,   0},
1347     {100, 100, 150,   0},
1348     {100, 100, 200,  50}
1349 };
1350
1351 static const RECT hline_clips[] =
1352 {
1353     {120, 120, 140, 120}, /* unclipped */
1354     {100, 122, 140, 122}, /* l edgecase */
1355     { 99, 124, 140, 124}, /* l edgecase clipped */
1356     {120, 126, 200, 126}, /* r edgecase */
1357     {120, 128, 201, 128}, /* r edgecase clipped */
1358     { 99, 130, 201, 130}, /* l and r clipped */
1359     {120, 100, 140, 100}, /* t edgecase */
1360     {120,  99, 140,  99}, /* t edgecase clipped */
1361     {120, 199, 140, 199}, /* b edgecase */
1362     {120, 200, 140, 200}, /* b edgecase clipped */
1363     {120, 132, 310, 132}, /* inside two clip rects */
1364     { 10, 134, 101, 134}, /* r end on l edgecase */
1365     { 10, 136, 100, 136}, /* r end on l edgecase clipped */
1366     {199, 138, 220, 138}, /* l end on r edgecase */
1367     {200, 140, 220, 140}  /* l end on r edgecase clipped */
1368 };
1369
1370 static const RECT vline_clips[] =
1371 {
1372     {120, 120, 120, 140}, /* unclipped */
1373     {100, 120, 100, 140}, /* l edgecase */
1374     { 99, 120,  99, 140}, /* l edgecase clipped */
1375     {199, 120, 199, 140}, /* r edgecase */
1376     {200, 120, 200, 140}, /* r edgecase clipped */
1377     {122,  99, 122, 201}, /* t and b clipped */
1378     {124, 100, 124, 140}, /* t edgecase */
1379     {126,  99, 126, 140}, /* t edgecase clipped */
1380     {128, 120, 128, 200}, /* b edgecase */
1381     {130, 120, 130, 201}, /* b edgecase clipped */
1382     {132,  12, 132, 140}, /* inside two clip rects */
1383     {134,  90, 134, 101}, /* b end on t edgecase */
1384     {136,  90, 136, 100}, /* b end on t edgecase clipped */
1385     {138, 199, 138, 220}, /* t end on b edgecase */
1386     {140, 200, 140, 220}  /* t end on b edgecase clipped */
1387 };
1388
1389 static const RECT line_clips[] =
1390 {
1391     { 90, 110, 310, 120},
1392     { 90, 120, 295, 130},
1393     { 90, 190, 110, 240}, /* totally clipped, moving outcodes */
1394     { 90, 130, 100, 135}, /* totally clipped, end pt on l edge */
1395     { 90, 132, 101, 137}, /* end pt just inside l edge */
1396     {200, 140, 210, 141}, /* totally clipped, start pt on r edge */
1397     {199, 142, 210, 143}  /* start pt just inside r edge */
1398 };
1399
1400 static const RECT wide_lines[] =
1401 {
1402     {100,  10, 200,  10},
1403     {100,  21, 200,  21},
1404     {200,  40, 100,  40},
1405     {200,  61, 100,  61},
1406     { 10, 100,  10, 200},
1407     { 21, 100,  21, 200},
1408     { 40, 200,  40, 100},
1409     { 61, 200,  61, 100},
1410 };
1411
1412 static const POINT poly_lines[] =
1413 {
1414     {100, 100}, {200, 100}, {200, 200}, {100, 200}
1415 };
1416
1417 static const POINT polypoly_lines[] =
1418 {
1419     {100, 100}, {200, 100}, {200, 100}, {200, 200}
1420 };
1421
1422 static const DWORD polypoly_counts[] =
1423 {
1424     sizeof(polypoly_lines)/sizeof(polypoly_lines[0])
1425 };
1426
1427 static const RECT patblt_clips[] =
1428 {
1429     {120, 120, 140, 126}, /* unclipped */
1430     {100, 130, 140, 136}, /* l edgecase */
1431     { 99, 140, 140, 146}, /* l edgecase clipped */
1432     {180, 130, 200, 136}, /* r edgecase */
1433     {180, 140, 201, 146}, /* r edgecase clipped */
1434     {120, 100, 130, 110}, /* t edgecase */
1435     {140,  99, 150, 110}, /* t edgecase clipped */
1436     {120, 180, 130, 200}, /* b edgecase */
1437     {140, 180, 150, 201}, /* b edgecase */
1438     {199, 150, 210, 156}, /* l edge on r edgecase */
1439     {200, 160, 210, 166}, /* l edge on r edgecase clipped */
1440     { 90, 150, 101, 156}, /* r edge on l edgecase */
1441     { 90, 160, 100, 166}, /* r edge on l edgecase clipped */
1442     {160,  90, 166, 101}, /* b edge on t edgecase */
1443     {170,  90, 176, 101}, /* b edge on t edgecase clipped */
1444     {160, 199, 166, 210}, /* t edge on b edgecase */
1445     {170, 200, 176, 210}, /* t edge on b edgecase clipped */
1446 };
1447
1448 static const RECT rectangles[] =
1449 {
1450     {10,   11, 100, 101},
1451     {250, 100, 350,  10},
1452     {120,  10, 120,  20}, /* zero width */
1453     {120,  10, 130,  10}, /* zero height */
1454     {120,  40, 121,  41}, /* 1 x 1 */
1455     {130,  50, 132,  52}, /* 2 x 2 */
1456     {140,  60, 143,  63}, /* 3 x 3 */
1457     {150,  70, 154,  74}, /* 4 x 4 */
1458     {120,  20, 121,  30}, /* width == 1 */
1459     {130,  20, 132,  30}, /* width == 2 */
1460     {140,  20, 143,  30}, /* width == 3 */
1461     {200,  20, 210,  21}, /* height == 1 */
1462     {200,  30, 210,  32}, /* height == 2 */
1463     {200,  40, 210,  43}  /* height == 3 */
1464 };
1465
1466 static const BITMAPINFOHEADER dib_brush_header_8888 = {sizeof(BITMAPINFOHEADER), 16, -16, 1, 32, BI_RGB, 0, 0, 0, 0, 0};
1467 static const BITMAPINFOHEADER dib_brush_header_24   = {sizeof(BITMAPINFOHEADER), 16, -16, 1, 24, BI_RGB, 0, 0, 0, 0, 0};
1468 static const BITMAPINFOHEADER dib_brush_header_555  = {sizeof(BITMAPINFOHEADER), 16, -16, 1, 16, BI_RGB, 0, 0, 0, 0, 0};
1469 static const BITMAPINFOHEADER dib_brush_header_8    = {sizeof(BITMAPINFOHEADER), 16, -16, 1,  8, BI_RGB, 0, 0, 0, 0, 0};
1470 static const BITMAPINFOHEADER dib_brush_header_4    = {sizeof(BITMAPINFOHEADER), 16, -16, 1,  4, BI_RGB, 0, 0, 0, 0, 0};
1471 static const BITMAPINFOHEADER dib_brush_header_1    = {sizeof(BITMAPINFOHEADER), 16, -16, 1,  1, BI_RGB, 0, 0, 0, 0, 0};
1472
1473 static const BYTE rle8_data[20] = { 0x03, 0x02, 0x04, 0xf0, 0x00, 0x00,     /* 2, 2, 2, f0, f0, f0, f0, <eol> */
1474                                     0x00, 0x03, 0x04, 0x05, 0x06, 0x00,     /* 4, 5, 6, <pad> */
1475                                     0x00, 0x02, 0x01, 0x02, 0x05, 0x80,     /* dx=1, dy=2, 80, 80, 80, 80, (80) */
1476                                     0x00, 0x01 };                           /* <eod> */
1477
1478 static const DWORD four_by_four_data[16] = { 0x000000, 0xff0000, 0x00ff00, 0x0000ff,
1479                                              0xffffff, 0x00ffff, 0xff00ff, 0xffff00,
1480                                              0x000000, 0xff0000, 0x00ff00, 0x0000ff,
1481                                              0xffffff, 0x00ffff, 0xff00ff, 0xffff00 };
1482
1483 static const DWORD ddb_brush_bits[8] = { 0x11112222, 0x33334444, 0x55556666, 0x77778888,
1484                                          0xaaaaaaaa, 0x00000000, 0x98765432, 0xabcdef00 };
1485
1486 static inline void solid_patblt( HDC hdc, int x, int y, int width, int height, COLORREF color )
1487 {
1488     HBRUSH brush = CreateSolidBrush( color );
1489     brush = SelectObject( hdc, brush );
1490     PatBlt( hdc, x, y, width, height, PATCOPY );
1491     DeleteObject( SelectObject( hdc, brush ) );
1492 }
1493
1494 static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits)
1495 {
1496     char pal_buffer[sizeof(LOGPALETTE) + 255 * sizeof(PALETTEENTRY)];
1497     LOGPALETTE *pal = (LOGPALETTE *)pal_buffer;
1498     PALETTEENTRY *entries = pal->palPalEntry;
1499     HPEN solid_pen, dashed_pen, wide_pen, orig_pen;
1500     LOGBRUSH log_brush;
1501     HBRUSH solid_brush, dib_brush, hatch_brush, orig_brush;
1502     HBITMAP bmp;
1503     INT i, j, x, y, hatch_style;
1504     HDC src_dc;
1505     HRGN hrgn, hrgn2;
1506     BYTE dib_src_buf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)];
1507     BYTE dib_brush_buf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD) + 16 * 16 * sizeof(DWORD)]; /* Enough for 16 x 16 at 32 bpp */
1508     BITMAPINFO *src_bi = (BITMAPINFO*)dib_src_buf;
1509     BITMAPINFO *brush_bi = (BITMAPINFO*)dib_brush_buf;
1510     RGBQUAD *brush_colors = brush_bi->bmiColors;
1511     BYTE *brush_bits, *src_bits;
1512     BOOL ret, dib_is_1bpp = (bmi->bmiHeader.biBitCount == 1);
1513     BOOL dib_is_8bpp_gray = (bmi->bmiHeader.biBitCount == 8 && bmi->bmiColors[1].rgbRed == 1);
1514     BLENDFUNCTION blend;
1515     COLORREF old_text, old_bkgnd;
1516     HPALETTE hpal;
1517
1518     blend.BlendOp = AC_SRC_OVER;
1519     blend.BlendFlags = 0;
1520
1521     reset_bounds( hdc );
1522
1523     memset(bits, 0xcc, get_dib_size(bmi));
1524     compare_hash(hdc, bmi, bits, "empty");
1525
1526     src_dc = CreateCompatibleDC( 0 );
1527     solid_pen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0xff));
1528     orig_pen = SelectObject(hdc, solid_pen);
1529     SetBrushOrgEx(hdc, 0, 0, NULL);
1530
1531     /* horizontal and vertical lines */
1532     for(i = 1; i <= 16; i++)
1533     {
1534         SetROP2(hdc, i);
1535         MoveToEx(hdc, 10, i * 3, NULL);
1536         LineTo(hdc, 100, i * 3); /* l -> r */
1537         MoveToEx(hdc, 100, 50 + i * 3, NULL);
1538         LineTo(hdc, 10, 50 + i * 3); /* r -> l */
1539         MoveToEx(hdc, 120 + i * 3, 10, NULL);
1540         LineTo(hdc, 120 + i * 3, 100); /* t -> b */
1541         MoveToEx(hdc, 170 + i * 3, 100, NULL);
1542         LineTo(hdc, 170 + i * 3, 10); /* b -> t */
1543     }
1544     compare_hash(hdc, bmi, bits, "h and v solid lines");
1545
1546     /* diagonal lines */
1547     SetROP2(hdc, R2_COPYPEN);
1548     for(i = 0; i < 16; i++)
1549     {
1550         double s = sin(M_PI * i / 8.0);
1551         double c = cos(M_PI * i / 8.0);
1552
1553         MoveToEx(hdc, 200.5 + 10 * c, 200.5 + 10 * s, NULL);
1554         LineTo(hdc, 200.5 + 100 * c, 200.5 + 100 * s);
1555     }
1556     compare_hash(hdc, bmi, bits, "diagonal solid lines");
1557
1558     for(i = 0; i < sizeof(bias_check) / sizeof(bias_check[0]); i++)
1559     {
1560         MoveToEx(hdc, bias_check[i].left, bias_check[i].top, NULL);
1561         LineTo(hdc, bias_check[i].right, bias_check[i].bottom);
1562     }
1563     compare_hash(hdc, bmi, bits, "more diagonal solid lines");
1564
1565     /* solid brush PatBlt */
1566     solid_brush = CreateSolidBrush(RGB(0x33, 0xaa, 0xff));
1567     orig_brush = SelectObject(hdc, solid_brush);
1568
1569     for(i = 0, y = 10; i < 256; i++)
1570     {
1571         ret = PatBlt(hdc, 10, y, 100, 10, rop3[i]);
1572
1573         if(rop_uses_src(rop3[i]))
1574             ok(ret == FALSE, "got TRUE for %x\n", rop3[i]);
1575         else
1576         {
1577             ok(ret, "got FALSE for %x\n", rop3[i]);
1578             y += 20;
1579         }
1580
1581     }
1582     compare_hash(hdc, bmi, bits, "solid patblt");
1583
1584     /* clipped lines */
1585     hrgn = CreateRectRgn(10, 10, 200, 20);
1586     hrgn2 = CreateRectRgn(100, 100, 200, 200);
1587     CombineRgn(hrgn, hrgn, hrgn2, RGN_OR);
1588     SetRectRgn(hrgn2, 290, 100, 300, 200);
1589     CombineRgn(hrgn, hrgn, hrgn2, RGN_OR);
1590     ExtSelectClipRgn(hdc, hrgn, RGN_COPY);
1591     DeleteObject(hrgn2);
1592
1593     for(i = 0; i < sizeof(hline_clips)/sizeof(hline_clips[0]); i++)
1594     {
1595         MoveToEx(hdc, hline_clips[i].left, hline_clips[i].top, NULL);
1596         LineTo(hdc, hline_clips[i].right, hline_clips[i].bottom);
1597     }
1598     compare_hash(hdc, bmi, bits, "clipped solid hlines");
1599
1600     for(i = 0; i < sizeof(vline_clips)/sizeof(vline_clips[0]); i++)
1601     {
1602         MoveToEx(hdc, vline_clips[i].left, vline_clips[i].top, NULL);
1603         LineTo(hdc, vline_clips[i].right, vline_clips[i].bottom);
1604     }
1605     compare_hash(hdc, bmi, bits, "clipped solid vlines");
1606
1607     for(i = 0; i < sizeof(line_clips)/sizeof(line_clips[0]); i++)
1608     {
1609         MoveToEx(hdc, line_clips[i].left, line_clips[i].top, NULL);
1610         LineTo(hdc, line_clips[i].right, line_clips[i].bottom);
1611     }
1612     compare_hash(hdc, bmi, bits, "clipped solid diagonal lines");
1613
1614     /* clipped PatBlt */
1615     for(i = 0; i < sizeof(patblt_clips) / sizeof(patblt_clips[0]); i++)
1616     {
1617         PatBlt(hdc, patblt_clips[i].left, patblt_clips[i].top,
1618                patblt_clips[i].right - patblt_clips[i].left,
1619                patblt_clips[i].bottom - patblt_clips[i].top, PATCOPY);
1620     }
1621     compare_hash(hdc, bmi, bits, "clipped patblt");
1622
1623     /* clipped dashed lines */
1624     dashed_pen = CreatePen(PS_DASH, 1, RGB(0xff, 0, 0));
1625     SelectObject(hdc, dashed_pen);
1626     SetBkMode(hdc, TRANSPARENT);
1627     SetBkColor(hdc, RGB(0, 0xff, 0));
1628
1629     for(i = 0; i < sizeof(hline_clips)/sizeof(hline_clips[0]); i++)
1630     {
1631         MoveToEx(hdc, hline_clips[i].left, hline_clips[i].top, NULL);
1632         LineTo(hdc, hline_clips[i].right, hline_clips[i].bottom);
1633     }
1634     compare_hash(hdc, bmi, bits, "clipped dashed hlines");
1635
1636     for(i = 0; i < sizeof(hline_clips)/sizeof(hline_clips[0]); i++)
1637     {
1638         MoveToEx(hdc, hline_clips[i].right - 1, hline_clips[i].bottom, NULL);
1639         LineTo(hdc, hline_clips[i].left - 1, hline_clips[i].top);
1640     }
1641     compare_hash(hdc, bmi, bits, "clipped dashed hlines r -> l");
1642
1643     for(i = 0; i < sizeof(vline_clips)/sizeof(vline_clips[0]); i++)
1644     {
1645         MoveToEx(hdc, vline_clips[i].left, vline_clips[i].top, NULL);
1646         LineTo(hdc, vline_clips[i].right, vline_clips[i].bottom);
1647     }
1648     compare_hash(hdc, bmi, bits, "clipped dashed vlines");
1649
1650     for(i = 0; i < sizeof(vline_clips)/sizeof(vline_clips[0]); i++)
1651     {
1652         MoveToEx(hdc, vline_clips[i].right, vline_clips[i].bottom - 1, NULL);
1653         LineTo(hdc, vline_clips[i].left, vline_clips[i].top - 1);
1654     }
1655     compare_hash(hdc, bmi, bits, "clipped dashed vlines b -> t");
1656
1657     for(i = 0; i < sizeof(line_clips)/sizeof(line_clips[0]); i++)
1658     {
1659         MoveToEx(hdc, line_clips[i].left, line_clips[i].top, NULL);
1660         LineTo(hdc, line_clips[i].right, line_clips[i].bottom);
1661     }
1662     compare_hash(hdc, bmi, bits, "clipped dashed diagonal lines");
1663
1664     SetBkMode(hdc, OPAQUE);
1665
1666     for(i = 0; i < sizeof(line_clips)/sizeof(line_clips[0]); i++)
1667     {
1668         MoveToEx(hdc, line_clips[i].left, line_clips[i].top, NULL);
1669         LineTo(hdc, line_clips[i].right, line_clips[i].bottom);
1670     }
1671     compare_hash(hdc, bmi, bits, "clipped opaque dashed diagonal lines");
1672
1673     ExtSelectClipRgn(hdc, NULL, RGN_COPY);
1674
1675     /* 8888 DIB pattern brush */
1676
1677     brush_bi->bmiHeader = dib_brush_header_8888;
1678     brush_bits = (BYTE*)brush_bi + sizeof(BITMAPINFOHEADER);
1679     memset(brush_bits, 0, 16 * 16 * sizeof(DWORD));
1680     brush_bits[2] = 0xff;
1681     brush_bits[6] = 0xff;
1682     brush_bits[14] = 0xff;
1683     brush_bits[65] = 0xff;
1684     brush_bits[69] = 0xff;
1685     brush_bits[72] = 0xff;
1686
1687     dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
1688
1689     SelectObject(hdc, dib_brush);
1690     SetBrushOrgEx(hdc, 1, 1, NULL);
1691
1692     for(i = 0, y = 10; i < 256; i++)
1693     {
1694         if(!rop_uses_src(rop3[i]))
1695         {
1696             ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
1697             ok(ret, "got FALSE for %x\n", rop3[i]);
1698             y += 25;
1699         }
1700     }
1701     if (bmi->bmiHeader.biBitCount == 8 && bmi->bmiHeader.biClrUsed == 256)  /* 8-bpp grayscale broken on NT4 */
1702         compare_hash_broken_todo(hdc, bmi, bits, "top-down 8888 dib brush patblt", 1, FALSE);
1703     else
1704         compare_hash_broken_todo(hdc, bmi, bits, "top-down 8888 dib brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp);
1705
1706     SelectObject(hdc, orig_brush);
1707     DeleteObject(dib_brush);
1708
1709     /* 8888 bottom-up DIB pattern brush */
1710
1711     brush_bi->bmiHeader.biHeight = -brush_bi->bmiHeader.biHeight;
1712
1713     dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
1714
1715     SelectObject(hdc, dib_brush);
1716
1717     /* This used to set the x origin to 100 as well, but
1718        there's a Windows bug for 24 bpp where the brush's x offset
1719        is incorrectly calculated for rops that involve both D and P */
1720     SetBrushOrgEx(hdc, 4, 100, NULL);
1721
1722     for(i = 0, y = 10; i < 256; i++)
1723     {
1724         if(!rop_uses_src(rop3[i]))
1725         {
1726             ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
1727             ok(ret, "got FALSE for %x\n", rop3[i]);
1728             y += 25;
1729         }
1730     }
1731     if (bmi->bmiHeader.biBitCount == 8 && bmi->bmiHeader.biClrUsed == 256)  /* 8-bpp grayscale broken on NT4 */
1732         compare_hash_broken_todo(hdc, bmi, bits, "bottom-up 8888 dib brush patblt", 1, FALSE);
1733     else
1734         compare_hash_broken_todo(hdc, bmi, bits, "bottom-up 8888 dib brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp);
1735
1736     SelectObject(hdc, orig_brush);
1737     DeleteObject(dib_brush);
1738
1739     /* 24 bpp dib pattern brush */
1740
1741     brush_bi->bmiHeader = dib_brush_header_24;
1742     brush_bits = (BYTE*)brush_bi + sizeof(BITMAPINFOHEADER);
1743     memset(brush_bits, 0, 16 * 16 * 3);
1744     brush_bits[0] = brush_bits[3] = brush_bits[6] = brush_bits[8] = 0xff;
1745     brush_bits[49] = brush_bits[52] = 0xff;
1746
1747     dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
1748
1749     SelectObject(hdc, dib_brush);
1750     SetBrushOrgEx(hdc, 1, 1, NULL);
1751
1752     for(i = 0, y = 10; i < 256; i++)
1753     {
1754         if(!rop_uses_src(rop3[i]))
1755         {
1756             ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
1757             ok(ret, "got FALSE for %x\n", rop3[i]);
1758             y += 25;
1759         }
1760     }
1761     if (bmi->bmiHeader.biBitCount == 8 && bmi->bmiHeader.biClrUsed == 256)  /* 8-bpp grayscale broken on NT4 */
1762         compare_hash_broken_todo(hdc, bmi, bits, "top-down 24 bpp brush patblt", 1, FALSE);
1763     else
1764         compare_hash_broken_todo(hdc, bmi, bits, "top-down 24 bpp brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp);
1765
1766     SelectObject(hdc, orig_brush);
1767     DeleteObject(dib_brush);
1768
1769     /* 555 dib pattern brush */
1770
1771     brush_bi->bmiHeader = dib_brush_header_555;
1772     brush_bits = (BYTE*)brush_bi + sizeof(BITMAPINFOHEADER);
1773     memset(brush_bits, 0, 16 * 16 * sizeof(WORD));
1774     brush_bits[0] = brush_bits[1] = 0xff;
1775     brush_bits[32] = brush_bits[34] = 0x7c;
1776
1777     dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
1778
1779     SelectObject(hdc, dib_brush);
1780     SetBrushOrgEx(hdc, 1, 1, NULL);
1781
1782     for(i = 0, y = 10; i < 256; i++)
1783     {
1784         if(!rop_uses_src(rop3[i]))
1785         {
1786             ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
1787             ok(ret, "got FALSE for %x\n", rop3[i]);
1788             y += 25;
1789         }
1790     }
1791     if (bmi->bmiHeader.biBitCount == 8 && bmi->bmiHeader.biClrUsed == 256)  /* 8-bpp grayscale broken on NT4 */
1792         compare_hash_broken_todo(hdc, bmi, bits, "top-down 555 dib brush patblt", 1, FALSE);
1793     else
1794         compare_hash_broken_todo(hdc, bmi, bits, "top-down 555 dib brush patblt", dib_is_1bpp ? 1 : 0, dib_is_1bpp);
1795
1796     SelectObject(hdc, orig_brush);
1797     DeleteObject(dib_brush);
1798
1799     SetBrushOrgEx(hdc, 0, 0, NULL);
1800
1801     /* 8 bpp dib pattern brush */
1802
1803     brush_bi->bmiHeader = dib_brush_header_8;
1804     brush_bi->bmiHeader.biClrUsed = 3;
1805     memset(brush_colors, 0, brush_bi->bmiHeader.biClrUsed * sizeof(RGBQUAD));
1806     brush_colors[0].rgbRed = 0xff;
1807     brush_colors[1].rgbRed = 0xff;
1808     brush_colors[1].rgbGreen = 0xff;
1809     brush_colors[1].rgbBlue = 0xff;
1810
1811     brush_bits = (BYTE*)brush_bi + sizeof(BITMAPINFOHEADER) + brush_bi->bmiHeader.biClrUsed * sizeof(RGBQUAD);
1812     memset(brush_bits, 0, 16 * 16 * sizeof(BYTE));
1813     brush_bits[0] = brush_bits[1] = 1;
1814     brush_bits[16] = brush_bits[17] = 2;
1815     brush_bits[32] = brush_bits[33] = 6;
1816
1817     dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
1818
1819     SelectObject(hdc, dib_brush);
1820     SetBrushOrgEx(hdc, 1, 1, NULL);
1821
1822     for(i = 0, y = 10; i < 256; i++)
1823     {
1824         if(!rop_uses_src(rop3[i]))
1825         {
1826             ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
1827             ok(ret, "got FALSE for %x\n", rop3[i]);
1828             y += 25;
1829         }
1830     }
1831     compare_hash_broken_todo(hdc, bmi, bits, "top-down 8 bpp dib brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp);
1832
1833     SelectObject(hdc, orig_brush);
1834     DeleteObject(dib_brush);
1835
1836     /* 4 bpp dib pattern brush */
1837
1838     brush_bi->bmiHeader = dib_brush_header_4;
1839     dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
1840
1841     SelectObject(hdc, dib_brush);
1842     SetBrushOrgEx(hdc, 1, 1, NULL);
1843
1844     for(i = 0, y = 10; i < 256; i++)
1845     {
1846         if(!rop_uses_src(rop3[i]))
1847         {
1848             ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
1849             ok(ret, "got FALSE for %x\n", rop3[i]);
1850             y += 25;
1851         }
1852     }
1853     compare_hash_broken_todo(hdc, bmi, bits, "top-down 4 bpp dib brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp);
1854
1855     SelectObject(hdc, orig_brush);
1856     DeleteObject(dib_brush);
1857
1858     /* 1 bpp dib pattern brush */
1859
1860     brush_bi->bmiHeader = dib_brush_header_1;
1861     brush_bi->bmiHeader.biClrUsed = 2;
1862     memset(brush_bits, 0, 16 * 4);
1863     brush_bits[0] = 0xf0;
1864     brush_bits[4] = 0xf0;
1865     brush_bits[8] = 0xf0;
1866
1867     dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
1868     SelectObject(hdc, dib_brush);
1869     for(i = 0, y = 10; i < 256; i++)
1870     {
1871         if(!rop_uses_src(rop3[i]))
1872         {
1873             ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
1874             ok(ret, "got FALSE for %x\n", rop3[i]);
1875             y += 25;
1876         }
1877     }
1878
1879     compare_hash_broken_todo(hdc, bmi, bits, "top-down 1 bpp dib brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp);
1880
1881     SelectObject(hdc, orig_brush);
1882     DeleteObject(dib_brush);
1883
1884     /* 1 bpp ddb pattern brush */
1885
1886     old_text = GetTextColor( hdc );
1887     old_bkgnd = GetBkColor( hdc );
1888     bmp = CreateBitmap( 16, 16, 1, 1, ddb_brush_bits );
1889     dib_brush = CreatePatternBrush( bmp );
1890     SelectObject(hdc, dib_brush);
1891     for(i = 0, y = 10; i < 256; i++)
1892     {
1893         SetTextColor(hdc, RGB( i, 2*i, 255 - i ) );
1894         SetBkColor(hdc, RGB( 255 - i, i / 3, i ) );
1895         if(!rop_uses_src(rop3[i]))
1896         {
1897             ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
1898             ok(ret, "got FALSE for %x\n", rop3[i]);
1899             y += 25;
1900         }
1901     }
1902
1903     compare_hash_broken_todo(hdc, bmi, bits, "1 bpp ddb brush patblt", dib_is_1bpp ? 3 : 0, dib_is_1bpp);
1904
1905     DeleteObject(bmp);
1906     SelectObject(hdc, orig_brush);
1907     DeleteObject( dib_brush );
1908     SetBrushOrgEx(hdc, 0, 0, NULL);
1909     SetTextColor(hdc, old_text);
1910     SetBkColor(hdc, old_bkgnd);
1911
1912     /* Rectangle */
1913
1914     SelectObject(hdc, solid_pen);
1915     SelectObject(hdc, solid_brush);
1916
1917     for(i = 0; i < sizeof(rectangles)/sizeof(rectangles[0]); i++)
1918     {
1919         Rectangle(hdc, rectangles[i].left, rectangles[i].top, rectangles[i].right, rectangles[i].bottom);
1920     }
1921
1922     SelectObject(hdc, dashed_pen);
1923     for(i = 0; i < sizeof(rectangles)/sizeof(rectangles[0]); i++)
1924     {
1925         Rectangle(hdc, rectangles[i].left, rectangles[i].top + 150, rectangles[i].right, rectangles[i].bottom + 150);
1926     }
1927
1928     compare_hash(hdc, bmi, bits, "rectangles");
1929     SelectObject(hdc, solid_pen);
1930
1931     /* PaintRgn */
1932
1933     PaintRgn(hdc, hrgn);
1934     compare_hash(hdc, bmi, bits, "PaintRgn");
1935
1936     /* RTL rectangles */
1937
1938     if( !pSetLayout )
1939     {
1940         win_skip("Don't have SetLayout\n");
1941         skip_compare(1);
1942     }
1943     else
1944     {
1945         pSetLayout(hdc, LAYOUT_RTL);
1946         PaintRgn(hdc, hrgn);
1947         PatBlt(hdc, 10, 250, 10, 10, PATCOPY);
1948         Rectangle(hdc, 100, 250, 110, 260);
1949         compare_hash(hdc, bmi, bits, "rtl");
1950
1951         pSetLayout(hdc, LAYOUT_LTR);
1952     }
1953     DeleteObject( hrgn );
1954
1955     for(i = 0, y = 10; i < 256; i++)
1956     {
1957         if(!rop_uses_src(rop3[i]))
1958         {
1959             for(hatch_style = HS_HORIZONTAL; hatch_style <= HS_DIAGCROSS; hatch_style++)
1960             {
1961                 hatch_brush = CreateHatchBrush(hatch_style, RGB(0xff, 0, 0));
1962                 SelectObject(hdc, hatch_brush);
1963                 ret = PatBlt(hdc, 10 + i + 30 * hatch_style, y, 20, 20, rop3[i]);
1964                 ok(ret, "got FALSE for %x\n", rop3[i]);
1965                 SelectObject(hdc, orig_brush);
1966                 DeleteObject(hatch_brush);
1967             }
1968             y += 25;
1969         }
1970     }
1971
1972     compare_hash_broken_todo(hdc, bmi, bits, "hatch brushes", 1, FALSE); /* nt4 is different */
1973
1974     /* overlapping blits */
1975
1976     orig_brush = SelectObject(hdc, solid_brush);
1977
1978     Rectangle(hdc, 10, 10, 100, 100);
1979     Rectangle(hdc, 20, 15, 30, 40);
1980     Rectangle(hdc, 15, 15, 20, 20);
1981     Rectangle(hdc, 15, 20, 50, 45);
1982     BitBlt( hdc, 20, 20, 100, 100, hdc, 10, 10, SRCCOPY );
1983     compare_hash(hdc, bmi, bits, "overlapping BitBlt SRCCOPY +x, +y");
1984
1985     Rectangle(hdc, 10, 10, 100, 100);
1986     Rectangle(hdc, 20, 15, 30, 40);
1987     Rectangle(hdc, 15, 15, 20, 20);
1988     Rectangle(hdc, 15, 20, 50, 45);
1989     BitBlt( hdc, 10, 10, 100, 100, hdc, 20, 20, SRCCOPY );
1990     if (bmi->bmiHeader.biBitCount == 1)  /* Windows gets this one wrong */
1991         compare_hash_broken_todo(hdc, bmi, bits, "overlapping BitBlt SRCCOPY -x, -y",1, FALSE);
1992     else
1993         compare_hash(hdc, bmi, bits, "overlapping BitBlt SRCCOPY -x, -y");
1994
1995     Rectangle(hdc, 10, 10, 100, 100);
1996     Rectangle(hdc, 20, 15, 30, 40);
1997     Rectangle(hdc, 15, 15, 20, 20);
1998     Rectangle(hdc, 15, 20, 50, 45);
1999     BitBlt( hdc, 20, 10, 100, 100, hdc, 10, 20, SRCCOPY );
2000     compare_hash(hdc, bmi, bits, "overlapping BitBlt SRCCOPY +x, -y");
2001
2002     Rectangle(hdc, 10, 10, 100, 100);
2003     Rectangle(hdc, 20, 15, 30, 40);
2004     Rectangle(hdc, 15, 15, 20, 20);
2005     Rectangle(hdc, 15, 20, 50, 45);
2006     BitBlt( hdc, 10, 20, 100, 100, hdc, 20, 10, SRCCOPY );
2007     if (bmi->bmiHeader.biBitCount == 1)  /* Windows gets this one wrong */
2008         compare_hash_broken_todo(hdc, bmi, bits, "overlapping BitBlt SRCCOPY -x, +y", 1, FALSE );
2009     else
2010         compare_hash(hdc, bmi, bits, "overlapping BitBlt SRCCOPY -x, +y" );
2011
2012     Rectangle(hdc, 10, 10, 100, 100);
2013     Rectangle(hdc, 20, 15, 30, 40);
2014     Rectangle(hdc, 15, 15, 20, 20);
2015     Rectangle(hdc, 15, 20, 50, 45);
2016     BitBlt( hdc, 20, 20, 100, 100, hdc, 10, 10, PATPAINT );
2017     compare_hash(hdc, bmi, bits, "overlapping BitBlt PATPAINT +x, +y");
2018
2019     Rectangle(hdc, 10, 10, 100, 100);
2020     Rectangle(hdc, 20, 15, 30, 40);
2021     Rectangle(hdc, 15, 15, 20, 20);
2022     Rectangle(hdc, 15, 20, 50, 45);
2023     BitBlt( hdc, 10, 10, 100, 100, hdc, 20, 20, PATPAINT );
2024     compare_hash(hdc, bmi, bits, "overlapping BitBlt PATPAINT -x, -y");
2025
2026     Rectangle(hdc, 10, 10, 100, 100);
2027     Rectangle(hdc, 20, 15, 30, 40);
2028     Rectangle(hdc, 15, 15, 20, 20);
2029     Rectangle(hdc, 15, 20, 50, 45);
2030     BitBlt( hdc, 20, 10, 100, 100, hdc, 10, 20, PATPAINT );
2031     if (bmi->bmiHeader.biBitCount >= 24)  /* Windows gets this one wrong */
2032         compare_hash_broken_todo(hdc, bmi, bits, "overlapping BitBlt PATPAINT +x, -y", 1, FALSE);
2033     else
2034         compare_hash(hdc, bmi, bits, "overlapping BitBlt PATPAINT +x, -y");
2035
2036     Rectangle(hdc, 10, 10, 100, 100);
2037     Rectangle(hdc, 20, 15, 30, 40);
2038     Rectangle(hdc, 15, 15, 20, 20);
2039     Rectangle(hdc, 15, 20, 50, 45);
2040     BitBlt( hdc, 10, 20, 100, 100, hdc, 20, 10, PATPAINT );
2041     compare_hash(hdc, bmi, bits, "overlapping BitBlt PATPAINT -x, +y" );
2042
2043     /* blitting with 32-bpp BI_RGB source */
2044
2045     memset( dib_src_buf, 0, sizeof(dib_src_buf) );
2046     src_bi->bmiHeader.biSize = sizeof(bmi->bmiHeader);
2047     src_bi->bmiHeader.biHeight = 256;
2048     src_bi->bmiHeader.biWidth = 256;
2049     src_bi->bmiHeader.biBitCount = 32;
2050     src_bi->bmiHeader.biPlanes = 1;
2051     src_bi->bmiHeader.biCompression = BI_RGB;
2052     bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2053     SelectObject( src_dc, bmp );
2054     for (y = 0; y < 256; y++)
2055         for (x = 0; x < 256; x++)
2056         {
2057             BYTE a = (x + y) * 2;
2058             BYTE r = (BYTE)(y + 2 * x) * a / 255;
2059             BYTE g = (BYTE)(x + y / 3) * a / 255;
2060             BYTE b = (BYTE)(x / 3 + 2 * y) * a / 255;
2061             ((DWORD *)src_bits)[y * 256 + x] = (a << 24) | RGB( r, g, b );
2062         }
2063
2064     BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2065     if (bmi->bmiHeader.biBitCount == 8)  /* broken on NT4 */
2066         compare_hash_broken_todo(hdc, bmi, bits, "BitBlt src 32-bpp SRCCOPY", 1, FALSE );
2067     else
2068         compare_hash(hdc, bmi, bits, "BitBlt src 32-bpp SRCCOPY" );
2069
2070     blend.SourceConstantAlpha = 0xd0;
2071     blend.AlphaFormat = 0;
2072     if (pGdiAlphaBlend) pGdiAlphaBlend( hdc, 100, 100, 256, 256, src_dc, 0, 0, 256, 256, blend );
2073     if (bmi->bmiHeader.biBitCount == 16 && bmi->bmiHeader.biCompression == BI_RGB) /* 555 broken on w2k */
2074     {
2075         if (!pGdiAlphaBlend) skip_compare(2);
2076         else compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 32-bpp no alpha", 1, FALSE );
2077     }
2078     else
2079     {
2080         if (!pGdiAlphaBlend) skip_compare(1);
2081         else compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 32-bpp no alpha", 0, dib_is_1bpp );
2082     }
2083
2084     blend.SourceConstantAlpha = 0xb0;
2085     blend.AlphaFormat = AC_SRC_ALPHA;
2086     if (pGdiAlphaBlend) pGdiAlphaBlend( hdc, 50, 50, 256, 256, src_dc, 0, 0, 256, 256, blend );
2087     if (bmi->bmiHeader.biBitCount == 16 && bmi->bmiHeader.biCompression == BI_RGB) /* 555 broken on w2k */
2088     {
2089         if (!pGdiAlphaBlend) skip_compare(2);
2090         else compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 32-bpp alpha", 1, FALSE );
2091     }
2092     else
2093     {
2094         if (!pGdiAlphaBlend) skip_compare(1);
2095         else compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 32-bpp alpha", 0, dib_is_1bpp );
2096     }
2097
2098     /* blitting with 32-bpp r10g10b10 source */
2099
2100     src_bi->bmiHeader.biBitCount = 32;
2101     src_bi->bmiHeader.biCompression = BI_BITFIELDS;
2102     ((DWORD *)src_bi->bmiColors)[0] = 0x3ff00000;
2103     ((DWORD *)src_bi->bmiColors)[1] = 0x000ffc00;
2104     ((DWORD *)src_bi->bmiColors)[2] = 0x000003ff;
2105     bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2106     SelectObject( src_dc, bmp );
2107     for (y = 0; y < 256; y++)
2108         for (x = 0; x < 256; x++)
2109         {
2110             WORD r = (7 * x + 3 * y) % 1024;
2111             WORD g = (11 * x + y / 3) % 1024;
2112             WORD b = (x / 3 + 9 * y) % 1024;
2113             ((DWORD *)src_bits)[y * 256 + x] = r << 20 | g << 10 | b;
2114         }
2115
2116     BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2117     if (bmi->bmiHeader.biBitCount == 8)  /* broken on NT4 */
2118         compare_hash_broken_todo(hdc, bmi, bits, "BitBlt src 32-bpp r10g10b10 SRCCOPY", 1, FALSE );
2119     else
2120         compare_hash(hdc, bmi, bits, "BitBlt src 32-bpp r10g10b10 SRCCOPY" );
2121
2122     /* blitting with 32-bpp b6g6r6 source */
2123
2124     src_bi->bmiHeader.biBitCount = 32;
2125     src_bi->bmiHeader.biCompression = BI_BITFIELDS;
2126     ((DWORD *)src_bi->bmiColors)[0] = 0x00003f;
2127     ((DWORD *)src_bi->bmiColors)[1] = 0x000fc0;
2128     ((DWORD *)src_bi->bmiColors)[2] = 0x03f000;
2129     bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2130     SelectObject( src_dc, bmp );
2131     for (y = 0; y < 256; y++)
2132         for (x = 0; x < 256; x++)
2133         {
2134             BYTE r = (y + 2 * x) % 64;
2135             BYTE g = (x + y / 3) % 64;
2136             BYTE b = (x / 3 + 2 * y) % 64;
2137             ((DWORD *)src_bits)[y * 256 + x] = r | g << 6 | b << 12;
2138         }
2139
2140     BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2141     if (bmi->bmiHeader.biBitCount == 8)  /* broken on NT4 */
2142         compare_hash_broken_todo(hdc, bmi, bits, "BitBlt src 32-bpp b6g6r6 SRCCOPY", 1, FALSE );
2143     else
2144         compare_hash(hdc, bmi, bits, "BitBlt src 32-bpp b6g6r6 SRCCOPY" );
2145
2146     /* blitting with 24-bpp source */
2147
2148     src_bi->bmiHeader.biBitCount = 24;
2149     src_bi->bmiHeader.biCompression = BI_RGB;
2150     bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2151     DeleteObject( SelectObject( src_dc, bmp ) );
2152     for (y = 0; y < 256; y++)
2153         for (x = 0; x < 256; x++)
2154         {
2155             src_bits[(y * 256 + x) * 3 + 0] = x + 3 * y;
2156             src_bits[(y * 256 + x) * 3 + 1] = 2 * x + 7 * y;
2157             src_bits[(y * 256 + x) * 3 + 2] = 5 * x + 12 * y;
2158         }
2159
2160     BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2161     if (bmi->bmiHeader.biBitCount == 8)  /* broken on NT4 */
2162         compare_hash_broken_todo(hdc, bmi, bits, "BitBlt src 24-bpp SRCCOPY", 1, FALSE );
2163     else
2164         compare_hash(hdc, bmi, bits, "BitBlt src 24-bpp SRCCOPY" );
2165
2166     blend.SourceConstantAlpha = 0xe0;
2167     blend.AlphaFormat = 0;
2168     if (pGdiAlphaBlend) pGdiAlphaBlend( hdc, 100, 100, 256, 256, src_dc, 0, 0, 256, 256, blend );
2169     if (bmi->bmiHeader.biBitCount == 16 && bmi->bmiHeader.biCompression == BI_RGB) /* 555 broken on w2k */
2170     {
2171         if (!pGdiAlphaBlend) skip_compare(2);
2172         else compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 24-bpp", 1, FALSE );
2173     }
2174     else
2175     {
2176         if (!pGdiAlphaBlend) skip_compare(1);
2177         else compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 24-bpp", 0, dib_is_1bpp );
2178     }
2179
2180     /* blitting with 16-bpp BI_RGB source */
2181
2182     src_bi->bmiHeader.biBitCount = 16;
2183     src_bi->bmiHeader.biCompression = BI_RGB;
2184     bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2185     DeleteObject( SelectObject( src_dc, bmp ) );
2186     for (y = 0; y < 256; y++)
2187         for (x = 0; x < 256; x++)
2188             ((WORD *)src_bits)[y * 256 + x] = x | x << 4 | x << 8 | y << 3 | y << 7;
2189
2190     BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2191     if (bmi->bmiHeader.biBitCount == 8 && bmi->bmiHeader.biClrUsed > 5)  /* broken on NT4 */
2192         compare_hash_broken_todo(hdc, bmi, bits, "BitBlt src 16-bpp SRCCOPY", 1, FALSE );
2193     else
2194         compare_hash(hdc, bmi, bits, "BitBlt src 16-bpp SRCCOPY" );
2195
2196     /* blitting with 16-bpp b4g4r4 source */
2197
2198     src_bi->bmiHeader.biBitCount = 16;
2199     src_bi->bmiHeader.biCompression = BI_BITFIELDS;
2200     ((DWORD *)src_bi->bmiColors)[0] = 0x00000f;
2201     ((DWORD *)src_bi->bmiColors)[1] = 0x0000f0;
2202     ((DWORD *)src_bi->bmiColors)[2] = 0x000f00;
2203     bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2204     DeleteObject( SelectObject( src_dc, bmp ) );
2205     for (y = 0; y < 256; y++)
2206         for (x = 0; x < 256; x++)
2207             ((WORD *)src_bits)[y * 256 + x] = x | x << 4 | x << 8 | y << 3 | y << 7;
2208
2209     BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2210     if (bmi->bmiHeader.biBitCount == 8 && bmi->bmiHeader.biClrUsed > 5)  /* broken on NT4 */
2211         compare_hash_broken_todo(hdc, bmi, bits, "BitBlt src 16-bpp b4g4r4 SRCCOPY", 1, FALSE );
2212     else
2213         compare_hash(hdc, bmi, bits, "BitBlt src 16-bpp b4g4r4 SRCCOPY" );
2214
2215     /* blitting with 8-bpp source */
2216
2217     src_bi->bmiHeader.biBitCount = 8;
2218     src_bi->bmiHeader.biCompression = BI_RGB;
2219     src_bi->bmiHeader.biClrUsed = 160;
2220     for (i = 0; i < 256; i++) ((DWORD *)src_bi->bmiColors)[i] = i | (i * 3) << 8 | (i / 2) << 16;
2221     bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2222     DeleteObject( SelectObject( src_dc, bmp ) );
2223     for (y = 0; y < 256; y++)
2224         for (x = 0; x < 256; x++)
2225             src_bits[y * 256 + x] = 3 * x + 5 * y;
2226
2227     BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2228     compare_hash(hdc, bmi, bits, "BitBlt src 8-bpp SRCCOPY" );
2229
2230     blend.SourceConstantAlpha = 0xd0;
2231     blend.AlphaFormat = 0;
2232     if (pGdiAlphaBlend) pGdiAlphaBlend( hdc, 100, 100, 256, 256, src_dc, 0, 0, 256, 256, blend );
2233     if (bmi->bmiHeader.biBitCount == 16 && bmi->bmiHeader.biCompression == BI_RGB) /* 555 broken on w2k */
2234     {
2235         if (!pGdiAlphaBlend) skip_compare(2);
2236         else compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 8-bpp", 1, FALSE );
2237     }
2238     else
2239     {
2240         if (!pGdiAlphaBlend) skip_compare(1);
2241         else compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 8-bpp", 0, dib_is_1bpp );
2242     }
2243
2244     /* blitting with 4-bpp source */
2245
2246     src_bi->bmiHeader.biBitCount = 4;
2247     src_bi->bmiHeader.biClrUsed = 12;
2248     for (i = 0; i < 16; i++) ((DWORD *)src_bi->bmiColors)[i] = i | (i * 5) << 8 | (i * 19) << 16;
2249     bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2250     DeleteObject( SelectObject( src_dc, bmp ) );
2251     for (y = 0; y < 256; y++)
2252         for (x = 0; x < 256; x += 2)
2253             src_bits[(y * 256 + x) / 2] = 7 * x + 3 * y;
2254
2255     BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2256     compare_hash(hdc, bmi, bits, "BitBlt src 4-bpp SRCCOPY" );
2257
2258     /* blitting with 1-bpp source */
2259
2260     src_bi->bmiHeader.biBitCount = 1;
2261     src_bi->bmiHeader.biClrUsed = 0;
2262     for (i = 0; i < 2; i++) ((DWORD *)src_bi->bmiColors)[i] = (i + 37) | (i * 91) << 8 | (i * 53) << 16;
2263     bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2264     DeleteObject( SelectObject( src_dc, bmp ) );
2265     for (y = 0; y < 256; y++)
2266         for (x = 0; x < 256; x += 8)
2267             src_bits[(y * 256 + x) / 8] = 7 * x + 3 * y;
2268
2269     BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2270     compare_hash(hdc, bmi, bits, "BitBlt src 1-bpp SRCCOPY" );
2271
2272     blend.SourceConstantAlpha = 0x90;
2273     blend.AlphaFormat = 0;
2274     if (pGdiAlphaBlend) pGdiAlphaBlend( hdc, 100, 100, 256, 256, src_dc, 0, 0, 256, 256, blend );
2275     if (bmi->bmiHeader.biBitCount == 16 && bmi->bmiHeader.biCompression == BI_RGB) /* 555 broken on w2k */
2276     {
2277         if (!pGdiAlphaBlend) skip_compare(2);
2278         else compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 1-bpp", 1, FALSE );
2279     }
2280     else
2281     {
2282         if (!pGdiAlphaBlend) skip_compare(1);
2283         else compare_hash(hdc, bmi, bits, "AlphaBlend src 1-bpp" );
2284     }
2285
2286     DeleteDC( src_dc );
2287     DeleteObject( bmp );
2288
2289     /* RLE StretchDIBits */
2290     src_bi->bmiHeader.biSize        = sizeof(src_bi->bmiHeader);
2291     src_bi->bmiHeader.biWidth       = 8;
2292     src_bi->bmiHeader.biHeight      = 8;
2293     src_bi->bmiHeader.biPlanes      = 1;
2294     src_bi->bmiHeader.biBitCount    = 8;
2295     src_bi->bmiHeader.biCompression = BI_RLE8;
2296     src_bi->bmiHeader.biClrUsed     = 0;
2297     src_bi->bmiHeader.biSizeImage   = sizeof(rle8_data);
2298
2299     for (i = 0; i < 256; i++)
2300     {
2301         src_bi->bmiColors[i].rgbRed      = i;
2302         src_bi->bmiColors[i].rgbGreen    = i;
2303         src_bi->bmiColors[i].rgbBlue     = i;
2304         src_bi->bmiColors[i].rgbReserved = 0;
2305     }
2306
2307     StretchDIBits( hdc,  10, 10, 7, 7, 0, 0, 7, 7, rle8_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2308     StretchDIBits( hdc, 100, 10, 7, 7, 0, 0, 7, 7, rle8_data, src_bi, DIB_RGB_COLORS, SRCAND );
2309     StretchDIBits( hdc, 200, 10, 7, 7, 0, 1, 7, 7, rle8_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2310     StretchDIBits( hdc, 300, 10, 7, 7, 1, 0, 7, 7, rle8_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2311     StretchDIBits( hdc, 400, 10, 16, 16, 0, 0, 8, 8, rle8_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2312     compare_hash_broken_todo(hdc,  bmi, bits, "rle stretchdibits", 0, dib_is_1bpp );
2313
2314     /* 32 bpp StretchDIBits */
2315
2316     src_bi->bmiHeader.biWidth       = 4;
2317     src_bi->bmiHeader.biHeight      = 4;
2318     src_bi->bmiHeader.biPlanes      = 1;
2319     src_bi->bmiHeader.biBitCount    = 32;
2320     src_bi->bmiHeader.biCompression = BI_RGB;
2321     src_bi->bmiHeader.biClrUsed     = 0;
2322     src_bi->bmiHeader.biSizeImage   = 0;
2323
2324     ret = StretchDIBits( hdc,  10, 10, 4, 4, 0, 0, 4, 4, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2325     ok(ret == 4, "got %d\n", ret);
2326     ret = StretchDIBits( hdc,  20, 10, 4, 4, 0, 0, 4, 4, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCAND );
2327     ok(ret == 4, "got %d\n", ret);
2328     ret = StretchDIBits( hdc,  30, 10, 3, 3, 1, 1, 3, 3, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2329     ok(ret == 4, "got %d\n", ret);
2330     ret = StretchDIBits( hdc,  40, 10, 3, 3, 1, 1, 3, 3, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCAND );
2331     ok(ret == 4, "got %d\n", ret);
2332     ret = StretchDIBits( hdc,  50, 10, -2, -2, 2, 3, -2, -2, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2333     ok(ret == 4, "got %d\n", ret);
2334     ret = StretchDIBits( hdc,  60, 10, -2, -2, 2, 3, -2, -2, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCAND );
2335     ok(ret == 4, "got %d\n", ret);
2336
2337     src_bi->bmiHeader.biHeight = -4;
2338
2339     ret = StretchDIBits( hdc,  10, 100, 4, 4, 0, 0, 4, 4, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2340     ok(ret == 4, "got %d\n", ret);
2341     ret = StretchDIBits( hdc,  20, 100, 4, 4, 0, 0, 4, 4, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCAND );
2342     ok(ret == -4, "got %d\n", ret);
2343     ret = StretchDIBits( hdc,  30, 100, 3, 3, 1, 1, 3, 3, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2344     ok(ret == 4, "got %d\n", ret);
2345     ret = StretchDIBits( hdc,  40, 100, 3, 3, 1, 1, 3, 3, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCAND );
2346     ok(ret == -4, "got %d\n", ret);
2347     ret = StretchDIBits( hdc,  50, 100, -2, -2, 2, 3, -2, -2, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2348     ok(ret == 4, "got %d\n", ret);
2349     ret = StretchDIBits( hdc,  60, 100, -2, -2, 2, 3, -2, -2, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCAND );
2350     ok(ret == -4, "got %d\n", ret);
2351
2352     compare_hash_broken_todo(hdc,  bmi, bits, "stretchdibits", dib_is_8bpp_gray ? 1 : 0, dib_is_8bpp_gray );
2353
2354     /* Solid colors */
2355     for (i = 0; i < 256; i++)
2356     {
2357         solid_patblt( hdc, i * 2, 10, 1, 1, DIBINDEX(i) );
2358         solid_patblt( hdc, i * 2, 20, 1, 1, PALETTEINDEX(i) );
2359         solid_patblt( hdc, i * 2, 30, 1, 1, RGB( (i & 0x07) << 5, (i & 0x38) << 2, i & 0xc0 ) );
2360         solid_patblt( hdc, i * 2, 40, 1, 1, PALETTERGB( (i & 0x07) << 5, (i & 0x38) << 2, i & 0xc0 ) );
2361         for (j = 0; j < 256; j++) solid_patblt( hdc, i * 2, 50 + j, 1, 1, (j << 24) | i );
2362     }
2363
2364     /* A few extra colors that are interesting in the 1bpp case */
2365
2366     /* bk color */
2367     solid_patblt( hdc, 0, 50, 1, 1, RGB( 0, 0xff, 0 ) );
2368     solid_patblt( hdc, 2, 50, 1, 1, PALETTERGB( 0, 0xff, 0 ) );
2369
2370     /* color 0 */
2371     solid_patblt( hdc, 4, 50, 1, 1, RGB( 0, 0x1, 0xff ) );
2372     solid_patblt( hdc, 6, 50, 1, 1, PALETTERGB( 0, 0x1, 0xff ) );
2373
2374     /* color 1 */
2375     solid_patblt( hdc,  8, 50, 1, 1, RGB( 0xff, 0, 0 ) );
2376     solid_patblt( hdc, 10, 50, 1, 1, PALETTERGB( 0xff, 0, 0 ) );
2377
2378     compare_hash(hdc, bmi, bits, "Colors");
2379
2380     for (i = 0; i < 256; i++)
2381     {
2382         COLORREF s, g;
2383         s = SetPixel( hdc, i * 2, 10, DIBINDEX(i) );
2384         g = GetPixel( hdc, i * 2, 10 );
2385         ok( s == g, "got %08x and %08x\n", s, g );
2386
2387         s = SetPixel( hdc, i * 2, 20, PALETTEINDEX(i) );
2388         g = GetPixel( hdc, i * 2, 20 );
2389         ok( s == g, "got %08x and %08x\n", s, g );
2390
2391         s = SetPixel( hdc, i * 2, 30, RGB( (i & 0x07) << 5, (i & 0x38) << 2, i & 0xc0 ) );
2392         g = GetPixel( hdc, i * 2, 30 );
2393         ok( s == g, "got %08x and %08x\n", s, g );
2394
2395         s = SetPixel( hdc, i * 2, 40, PALETTERGB( (i & 0x07) << 5, (i & 0x38) << 2, i & 0xc0 ) );
2396         g = GetPixel( hdc, i * 2, 40 );
2397         ok( s == g, "got %08x and %08x\n", s, g );
2398
2399         for (j = 0; j < 256; j++)
2400         {
2401             s = SetPixel( hdc, i * 2, 50+j, (j << 24) | RGB( (i & 0x07) << 5, (i & 0x38) << 2, i & 0xc0 ));
2402             g = GetPixel( hdc, i * 2, 50+j );
2403             ok( s == g, "got %08x and %08x\n", s, g );
2404
2405             s = SetPixel( hdc, i * 2 + 1, 50+j, (j << 24) | i );
2406             g = GetPixel( hdc, i * 2 + 1, 50+j );
2407             ok( s == g, "got %08x and %08x\n", s, g );
2408         }
2409     }
2410
2411     compare_hash(hdc, bmi, bits, "SetPixel");
2412
2413     /* gradients */
2414
2415     if (pGdiGradientFill)
2416     {
2417         TRIVERTEX vrect[] =
2418         {
2419             {   1,   1, 0xff00, 0x8000, 0x0000, 0x8000 },
2420             { 200, 200, 0x0000, 0x0000, 0xff00, 0xff00 },
2421             { 180, 180, 0x1234, 0x5678, 0x9abc, 0xdef0 },
2422             { 300, 300, 0xff00, 0xff00, 0xff00, 0x0000 }
2423         };
2424         GRADIENT_RECT rect[] = { { 0, 1 }, { 2, 3 }, { 2, 1 } };
2425
2426         TRIVERTEX vtri[] =
2427         {
2428             { 250,   0, 0xff00, 0x0000, 0xff00, 0xff00 },
2429             { 500, 500, 0x0000, 0xff00, 0x0000, 0xff00 },
2430             {   0, 500, 0x0000, 0x0000, 0xff00, 0xff00 },
2431
2432             {  10,   0, 0x8000, 0x0000, 0x8000, 0x8000 },
2433             {   0,  20, 0xff00, 0xff00, 0xff00, 0x0000 },
2434             {   5,  30, 0x4000, 0xc000, 0x7000, 0x9000 },
2435
2436             {  30,   0, 0x9000, 0x8800, 0xcc00, 0xff00 },
2437             {   5,  12, 0x9900, 0xaa00, 0xbb00, 0xcc00 },
2438             {   0,  30, 0x5000, 0xd000, 0x9000, 0xbb00 },
2439
2440             {  35,   3, 0xaa00, 0x6500, 0x4300, 0x2100 },
2441             {  50,   6, 0x9800, 0x9800, 0x9800, 0x2000 },
2442             {  60,  10, 0x0100, 0x0200, 0x0300, 0x3000 },
2443
2444             {  60,   2, 0x0700, 0x0800, 0x0900, 0xff00 },
2445             {  73,  10, 0x9900, 0x8800, 0x7700, 0xff00 },
2446             {  66,  23, 0x1100, 0x2200, 0x3300, 0xff00 },
2447
2448             {  80,   1, 0xa000, 0x6000, 0x4000, 0x2000 },
2449             {  76,   9, 0x7000, 0x5000, 0x3000, 0x1000 },
2450             {  85,  23, 0x3300, 0x3300, 0x3300, 0x3300 },
2451
2452             {  90,   4, 0x4400, 0x5500, 0x6600, 0x9900 },
2453             {  95,  12, 0x4500, 0x5600, 0x6700, 0x9900 },
2454             {  85,  14, 0x4600, 0x5700, 0x6800, 0x9900 },
2455         };
2456         GRADIENT_TRIANGLE tri[] =
2457         {
2458             { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 }, { 9, 10, 11 }, { 12, 13, 14 }, { 15, 16, 17 }, { 18, 19, 20 },
2459             { 2, 1, 0 }, { 3, 5, 4 }, { 7, 6, 8 }, { 10, 11, 9 }, { 14, 13, 12 }, { 17, 15, 16 }, { 19, 20, 18 }
2460         };
2461
2462         pGdiGradientFill( hdc, vrect, 4, rect, 2, GRADIENT_FILL_RECT_H );
2463         for (i = 0; i < 4; i++) vrect[i].y += 250;
2464         pGdiGradientFill( hdc, vrect, 4, rect, 2, GRADIENT_FILL_RECT_V );
2465
2466         if (bmi->bmiHeader.biBitCount <= 8) /* Wine's 8-bit dithering isn't identical to Windows */
2467             compare_hash_broken_todo(hdc,  bmi, bits, "GdiGradientFill", 0, 1 );
2468         else
2469             compare_hash(hdc, bmi, bits, "GdiGradientFill" );
2470
2471         pGdiGradientFill( hdc, vtri, 7*3, tri, 7, GRADIENT_FILL_TRIANGLE );
2472         for (i = 0; i < 7*3; i++) vtri[i].y += 100;
2473         pGdiGradientFill( hdc, vtri, 7*3, tri + 7, 7, GRADIENT_FILL_TRIANGLE );
2474         if (bmi->bmiHeader.biBitCount <= 8) /* Wine's 8-bit dithering isn't identical to Windows */
2475             compare_hash_broken_todo(hdc,  bmi, bits, "GdiGradientFill", 0, 1 );
2476         else
2477             compare_hash(hdc, bmi, bits, "GdiGradientFill" );
2478     }
2479     else
2480     {
2481         win_skip( "GdiGradientFill not supported\n" );
2482         skip_compare(1);
2483         skip_compare(1);
2484     }
2485
2486     /* wide pen */
2487
2488     wide_pen = CreatePen( PS_SOLID, 7, RGB( 0xff, 0, 0 ) );
2489     SelectObject( hdc, wide_pen );
2490
2491     for (i = 0; i < sizeof( wide_lines ) / sizeof( wide_lines[0] ); i++)
2492     {
2493         MoveToEx( hdc, wide_lines[i].left, wide_lines[i].top, NULL );
2494         LineTo( hdc, wide_lines[i].right, wide_lines[i].bottom );
2495     }
2496
2497     compare_hash(hdc, bmi, bits, "wide pen" );
2498
2499     SelectObject( hdc, orig_pen );
2500     DeleteObject( wide_pen );
2501
2502     log_brush.lbStyle = BS_SOLID;
2503     log_brush.lbColor = RGB(0xff, 0, 0);
2504     log_brush.lbHatch = 0;
2505
2506     wide_pen = ExtCreatePen( PS_GEOMETRIC | PS_ENDCAP_FLAT | PS_JOIN_MITER | PS_SOLID,
2507                              9, &log_brush, 0, NULL );
2508     SelectObject( hdc, wide_pen );
2509
2510     Polyline( hdc, poly_lines, sizeof(poly_lines) / sizeof(poly_lines[0]) );
2511     compare_hash(hdc, bmi, bits, "wide pen - flat caps, mitred" );
2512
2513     SelectObject( hdc, orig_pen );
2514     DeleteObject( wide_pen );
2515
2516     wide_pen = ExtCreatePen( PS_GEOMETRIC | PS_ENDCAP_SQUARE | PS_JOIN_BEVEL | PS_SOLID,
2517                              16, &log_brush, 0, NULL );
2518     SelectObject( hdc, wide_pen );
2519
2520     Polyline( hdc, poly_lines, sizeof(poly_lines) / sizeof(poly_lines[0]) );
2521     compare_hash(hdc, bmi, bits, "wide pen - square caps, bevelled" );
2522
2523     SelectObject( hdc, orig_pen );
2524     DeleteObject( wide_pen );
2525
2526     wide_pen = ExtCreatePen( PS_GEOMETRIC | PS_ENDCAP_FLAT | PS_JOIN_MITER | PS_SOLID,
2527                              9, &log_brush, 0, NULL );
2528     SelectObject( hdc, wide_pen );
2529
2530     PolyPolyline( hdc, polypoly_lines, polypoly_counts, sizeof(polypoly_counts)/sizeof(polypoly_counts[0]) );
2531     compare_hash(hdc, bmi, bits, "wide pen - empty segments" );
2532
2533     SelectObject( hdc, orig_pen );
2534     DeleteObject( wide_pen );
2535
2536     /* brushed wide pen */
2537
2538     old_text = GetTextColor( hdc );
2539     old_bkgnd = GetBkColor( hdc );
2540     bmp = CreateBitmap( 16, 16, 1, 1, ddb_brush_bits );
2541     log_brush.lbStyle = BS_PATTERN;
2542     log_brush.lbColor = 0;
2543     log_brush.lbHatch = (ULONG_PTR)bmp;
2544     wide_pen = ExtCreatePen( PS_GEOMETRIC | PS_ENDCAP_FLAT | PS_JOIN_BEVEL | PS_SOLID,
2545                              12, &log_brush, 0, NULL );
2546     ok( wide_pen != 0, "failed to create pen\n" );
2547     SelectObject( hdc, wide_pen );
2548     Polyline( hdc, poly_lines, sizeof(poly_lines) / sizeof(poly_lines[0]) );
2549
2550     for (i = 1; i < 20; i++)
2551     {
2552         wide_pen = ExtCreatePen( PS_GEOMETRIC | PS_ENDCAP_FLAT | PS_JOIN_BEVEL | PS_SOLID,
2553                                  i, &log_brush, 0, NULL );
2554         ok( wide_pen != 0, "failed to create pen\n" );
2555         DeleteObject( SelectObject( hdc, wide_pen ));
2556         SetTextColor(hdc, RGB( 2*i, i, 255 - i ) );
2557         SetBkColor(hdc, RGB( 255 - i, i, i / 3 ) );
2558         MoveToEx( hdc, 10 * i, 10, NULL );
2559         LineTo( hdc, 10 * i, 200 + i );
2560         LineTo( hdc, 20 * i, 200 + i );
2561     }
2562     /* NT4 broken for all cases, W2K for 1 bpp only */
2563     compare_hash_broken_todo(hdc,  bmi, bits, "wide brushed pen", 1 + dib_is_1bpp, dib_is_1bpp );
2564
2565     for (i = 1; i < 20; i++)
2566     {
2567         wide_pen = ExtCreatePen( PS_GEOMETRIC | PS_ENDCAP_FLAT | PS_JOIN_BEVEL | (i % 5),
2568                                  i, &log_brush, 0, NULL );
2569         DeleteObject( SelectObject( hdc, wide_pen ));
2570         SetTextColor(hdc, RGB( 2*i, i, 255 - i ) );
2571         SetBkColor(hdc, RGB( i, 255 - i, i / 3 ) );
2572         MoveToEx( hdc, 10 * i, 10, NULL );
2573         LineTo( hdc, 10 * i, 200 + i );
2574         LineTo( hdc, 20 * i, 200 + i );
2575     }
2576     /* NT4 broken for all cases, W2K for 1 bpp only */
2577     compare_hash_broken_todo(hdc,  bmi, bits, "dashed wide brushed pen", 1 + dib_is_1bpp, dib_is_1bpp );
2578
2579     DeleteObject(bmp);
2580     SetTextColor(hdc, old_text);
2581     SetBkColor(hdc, old_bkgnd);
2582     SelectObject( hdc, orig_pen );
2583
2584     /* PALETTEINDEX */
2585
2586     solid_brush = CreateSolidBrush( PALETTEINDEX(3) );
2587     solid_pen = CreatePen( PS_DASH, 1, PALETTEINDEX(5) );
2588     SetTextColor( hdc, PALETTEINDEX(38) );
2589     SetBkColor( hdc, PALETTEINDEX(9) );
2590     SelectObject( hdc, solid_brush );
2591     SelectObject( hdc, solid_pen );
2592
2593     pal->palVersion = 0x300;
2594     pal->palNumEntries = 40;
2595     for (i = 0; i < 80; i++)
2596     {
2597         entries[i].peRed   = i * 3;
2598         entries[i].peGreen = i * 7;
2599         entries[i].peBlue  = 128 - i;
2600         entries[i].peFlags = 0;
2601     }
2602     hpal = CreatePalette( pal );
2603     SelectPalette( hdc, hpal, FALSE );
2604
2605     solid_patblt( hdc, 20, 10, 10, 10, PALETTEINDEX(15) );
2606     Rectangle( hdc, 0, 0, 10, 10 );
2607     SetPaletteEntries( hpal, 0, 40, entries + 40 );
2608     Rectangle( hdc, 10, 0, 10, 10 );
2609     SelectObject( hdc, orig_brush );
2610     DeleteObject( solid_brush );
2611
2612     solid_brush = CreateHatchBrush( HS_CROSS, PALETTEINDEX(7) );
2613     DeleteObject( SelectObject( hdc, solid_brush ));
2614     PatBlt( hdc, 20, 0, 10, 10, PATCOPY );
2615     SetPaletteEntries( hpal, 0, 40, entries );
2616     PatBlt( hdc, 30, 0, 10, 10, PATCOPY );
2617     SelectObject( hdc, orig_brush );
2618     DeleteObject( solid_brush );
2619
2620     bmp = CreateBitmap( 16, 16, 1, 1, ddb_brush_bits );
2621     dib_brush = CreatePatternBrush( bmp );
2622     SelectObject( hdc, dib_brush );
2623     PatBlt( hdc, 40, 0, 10, 10, PATCOPY );
2624     SetPaletteEntries( hpal, 0, 40, entries + 40 );
2625     PatBlt( hdc, 50, 0, 10, 10, PATCOPY );
2626     DeleteObject( bmp );
2627     SelectObject( hdc, orig_brush );
2628     DeleteObject( dib_brush );
2629
2630     SelectPalette( hdc, GetStockObject(DEFAULT_PALETTE), FALSE );
2631     DeleteObject( hpal );
2632
2633     /* NT4 broken for all cases, W2K for 1 bpp only */
2634     compare_hash_broken_todo(hdc, bmi, bits, "PALETTEINDEX", 1 + dib_is_1bpp, dib_is_1bpp );
2635
2636     /* ExtFloodFill */
2637
2638     solid_patblt( hdc,   0,   0, 512, 512, RGB( 0, 0, 0xff ) );
2639     solid_patblt( hdc,  10,  10, 200, 200, RGB( 0, 0xff, 0 ) );
2640     solid_patblt( hdc,  10,  50,  50,  50, RGB( 0, 0, 0xff ) );
2641     solid_patblt( hdc, 100, 160,  50,  50, RGB( 0, 0, 0xff ) );
2642     solid_patblt( hdc,  90, 160,  70,  10, RGB( 0, 0, 0xff ) );
2643
2644     /* add a vertical 'bar' to show that the clip rgn stops the flooding */
2645     hrgn = CreateRectRgn( 180, 10, 190, 210 );
2646     ExtSelectClipRgn( hdc, hrgn, RGN_DIFF );
2647     DeleteObject( hrgn );
2648
2649     solid_brush = CreateSolidBrush( RGB( 0xff, 0, 0 ) );
2650     SelectObject( hdc, solid_brush );
2651
2652     ret = ExtFloodFill( hdc, 100, 100, RGB( 0, 0xff, 0 ), FLOODFILLSURFACE );
2653     ok (!ret == !!dib_is_1bpp, "got ret %d\n", ret);
2654     compare_hash(hdc, bmi, bits, "flood fill" );
2655
2656     ExtSelectClipRgn( hdc, NULL, RGN_COPY );
2657
2658     SelectObject(hdc, orig_brush);
2659     SelectObject(hdc, orig_pen);
2660     DeleteObject(solid_brush);
2661     DeleteObject(wide_pen);
2662     DeleteObject(dashed_pen);
2663     DeleteObject(solid_pen);
2664 }
2665
2666 static const BYTE ramp[17] =
2667 {
2668     0,    0x4d, 0x68, 0x7c,
2669     0x8c, 0x9a, 0xa7, 0xb2,
2670     0xbd, 0xc7, 0xd0, 0xd9,
2671     0xe1, 0xe9, 0xf0, 0xf8,
2672     0xff
2673 };
2674
2675 static inline void get_range(BYTE alpha, DWORD text_comp, BYTE *min_comp, BYTE *max_comp)
2676 {
2677     *min_comp = (ramp[alpha] * text_comp) / 0xff;
2678     *max_comp = ramp[16 - alpha] + ((0xff - ramp[16 - alpha]) * text_comp) / 0xff;
2679 }
2680
2681 static inline BYTE aa_comp(BYTE dst, BYTE text, BYTE alpha)
2682 {
2683     BYTE min_comp, max_comp;
2684
2685     if (alpha == 16)  return text;
2686     if (alpha <= 1)   return dst;
2687     if (text == dst)  return dst;
2688
2689     get_range( alpha, text, &min_comp, &max_comp );
2690
2691     if (dst > text)
2692     {
2693         DWORD diff = dst - text;
2694         DWORD range = max_comp - text;
2695         dst = text + (diff * range ) / (0xff - text);
2696         return dst;
2697     }
2698     else
2699     {
2700         DWORD diff = text - dst;
2701         DWORD range = text - min_comp ;
2702         dst = text - (diff * range) / text;
2703         return dst;
2704     }
2705 }
2706
2707 static inline COLORREF aa_colorref( COLORREF dst, COLORREF text, BYTE glyph )
2708 {
2709     COLORREF ret;
2710
2711     ret = RGB( aa_comp( GetRValue(dst), GetRValue(text), glyph ),
2712                aa_comp( GetGValue(dst), GetGValue(text), glyph ),
2713                aa_comp( GetBValue(dst), GetBValue(text), glyph ) );
2714     return ret;
2715 }
2716
2717 static const BYTE masks[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
2718
2719 static void draw_text_2( HDC hdc, BITMAPINFO *bmi, BYTE *bits, BOOL aa )
2720 {
2721     DWORD dib_size = get_dib_size(bmi), ret;
2722     LOGFONT lf;
2723     HFONT font;
2724     GLYPHMETRICS gm;
2725     BYTE g_buf[10000];
2726     int i, stride, x, y;
2727     static const MAT2 identity = { {0,1}, {0,0}, {0,0}, {0,1} };
2728     char *eto_hash = NULL, *diy_hash = NULL;
2729     static const char *str = "Hello Wine";
2730     POINT origin, g_org;
2731     static const BYTE vals[4] = { 0x00, 0x00, 0x00, 0x00 };
2732     TEXTMETRIC tm;
2733     COLORREF text_color;
2734
2735     for(i = 0; i < dib_size; i++)
2736         bits[i] = vals[i % 4];
2737
2738     memset( &lf, 0, sizeof(lf) );
2739     strcpy( lf.lfFaceName, "Tahoma" );
2740     lf.lfHeight = 24;
2741     lf.lfQuality = aa ? ANTIALIASED_QUALITY : NONANTIALIASED_QUALITY;
2742
2743     font = CreateFontIndirect( &lf );
2744     font = SelectObject( hdc, font );
2745
2746     GetTextMetrics( hdc, &tm );
2747     if (!(tm.tmPitchAndFamily & TMPF_VECTOR))
2748     {
2749         skip( "skipping as a bitmap font has been selected for Tahoma.\n" );
2750         DeleteObject( SelectObject( hdc, font ) );
2751         return;
2752     }
2753
2754     SetTextColor( hdc, RGB(0xff, 0x00, 0x00) );
2755     SetTextAlign( hdc, TA_BASELINE );
2756     SetBkMode( hdc, TRANSPARENT );
2757     origin.x = 10;
2758     origin.y = 100;
2759
2760     ExtTextOut( hdc, origin.x, origin.y, 0, NULL, str, strlen(str), NULL );
2761     eto_hash = hash_dib( bmi, bits );
2762
2763     for(i = 0; i < dib_size; i++)
2764         bits[i] = vals[i % 4];
2765
2766     if (bmi->bmiHeader.biBitCount <= 8) aa = FALSE;
2767
2768     text_color = GetTextColor( hdc );
2769     for (i = 0; i < strlen(str); i++)
2770     {
2771         DWORD ggo_flags = aa ? GGO_GRAY4_BITMAP : GGO_BITMAP;
2772
2773         ret = GetGlyphOutline( hdc, str[i], ggo_flags, &gm, 0, NULL, &identity );
2774
2775         if (ret == GDI_ERROR) continue;
2776
2777         if (ret) GetGlyphOutline( hdc, str[i], ggo_flags, &gm, sizeof(g_buf), g_buf, &identity );
2778
2779         g_org.x = origin.x + gm.gmptGlyphOrigin.x;
2780         g_org.y = origin.y - gm.gmptGlyphOrigin.y;
2781
2782         origin.x += gm.gmCellIncX;
2783         origin.y += gm.gmCellIncY;
2784
2785         if (!ret) continue;
2786
2787         if (aa)
2788         {
2789             stride = (gm.gmBlackBoxX + 3) & ~3;
2790
2791             for (y = 0; y < gm.gmBlackBoxY; y++)
2792             {
2793                 BYTE *g_ptr = g_buf + y * stride;
2794                 COLORREF val;
2795
2796                 for (x = 0; x < gm.gmBlackBoxX; x++)
2797                 {
2798                     if (g_ptr[x] <= 1) continue;
2799                     if (g_ptr[x] >= 16) val = text_color;
2800                     else
2801                     {
2802                         val = GetPixel( hdc, g_org.x + x, g_org.y + y );
2803                         val = aa_colorref( val, text_color, g_ptr[x] );
2804                     }
2805                     SetPixel( hdc, g_org.x + x, g_org.y + y, val );
2806                 }
2807             }
2808         }
2809         else
2810         {
2811             stride = ((gm.gmBlackBoxX + 31) >> 3) & ~3;
2812
2813             for (y = 0; y < gm.gmBlackBoxY; y++)
2814             {
2815                 BYTE *g_ptr = g_buf + y * stride;
2816                 for (x = 0; x < gm.gmBlackBoxX; x++)
2817                 {
2818                     if (g_ptr[x / 8] & masks[x % 8])
2819                         SetPixel( hdc, g_org.x + x, g_org.y + y, text_color );
2820                 }
2821             }
2822         }
2823     }
2824
2825     diy_hash = hash_dib( bmi, bits );
2826     ok( !strcmp( eto_hash, diy_hash ), "hash mismatch - aa %d\n", aa );
2827
2828     HeapFree( GetProcessHeap(), 0, diy_hash );
2829     HeapFree( GetProcessHeap(), 0, eto_hash );
2830
2831     font = SelectObject( hdc, font );
2832     DeleteObject( font );
2833 }
2834
2835 static void draw_text( HDC hdc, BITMAPINFO *bmi, BYTE *bits )
2836 {
2837     draw_text_2( hdc, bmi, bits, FALSE );
2838
2839     /* Rounding errors make these cases hard to test */
2840     if ((bmi->bmiHeader.biCompression == BI_BITFIELDS && ((DWORD*)bmi->bmiColors)[0] == 0x3f000) ||
2841         (bmi->bmiHeader.biBitCount == 16))
2842         return;
2843
2844     draw_text_2( hdc, bmi, bits, TRUE );
2845 }
2846
2847 static void test_simple_graphics(void)
2848 {
2849     char bmibuf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)];
2850     BITMAPINFO *bmi = (BITMAPINFO *)bmibuf;
2851     RGBQUAD *colors = bmi->bmiColors;
2852     DWORD *bit_fields = (DWORD*)(bmibuf + sizeof(BITMAPINFOHEADER));
2853     HDC mem_dc;
2854     BYTE *bits;
2855     HBITMAP dib, orig_bm;
2856     DIBSECTION ds;
2857     int i;
2858
2859     mem_dc = CreateCompatibleDC(NULL);
2860
2861     /* a8r8g8b8 */
2862     trace("8888\n");
2863     memset(bmi, 0, sizeof(bmibuf));
2864     bmi->bmiHeader.biSize = sizeof(bmi->bmiHeader);
2865     bmi->bmiHeader.biHeight = 512;
2866     bmi->bmiHeader.biWidth = 512;
2867     bmi->bmiHeader.biBitCount = 32;
2868     bmi->bmiHeader.biPlanes = 1;
2869     bmi->bmiHeader.biCompression = BI_RGB;
2870
2871     dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
2872     ok(dib != NULL, "ret NULL\n");
2873     ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
2874     ok(ds.dsBitfields[0] == 0, "got %08x\n", ds.dsBitfields[0]);
2875     ok(ds.dsBitfields[1] == 0, "got %08x\n", ds.dsBitfields[1]);
2876     ok(ds.dsBitfields[2] == 0, "got %08x\n", ds.dsBitfields[2]);
2877     ok(ds.dsBmih.biCompression == BI_RGB ||
2878        broken(ds.dsBmih.biCompression == BI_BITFIELDS), /* nt4 sp1 and 2 */
2879        "got %x\n", ds.dsBmih.biCompression);
2880
2881     orig_bm = SelectObject(mem_dc, dib);
2882
2883     dst_format = "8888";
2884     current_sha1 = sha1_graphics_a8r8g8b8;
2885     draw_graphics(mem_dc, bmi, bits);
2886     draw_text(mem_dc, bmi, bits);
2887
2888     SelectObject(mem_dc, orig_bm);
2889     DeleteObject(dib);
2890
2891     /* a8r8g8b8 - bitfields.  Should be the same as the regular 32 bit case.*/
2892     trace("8888 - bitfields\n");
2893     bmi->bmiHeader.biBitCount = 32;
2894     bmi->bmiHeader.biCompression = BI_BITFIELDS;
2895     bit_fields[0] = 0xff0000;
2896     bit_fields[1] = 0x00ff00;
2897     bit_fields[2] = 0x0000ff;
2898
2899     dib = CreateDIBSection(mem_dc, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
2900     ok(dib != NULL, "ret NULL\n");
2901     ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
2902     ok(ds.dsBitfields[0] == 0xff0000, "got %08x\n", ds.dsBitfields[0]);
2903     ok(ds.dsBitfields[1] == 0x00ff00, "got %08x\n", ds.dsBitfields[1]);
2904     ok(ds.dsBitfields[2] == 0x0000ff, "got %08x\n", ds.dsBitfields[2]);
2905     ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %x\n", ds.dsBmih.biCompression);
2906
2907     orig_bm = SelectObject(mem_dc, dib);
2908
2909     dst_format = "8888 - bitfields";
2910     current_sha1 = sha1_graphics_a8r8g8b8_bitfields;
2911     draw_graphics(mem_dc, bmi, bits);
2912     draw_text(mem_dc, bmi, bits);
2913
2914     SelectObject(mem_dc, orig_bm);
2915     DeleteObject(dib);
2916
2917     /* a8b8g8r8. */
2918     trace("a8b8g8r8\n");
2919     bmi->bmiHeader.biBitCount = 32;
2920     bmi->bmiHeader.biCompression = BI_BITFIELDS;
2921     bit_fields[0] = 0x0000ff;
2922     bit_fields[1] = 0x00ff00;
2923     bit_fields[2] = 0xff0000;
2924
2925     dib = CreateDIBSection(mem_dc, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
2926     ok(dib != NULL, "ret NULL\n");
2927     ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
2928     ok(ds.dsBitfields[0] == 0x0000ff, "got %08x\n", ds.dsBitfields[0]);
2929     ok(ds.dsBitfields[1] == 0x00ff00, "got %08x\n", ds.dsBitfields[1]);
2930     ok(ds.dsBitfields[2] == 0xff0000, "got %08x\n", ds.dsBitfields[2]);
2931     ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %x\n", ds.dsBmih.biCompression);
2932
2933     orig_bm = SelectObject(mem_dc, dib);
2934
2935     dst_format = "a8b8g8r8";
2936     current_sha1 = sha1_graphics_a8b8g8r8;
2937     draw_graphics(mem_dc, bmi, bits);
2938     draw_text(mem_dc, bmi, bits);
2939
2940     SelectObject(mem_dc, orig_bm);
2941     DeleteObject(dib);
2942
2943     /* r10g10b10. */
2944     trace("r10g10b10\n");
2945     bmi->bmiHeader.biBitCount = 32;
2946     bmi->bmiHeader.biCompression = BI_BITFIELDS;
2947     bit_fields[0] = 0x3ff00000;
2948     bit_fields[1] = 0x000ffc00;
2949     bit_fields[2] = 0x000003ff;
2950
2951     dib = CreateDIBSection(mem_dc, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
2952     ok(dib != NULL, "ret NULL\n");
2953     ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
2954     ok(ds.dsBitfields[0] == 0x3ff00000, "got %08x\n", ds.dsBitfields[0]);
2955     ok(ds.dsBitfields[1] == 0x000ffc00, "got %08x\n", ds.dsBitfields[1]);
2956     ok(ds.dsBitfields[2] == 0x000003ff, "got %08x\n", ds.dsBitfields[2]);
2957     ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %x\n", ds.dsBmih.biCompression);
2958
2959     orig_bm = SelectObject(mem_dc, dib);
2960
2961     dst_format = "r10g10b10";
2962     current_sha1 = sha1_graphics_r10g10b10;
2963     draw_graphics(mem_dc, bmi, bits);
2964     draw_text(mem_dc, bmi, bits);
2965
2966     SelectObject(mem_dc, orig_bm);
2967     DeleteObject(dib);
2968
2969     /* r6g6b6. */
2970     trace("r6g6b6\n");
2971     bmi->bmiHeader.biBitCount = 32;
2972     bmi->bmiHeader.biCompression = BI_BITFIELDS;
2973     bit_fields[0] = 0x0003f000;
2974     bit_fields[1] = 0x00000fc0;
2975     bit_fields[2] = 0x0000003f;
2976
2977     dib = CreateDIBSection(mem_dc, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
2978     ok(dib != NULL, "ret NULL\n");
2979     ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
2980     ok(ds.dsBitfields[0] == 0x0003f000, "got %08x\n", ds.dsBitfields[0]);
2981     ok(ds.dsBitfields[1] == 0x00000fc0, "got %08x\n", ds.dsBitfields[1]);
2982     ok(ds.dsBitfields[2] == 0x0000003f, "got %08x\n", ds.dsBitfields[2]);
2983     ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %x\n", ds.dsBmih.biCompression);
2984
2985     orig_bm = SelectObject(mem_dc, dib);
2986
2987     dst_format = "r6g6b6";
2988     current_sha1 = sha1_graphics_r6g6b6;
2989     draw_graphics(mem_dc, bmi, bits);
2990     draw_text(mem_dc, bmi, bits);
2991
2992     SelectObject(mem_dc, orig_bm);
2993     DeleteObject(dib);
2994
2995     /* 24 */
2996     trace("24\n");
2997     bmi->bmiHeader.biBitCount = 24;
2998     bmi->bmiHeader.biCompression = BI_RGB;
2999
3000     dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3001     ok(dib != NULL, "ret NULL\n");
3002     orig_bm = SelectObject(mem_dc, dib);
3003
3004     dst_format = "24";
3005     current_sha1 = sha1_graphics_24;
3006     draw_graphics(mem_dc, bmi, bits);
3007     draw_text(mem_dc, bmi, bits);
3008
3009     SelectObject(mem_dc, orig_bm);
3010     DeleteObject(dib);
3011
3012     /* r5g5b5 */
3013     trace("555\n");
3014     bmi->bmiHeader.biBitCount = 16;
3015     bmi->bmiHeader.biCompression = BI_RGB;
3016
3017     dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3018     ok(dib != NULL, "ret NULL\n");
3019     ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
3020     ok(ds.dsBitfields[0] == 0x7c00, "got %08x\n", ds.dsBitfields[0]);
3021     ok(ds.dsBitfields[1] == 0x03e0, "got %08x\n", ds.dsBitfields[1]);
3022     ok(ds.dsBitfields[2] == 0x001f, "got %08x\n", ds.dsBitfields[2]);
3023     ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %x\n", ds.dsBmih.biCompression);
3024
3025     orig_bm = SelectObject(mem_dc, dib);
3026
3027     dst_format = "r5g5b5";
3028     current_sha1 = sha1_graphics_r5g5b5;
3029     draw_graphics(mem_dc, bmi, bits);
3030     draw_text(mem_dc, bmi, bits);
3031
3032     SelectObject(mem_dc, orig_bm);
3033     DeleteObject(dib);
3034
3035     /* r4g4b4 */
3036     trace("444\n");
3037     bmi->bmiHeader.biBitCount = 16;
3038     bmi->bmiHeader.biCompression = BI_BITFIELDS;
3039     bit_fields[0] = 0x0f00;
3040     bit_fields[1] = 0x00f0;
3041     bit_fields[2] = 0x000f;
3042     dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3043     ok(dib != NULL, "ret NULL\n");
3044     ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
3045     ok(ds.dsBitfields[0] == 0x0f00, "got %08x\n", ds.dsBitfields[0]);
3046     ok(ds.dsBitfields[1] == 0x00f0, "got %08x\n", ds.dsBitfields[1]);
3047     ok(ds.dsBitfields[2] == 0x000f, "got %08x\n", ds.dsBitfields[2]);
3048     ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %x\n", ds.dsBmih.biCompression);
3049
3050     orig_bm = SelectObject(mem_dc, dib);
3051
3052     dst_format = "r4g4b4";
3053     current_sha1 = sha1_graphics_r4g4b4;
3054     draw_graphics(mem_dc, bmi, bits);
3055     draw_text(mem_dc, bmi, bits);
3056
3057     SelectObject(mem_dc, orig_bm);
3058     DeleteObject(dib);
3059
3060     /* 8 color */
3061     trace("8 color\n");
3062     bmi->bmiHeader.biBitCount = 8;
3063     bmi->bmiHeader.biCompression = BI_RGB;
3064     bmi->bmiHeader.biClrUsed = 236;
3065     for (i = 0; i < 236; i++)
3066     {
3067         colors[i].rgbRed   = (i & 0x07) << 5;
3068         colors[i].rgbGreen = (i & 0x38) << 2;
3069         colors[i].rgbBlue  =  i & 0xc0;
3070     }
3071     dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3072     ok(dib != NULL, "ret NULL\n");
3073
3074     orig_bm = SelectObject(mem_dc, dib);
3075
3076     dst_format = "8 color";
3077     current_sha1 = sha1_graphics_8_color;
3078     draw_graphics(mem_dc, bmi, bits);
3079     draw_text(mem_dc, bmi, bits);
3080
3081     SelectObject(mem_dc, orig_bm);
3082     DeleteObject(dib);
3083
3084     /* 8 grayscale */
3085     trace("8 grayscale\n");
3086     bmi->bmiHeader.biBitCount = 8;
3087     bmi->bmiHeader.biCompression = BI_RGB;
3088     bmi->bmiHeader.biClrUsed = 256;
3089     for (i = 0; i < 256; i++) colors[i].rgbRed = colors[i].rgbGreen = colors[i].rgbBlue = i;
3090
3091     dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3092     ok(dib != NULL, "ret NULL\n");
3093
3094     orig_bm = SelectObject(mem_dc, dib);
3095
3096     dst_format = "8 grayscale";
3097     current_sha1 = sha1_graphics_8_grayscale;
3098     draw_graphics(mem_dc, bmi, bits);
3099     draw_text(mem_dc, bmi, bits);
3100
3101     SelectObject(mem_dc, orig_bm);
3102     DeleteObject(dib);
3103
3104     /* 8 */
3105     trace("8\n");
3106     bmi->bmiHeader.biBitCount = 8;
3107     bmi->bmiHeader.biCompression = BI_RGB;
3108     bmi->bmiHeader.biClrUsed = 5;
3109     colors[0].rgbRed = 0xff;
3110     colors[0].rgbGreen = 0xff;
3111     colors[0].rgbBlue = 0xff;
3112     colors[1].rgbRed = 0;
3113     colors[1].rgbGreen = 0;
3114     colors[1].rgbBlue = 0;
3115     colors[2].rgbRed = 0xff;
3116     colors[2].rgbGreen = 0;
3117     colors[2].rgbBlue = 0;
3118     colors[3].rgbRed = 0;
3119     colors[3].rgbGreen = 0xff;
3120     colors[3].rgbBlue = 0;
3121     colors[4].rgbRed = 0;
3122     colors[4].rgbGreen = 0;
3123     colors[4].rgbBlue = 0xff;
3124
3125     dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3126     ok(dib != NULL, "ret NULL\n");
3127
3128     orig_bm = SelectObject(mem_dc, dib);
3129
3130     dst_format = "8";
3131     current_sha1 = sha1_graphics_8;
3132     draw_graphics(mem_dc, bmi, bits);
3133     draw_text(mem_dc, bmi, bits);
3134
3135     SelectObject(mem_dc, orig_bm);
3136     DeleteObject(dib);
3137
3138     /* 4 */
3139     trace("4\n");
3140     bmi->bmiHeader.biBitCount = 4;
3141
3142     dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3143     ok(dib != NULL, "ret NULL\n");
3144
3145     orig_bm = SelectObject(mem_dc, dib);
3146
3147     dst_format = "4";
3148     current_sha1 = sha1_graphics_4;
3149     draw_graphics(mem_dc, bmi, bits);
3150     draw_text(mem_dc, bmi, bits);
3151
3152     SelectObject(mem_dc, orig_bm);
3153     DeleteObject(dib);
3154
3155     /* 4 grayscale */
3156     trace("4 grayscale\n");
3157     bmi->bmiHeader.biClrUsed = 16;
3158     for (i = 0; i < 16; i++) colors[i].rgbRed = colors[i].rgbGreen = colors[i].rgbBlue = i * 17;
3159
3160     dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3161     ok(dib != NULL, "ret NULL\n");
3162
3163     orig_bm = SelectObject(mem_dc, dib);
3164
3165     dst_format = "4 grayscale";
3166     current_sha1 = sha1_graphics_4_grayscale;
3167     draw_graphics(mem_dc, bmi, bits);
3168     draw_text(mem_dc, bmi, bits);
3169
3170     SelectObject(mem_dc, orig_bm);
3171     DeleteObject(dib);
3172
3173     /* 1 */
3174     trace("1\n");
3175     bmi->bmiHeader.biBitCount = 1;
3176     bmi->bmiHeader.biClrUsed = 2;
3177
3178     colors[0].rgbRed = 0x00;
3179     colors[0].rgbGreen = 0x01;
3180     colors[0].rgbBlue = 0xff;
3181     colors[1].rgbRed = 0xff;
3182     colors[1].rgbGreen = 0x00;
3183     colors[1].rgbBlue = 0x00;
3184
3185     dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3186     ok(dib != NULL, "ret NULL\n");
3187
3188     orig_bm = SelectObject(mem_dc, dib);
3189
3190     dst_format = "1";
3191     current_sha1 = sha1_graphics_1;
3192     draw_graphics(mem_dc, bmi, bits);
3193     draw_text(mem_dc, bmi, bits);
3194
3195     SelectObject(mem_dc, orig_bm);
3196     DeleteObject(dib);
3197
3198     DeleteDC(mem_dc);
3199 }
3200
3201 START_TEST(dib)
3202 {
3203     HMODULE mod = GetModuleHandleA("gdi32.dll");
3204     pSetLayout = (void *)GetProcAddress( mod, "SetLayout" );
3205     pGdiAlphaBlend = (void *)GetProcAddress( mod, "GdiAlphaBlend" );
3206     pGdiGradientFill = (void *)GetProcAddress( mod, "GdiGradientFill" );
3207
3208     CryptAcquireContextW(&crypt_prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
3209
3210     test_simple_graphics();
3211
3212     CryptReleaseContext(crypt_prov, 0);
3213 }