ReactOS 0.4.17-dev-357-ga8f14ff
olepicture.c
Go to the documentation of this file.
1/*
2 * OLEPICTURE test program
3 *
4 * Copyright 2005 Marcus Meissner
5 * Copyright 2012 Dmitry Timoshkov
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22#include <stdarg.h>
23#include <stdio.h>
24#include <math.h>
25#include <float.h>
26
27#define COBJMACROS
28#define CONST_VTABLE
29
30#include "wine/test.h"
31#include <windef.h>
32#include <winbase.h>
33#include <winuser.h>
34#include <wingdi.h>
35#include <winnls.h>
36#include <winerror.h>
37#include <winnt.h>
38
39#include <urlmon.h>
40#include <wtypes.h>
41#include <olectl.h>
42#include <objidl.h>
43
44#define expect_eq(expr, value, type, format) { type ret = (expr); ok((value) == ret, #expr " expected " format " got " format "\n", value, ret); }
45
46#define ole_expect(expr, expect) { \
47 HRESULT r = expr; \
48 ok(r == (expect), #expr " returned %lx, expected %s (%lx)\n", r, #expect, expect); \
49}
50
51#define ole_check(expr) ole_expect(expr, S_OK);
52
54
55static HRESULT (WINAPI *pOleLoadPicture)(LPSTREAM,LONG,BOOL,REFIID,LPVOID*);
56static HRESULT (WINAPI *pOleLoadPictureEx)(LPSTREAM,LONG,BOOL,REFIID,DWORD,DWORD,DWORD,LPVOID*);
57
58#define ok_ole_success(hr, func) ok(hr == S_OK, func " failed with error %#08lx\n", hr)
59
60/* 1x1 pixel gif */
61static const unsigned char gifimage[35] = {
620x47,0x49,0x46,0x38,0x37,0x61,0x01,0x00,0x01,0x00,0x80,0x00,0x00,0xff,0xff,0xff,
630xff,0xff,0xff,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x02,0x02,0x44,
640x01,0x00,0x3b
65};
66
67/* 1x1 pixel jpg */
68static const unsigned char jpgimage[285] = {
690xff,0xd8,0xff,0xe0,0x00,0x10,0x4a,0x46,0x49,0x46,0x00,0x01,0x01,0x01,0x01,0x2c,
700x01,0x2c,0x00,0x00,0xff,0xdb,0x00,0x43,0x00,0x05,0x03,0x04,0x04,0x04,0x03,0x05,
710x04,0x04,0x04,0x05,0x05,0x05,0x06,0x07,0x0c,0x08,0x07,0x07,0x07,0x07,0x0f,0x0b,
720x0b,0x09,0x0c,0x11,0x0f,0x12,0x12,0x11,0x0f,0x11,0x11,0x13,0x16,0x1c,0x17,0x13,
730x14,0x1a,0x15,0x11,0x11,0x18,0x21,0x18,0x1a,0x1d,0x1d,0x1f,0x1f,0x1f,0x13,0x17,
740x22,0x24,0x22,0x1e,0x24,0x1c,0x1e,0x1f,0x1e,0xff,0xdb,0x00,0x43,0x01,0x05,0x05,
750x05,0x07,0x06,0x07,0x0e,0x08,0x08,0x0e,0x1e,0x14,0x11,0x14,0x1e,0x1e,0x1e,0x1e,
760x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,
770x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,
780x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0xff,0xc0,
790x00,0x11,0x08,0x00,0x01,0x00,0x01,0x03,0x01,0x22,0x00,0x02,0x11,0x01,0x03,0x11,
800x01,0xff,0xc4,0x00,0x15,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
810x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0xff,0xc4,0x00,0x14,0x10,0x01,0x00,0x00,
820x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xc4,
830x00,0x14,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
840x00,0x00,0x00,0x00,0xff,0xc4,0x00,0x14,0x11,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
850x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xda,0x00,0x0c,0x03,0x01,
860x00,0x02,0x11,0x03,0x11,0x00,0x3f,0x00,0xb2,0xc0,0x07,0xff,0xd9
87};
88
89/* 1x1 pixel png */
90static const unsigned char pngimage[285] = {
910x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52,
920x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x08,0x02,0x00,0x00,0x00,0x90,0x77,0x53,
930xde,0x00,0x00,0x00,0x09,0x70,0x48,0x59,0x73,0x00,0x00,0x0b,0x13,0x00,0x00,0x0b,
940x13,0x01,0x00,0x9a,0x9c,0x18,0x00,0x00,0x00,0x07,0x74,0x49,0x4d,0x45,0x07,0xd5,
950x06,0x03,0x0f,0x07,0x2d,0x12,0x10,0xf0,0xfd,0x00,0x00,0x00,0x0c,0x49,0x44,0x41,
960x54,0x08,0xd7,0x63,0xf8,0xff,0xff,0x3f,0x00,0x05,0xfe,0x02,0xfe,0xdc,0xcc,0x59,
970xe7,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
98};
99
100/* 1x1 pixel bmp */
101static const unsigned char bmpimage[66] = {
1020x42,0x4d,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x28,0x00,
1030x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00,
1040x00,0x00,0x04,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x02,0x00,
1050x00,0x00,0x02,0x00,0x00,0x00,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,0x00,0x00,
1060x00,0x00
107};
108
109/* 2x2 pixel gif */
110static const unsigned char gif4pixel[42] = {
1110x47,0x49,0x46,0x38,0x37,0x61,0x02,0x00,0x02,0x00,0xa1,0x00,0x00,0x00,0x00,0x00,
1120x39,0x62,0xfc,0xff,0x1a,0xe5,0xff,0xff,0xff,0x2c,0x00,0x00,0x00,0x00,0x02,0x00,
1130x02,0x00,0x00,0x02,0x03,0x14,0x16,0x05,0x00,0x3b
114};
115
116/* APM with an empty metafile with some padding zeros - looks like under Window the
117 * metafile data should be at least 20 bytes */
118static const unsigned char apmdata[] = {
1190xd7,0xcd,0xc6,0x9a, 0x00,0x00,0x00,0x00, 0x00,0x00,0xee,0x02, 0xb1,0x03,0xa0,0x05,
1200x00,0x00,0x00,0x00, 0xee,0x53,0x01,0x00, 0x09,0x00,0x00,0x03, 0x13,0x00,0x00,0x00,
1210x01,0x00,0x05,0x00, 0x00,0x00,0x00,0x00, 0x03,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
1220x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00
123};
124
125/* MF_TEXTOUT_ON_PATH_BITS from gdi32/tests/metafile.c */
126static const unsigned char metafile[] = {
127 0x01, 0x00, 0x09, 0x00, 0x00, 0x03, 0x19, 0x00,
128 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00,
129 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x32, 0x0a,
130 0x16, 0x00, 0x0b, 0x00, 0x04, 0x00, 0x00, 0x00,
131 0x54, 0x65, 0x73, 0x74, 0x03, 0x00, 0x05, 0x00,
132 0x08, 0x00, 0x0c, 0x00, 0x03, 0x00, 0x00, 0x00,
133 0x00, 0x00
134};
135
136/* EMF_TEXTOUT_ON_PATH_BITS from gdi32/tests/metafile.c */
137static const unsigned char enhmetafile[] = {
138 0x01, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00,
139 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
140 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
141 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
142 0xe7, 0xff, 0xff, 0xff, 0xe9, 0xff, 0xff, 0xff,
143 0x20, 0x45, 0x4d, 0x46, 0x00, 0x00, 0x01, 0x00,
144 0xf4, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
145 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
146 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
147 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
148 0x40, 0x01, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00,
149 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
150 0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, 0x04, 0x00,
151 0x80, 0xa9, 0x03, 0x00, 0x3b, 0x00, 0x00, 0x00,
152 0x08, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00,
153 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
154 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
155 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
156 0x00, 0x00, 0xc8, 0x41, 0x00, 0x80, 0xbb, 0x41,
157 0x0b, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00,
158 0x04, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00,
159 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
160 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
161 0xff, 0xff, 0xff, 0xff, 0x54, 0x00, 0x00, 0x00,
162 0x54, 0x00, 0x65, 0x00, 0x73, 0x00, 0x74, 0x00,
163 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
164 0x08, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
165 0x3c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
166 0x0e, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
167 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
168 0x14, 0x00, 0x00, 0x00
169};
170
172
173static HDC create_render_dc( void )
174{
176 BITMAPINFO info = {{sizeof(info.bmiHeader), 100, 100, 1, 32, BI_RGB }};
177 void *bits;
179
180 stock_bm = SelectObject( dc, dib );
181 return dc;
182}
183
184static void delete_render_dc( HDC dc )
185{
187 DeleteObject( dib );
188 DeleteDC( dc );
189}
190
191typedef struct NoStatStreamImpl
192{
195
200
201static IStream* NoStatStream_Construct(HGLOBAL hGlobal);
202
203static void
205{
206 IPicture* pic = NULL;
208 LPVOID pvObj = NULL;
209 OLE_HANDLE handle, hPal;
210 OLE_XSIZE_HIMETRIC width;
211 OLE_YSIZE_HIMETRIC height;
212 short type;
213 DWORD attr;
214 ULONG res;
215
216 pvObj = NULL;
217 hres = pOleLoadPicture(stream, imgsize, TRUE, &IID_IPicture, &pvObj);
218 pic = pvObj;
219
220 ok(hres == S_OK,"OLP (NULL,..) does not return 0, but 0x%08lx\n",hres);
221 ok(pic != NULL,"OLP (NULL,..) returns NULL, instead of !NULL\n");
222 if (pic == NULL)
223 return;
224
225 pvObj = NULL;
226 hres = IPicture_QueryInterface (pic, &IID_IPicture, &pvObj);
227
228 ok(hres == S_OK,"IPicture_QI does not return S_OK, but 0x%08lx\n", hres);
229 ok(pvObj != NULL,"IPicture_QI does return NULL, instead of a ptr\n");
230
231 IPicture_Release ((IPicture*)pvObj);
232
233 handle = 0;
234 hres = IPicture_get_Handle (pic, &handle);
235 ok(hres == S_OK,"IPicture_get_Handle does not return S_OK, but 0x%08lx\n", hres);
236 ok(handle != 0, "IPicture_get_Handle returns a NULL handle, but it should be non NULL\n");
237
238 if (handle)
239 {
240 BITMAP bmp;
242 todo_wine ok(bmp.bmBits != 0, "not a dib\n");
243 }
244
245 width = 0;
246 hres = IPicture_get_Width (pic, &width);
247 ok(hres == S_OK,"IPicture_get_Width does not return S_OK, but 0x%08lx\n", hres);
248 ok(width != 0, "IPicture_get_Width returns 0, but it should not be 0.\n");
249
250 height = 0;
251 hres = IPicture_get_Height (pic, &height);
252 ok(hres == S_OK,"IPicture_get_Height does not return S_OK, but 0x%08lx\n", hres);
253 ok(height != 0, "IPicture_get_Height returns 0, but it should not be 0.\n");
254
255 type = 0;
256 hres = IPicture_get_Type (pic, &type);
257 ok(hres == S_OK,"IPicture_get_Type does not return S_OK, but 0x%08lx\n", hres);
258 ok(type == PICTYPE_BITMAP, "IPicture_get_Type returns %d, but it should be PICTYPE_BITMAP(%d).\n", type, PICTYPE_BITMAP);
259
260 attr = 0;
261 hres = IPicture_get_Attributes (pic, &attr);
262 ok(hres == S_OK,"IPicture_get_Attributes does not return S_OK, but 0x%08lx\n", hres);
263 ok(attr == 0, "IPicture_get_Attributes returns %ld, but it should be 0.\n", attr);
264
265 hPal = 0;
266 hres = IPicture_get_hPal (pic, &hPal);
267 ok(hres == S_OK,"IPicture_get_hPal does not return S_OK, but 0x%08lx\n", hres);
268 /* a single pixel b/w image has no palette */
269 ok(hPal == 0, "IPicture_get_hPal returns %d, but it should be 0.\n", hPal);
270
271 res = IPicture_Release (pic);
272 ok (res == 0, "refcount after release is %ld, but should be 0?\n", res);
273}
274
275static void
276test_pic(const unsigned char *imgdata, unsigned int imgsize)
277{
279 HGLOBAL hglob;
280 LPBYTE data;
283 ULARGE_INTEGER newpos1;
284 DWORD * header;
285 unsigned int i,j;
286
287 /* Let the fun begin */
288 hglob = GlobalAlloc (0, imgsize);
289 data = GlobalLock (hglob);
290 memcpy(data, imgdata, imgsize);
291 GlobalUnlock(hglob); data = NULL;
292
294 ok (hres == S_OK, "createstreamonhglobal failed? doubt it... hres 0x%08lx\n", hres);
295
296 memset(&seekto,0,sizeof(seekto));
297 hres = IStream_Seek(stream,seekto,SEEK_CUR,&newpos1);
298 ok (hres == S_OK, "istream seek failed? doubt it... hres 0x%08lx\n", hres);
300
301 IStream_Release(stream);
302
303 /* again with Non Statable and Non Seekable stream */
305 hglob = 0; /* Non-statable impl always deletes on release */
307
308 IStream_Release(stream);
309 for (i = 1; i <= 8; i++) {
310 /* more fun!!! */
311 hglob = GlobalAlloc (0, imgsize + i * (2 * sizeof(DWORD)));
312 data = GlobalLock (hglob);
313 header = (DWORD *)data;
314
315 /* multiple copies of header */
316 memcpy(data,"lt\0\0",4);
317 header[1] = imgsize;
318 for (j = 2; j <= i; j++) {
319 memcpy(&(header[2 * (j - 1)]), header, 2 * sizeof(DWORD));
320 }
321 memcpy(data + i * (2 * sizeof(DWORD)), imgdata, imgsize);
322 GlobalUnlock(hglob); data = NULL;
323
325 ok (hres == S_OK, "createstreamonhglobal failed? doubt it... hres 0x%08lx\n", hres);
326
327 memset(&seekto,0,sizeof(seekto));
328 hres = IStream_Seek(stream,seekto,SEEK_CUR,&newpos1);
329 ok (hres == S_OK, "istream seek failed? doubt it... hres 0x%08lx\n", hres);
331
332 IStream_Release(stream);
333
334 /* again with Non Statable and Non Seekable stream */
336 hglob = 0; /* Non-statable impl always deletes on release */
338
339 IStream_Release(stream);
340 }
341}
342
343static void test_empty_image(void) {
344 LPBYTE data;
346 IPicture* pic = NULL;
348 LPVOID pvObj = NULL;
349 HGLOBAL hglob;
350 OLE_HANDLE handle;
351 ULARGE_INTEGER newpos1;
353 short type;
354 DWORD attr;
355
356 /* Empty image. Happens occasionally in VB programs. */
357 hglob = GlobalAlloc (0, 8);
358 data = GlobalLock (hglob);
359 memcpy(data,"lt\0\0",4);
360 ((DWORD*)data)[1] = 0;
362 ok (hres == S_OK, "CreatestreamOnHGlobal failed? doubt it... hres 0x%08lx\n", hres);
363
364 memset(&seekto,0,sizeof(seekto));
365 hres = IStream_Seek(stream,seekto,SEEK_CUR,&newpos1);
366 ok (hres == S_OK, "istream seek failed? doubt it... hres 0x%08lx\n", hres);
367
368 pvObj = NULL;
369 hres = pOleLoadPicture(stream, 8, TRUE, &IID_IPicture, &pvObj);
370 pic = pvObj;
371 ok(hres == S_OK,"empty picture not loaded, hres 0x%08lx\n", hres);
372 ok(pic != NULL,"empty picture not loaded, pic is NULL\n");
373
374 hres = IPicture_get_Type (pic, &type);
375 ok (hres == S_OK,"empty picture get type failed with hres 0x%08lx\n", hres);
376 ok (type == PICTYPE_NONE,"type is %d, but should be PICTYPE_NONE(0)\n", type);
377
378 attr = 0xdeadbeef;
379 hres = IPicture_get_Attributes (pic, &attr);
380 ok (hres == S_OK,"empty picture get attributes failed with hres 0x%08lx\n", hres);
381 ok (attr == 0,"attr is %ld, but should be 0\n", attr);
382
383 hres = IPicture_get_Handle (pic, &handle);
384 ok (hres == S_OK,"empty picture get handle failed with hres 0x%08lx\n", hres);
385 ok (handle == 0, "empty picture get handle did not return 0, but 0x%08x\n", handle);
386 IPicture_Release (pic);
387 IStream_Release (stream);
388}
389
390static void test_empty_image_2(void) {
391 LPBYTE data;
393 IPicture* pic = NULL;
395 LPVOID pvObj = NULL;
396 HGLOBAL hglob;
397 ULARGE_INTEGER newpos1;
399 short type;
400
401 /* Empty image at random stream position. */
402 hglob = GlobalAlloc (0, 200);
403 data = GlobalLock (hglob);
404 data += 42;
405 memcpy(data,"lt\0\0",4);
406 ((DWORD*)data)[1] = 0;
408 ok (hres == S_OK, "CreatestreamOnHGlobal failed? doubt it... hres 0x%08lx\n", hres);
409
410 memset(&seekto,0,sizeof(seekto));
411 seekto.LowPart = 42;
412 hres = IStream_Seek(stream,seekto,SEEK_CUR,&newpos1);
413 ok (hres == S_OK, "istream seek failed? doubt it... hres 0x%08lx\n", hres);
414
415 pvObj = NULL;
416 hres = pOleLoadPicture(stream, 8, TRUE, &IID_IPicture, &pvObj);
417 pic = pvObj;
418 ok(hres == S_OK,"empty picture not loaded, hres 0x%08lx\n", hres);
419 ok(pic != NULL,"empty picture not loaded, pic is NULL\n");
420
421 hres = IPicture_get_Type (pic, &type);
422 ok (hres == S_OK,"empty picture get type failed with hres 0x%08lx\n", hres);
423 ok (type == PICTYPE_NONE,"type is %d, but should be PICTYPE_NONE(0)\n", type);
424
425 IPicture_Release (pic);
426 IStream_Release (stream);
427}
428
429static void test_Invoke(void)
430{
431 IPictureDisp *picdisp;
432 HRESULT hr;
433 VARIANTARG vararg, args[10];
434 DISPPARAMS dispparams;
435 VARIANT varresult;
437 HGLOBAL hglob;
438 void *data;
439 HDC hdc;
440 int i;
441
442 hglob = GlobalAlloc (0, sizeof(gifimage));
443 data = GlobalLock(hglob);
444 memcpy(data, gifimage, sizeof(gifimage));
445 GlobalUnlock(hglob);
446
448 ok_ole_success(hr, "CreateStreamOnHGlobal");
449
450 hr = pOleLoadPicture(stream, sizeof(gifimage), TRUE, &IID_IPictureDisp, (void **)&picdisp);
451 IStream_Release(stream);
452 GlobalFree(hglob);
453 ok_ole_success(hr, "OleLoadPicture");
454
455 V_VT(&vararg) = VT_BOOL;
456 V_BOOL(&vararg) = VARIANT_FALSE;
457 dispparams.cNamedArgs = 0;
458 dispparams.rgdispidNamedArgs = NULL;
459 dispparams.cArgs = 1;
460 dispparams.rgvarg = &vararg;
461 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_IPictureDisp, 0, DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL);
462 ok(hr == DISP_E_UNKNOWNNAME, "IPictureDisp_Invoke should have returned DISP_E_UNKNOWNNAME instead of 0x%08lx\n", hr);
463 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_IUnknown, 0, DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL);
464 ok(hr == DISP_E_UNKNOWNNAME, "IPictureDisp_Invoke should have returned DISP_E_UNKNOWNNAME instead of 0x%08lx\n", hr);
465
466 dispparams.cArgs = 0;
467 dispparams.rgvarg = NULL;
468 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL);
469 ok(hr == DISP_E_BADPARAMCOUNT, "IPictureDisp_Invoke should have returned DISP_E_BADPARAMCOUNT instead of 0x%08lx\n", hr);
470
471 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYPUT, NULL, NULL, NULL, NULL);
472 ok(hr == DISP_E_PARAMNOTOPTIONAL, "IPictureDisp_Invoke should have returned DISP_E_PARAMNOTOPTIONAL instead of 0x%08lx\n", hr);
473
474 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYGET, NULL, NULL, NULL, NULL);
475 ok(hr == DISP_E_PARAMNOTOPTIONAL, "IPictureDisp_Invoke should have returned DISP_E_PARAMNOTOPTIONAL instead of 0x%08lx\n", hr);
476
477 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYGET, NULL, &varresult, NULL, NULL);
478 ok(hr == DISP_E_PARAMNOTOPTIONAL, "IPictureDisp_Invoke should have returned DISP_E_PARAMNOTOPTIONAL instead of 0x%08lx\n", hr);
479
480 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dispparams, &varresult, NULL, NULL);
481 ok_ole_success(hr, "IPictureDisp_Invoke");
482 ok(V_VT(&varresult) == VT_I4, "V_VT(&varresult) should have been VT_UINT instead of %d\n", V_VT(&varresult));
483
484 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_METHOD, &dispparams, &varresult, NULL, NULL);
485 ok(hr == DISP_E_MEMBERNOTFOUND, "IPictureDisp_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08lx\n", hr);
486
487 hr = IPictureDisp_Invoke(picdisp, 0xdeadbeef, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dispparams, &varresult, NULL, NULL);
488 ok(hr == DISP_E_MEMBERNOTFOUND, "IPictureDisp_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08lx\n", hr);
489
490 dispparams.cArgs = 1;
491 dispparams.rgvarg = &vararg;
492 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dispparams, &varresult, NULL, NULL);
493 ok(hr == DISP_E_BADPARAMCOUNT, "IPictureDisp_Invoke should have returned DISP_E_BADPARAMCOUNT instead of 0x%08lx\n", hr);
494
495 dispparams.cArgs = 1;
496 dispparams.rgvarg = &vararg;
497 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dispparams, &varresult, NULL, NULL);
498 ok(hr == DISP_E_BADPARAMCOUNT, "IPictureDisp_Invoke should have returned DISP_E_BADPARAMCOUNT instead of 0x%08lx\n", hr);
499
500 /* DISPID_PICT_RENDER */
502
503 for (i = 0; i < ARRAY_SIZE(args); i++)
504 V_VT(&args[i]) = VT_I4;
505
506 V_I4(&args[0]) = 0;
507 V_I4(&args[1]) = 10;
508 V_I4(&args[2]) = 10;
509 V_I4(&args[3]) = 0;
510 V_I4(&args[4]) = 0;
511 V_I4(&args[5]) = 10;
512 V_I4(&args[6]) = 10;
513 V_I4(&args[7]) = 0;
514 V_I4(&args[8]) = 0;
515 V_I4(&args[9]) = HandleToLong(hdc);
516
517 dispparams.rgvarg = args;
518 dispparams.rgdispidNamedArgs = NULL;
519 dispparams.cArgs = 10;
520 dispparams.cNamedArgs = 0;
521
522 V_VT(&varresult) = VT_EMPTY;
523 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_RENDER, &GUID_NULL, 0, DISPATCH_METHOD, &dispparams, &varresult, NULL, NULL);
524 ok(hr == S_OK, "got 0x%08lx\n", hr);
525
526 /* Try with one argument set to VT_I2, it'd still work if coerced. */
527 V_VT(&args[3]) = VT_I2;
528 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_RENDER, &GUID_NULL, 0, DISPATCH_METHOD, &dispparams, &varresult, NULL, NULL);
529 ok(hr == DISP_E_TYPEMISMATCH, "got 0x%08lx\n", hr);
530 V_VT(&args[3]) = VT_I4;
531
532 /* Wrong argument count */
533 dispparams.cArgs = 9;
534 hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_RENDER, &GUID_NULL, 0, DISPATCH_METHOD, &dispparams, &varresult, NULL, NULL);
535 ok(hr == DISP_E_BADPARAMCOUNT, "got 0x%08lx\n", hr);
536
538 IPictureDisp_Release(picdisp);
539}
540
541static HRESULT create_picture(short type, IPicture **pict)
542{
544
545 desc.cbSizeofstruct = sizeof(desc);
546 desc.picType = type;
547
548 switch (type)
549 {
551 return OleCreatePictureIndirect(NULL, &IID_IPicture, TRUE, (void **)pict);
552
553 case PICTYPE_NONE:
554 break;
555
556 case PICTYPE_BITMAP:
557 desc.bmp.hbitmap = CreateBitmap(1, 1, 1, 1, NULL);
558 desc.bmp.hpal = (HPALETTE)0xbeefdead;
559 break;
560
561 case PICTYPE_ICON:
562 desc.icon.hicon = LoadIconA(NULL, (LPCSTR)IDI_APPLICATION);
563 break;
564
565 case PICTYPE_METAFILE:
566 {
568 desc.wmf.hmeta = CloseMetaFile(hdc);
569 desc.wmf.xExt = 1;
570 desc.wmf.yExt = 1;
571 break;
572 }
573
575 {
577 desc.emf.hemf = CloseEnhMetaFile(hdc);
578 break;
579 }
580
581 default:
582 ok(0, "picture type %d is not supported\n", type);
583 return E_NOTIMPL;
584 }
585
586 return OleCreatePictureIndirect(&desc, &IID_IPicture, TRUE, (void **)pict);
587}
588
590{
592 OLE_HANDLE handle;
593 IPicture *pict;
594 HRESULT hr;
595 short type, i;
596
597if (0)
598{
599 /* crashes on native */
601}
602
603 desc.cbSizeofstruct = sizeof(desc);
604 desc.picType = PICTYPE_UNINITIALIZED;
605 pict = (void *)0xdeadbeef;
606 hr = OleCreatePictureIndirect(&desc, &IID_IPicture, TRUE, (void **)&pict);
607 ok(hr == E_UNEXPECTED, "got %#lx\n", hr);
608 ok(pict == NULL, "got %p\n", pict);
609
611 {
612 hr = create_picture(i, &pict);
613 ok(hr == S_OK, "%d: got %#lx\n", i, hr);
614
615 type = 0xdead;
616 hr = IPicture_get_Type(pict, &type);
617 ok(hr == S_OK, "%d: got %#lx\n", i, hr);
618 ok(type == i, "%d: got %d\n", i, type);
619
620 handle = 0xdeadbeef;
621 hr = IPicture_get_Handle(pict, &handle);
622 ok(hr == S_OK, "%d: got %#lx\n", i, hr);
624 ok(handle == 0, "%d: got %#x\n", i, handle);
625 else
626 ok(handle != 0 && handle != 0xdeadbeef, "%d: got %#x\n", i, handle);
627
628 handle = 0xdeadbeef;
629 hr = IPicture_get_hPal(pict, &handle);
630 if (type == PICTYPE_BITMAP)
631 {
632 ok(hr == S_OK, "%d: got %#lx\n", i, hr);
633 ok(handle == 0xbeefdead, "%d: got %#x\n", i, handle);
634 }
635 else
636 {
637 ok(hr == E_FAIL, "%d: got %#lx\n", i, hr);
638 ok(handle == 0xdeadbeef || handle == 0 /* win64 */, "%d: got %#x\n", i, handle);
639 }
640
641 hr = IPicture_set_hPal(pict, HandleToUlong(GetStockObject(DEFAULT_PALETTE)));
642 if (type == PICTYPE_BITMAP)
643 ok(hr == S_OK, "%d: got %#lx\n", i, hr);
644 else
645 ok(hr == E_FAIL, "%d: got %#lx\n", i, hr);
646
647 IPicture_Release(pict);
648 }
649}
650
651static void test_apm(void)
652{
653 OLE_HANDLE handle;
655 IPicture *pict;
656 HGLOBAL hglob;
657 LPBYTE *data;
658 LONG cxy;
659 BOOL keep;
660 short type;
661
662 hglob = GlobalAlloc (0, sizeof(apmdata));
663 data = GlobalLock(hglob);
664 memcpy(data, apmdata, sizeof(apmdata));
665
667 ole_check(pOleLoadPictureEx(stream, sizeof(apmdata), TRUE, &IID_IPicture, 100, 100, 0, (LPVOID *)&pict));
668
669 ole_check(IPicture_get_Handle(pict, &handle));
670 ok(handle != 0, "handle is null\n");
671
672 ole_check(IPicture_get_Type(pict, &type));
673 expect_eq(type, PICTYPE_METAFILE, short, "%d");
674
675 ole_check(IPicture_get_Height(pict, &cxy));
676 expect_eq(cxy, 1667l, LONG, "%ld");
677
678 ole_check(IPicture_get_Width(pict, &cxy));
679 expect_eq(cxy, 1323l, LONG, "%ld");
680
681 ole_check(IPicture_get_KeepOriginalFormat(pict, &keep));
682 todo_wine expect_eq(keep, (LONG)FALSE, LONG, "%ld");
683
684 ole_expect(IPicture_get_hPal(pict, &handle), E_FAIL);
685 IPicture_Release(pict);
686 IStream_Release(stream);
687}
688
689static void test_metafile(void)
690{
692 IPicture *pict;
693 HGLOBAL hglob;
694 LPBYTE *data;
695
696 hglob = GlobalAlloc (0, sizeof(metafile));
697 data = GlobalLock(hglob);
698 memcpy(data, metafile, sizeof(metafile));
699
701 /* Windows does not load simple metafiles */
702 ole_expect(pOleLoadPictureEx(stream, sizeof(metafile), TRUE, &IID_IPicture, 100, 100, 0, (LPVOID *)&pict), E_FAIL);
703
704 IStream_Release(stream);
705}
706
707static void test_enhmetafile(void)
708{
709 OLE_HANDLE handle;
711 IPicture *pict;
712 HGLOBAL hglob;
713 LPBYTE *data;
714 LONG cxy;
715 BOOL keep;
716 short type;
717
718 hglob = GlobalAlloc (0, sizeof(enhmetafile));
719 data = GlobalLock(hglob);
721
723 ole_check(pOleLoadPictureEx(stream, sizeof(enhmetafile), TRUE, &IID_IPicture, 10, 10, 0, (LPVOID *)&pict));
724
725 ole_check(IPicture_get_Handle(pict, &handle));
726 ok(handle != 0, "handle is null\n");
727
728 ole_check(IPicture_get_Type(pict, &type));
729 expect_eq(type, PICTYPE_ENHMETAFILE, short, "%d");
730
731 ole_check(IPicture_get_Height(pict, &cxy));
732 expect_eq(cxy, -23l, LONG, "%ld");
733
734 ole_check(IPicture_get_Width(pict, &cxy));
735 expect_eq(cxy, -25l, LONG, "%ld");
736
737 ole_check(IPicture_get_KeepOriginalFormat(pict, &keep));
738 todo_wine expect_eq(keep, (LONG)FALSE, LONG, "%ld");
739
740 IPicture_Release(pict);
741 IStream_Release(stream);
742}
743
745 OLE_XPOS_HIMETRIC xSrc,
746 OLE_YPOS_HIMETRIC ySrc,
747 OLE_XSIZE_HIMETRIC cxSrc,
748 OLE_YSIZE_HIMETRIC cySrc,
749 const RECT *bounds)
750{
751 VARIANT ret, args[10];
752 HRESULT hr, hr_disp;
753 DISPPARAMS params;
754 IDispatch *disp;
755 int i;
756
757 hr = IPicture_Render(iface, hdc, x, y, cx, cy, xSrc, ySrc, cxSrc, cySrc, bounds);
758
759 IPicture_QueryInterface(iface, &IID_IDispatch, (void**)&disp);
760
761 /* This is broken on 64 bits - accepted pointer argument type is still VT_I4 */
762 for (i = 0; i < ARRAY_SIZE(args); i++)
763 V_VT(&args[i]) = VT_I4;
764
765 /* pack arguments and call */
766 V_INT_PTR(&args[0]) = (INT_PTR)bounds;
767 V_I4(&args[1]) = cySrc;
768 V_I4(&args[2]) = cxSrc;
769 V_I4(&args[3]) = ySrc;
770 V_I4(&args[4]) = xSrc;
771 V_I4(&args[5]) = cy;
772 V_I4(&args[6]) = cx;
773 V_I4(&args[7]) = y;
774 V_I4(&args[8]) = x;
775 V_I4(&args[9]) = HandleToLong(hdc);
776
777 params.rgvarg = args;
778 params.rgdispidNamedArgs = NULL;
779 params.cArgs = 10;
780 params.cNamedArgs = 0;
781
782 V_VT(&ret) = VT_EMPTY;
783 hr_disp = IDispatch_Invoke(disp, DISPID_PICT_RENDER, &GUID_NULL, 0, DISPATCH_METHOD,
784 &params, &ret, NULL, NULL);
785 ok(hr == hr_disp, "DISPID_PICT_RENDER returned wrong code, 0x%08lx, expected 0x%08lx\n",
786 hr_disp, hr);
787
788 IDispatch_Release(disp);
789
790 return hr;
791}
792
793static void test_Render(void)
794{
795 IPicture *pic;
797 short type;
799 OLE_XSIZE_HIMETRIC pWidth;
800 OLE_YSIZE_HIMETRIC pHeight;
803
804 /* test IPicture::Render return code on uninitialized picture */
806 ok(hres == S_OK, "Failed to create a picture, hr %#lx.\n", hres);
807 hres = IPicture_get_Type(pic, &type);
808 ok(hres == S_OK, "IPicture_get_Type does not return S_OK, but 0x%08lx\n", hres);
809 ok(type == PICTYPE_UNINITIALIZED, "Expected type = PICTYPE_UNINITIALIZED, got = %d\n", type);
810 /* zero dimensions */
811 hres = picture_render(pic, hdc, 0, 0, 0, 0, 0, 0, 0, 0, NULL);
813 hres = picture_render(pic, hdc, 0, 0, 10, 10, 0, 0, 10, 0, NULL);
815 hres = picture_render(pic, hdc, 0, 0, 10, 10, 0, 0, 0, 10, NULL);
817 hres = picture_render(pic, hdc, 0, 0, 10, 10, 0, 0, 0, 0, NULL);
819 hres = picture_render(pic, hdc, 0, 0, 0, 10, 0, 0, 10, 10, NULL);
821 hres = picture_render(pic, hdc, 0, 0, 10, 0, 0, 0, 10, 10, NULL);
823 hres = picture_render(pic, hdc, 0, 0, 0, 0, 0, 0, 10, 10, NULL);
825 /* nonzero dimensions, PICTYPE_UNINITIALIZED */
826 hres = picture_render(pic, hdc, 0, 0, 10, 10, 0, 0, 10, 10, NULL);
828 IPicture_Release(pic);
829
830 desc.cbSizeofstruct = sizeof(PICTDESC);
831 desc.picType = PICTYPE_ICON;
832 desc.icon.hicon = LoadIconA(NULL, (LPCSTR)IDI_APPLICATION);
833 if(!desc.icon.hicon){
834 win_skip("LoadIcon failed. Skipping...\n");
836 return;
837 }
838
839 hres = OleCreatePictureIndirect(&desc, &IID_IPicture, TRUE, (void **)&pic);
840 ok(hres == S_OK, "Failed to create a picture, hr %#lx.\n", hres);
841 /* zero dimensions, PICTYPE_ICON */
842 hres = picture_render(pic, hdc, 0, 0, 0, 0, 0, 0, 0, 0, NULL);
844 hres = picture_render(pic, hdc, 0, 0, 10, 10, 0, 0, 10, 0, NULL);
846 hres = picture_render(pic, hdc, 0, 0, 10, 10, 0, 0, 0, 10, NULL);
848 hres = picture_render(pic, hdc, 0, 0, 10, 10, 0, 0, 0, 0, NULL);
850 hres = picture_render(pic, hdc, 0, 0, 0, 10, 0, 0, 10, 10, NULL);
852 hres = picture_render(pic, hdc, 0, 0, 10, 0, 0, 0, 10, 10, NULL);
854 hres = picture_render(pic, hdc, 0, 0, 0, 0, 0, 0, 10, 10, NULL);
856
857 /* Check if target size and position is respected */
858 IPicture_get_Width(pic, &pWidth);
859 IPicture_get_Height(pic, &pHeight);
860
861 SetPixelV(hdc, 0, 0, 0x00223344);
862 SetPixelV(hdc, 5, 5, 0x00223344);
863 SetPixelV(hdc, 10, 10, 0x00223344);
864 expected = GetPixel(hdc, 0, 0);
865
866 hres = picture_render(pic, hdc, 1, 1, 9, 9, 0, pHeight, pWidth, -pHeight, NULL);
868
869 if(hres != S_OK) goto done;
870
871 /* Evaluate the rendered Icon */
872 result = GetPixel(hdc, 0, 0);
873 ok(result == expected,
874 "Color at 0,0 should be unchanged 0x%06lX, but was 0x%06lX\n", expected, result);
875 result = GetPixel(hdc, 5, 5);
876 ok(result != expected,
877 "Color at 5,5 should have changed, but still was 0x%06lX\n", expected);
878 result = GetPixel(hdc, 10, 10);
879 ok(result == expected,
880 "Color at 10,10 should be unchanged 0x%06lX, but was 0x%06lX\n", expected, result);
881
882done:
883 IPicture_Release(pic);
885}
886
887static void test_get_Attributes(void)
888{
889 IPicture *pic;
891 short type;
892 DWORD attr;
893
895 ok(hres == S_OK, "Failed to create a picture, hr %#lx.\n", hres);
896 hres = IPicture_get_Type(pic, &type);
897 ok(hres == S_OK, "IPicture_get_Type does not return S_OK, but 0x%08lx\n", hres);
898 ok(type == PICTYPE_UNINITIALIZED, "Expected type = PICTYPE_UNINITIALIZED, got = %d\n", type);
899
900 hres = IPicture_get_Attributes(pic, NULL);
902
903 attr = 0xdeadbeef;
904 hres = IPicture_get_Attributes(pic, &attr);
906 ok(attr == 0, "IPicture_get_Attributes does not reset attr to zero, got %ld\n", attr);
907
908 IPicture_Release(pic);
909}
910
911static void test_get_Handle(void)
912{
913 IPicture *pic;
915
917 ok(hres == S_OK, "Failed to create a picture, hr %#lx.\n", hres);
918 hres = IPicture_get_Handle(pic, NULL);
920
921 IPicture_Release(pic);
922}
923
924static void test_get_Type(void)
925{
926 IPicture *pic;
928
930 ok(hres == S_OK, "Failed to create a picture, hr %#lx.\n", hres);
931
932 hres = IPicture_get_Type(pic, NULL);
934
935 IPicture_Release(pic);
936}
937
938static void test_OleLoadPicturePath(void)
939{
940 static WCHAR emptyW[] = {0};
941
942 IPicture *pic;
944 int i;
945 char temp_path[MAX_PATH];
946 char temp_file[MAX_PATH];
947 WCHAR temp_fileW[MAX_PATH + 5] = {'f','i','l','e',':','/','/','/'};
948 HANDLE file;
949 DWORD size;
950 WCHAR *ptr;
951 VARIANT var;
952
953 const struct
954 {
955 LPOLESTR szURLorPath;
956 REFIID riid;
957 IPicture **pic;
958 } invalid_parameters[] =
959 {
960 {NULL, NULL, NULL},
961 {NULL, NULL, &pic},
963 {NULL, &IID_IPicture, &pic},
964 {emptyW, NULL, NULL},
966 };
967
968 for (i = 0; i < ARRAY_SIZE(invalid_parameters); i++)
969 {
970 pic = (IPicture *)0xdeadbeef;
971 hres = OleLoadPicturePath(invalid_parameters[i].szURLorPath, NULL, 0, 0,
972 invalid_parameters[i].riid,
973 (void **)invalid_parameters[i].pic);
975 "[%d] Expected OleLoadPicturePath to return E_INVALIDARG, got 0x%08lx\n", i, hres);
976 ok(pic == (IPicture *)0xdeadbeef,
977 "[%d] Expected output pointer to be 0xdeadbeef, got %p\n", i, pic);
978 }
979
980 pic = (IPicture *)0xdeadbeef;
981 hres = OleLoadPicturePath(emptyW, NULL, 0, 0, NULL, (void **)&pic);
983 ok(hres == INET_E_UNKNOWN_PROTOCOL || /* XP/Vista+ */
984 broken(hres == E_UNEXPECTED) || /* NT4 */
985 broken(hres == E_OUTOFMEMORY), /* Win2k/Win2k3 */
986 "Expected OleLoadPicturePath to return INET_E_UNKNOWN_PROTOCOL, got 0x%08lx\n", hres);
987 ok(pic == NULL,
988 "Expected the output interface pointer to be NULL, got %p\n", pic);
989
990 pic = (IPicture *)0xdeadbeef;
991 hres = OleLoadPicturePath(emptyW, NULL, 0, 0, &IID_IPicture, (void **)&pic);
993 ok(hres == INET_E_UNKNOWN_PROTOCOL || /* XP/Vista+ */
994 broken(hres == E_UNEXPECTED) || /* NT4 */
995 broken(hres == E_OUTOFMEMORY), /* Win2k/Win2k3 */
996 "Expected OleLoadPicturePath to return INET_E_UNKNOWN_PROTOCOL, got 0x%08lx\n", hres);
997 ok(pic == NULL,
998 "Expected the output interface pointer to be NULL, got %p\n", pic);
999
1000 /* Create a local temporary image file for testing. */
1005 WriteFile(file, bmpimage, sizeof(bmpimage), &size, NULL);
1007
1008 MultiByteToWideChar(CP_ACP, 0, temp_file, -1, temp_fileW + 8, ARRAY_SIZE(temp_fileW) - 8);
1009
1010 /* Try a normal DOS path. */
1011 hres = OleLoadPicturePath(temp_fileW + 8, NULL, 0, 0, &IID_IPicture, (void **)&pic);
1012 ok(hres == S_OK ||
1013 broken(hres == E_UNEXPECTED), /* NT4 */
1014 "Expected OleLoadPicturePath to return S_OK, got 0x%08lx\n", hres);
1015 if (pic)
1016 IPicture_Release(pic);
1017
1018 VariantInit(&var);
1019 V_VT(&var) = VT_BSTR;
1020 V_BSTR(&var) = SysAllocString(temp_fileW + 8);
1021 hres = OleLoadPictureFile(var, (IDispatch **)&pic);
1022 ok(hres == S_OK, "OleLoadPictureFile error %#lx\n", hres);
1023 IPicture_Release(pic);
1024 VariantClear(&var);
1025
1026 /* Try a DOS path with tacked on "file:". */
1027 hres = OleLoadPicturePath(temp_fileW, NULL, 0, 0, &IID_IPicture, (void **)&pic);
1028 ok(hres == S_OK ||
1029 broken(hres == E_UNEXPECTED), /* NT4 */
1030 "Expected OleLoadPicturePath to return S_OK, got 0x%08lx\n", hres);
1031 if (pic)
1032 IPicture_Release(pic);
1033
1034 VariantInit(&var);
1035 V_VT(&var) = VT_BSTR;
1036 V_BSTR(&var) = SysAllocString(temp_fileW);
1037 hres = OleLoadPictureFile(var, (IDispatch **)&pic);
1038 ok(hres == CTL_E_PATHFILEACCESSERROR, "wrong error %#lx\n", hres);
1039 VariantClear(&var);
1040
1042
1043 /* Try with a nonexistent file. */
1044 hres = OleLoadPicturePath(temp_fileW + 8, NULL, 0, 0, &IID_IPicture, (void **)&pic);
1045 ok(hres == INET_E_RESOURCE_NOT_FOUND || /* XP+ */
1046 broken(hres == E_UNEXPECTED) || /* NT4 */
1047 broken(hres == E_FAIL), /*Win2k */
1048 "Expected OleLoadPicturePath to return INET_E_RESOURCE_NOT_FOUND, got 0x%08lx\n", hres);
1049
1050 VariantInit(&var);
1051 V_VT(&var) = VT_BSTR;
1052 V_BSTR(&var) = SysAllocString(temp_fileW + 8);
1053 hres = OleLoadPictureFile(var, (IDispatch **)&pic);
1054 ok(hres == CTL_E_FILENOTFOUND, "wrong error %#lx\n", hres);
1055 VariantClear(&var);
1056
1057 hres = OleLoadPicturePath(temp_fileW, NULL, 0, 0, &IID_IPicture, (void **)&pic);
1058 ok(hres == INET_E_RESOURCE_NOT_FOUND || /* XP+ */
1059 broken(hres == E_UNEXPECTED) || /* NT4 */
1060 broken(hres == E_FAIL), /* Win2k */
1061 "Expected OleLoadPicturePath to return INET_E_RESOURCE_NOT_FOUND, got 0x%08lx\n", hres);
1062
1063 VariantInit(&var);
1064 V_VT(&var) = VT_BSTR;
1065 V_BSTR(&var) = SysAllocString(temp_fileW);
1066 hres = OleLoadPictureFile(var, (IDispatch **)&pic);
1067 ok(hres == CTL_E_PATHFILEACCESSERROR, "wrong error %#lx\n", hres);
1068 VariantClear(&var);
1069
1072 WriteFile(file, bmpimage, sizeof(bmpimage), &size, NULL);
1074
1075 /* Try a "file:" URL with slash separators. */
1076 ptr = temp_fileW + 8;
1077 while (*ptr)
1078 {
1079 if (*ptr == '\\')
1080 *ptr = '/';
1081 ptr++;
1082 }
1083
1084 hres = OleLoadPicturePath(temp_fileW, NULL, 0, 0, &IID_IPicture, (void **)&pic);
1085 ok(hres == S_OK ||
1086 broken(hres == E_UNEXPECTED), /* NT4 */
1087 "Expected OleLoadPicturePath to return S_OK, got 0x%08lx\n", hres);
1088 if (pic)
1089 IPicture_Release(pic);
1090
1091 VariantInit(&var);
1092 V_VT(&var) = VT_BSTR;
1093 V_BSTR(&var) = SysAllocString(temp_fileW);
1094 hres = OleLoadPictureFile(var, (IDispatch **)&pic);
1095 ok(hres == CTL_E_PATHFILEACCESSERROR, "wrong error %#lx\n", hres);
1096 VariantClear(&var);
1097
1099
1100 /* Try with a nonexistent file. */
1101 hres = OleLoadPicturePath(temp_fileW, NULL, 0, 0, &IID_IPicture, (void **)&pic);
1102 ok(hres == INET_E_RESOURCE_NOT_FOUND || /* XP+ */
1103 broken(hres == E_UNEXPECTED) || /* NT4 */
1104 broken(hres == E_FAIL), /* Win2k */
1105 "Expected OleLoadPicturePath to return INET_E_RESOURCE_NOT_FOUND, got 0x%08lx\n", hres);
1106
1107 VariantInit(&var);
1108 V_VT(&var) = VT_BSTR;
1109 V_BSTR(&var) = SysAllocString(temp_fileW);
1110 hres = OleLoadPictureFile(var, (IDispatch **)&pic);
1111 ok(hres == CTL_E_PATHFILEACCESSERROR, "wrong error %#lx\n", hres);
1112 VariantClear(&var);
1113
1114 VariantInit(&var);
1115 V_VT(&var) = VT_INT;
1116 V_INT(&var) = 762;
1117 hres = OleLoadPictureFile(var, (IDispatch **)&pic);
1118 ok(hres == CTL_E_FILENOTFOUND, "wrong error %#lx\n", hres);
1119
1120 if (0) /* crashes under Windows */
1122}
1123
1124static void test_himetric(void)
1125{
1126 static const BYTE bmp_bits[1024];
1127 OLE_XSIZE_HIMETRIC cx;
1128 OLE_YSIZE_HIMETRIC cy;
1129 IPicture *pic;
1130 PICTDESC desc;
1131 HBITMAP bmp;
1132 HRESULT hr;
1133 HICON icon;
1134 HDC hdc;
1135 INT d;
1136
1137 desc.cbSizeofstruct = sizeof(desc);
1138 desc.picType = PICTYPE_BITMAP;
1139 desc.bmp.hpal = NULL;
1140
1142
1144 1.9 * GetDeviceCaps(hdc, LOGPIXELSY), 1, 1, NULL);
1145
1146 desc.bmp.hbitmap = bmp;
1147
1148 /* size in himetric units reported rounded up to next integer value */
1149 hr = OleCreatePictureIndirect(&desc, &IID_IPicture, FALSE, (void**)&pic);
1150 ok(hr == S_OK, "got 0x%08lx\n", hr);
1151
1152 cx = 0;
1154 hr = IPicture_get_Width(pic, &cx);
1155 ok(hr == S_OK, "got 0x%08lx\n", hr);
1156 ok(cx == d, "got %ld, expected %d\n", cx, d);
1157
1158 cy = 0;
1160 hr = IPicture_get_Height(pic, &cy);
1161 ok(hr == S_OK, "got 0x%08lx\n", hr);
1162 ok(cy == d, "got %ld, expected %d\n", cy, d);
1163
1165 IPicture_Release(pic);
1166
1167 /* same thing with icon */
1169 1, 1, bmp_bits, bmp_bits);
1170 ok(icon != NULL, "failed to create icon\n");
1171
1172 desc.picType = PICTYPE_ICON;
1173 desc.icon.hicon = icon;
1174
1175 hr = OleCreatePictureIndirect(&desc, &IID_IPicture, FALSE, (void**)&pic);
1176 ok(hr == S_OK, "got 0x%08lx\n", hr);
1177
1178 cx = 0;
1180 hr = IPicture_get_Width(pic, &cx);
1181 ok(hr == S_OK, "got 0x%08lx\n", hr);
1182 ok(cx == d, "got %ld, expected %d\n", cx, d);
1183
1184 cy = 0;
1186 hr = IPicture_get_Height(pic, &cy);
1187 ok(hr == S_OK, "got 0x%08lx\n", hr);
1188 ok(cy == d, "got %ld, expected %d\n", cy, d);
1189
1190 IPicture_Release(pic);
1191 DestroyIcon(icon);
1192
1193 DeleteDC(hdc);
1194}
1195
1196static void test_load_save_bmp(void)
1197{
1198 IPicture *pic;
1199 PICTDESC desc;
1200 short type;
1201 OLE_HANDLE handle;
1202 HGLOBAL hmem;
1203 DWORD *mem;
1204 IPersistStream *src_stream;
1205 IStream *dst_stream;
1207 HRESULT hr;
1208 LONG size;
1210
1211 desc.cbSizeofstruct = sizeof(desc);
1212 desc.picType = PICTYPE_BITMAP;
1213 desc.bmp.hpal = 0;
1214 desc.bmp.hbitmap = CreateBitmap(1, 1, 1, 1, NULL);
1215 hr = OleCreatePictureIndirect(&desc, &IID_IPicture, FALSE, (void**)&pic);
1216 ok(hr == S_OK, "OleCreatePictureIndirect error %#lx\n", hr);
1217
1218 type = -1;
1219 hr = IPicture_get_Type(pic, &type);
1220 ok(hr == S_OK,"get_Type error %#8lx\n", hr);
1221 ok(type == PICTYPE_BITMAP,"expected picture type PICTYPE_BITMAP, got %d\n", type);
1222
1223 hr = IPicture_get_Handle(pic, &handle);
1224 ok(hr == S_OK,"get_Handle error %#8lx\n", hr);
1225 ok(IntToPtr(handle) == desc.bmp.hbitmap, "get_Handle returned wrong handle %#x\n", handle);
1226
1227 hmem = GlobalAlloc(GMEM_ZEROINIT, 4096);
1228 hr = CreateStreamOnHGlobal(hmem, FALSE, &dst_stream);
1229 ok(hr == S_OK, "createstreamonhglobal error %#lx\n", hr);
1230
1231 size = -1;
1232 hr = IPicture_SaveAsFile(pic, dst_stream, TRUE, &size);
1233 ok(hr == S_OK, "IPicture_SaveasFile error %#lx\n", hr);
1234 todo_wine
1235 ok(size == 66, "expected 66, got %ld\n", size);
1236 mem = GlobalLock(hmem);
1237 todo_wine
1238 ok(!memcmp(&mem[0], "BM", 2), "got wrong bmp header %04lx\n", mem[0]);
1239 GlobalUnlock(hmem);
1240
1241 size = -1;
1242 hr = IPicture_SaveAsFile(pic, dst_stream, FALSE, &size);
1243 todo_wine
1244 ok(hr == E_FAIL, "expected E_FAIL, got %#lx\n", hr);
1245 todo_wine
1246 ok(size == -1, "expected -1, got %ld\n", size);
1247
1248 offset.QuadPart = 0;
1249 hr = IStream_Seek(dst_stream, offset, SEEK_SET, NULL);
1250 ok(hr == S_OK, "IStream_Seek %#lx\n", hr);
1251
1252 hr = IPicture_QueryInterface(pic, &IID_IPersistStream, (void **)&src_stream);
1253 ok(hr == S_OK, "QueryInterface error %#lx\n", hr);
1254
1255 maxsize.QuadPart = 0;
1256 hr = IPersistStream_GetSizeMax(src_stream, &maxsize);
1257 ok(hr == S_OK, "GetSizeMax error %#lx\n", hr);
1258 ok(maxsize.QuadPart == 74, "expected 74, got %s\n", wine_dbgstr_longlong(maxsize.QuadPart));
1259
1260 hr = IPersistStream_Save(src_stream, dst_stream, TRUE);
1261 ok(hr == S_OK, "Save error %#lx\n", hr);
1262
1263 maxsize.QuadPart = 0;
1264 hr = IPersistStream_GetSizeMax(src_stream, &maxsize);
1265 ok(hr == S_OK, "GetSizeMax error %#lx\n", hr);
1266 ok(maxsize.QuadPart == 74, "expected 74, got %s\n", wine_dbgstr_longlong(maxsize.QuadPart));
1267
1268 IPersistStream_Release(src_stream);
1269 IStream_Release(dst_stream);
1270
1271 mem = GlobalLock(hmem);
1272 ok(!memcmp(mem, "lt\0\0", 4), "got wrong stream header %04lx\n", mem[0]);
1273 ok(mem[1] == 66, "expected stream size 66, got %lu\n", mem[1]);
1274 ok(!memcmp(&mem[2], "BM", 2), "got wrong bmp header %04lx\n", mem[2]);
1275
1276 GlobalUnlock(hmem);
1277 GlobalFree(hmem);
1278
1279 DeleteObject(desc.bmp.hbitmap);
1280 IPicture_Release(pic);
1281}
1282
1283static void test_load_save_icon(void)
1284{
1285 IPicture *pic;
1286 PICTDESC desc;
1287 short type;
1288 OLE_HANDLE handle;
1289 HGLOBAL hmem;
1290 DWORD *mem;
1291 IPersistStream *src_stream;
1292 IStream *dst_stream;
1294 HRESULT hr;
1295 LONG size;
1297
1298 desc.cbSizeofstruct = sizeof(desc);
1299 desc.picType = PICTYPE_ICON;
1300 desc.icon.hicon = LoadIconA(NULL, (LPCSTR)IDI_APPLICATION);
1301 hr = OleCreatePictureIndirect(&desc, &IID_IPicture, FALSE, (void**)&pic);
1302 ok(hr == S_OK, "OleCreatePictureIndirect error %#lx\n", hr);
1303
1304 type = -1;
1305 hr = IPicture_get_Type(pic, &type);
1306 ok(hr == S_OK,"get_Type error %#8lx\n", hr);
1307 ok(type == PICTYPE_ICON,"expected picture type PICTYPE_ICON, got %d\n", type);
1308
1309 hr = IPicture_get_Handle(pic, &handle);
1310 ok(hr == S_OK,"get_Handle error %#8lx\n", hr);
1311 ok(IntToPtr(handle) == desc.icon.hicon, "get_Handle returned wrong handle %#x\n", handle);
1312
1313 hmem = GlobalAlloc(GMEM_ZEROINIT, 8192);
1314 hr = CreateStreamOnHGlobal(hmem, FALSE, &dst_stream);
1315 ok(hr == S_OK, "CreateStreamOnHGlobal error %#lx\n", hr);
1316
1317 size = -1;
1318 hr = IPicture_SaveAsFile(pic, dst_stream, TRUE, &size);
1319 ok(hr == S_OK, "IPicture_SaveasFile error %#lx\n", hr);
1320 todo_wine
1321 ok(size == 766, "expected 766, got %ld\n", size);
1322 mem = GlobalLock(hmem);
1323 todo_wine
1324 ok(mem[0] == 0x00010000, "got wrong icon header %04lx\n", mem[0]);
1325 GlobalUnlock(hmem);
1326
1327 size = -1;
1328 hr = IPicture_SaveAsFile(pic, dst_stream, FALSE, &size);
1329 todo_wine
1330 ok(hr == E_FAIL, "expected E_FAIL, got %#lx\n", hr);
1331 todo_wine
1332 ok(size == -1, "expected -1, got %ld\n", size);
1333
1334 offset.QuadPart = 0;
1335 hr = IStream_Seek(dst_stream, offset, SEEK_SET, NULL);
1336 ok(hr == S_OK, "IStream_Seek %#lx\n", hr);
1337
1338 hr = IPicture_QueryInterface(pic, &IID_IPersistStream, (void **)&src_stream);
1339 ok(hr == S_OK, "QueryInterface error %#lx\n", hr);
1340
1341 maxsize.QuadPart = 0;
1342 hr = IPersistStream_GetSizeMax(src_stream, &maxsize);
1343 todo_wine
1344 ok(hr == S_OK, "GetSizeMax error %#lx\n", hr);
1345 todo_wine
1346 ok(maxsize.QuadPart == 774, "expected 774, got %s\n", wine_dbgstr_longlong(maxsize.QuadPart));
1347
1348 hr = IPersistStream_Save(src_stream, dst_stream, TRUE);
1349 ok(hr == S_OK, "Saveerror %#lx\n", hr);
1350
1351 maxsize.QuadPart = 0;
1352 hr = IPersistStream_GetSizeMax(src_stream, &maxsize);
1353 todo_wine
1354 ok(hr == S_OK, "GetSizeMax error %#lx\n", hr);
1355 todo_wine
1356 ok(maxsize.QuadPart == 774, "expected 774, got %s\n", wine_dbgstr_longlong(maxsize.QuadPart));
1357
1358 IPersistStream_Release(src_stream);
1359 IStream_Release(dst_stream);
1360
1361 mem = GlobalLock(hmem);
1362 ok(!memcmp(mem, "lt\0\0", 4), "got wrong stream header %04lx\n", mem[0]);
1363 todo_wine
1364 ok(mem[1] == 766, "expected stream size 766, got %lu\n", mem[1]);
1365 ok(mem[2] == 0x00010000, "got wrong icon header %04lx\n", mem[2]);
1366
1367 GlobalUnlock(hmem);
1368 GlobalFree(hmem);
1369
1370 DestroyIcon(desc.icon.hicon);
1371 IPicture_Release(pic);
1372}
1373
1375{
1376 IPicture *pic;
1377 PICTDESC desc;
1378 short type;
1379 OLE_HANDLE handle;
1380 HGLOBAL hmem;
1381 DWORD *mem;
1382 IPersistStream *src_stream;
1383 IStream *dst_stream, *stream;
1385 HRESULT hr;
1386 LONG size;
1388
1389 memset(&pic, 0, sizeof(pic));
1390 desc.cbSizeofstruct = sizeof(desc);
1391 desc.picType = PICTYPE_NONE;
1392 hr = OleCreatePictureIndirect(&desc, &IID_IPicture, FALSE, (void **)&pic);
1393 ok(hr == S_OK, "OleCreatePictureIndirect error %#lx\n", hr);
1394
1395 type = -1;
1396 hr = IPicture_get_Type(pic, &type);
1397 ok(hr == S_OK, "get_Type error %#lx\n", hr);
1398 ok(type == PICTYPE_NONE,"expected picture type PICTYPE_NONE, got %d\n", type);
1399
1400 handle = (OLE_HANDLE)0xdeadbeef;
1401 hr = IPicture_get_Handle(pic, &handle);
1402 ok(hr == S_OK,"get_Handle error %#8lx\n", hr);
1403 ok(!handle, "get_Handle returned wrong handle %#x\n", handle);
1404
1405 hmem = GlobalAlloc(GMEM_ZEROINIT, 4096);
1406 hr = CreateStreamOnHGlobal(hmem, FALSE, &dst_stream);
1407 ok(hr == S_OK, "createstreamonhglobal error %#lx\n", hr);
1408
1409 size = -1;
1410 hr = IPicture_SaveAsFile(pic, dst_stream, TRUE, &size);
1411 ok(hr == S_OK, "IPicture_SaveasFile error %#lx\n", hr);
1412 todo_wine
1413 ok(size == -1, "expected -1, got %ld\n", size);
1414
1415 size = -1;
1416 hr = IPicture_SaveAsFile(pic, dst_stream, FALSE, &size);
1417 ok(hr == S_OK, "IPicture_SaveasFile error %#lx\n", hr);
1418 todo_wine
1419 ok(size == -1, "expected -1, got %ld\n", size);
1420
1421 hr = IPicture_QueryInterface(pic, &IID_IPersistStream, (void **)&src_stream);
1422 ok(hr == S_OK, "QueryInterface error %#lx\n", hr);
1423
1424 maxsize.QuadPart = 0;
1425 hr = IPersistStream_GetSizeMax(src_stream, &maxsize);
1426 ok(hr == S_OK, "GetSizeMax error %#lx\n", hr);
1427 ok(maxsize.QuadPart == 8, "expected 8, got %s\n", wine_dbgstr_longlong(maxsize.QuadPart));
1428
1429 hr = IPersistStream_GetSizeMax(src_stream, NULL);
1431
1432 hr = IPersistStream_Save(src_stream, dst_stream, TRUE);
1433 ok(hr == S_OK, "Save error %#lx\n", hr);
1434
1435 maxsize.QuadPart = 0;
1436 hr = IPersistStream_GetSizeMax(src_stream, &maxsize);
1437 ok(hr == S_OK, "GetSizeMax error %#lx\n", hr);
1438 ok(maxsize.QuadPart == 8, "expected 8, got %s\n", wine_dbgstr_longlong(maxsize.QuadPart));
1439
1440 mem = GlobalLock(hmem);
1441 ok(!memcmp(mem, "lt\0\0", 4), "got wrong stream header %04lx\n", mem[0]);
1442 ok(mem[1] == 0, "expected stream size 0, got %lu\n", mem[1]);
1443 GlobalUnlock(hmem);
1444
1445 IPersistStream_Release(src_stream);
1446 IPicture_Release(pic);
1447
1448 /* first with statable and seekable stream */
1449 offset.QuadPart = 0;
1450 hr = IStream_Seek(dst_stream, offset, SEEK_SET, NULL);
1451 ok(hr == S_OK, "IStream_Seek %#lx\n", hr);
1452
1453 pic = NULL;
1454 hr = pOleLoadPicture(dst_stream, 0, FALSE, &IID_IPicture, (void **)&pic);
1455 ok(hr == S_OK, "OleLoadPicture error %#lx\n", hr);
1456 ok(pic != NULL,"picture should not be not NULL\n");
1457 if (pic != NULL)
1458 {
1459 type = -1;
1460 hr = IPicture_get_Type(pic, &type);
1461 ok(hr == S_OK,"get_Type error %#8lx\n", hr);
1462 ok(type == PICTYPE_NONE,"expected picture type PICTYPE_NONE, got %d\n", type);
1463
1464 handle = (OLE_HANDLE)0xdeadbeef;
1465 hr = IPicture_get_Handle(pic, &handle);
1466 ok(hr == S_OK,"get_Handle error %#8lx\n", hr);
1467 ok(!handle, "get_Handle returned wrong handle %#x\n", handle);
1468
1469 IPicture_Release(pic);
1470 }
1471 IStream_Release(dst_stream);
1472
1473 /* again with non-statable and non-seekable stream */
1475 ok(stream != NULL, "failed to create empty image stream\n");
1476
1477 pic = NULL;
1478 hr = pOleLoadPicture(stream, 0, FALSE, &IID_IPicture, (void **)&pic);
1479 ok(hr == S_OK, "OleLoadPicture error %#lx\n", hr);
1480 ok(pic != NULL,"picture should not be not NULL\n");
1481 if (pic != NULL)
1482 {
1483 type = -1;
1484 hr = IPicture_get_Type(pic, &type);
1485 ok(hr == S_OK,"get_Type error %#8lx\n", hr);
1486 ok(type == PICTYPE_NONE,"expected picture type PICTYPE_NONE, got %d\n", type);
1487
1488 handle = (OLE_HANDLE)0xdeadbeef;
1489 hr = IPicture_get_Handle(pic, &handle);
1490 ok(hr == S_OK,"get_Handle error %#8lx\n", hr);
1491 ok(!handle, "get_Handle returned wrong handle %#x\n", handle);
1492
1493 IPicture_Release(pic);
1494 }
1495 /* Non-statable impl always deletes on release */
1496 IStream_Release(stream);
1497}
1498
1499static void test_load_save_dib(void)
1500{
1501 IPicture *pic;
1502 PICTDESC desc;
1503 short type;
1504 OLE_HANDLE handle;
1505 HGLOBAL hmem;
1506 DWORD *mem;
1507 IPersistStream *src_stream;
1508 IStream *dst_stream;
1510 HRESULT hr;
1511 LONG size;
1513 unsigned int bpp;
1514
1515 for (bpp = 4; bpp <= 32; bpp <<= 1) {
1516 char buffer[sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 256];
1518 RGBQUAD *colors = info->bmiColors;
1519 DWORD expected_size, expected_bpp;
1520 void *bits;
1521
1522 winetest_push_context("bpp %u", bpp);
1523 expected_size = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER)
1524 + (bpp <= 8 ? sizeof(RGBQUAD) * (1u << bpp) : 0)
1525 + sizeof(DWORD); /* pixels */;
1526 expected_bpp = bpp <= 8 ? bpp : 24;
1527
1528 memset(info, 0, sizeof(*info));
1529 info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
1530 info->bmiHeader.biWidth = 1;
1531 info->bmiHeader.biHeight = 1;
1532 info->bmiHeader.biPlanes = 1;
1533 info->bmiHeader.biBitCount = bpp;
1534 info->bmiHeader.biCompression = BI_RGB;
1535 memset(colors, 0xaa, sizeof(RGBQUAD) * 256);
1536
1537 desc.cbSizeofstruct = sizeof(desc);
1538 desc.picType = PICTYPE_BITMAP;
1539 desc.bmp.hpal = 0;
1540 desc.bmp.hbitmap = CreateDIBSection(NULL, info, DIB_RGB_COLORS, &bits, NULL, 0);
1541 hr = OleCreatePictureIndirect(&desc, &IID_IPicture, TRUE, (void**)&pic);
1542
1543 hr = IPicture_get_Type(pic, &type);
1544 ok(hr == S_OK,"get_Type error %#8lx\n", hr);
1545 ok(type == PICTYPE_BITMAP,"expected picture type PICTYPE_BITMAP, got %d\n", type);
1546
1547 hr = IPicture_get_Handle(pic, &handle);
1548 ok(hr == S_OK,"get_Handle error %#8lx\n", hr);
1549 ok(IntToPtr(handle) == desc.bmp.hbitmap, "get_Handle returned wrong handle %#x\n", handle);
1550
1551 hmem = GlobalAlloc(GMEM_ZEROINIT, 4096);
1552 hr = CreateStreamOnHGlobal(hmem, FALSE, &dst_stream);
1553 ok(hr == S_OK, "createstreamonhglobal error %#lx\n", hr);
1554
1555 size = -1;
1556 hr = IPicture_SaveAsFile(pic, dst_stream, TRUE, &size);
1557 ok(hr == S_OK, "IPicture_SaveasFile error %#lx\n", hr);
1558 todo_wine
1559 ok(size == expected_size, "expected %ld, got %ld\n", expected_size, size);
1560 if (size == expected_size) {
1561 mem = GlobalLock(hmem);
1562 ok(!memcmp(&mem[0], "BM", 2), "got wrong bmp header %04lx\n", mem[0]);
1563 info = (BITMAPINFO *)(((BITMAPFILEHEADER *)&mem[0]) + 1);
1564 ok(info->bmiHeader.biBitCount == expected_bpp, "expected bpp %lu, got %hu\n", expected_bpp, info->bmiHeader.biBitCount);
1565 ok(info->bmiHeader.biCompression == BI_RGB, "expected BI_RGB, got %lu\n", info->bmiHeader.biCompression);
1566 GlobalUnlock(hmem);
1567 }
1568
1569 size = -1;
1570 hr = IPicture_SaveAsFile(pic, dst_stream, FALSE, &size);
1571 todo_wine
1572 ok(hr == E_FAIL, "expected E_FAIL, got %#lx\n", hr);
1573 todo_wine
1574 ok(size == -1, "expected -1, got %ld\n", size);
1575
1576 offset.QuadPart = 0;
1577 hr = IStream_Seek(dst_stream, offset, SEEK_SET, NULL);
1578 ok(hr == S_OK, "IStream_Seek %#lx\n", hr);
1579
1580 hr = IPicture_QueryInterface(pic, &IID_IPersistStream, (void **)&src_stream);
1581 ok(hr == S_OK, "QueryInterface error %#lx\n", hr);
1582
1583 maxsize.QuadPart = 0;
1584 hr = IPersistStream_GetSizeMax(src_stream, &maxsize);
1585 ok(hr == S_OK, "GetSizeMax error %#lx\n", hr);
1586 ok(maxsize.QuadPart == expected_size + 8, "expected %lx, got %s\n", expected_size + 8, wine_dbgstr_longlong(maxsize.QuadPart));
1587
1588 hr = IPersistStream_Save(src_stream, dst_stream, TRUE);
1589 ok(hr == S_OK, "Save error %#lx\n", hr);
1590
1591 maxsize.QuadPart = 0;
1592 hr = IPersistStream_GetSizeMax(src_stream, &maxsize);
1593 ok(hr == S_OK, "GetSizeMax error %#lx\n", hr);
1594 ok(maxsize.QuadPart == expected_size + 8, "expected %lx, got %s\n", expected_size + 8, wine_dbgstr_longlong(maxsize.QuadPart));
1595
1596 IPersistStream_Release(src_stream);
1597 IStream_Release(dst_stream);
1598
1599 mem = GlobalLock(hmem);
1600 ok(!memcmp(mem, "lt\0\0", 4), "got wrong stream header %04lx\n", mem[0]);
1601 ok(mem[1] == expected_size, "expected stream size %lu, got %lu\n", expected_size, mem[1]);
1602 ok(!memcmp(&mem[2], "BM", 2), "got wrong bmp header %04lx\n", mem[2]);
1603 info = (BITMAPINFO *)(((BITMAPFILEHEADER *)&mem[2]) + 1);
1604 ok(info->bmiHeader.biBitCount == expected_bpp, "expected bpp %lu, got %hu\n", expected_bpp, info->bmiHeader.biBitCount);
1605 ok(info->bmiHeader.biCompression == BI_RGB, "expected BI_RGB, got %lu\n", info->bmiHeader.biCompression);
1606
1607 GlobalUnlock(hmem);
1608 GlobalFree(hmem);
1609
1610 DeleteObject(desc.bmp.hbitmap);
1611 IPicture_Release(pic);
1613 }
1614}
1615
1616START_TEST(olepicture)
1617{
1618 hOleaut32 = GetModuleHandleA("oleaut32.dll");
1619 pOleLoadPicture = (void*)GetProcAddress(hOleaut32, "OleLoadPicture");
1620 pOleLoadPictureEx = (void*)GetProcAddress(hOleaut32, "OleLoadPictureEx");
1621 if (!pOleLoadPicture)
1622 {
1623 win_skip("OleLoadPicture is not available\n");
1624 return;
1625 }
1626
1627 /* Test regular 1x1 pixel images of gif, jpg, bmp type */
1628 test_pic(gifimage, sizeof(gifimage));
1629 test_pic(jpgimage, sizeof(jpgimage));
1630 test_pic(bmpimage, sizeof(bmpimage));
1631 test_pic(gif4pixel, sizeof(gif4pixel));
1632 /* FIXME: No PNG support in Windows... */
1633 if (0) test_pic(pngimage, sizeof(pngimage));
1636 if (pOleLoadPictureEx)
1637 {
1638 test_apm();
1639 test_metafile();
1641 }
1642 else
1643 win_skip("OleLoadPictureEx is not available\n");
1644 test_Invoke();
1646 test_Render();
1649 test_get_Type();
1651 test_himetric();
1656}
1657
1658
1659/* Helper functions only ... */
1660
1661
1663{
1664 return CONTAINING_RECORD(iface, NoStatStreamImpl, IStream_iface);
1665}
1666
1668{
1669 GlobalFree(This->supportHandle);
1670 This->supportHandle=0;
1672}
1673
1675 IStream* iface)
1676{
1677 NoStatStreamImpl* const This = impl_from_IStream(iface);
1678 return InterlockedIncrement(&This->ref);
1679}
1680
1682 IStream* iface,
1683 REFIID riid, /* [in] */
1684 void** ppvObject) /* [iid_is][out] */
1685{
1686 NoStatStreamImpl* const This = impl_from_IStream(iface);
1687 if (ppvObject==0) return E_INVALIDARG;
1688 *ppvObject = 0;
1689
1690 if (IsEqualIID(&IID_IUnknown, riid) || IsEqualIID(&IID_IStream, riid))
1691 *ppvObject = &This->IStream_iface;
1692
1693 if ((*ppvObject)==0)
1694 return E_NOINTERFACE;
1696 return S_OK;
1697}
1698
1700 IStream* iface)
1701{
1702 NoStatStreamImpl* const This = impl_from_IStream(iface);
1703 ULONG newRef = InterlockedDecrement(&This->ref);
1704 if (newRef==0)
1706 return newRef;
1707}
1708
1710 IStream* iface,
1711 void* pv, /* [length_is][size_is][out] */
1712 ULONG cb, /* [in] */
1713 ULONG* pcbRead) /* [out] */
1714{
1715 NoStatStreamImpl* const This = impl_from_IStream(iface);
1716 void* supportBuffer;
1717 ULONG bytesReadBuffer;
1718 ULONG bytesToReadFromBuffer;
1719
1720 if (pcbRead==0)
1721 pcbRead = &bytesReadBuffer;
1722 bytesToReadFromBuffer = min( This->streamSize.LowPart - This->currentPosition.LowPart, cb);
1723 supportBuffer = GlobalLock(This->supportHandle);
1724 memcpy(pv, (char *) supportBuffer+This->currentPosition.LowPart, bytesToReadFromBuffer);
1725 This->currentPosition.LowPart+=bytesToReadFromBuffer;
1726 *pcbRead = bytesToReadFromBuffer;
1727 GlobalUnlock(This->supportHandle);
1728 if(*pcbRead == cb)
1729 return S_OK;
1730 return S_FALSE;
1731}
1732
1734 IStream* iface,
1735 const void* pv, /* [size_is][in] */
1736 ULONG cb, /* [in] */
1737 ULONG* pcbWritten) /* [out] */
1738{
1739 NoStatStreamImpl* const This = impl_from_IStream(iface);
1740 void* supportBuffer;
1741 ULARGE_INTEGER newSize;
1742 ULONG bytesWritten = 0;
1743
1744 if (pcbWritten == 0)
1745 pcbWritten = &bytesWritten;
1746 if (cb == 0)
1747 return S_OK;
1748 newSize.HighPart = 0;
1749 newSize.LowPart = This->currentPosition.LowPart + cb;
1750 if (newSize.LowPart > This->streamSize.LowPart)
1751 IStream_SetSize(iface, newSize);
1752
1753 supportBuffer = GlobalLock(This->supportHandle);
1754 memcpy((char *) supportBuffer+This->currentPosition.LowPart, pv, cb);
1755 This->currentPosition.LowPart+=cb;
1756 *pcbWritten = cb;
1757 GlobalUnlock(This->supportHandle);
1758 return S_OK;
1759}
1760
1762 IStream* iface,
1763 LARGE_INTEGER dlibMove, /* [in] */
1764 DWORD dwOrigin, /* [in] */
1765 ULARGE_INTEGER* plibNewPosition) /* [out] */
1766{
1767 NoStatStreamImpl* const This = impl_from_IStream(iface);
1768 ULARGE_INTEGER newPosition;
1769 switch (dwOrigin)
1770 {
1771 case STREAM_SEEK_SET:
1772 newPosition.HighPart = 0;
1773 newPosition.LowPart = 0;
1774 break;
1775 case STREAM_SEEK_CUR:
1776 newPosition = This->currentPosition;
1777 break;
1778 case STREAM_SEEK_END:
1779 newPosition = This->streamSize;
1780 break;
1781 default:
1782 return STG_E_INVALIDFUNCTION;
1783 }
1784 if (dlibMove.QuadPart < 0 && newPosition.QuadPart < -dlibMove.QuadPart)
1785 return STG_E_INVALIDFUNCTION;
1786 newPosition.QuadPart += dlibMove.QuadPart;
1787 if (plibNewPosition) *plibNewPosition = newPosition;
1788 This->currentPosition = newPosition;
1789 return S_OK;
1790}
1791
1793 IStream* iface,
1794 ULARGE_INTEGER libNewSize) /* [in] */
1795{
1796 NoStatStreamImpl* const This = impl_from_IStream(iface);
1797 HGLOBAL supportHandle;
1798 if (libNewSize.HighPart != 0)
1799 return STG_E_INVALIDFUNCTION;
1800 if (This->streamSize.LowPart == libNewSize.LowPart)
1801 return S_OK;
1802 supportHandle = GlobalReAlloc(This->supportHandle, libNewSize.LowPart, 0);
1803 if (supportHandle == 0)
1804 return STG_E_MEDIUMFULL;
1805 This->supportHandle = supportHandle;
1806 This->streamSize.LowPart = libNewSize.LowPart;
1807 return S_OK;
1808}
1809
1811 IStream* iface,
1812 IStream* pstm, /* [unique][in] */
1813 ULARGE_INTEGER cb, /* [in] */
1814 ULARGE_INTEGER* pcbRead, /* [out] */
1815 ULARGE_INTEGER* pcbWritten) /* [out] */
1816{
1817 HRESULT hr = S_OK;
1818 BYTE tmpBuffer[128];
1819 ULONG bytesRead, bytesWritten, copySize;
1820 ULARGE_INTEGER totalBytesRead;
1821 ULARGE_INTEGER totalBytesWritten;
1822
1823 if ( pstm == 0 )
1824 return STG_E_INVALIDPOINTER;
1825 totalBytesRead.LowPart = totalBytesRead.HighPart = 0;
1826 totalBytesWritten.LowPart = totalBytesWritten.HighPart = 0;
1827
1828 while ( cb.LowPart > 0 )
1829 {
1830 if ( cb.LowPart >= 128 )
1831 copySize = 128;
1832 else
1833 copySize = cb.LowPart;
1834 IStream_Read(iface, tmpBuffer, copySize, &bytesRead);
1835 totalBytesRead.LowPart += bytesRead;
1836 IStream_Write(pstm, tmpBuffer, bytesRead, &bytesWritten);
1837 totalBytesWritten.LowPart += bytesWritten;
1838 if (bytesRead != bytesWritten)
1839 {
1841 break;
1842 }
1843 if (bytesRead!=copySize)
1844 cb.LowPart = 0;
1845 else
1846 cb.LowPart -= bytesRead;
1847 }
1848 if (pcbRead)
1849 {
1850 pcbRead->u.LowPart = totalBytesRead.LowPart;
1851 pcbRead->u.HighPart = totalBytesRead.HighPart;
1852 }
1853
1854 if (pcbWritten)
1855 {
1856 pcbWritten->u.LowPart = totalBytesWritten.LowPart;
1857 pcbWritten->u.HighPart = totalBytesWritten.HighPart;
1858 }
1859 return hr;
1860}
1861
1863{
1864 return S_OK;
1865}
1867
1869 IStream* iface,
1870 ULARGE_INTEGER libOffset, /* [in] */
1871 ULARGE_INTEGER cb, /* [in] */
1872 DWORD dwLockType) /* [in] */
1873{
1874 return S_OK;
1875}
1876
1878 IStream* iface,
1879 ULARGE_INTEGER libOffset, /* [in] */
1880 ULARGE_INTEGER cb, /* [in] */
1881 DWORD dwLockType) /* [in] */
1882{
1883 return S_OK;
1884}
1885
1887 IStream* iface,
1888 STATSTG* pstatstg, /* [out] */
1889 DWORD grfStatFlag) /* [in] */
1890{
1891 return E_NOTIMPL;
1892}
1893
1895 IStream* iface,
1896 IStream** ppstm) /* [out] */
1897{
1898 return E_NOTIMPL;
1899}
1900static const IStreamVtbl NoStatStreamImpl_Vtbl;
1901
1902/*
1903 Build an object that implements IStream, without IStream_Stat capabilities.
1904 Receives a memory handle with data buffer. If memory handle is non-null,
1905 it is assumed to be unlocked, otherwise an internal memory handle is allocated.
1906 In any case the object takes ownership of memory handle and will free it on
1907 object release.
1908 */
1910{
1911 NoStatStreamImpl* newStream;
1912
1913 newStream = HeapAlloc(GetProcessHeap(), 0, sizeof(NoStatStreamImpl));
1914 if (newStream!=0)
1915 {
1916 newStream->IStream_iface.lpVtbl = &NoStatStreamImpl_Vtbl;
1917 newStream->ref = 1;
1918 newStream->supportHandle = hGlobal;
1919
1920 if (!newStream->supportHandle)
1922 GMEM_SHARE, 0);
1923 newStream->currentPosition.HighPart = 0;
1924 newStream->currentPosition.LowPart = 0;
1925 newStream->streamSize.HighPart = 0;
1926 newStream->streamSize.LowPart = GlobalSize(newStream->supportHandle);
1927 }
1928 return &newStream->IStream_iface;
1929}
1930
1931
1932static const IStreamVtbl NoStatStreamImpl_Vtbl =
1933{
1948};
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define ok(value,...)
Definition: atltest.h:57
#define broken(x)
Definition: atltest.h:178
#define START_TEST(x)
Definition: atltest.h:75
#define ARRAY_SIZE(A)
Definition: main.h:20
#define HandleToLong(h)
Definition: basetsd.h:74
#define UlongToHandle(ul)
Definition: basetsd.h:91
#define IntToPtr(i)
Definition: basetsd.h:83
#define HandleToUlong(h)
Definition: basetsd.h:73
const GUID IID_IUnknown
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
HDC dc
Definition: cylfrac.c:34
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD bpp
Definition: surface.c:185
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL delete_on_release, IStream **stream)
#define CloseHandle
Definition: compat.h:739
#define GetProcessHeap()
Definition: compat.h:736
#define CP_ACP
Definition: compat.h:109
#define GetProcAddress(x, y)
Definition: compat.h:753
#define HeapAlloc
Definition: compat.h:733
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define MultiByteToWideChar
Definition: compat.h:110
@ VT_BSTR
Definition: compat.h:2303
@ VT_INT
Definition: compat.h:2316
@ VT_I4
Definition: compat.h:2298
@ VT_BOOL
Definition: compat.h:2306
@ VT_I2
Definition: compat.h:2297
@ VT_EMPTY
Definition: compat.h:2295
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI WriteFile(_In_ HANDLE hFile, _In_reads_bytes_opt_(nNumberOfBytesToWrite) LPCVOID lpBuffer, _In_ DWORD nNumberOfBytesToWrite, _Out_opt_ LPDWORD lpNumberOfBytesWritten, _Inout_opt_ LPOVERLAPPED lpOverlapped)
Definition: rw.c:25
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:1973
static MonoProfilerRuntimeShutdownBeginCallback cb
Definition: metahost.c:118
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
#define SEEK_CUR
Definition: stdio.h:44
HRESULT WINAPI OleCreatePictureIndirect(LPPICTDESC lpPictDesc, REFIID riid, BOOL Own, void **ppvObj)
Definition: olepicture.c:2313
HRESULT WINAPI OleLoadPicturePath(LPOLESTR szURLorPath, LPUNKNOWN punkCaller, DWORD dwReserved, OLE_COLOR clrReserved, REFIID riid, LPVOID *ppvRet)
Definition: olepicture.c:2497
HRESULT WINAPI OleLoadPictureFile(VARIANT filename, IDispatch **picture)
Definition: olepicture.c:2461
ULONG RGBQUAD
Definition: precomp.h:47
return ret
Definition: mutex.c:146
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
pKey DeleteObject()
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
GLuint res
Definition: glext.h:9613
GLuint buffer
Definition: glext.h:5915
GLenum GLsizei GLuint GLint * bytesWritten
Definition: glext.h:11123
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
GLenum const GLfloat * params
Definition: glext.h:5645
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
GLuint64EXT * result
Definition: glext.h:11304
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
HGLOBAL NTAPI GlobalReAlloc(HGLOBAL hMem, SIZE_T dwBytes, UINT uFlags)
Definition: heapmem.c:825
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
Definition: heapmem.c:1090
static const WCHAR emptyW[]
Definition: navigate.c:40
REFIID riid
Definition: atlbase.h:39
#define bits
Definition: infblock.c:15
#define S_OK
Definition: intsafe.h:52
static ERESOURCE GlobalLock
Definition: sys_arch.c:8
#define SEEK_SET
Definition: jmemansi.c:26
#define d
Definition: ke_i.h:81
#define GUID_NULL
Definition: ks.h:106
#define win_skip
Definition: minitest.h:67
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl void winetest_pop_context(void)
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl winetest_push_context(const char *fmt,...) __WINE_PRINTF_ATTR(1
Definition: test.h:537
#define todo_wine
Definition: minitest.h:80
#define seekto(pos, errstr)
Definition: mkdosfs.c:1613
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define CREATE_ALWAYS
Definition: disk.h:72
static PVOID ptr
Definition: dispmode.c:27
BITMAP bmp
Definition: alphablend.c:62
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
static HICON
Definition: imagelist.c:80
BOOL expected
Definition: store.c:2000
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1204
const char * var
Definition: shader.c:5666
HRESULT hres
Definition: protocol.c:465
static ULONG WINAPI NoStatStreamImpl_Release(IStream *iface)
Definition: olepicture.c:1699
static void test_metafile(void)
Definition: olepicture.c:689
static HRESULT WINAPI NoStatStreamImpl_UnlockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
Definition: olepicture.c:1877
static void test_himetric(void)
Definition: olepicture.c:1124
static const unsigned char apmdata[]
Definition: olepicture.c:118
static void test_load_save_empty_picture(void)
Definition: olepicture.c:1374
static HRESULT WINAPI NoStatStreamImpl_Revert(IStream *iface)
Definition: olepicture.c:1866
static HRESULT WINAPI NoStatStreamImpl_CopyTo(IStream *iface, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
Definition: olepicture.c:1810
static HMODULE hOleaut32
Definition: olepicture.c:53
#define ok_ole_success(hr, func)
Definition: olepicture.c:58
static HRESULT WINAPI NoStatStreamImpl_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
Definition: olepicture.c:1792
static void test_Render(void)
Definition: olepicture.c:793
static const unsigned char metafile[]
Definition: olepicture.c:126
static void test_load_save_dib(void)
Definition: olepicture.c:1499
static void test_pic_with_stream(LPSTREAM stream, unsigned int imgsize)
Definition: olepicture.c:204
static void test_empty_image_2(void)
Definition: olepicture.c:390
static const unsigned char gifimage[35]
Definition: olepicture.c:61
static void test_get_Attributes(void)
Definition: olepicture.c:887
static HRESULT picture_render(IPicture *iface, HDC hdc, LONG x, LONG y, LONG cx, LONG cy, OLE_XPOS_HIMETRIC xSrc, OLE_YPOS_HIMETRIC ySrc, OLE_XSIZE_HIMETRIC cxSrc, OLE_YSIZE_HIMETRIC cySrc, const RECT *bounds)
Definition: olepicture.c:744
static IStream * NoStatStream_Construct(HGLOBAL hGlobal)
Definition: olepicture.c:1909
static void test_Invoke(void)
Definition: olepicture.c:429
static void test_load_save_icon(void)
Definition: olepicture.c:1283
static const unsigned char bmpimage[66]
Definition: olepicture.c:101
static HRESULT WINAPI NoStatStreamImpl_Clone(IStream *iface, IStream **ppstm)
Definition: olepicture.c:1894
#define expect_eq(expr, value, type, format)
Definition: olepicture.c:44
static NoStatStreamImpl * impl_from_IStream(IStream *iface)
Definition: olepicture.c:1662
static ULONG WINAPI NoStatStreamImpl_AddRef(IStream *iface)
Definition: olepicture.c:1674
static void test_get_Handle(void)
Definition: olepicture.c:911
static void NoStatStreamImpl_Destroy(NoStatStreamImpl *This)
Definition: olepicture.c:1667
static HRESULT WINAPI NoStatStreamImpl_Read(IStream *iface, void *pv, ULONG cb, ULONG *pcbRead)
Definition: olepicture.c:1709
static HRESULT WINAPI NoStatStreamImpl_Commit(IStream *iface, DWORD grfCommitFlags)
Definition: olepicture.c:1862
static HBITMAP stock_bm
Definition: olepicture.c:171
static void test_get_Type(void)
Definition: olepicture.c:924
static void test_load_save_bmp(void)
Definition: olepicture.c:1196
static BOOL
Definition: olepicture.c:55
static void delete_render_dc(HDC dc)
Definition: olepicture.c:184
static HRESULT WINAPI NoStatStreamImpl_Seek(IStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
Definition: olepicture.c:1761
static void test_OleLoadPicturePath(void)
Definition: olepicture.c:938
static HRESULT WINAPI NoStatStreamImpl_QueryInterface(IStream *iface, REFIID riid, void **ppvObject)
Definition: olepicture.c:1681
static void test_OleCreatePictureIndirect(void)
Definition: olepicture.c:589
static HDC create_render_dc(void)
Definition: olepicture.c:173
static const unsigned char pngimage[285]
Definition: olepicture.c:90
static LONG
Definition: olepicture.c:55
static void test_enhmetafile(void)
Definition: olepicture.c:707
#define ole_expect(expr, expect)
Definition: olepicture.c:46
#define ole_check(expr)
Definition: olepicture.c:51
static const unsigned char enhmetafile[]
Definition: olepicture.c:137
static HRESULT WINAPI NoStatStreamImpl_LockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
Definition: olepicture.c:1868
static const unsigned char jpgimage[285]
Definition: olepicture.c:68
static void test_empty_image(void)
Definition: olepicture.c:343
static HRESULT create_picture(short type, IPicture **pict)
Definition: olepicture.c:541
static HRESULT WINAPI NoStatStreamImpl_Stat(IStream *iface, STATSTG *pstatstg, DWORD grfStatFlag)
Definition: olepicture.c:1886
static void test_apm(void)
Definition: olepicture.c:651
static HRESULT WINAPI NoStatStreamImpl_Write(IStream *iface, const void *pv, ULONG cb, ULONG *pcbWritten)
Definition: olepicture.c:1733
static const unsigned char gif4pixel[42]
Definition: olepicture.c:110
static void test_pic(const unsigned char *imgdata, unsigned int imgsize)
Definition: olepicture.c:276
static const IStreamVtbl NoStatStreamImpl_Vtbl
Definition: olepicture.c:1900
#define min(a, b)
Definition: monoChain.cc:55
char temp_path[MAX_PATH]
Definition: mspatcha.c:123
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
#define DWORD
Definition: nt_native.h:44
#define GENERIC_WRITE
Definition: nt_native.h:90
interface IStream * LPSTREAM
Definition: objfwd.h:10
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
#define V_BOOL(A)
Definition: oleauto.h:224
#define V_INT(A)
Definition: oleauto.h:251
#define DISPATCH_PROPERTYPUT
Definition: oleauto.h:1008
#define DISPATCH_METHOD
Definition: oleauto.h:1006
#define V_VT(A)
Definition: oleauto.h:211
#define V_INT_PTR(A)
Definition: oleauto.h:257
#define V_BSTR(A)
Definition: oleauto.h:226
#define V_I4(A)
Definition: oleauto.h:247
#define DISPATCH_PROPERTYGET
Definition: oleauto.h:1007
#define PICTYPE_UNINITIALIZED
Definition: olectl.h:131
#define PICTYPE_BITMAP
Definition: olectl.h:133
#define CTL_E_PATHFILEACCESSERROR
Definition: olectl.h:287
#define PICTYPE_ENHMETAFILE
Definition: olectl.h:136
#define DISPID_PICT_RENDER
Definition: olectl.h:443
#define PICTYPE_NONE
Definition: olectl.h:132
struct tagPICTDESC PICTDESC
#define CTL_E_FILENOTFOUND
Definition: olectl.h:274
#define DISPID_PICT_HPAL
Definition: olectl.h:439
#define PICTYPE_METAFILE
Definition: olectl.h:134
#define PICTYPE_ICON
Definition: olectl.h:135
#define CTL_E_INVALIDPROPERTYVALUE
Definition: olectl.h:292
const GUID IID_IPicture
const GUID IID_IPictureDisp
const GUID IID_IDispatch
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
const GUID IID_IPersistStream
Definition: proxy.cpp:13
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
#define IID_NULL
Definition: guiddef.h:98
#define memset(x, y, z)
Definition: compat.h:39
#define args
Definition: format.c:66
_In_ size_t const maxsize
Definition: strftime.cpp:120
IStream IStream_iface
Definition: olepicture.c:193
ULARGE_INTEGER streamSize
Definition: olepicture.c:197
HGLOBAL supportHandle
Definition: olepicture.c:196
ULARGE_INTEGER currentPosition
Definition: olepicture.c:198
$ULONG LowPart
Definition: ntbasedef.h:581
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
$ULONG HighPart
Definition: ntbasedef.h:582
struct _ULARGE_INTEGER::@4623 u
Definition: match.c:390
Definition: cookie.c:202
Definition: fci.c:127
Definition: mem.c:349
Definition: parse.h:23
LPVOID bmBits
Definition: wingdi.h:1873
Definition: fci.c:110
const char * LPCSTR
Definition: typedefs.h:52
int32_t INT_PTR
Definition: typedefs.h:64
unsigned char * LPBYTE
Definition: typedefs.h:53
int32_t INT
Definition: typedefs.h:58
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define BI_RGB
Definition: uefivid.c:46
LONGLONG QuadPart
Definition: typedefs.h:114
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:568
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
#define GMEM_ZEROINIT
Definition: winbase.h:330
#define GMEM_NODISCARD
Definition: winbase.h:326
#define GMEM_MOVEABLE
Definition: winbase.h:318
#define GMEM_SHARE
Definition: winbase.h:329
DWORD COLORREF
Definition: windef.h:100
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
#define STG_E_INVALIDPOINTER
Definition: winerror.h:3666
#define S_FALSE
Definition: winerror.h:3451
#define E_NOINTERFACE
Definition: winerror.h:3479
#define DISP_E_BADPARAMCOUNT
Definition: winerror.h:3626
#define DISP_E_MEMBERNOTFOUND
Definition: winerror.h:3615
#define E_UNEXPECTED
Definition: winerror.h:3528
#define INET_E_RESOURCE_NOT_FOUND
Definition: winerror.h:4655
#define STG_E_MEDIUMFULL
Definition: winerror.h:3676
#define INET_E_UNKNOWN_PROTOCOL
Definition: winerror.h:4663
#define E_POINTER
Definition: winerror.h:3480
#define DISP_E_TYPEMISMATCH
Definition: winerror.h:3617
#define DISP_E_PARAMNOTOPTIONAL
Definition: winerror.h:3627
#define STG_E_INVALIDFUNCTION
Definition: winerror.h:3659
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:3618
#define DIB_RGB_COLORS
Definition: wingdi.h:367
HGDIOBJ WINAPI GetStockObject(_In_ int)
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
struct tagBITMAPFILEHEADER BITMAPFILEHEADER
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define DEFAULT_PALETTE
Definition: wingdi.h:913
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
HDC WINAPI CreateMetaFileA(_In_opt_ LPCSTR)
#define LOGPIXELSY
Definition: wingdi.h:719
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
HMETAFILE WINAPI CloseMetaFile(_In_ HDC hdc)
HDC WINAPI CreateEnhMetaFileA(_In_opt_ HDC, _In_opt_ LPCSTR, _In_opt_ LPCRECT, _In_opt_ LPCSTR)
HENHMETAFILE WINAPI CloseEnhMetaFile(_In_ HDC hdc)
BOOL WINAPI SetPixelV(_In_ HDC, _In_ int, _In_ int, _In_ COLORREF)
#define LOGPIXELSX
Definition: wingdi.h:718
BOOL WINAPI DeleteDC(_In_ HDC)
HICON WINAPI CreateIcon(_In_opt_ HINSTANCE, _In_ int, _In_ int, _In_ BYTE, _In_ BYTE, _In_ const BYTE *, _In_ const BYTE *)
Definition: cursoricon.c:2764
#define IDI_APPLICATION
Definition: winuser.h:712
#define SM_CYICON
Definition: winuser.h:984
HICON WINAPI LoadIconA(_In_opt_ HINSTANCE hInstance, _In_ LPCSTR lpIconName)
Definition: cursoricon.c:2429
#define SM_CXICON
Definition: winuser.h:983
int WINAPI GetSystemMetrics(_In_ int)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2422
unsigned char BYTE
Definition: xxhash.c:193