ReactOS  0.4.12-dev-432-g3463b2d
olepicture.c
Go to the documentation of this file.
1 /*
2  * OLE Picture object
3  *
4  * Implementation of OLE IPicture and related interfaces
5  *
6  * Copyright 2000 Huw D M Davies for CodeWeavers.
7  * Copyright 2001 Marcus Meissner
8  * Copyright 2008 Kirill K. Smirnov
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23  *
24  * BUGS
25  *
26  * Support PICTYPE_BITMAP and PICTYPE_ICON, although only bitmaps very well..
27  * Lots of methods are just stubs.
28  *
29  *
30  * NOTES (or things that msdn doesn't tell you)
31  *
32  * The width and height properties are returned in HIMETRIC units (0.01mm)
33  * IPicture::Render also uses these to select a region of the src picture.
34  * A bitmap's size is converted into these units by using the screen resolution
35  * thus an 8x8 bitmap on a 96dpi screen has a size of 212x212 (8/96 * 2540).
36  *
37  */
38 
39 #include "config.h"
40 #include "wine/port.h"
41 
42 #ifdef HAVE_UNISTD_H
43 # include <unistd.h>
44 #endif
45 #include <stdarg.h>
46 #include <stdio.h>
47 #include <string.h>
48 
49 #define COBJMACROS
50 #define NONAMELESSUNION
51 
52 #include "winerror.h"
53 #include "windef.h"
54 #include "winbase.h"
55 #include "wingdi.h"
56 #include "winuser.h"
57 #include "ole2.h"
58 #include "olectl.h"
59 #include "oleauto.h"
60 #include "connpt.h"
61 #include "urlmon.h"
62 #include "initguid.h"
63 #include "wincodec.h"
64 #include "wine/debug.h"
65 #include "wine/unicode.h"
66 #include "wine/library.h"
67 
68 WINE_DEFAULT_DEBUG_CHANNEL(olepicture);
69 
70 #define BITMAP_FORMAT_BMP 0x4d42 /* "BM" */
71 #define BITMAP_FORMAT_JPEG 0xd8ff
72 #define BITMAP_FORMAT_GIF 0x4947
73 #define BITMAP_FORMAT_PNG 0x5089
74 #define BITMAP_FORMAT_APM 0xcdd7
75 
76 #include "pshpack1.h"
77 
78 /* Header for Aldus Placable Metafiles - a standard metafile follows */
79 typedef struct _APM_HEADER
80 {
90 } APM_HEADER;
91 
92 typedef struct {
102 
103 typedef struct
104 {
110 
111 #include "poppack.h"
112 
113 /*************************************************************************
114  * Declaration of implementation class
115  */
116 
117 typedef struct OLEPictureImpl {
118 
119  /*
120  * IPicture handles IUnknown
121  */
122 
127 
128  /* Object reference count */
130 
131  /* We own the object and must destroy it ourselves */
133 
134  /* Picture description */
136 
137  /* These are the pixel size of a bitmap */
140 
141  /* And these are the size of the picture converted into HIMETRIC units */
144 
146 
150 
151  /* Bitmap transparency mask */
155 
156  /* data */
157  void* data;
158  int datalen;
159  BOOL bIsDirty; /* Set to TRUE if picture has changed */
160  unsigned int loadtime_magic; /* If a length header was found, saves value */
161  unsigned int loadtime_format; /* for PICTYPE_BITMAP only, keeps track of image format (GIF/BMP/JPEG) */
163 
165 {
166  return CONTAINING_RECORD(iface, OLEPictureImpl, IPicture_iface);
167 }
168 
170 {
171  return CONTAINING_RECORD(iface, OLEPictureImpl, IDispatch_iface);
172 }
173 
175 {
176  return CONTAINING_RECORD(iface, OLEPictureImpl, IPersistStream_iface);
177 }
178 
180 {
181  return CONTAINING_RECORD(iface, OLEPictureImpl, IConnectionPointContainer_iface);
182 }
183 
184 /*
185  * Predeclare VTables. They get initialized at the end.
186  */
187 static const IPictureVtbl OLEPictureImpl_VTable;
188 static const IDispatchVtbl OLEPictureImpl_IDispatch_VTable;
189 static const IPersistStreamVtbl OLEPictureImpl_IPersistStream_VTable;
190 static const IConnectionPointContainerVtbl OLEPictureImpl_IConnectionPointContainer_VTable;
191 
192 /* pixels to HIMETRIC units conversion */
194 {
195  return MulDiv(pixels, 2540, GetDeviceCaps(hdc, LOGPIXELSX));
196 }
197 
199 {
200  return MulDiv(pixels, 2540, GetDeviceCaps(hdc, LOGPIXELSY));
201 }
202 
203 /***********************************************************************
204  * Implementation of the OLEPictureImpl class.
205  */
206 
208 {
209  BITMAP bm;
210  HDC hdcRef;
211 
212  TRACE("bitmap handle %p\n", This->desc.u.bmp.hbitmap);
213  if(GetObjectW(This->desc.u.bmp.hbitmap, sizeof(bm), &bm) != sizeof(bm)) {
214  ERR("GetObject fails\n");
215  return;
216  }
217  This->origWidth = bm.bmWidth;
218  This->origHeight = bm.bmHeight;
219 
220  TRACE("width %d, height %d, bpp %d\n", bm.bmWidth, bm.bmHeight, bm.bmBitsPixel);
221 
222  /* The width and height are stored in HIMETRIC units (0.01 mm),
223  so we take our pixel width divide by pixels per inch and
224  multiply by 25.4 * 100 */
225  /* Should we use GetBitmapDimension if available? */
226  hdcRef = CreateCompatibleDC(0);
227 
228  This->himetricWidth = xpixels_to_himetric(bm.bmWidth, hdcRef);
229  This->himetricHeight = ypixels_to_himetric(bm.bmHeight, hdcRef);
230  This->stock_bitmap = GetCurrentObject( hdcRef, OBJ_BITMAP );
231 
232  This->loadtime_format = BITMAP_FORMAT_BMP;
233 
234  DeleteDC(hdcRef);
235 }
236 
238 {
239  ICONINFO infoIcon;
240 
241  TRACE("icon handle %p\n", This->desc.u.icon.hicon);
242  if (GetIconInfo(This->desc.u.icon.hicon, &infoIcon)) {
243  HDC hdcRef;
244  BITMAP bm;
245 
246  TRACE("bitmap handle for icon is %p\n", infoIcon.hbmColor);
247  if(GetObjectW(infoIcon.hbmColor ? infoIcon.hbmColor : infoIcon.hbmMask, sizeof(bm), &bm) != sizeof(bm)) {
248  ERR("GetObject fails on icon bitmap\n");
249  return;
250  }
251 
252  This->origWidth = bm.bmWidth;
253  This->origHeight = infoIcon.hbmColor ? bm.bmHeight : bm.bmHeight / 2;
254  /* see comment on HIMETRIC on OLEPictureImpl_SetBitmap() */
255  hdcRef = GetDC(0);
256 
257  This->himetricWidth = xpixels_to_himetric(This->origWidth, hdcRef);
258  This->himetricHeight = ypixels_to_himetric(This->origHeight, hdcRef);
259 
260  ReleaseDC(0, hdcRef);
261 
262  DeleteObject(infoIcon.hbmMask);
263  if (infoIcon.hbmColor) DeleteObject(infoIcon.hbmColor);
264  } else {
265  ERR("GetIconInfo() fails on icon %p\n", This->desc.u.icon.hicon);
266  }
267 }
268 
270 {
271  ENHMETAHEADER emh;
272 
273  GetEnhMetaFileHeader(This->desc.u.emf.hemf, sizeof(emh), &emh);
274 
275  This->origWidth = 0;
276  This->origHeight = 0;
277  This->himetricWidth = emh.rclFrame.right - emh.rclFrame.left;
278  This->himetricHeight = emh.rclFrame.bottom - emh.rclFrame.top;
279 }
280 
281 /************************************************************************
282  * OLEPictureImpl_Construct
283  *
284  * This method will construct a new instance of the OLEPictureImpl
285  * class.
286  *
287  * The caller of this method must release the object when it's
288  * done with it.
289  */
291 {
292  OLEPictureImpl* newObject = 0;
293 
294  if (pictDesc)
295  TRACE("(%p) type = %d\n", pictDesc, pictDesc->picType);
296 
297  /*
298  * Allocate space for the object.
299  */
300  newObject = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(OLEPictureImpl));
301 
302  if (newObject==0)
303  return newObject;
304 
305  /*
306  * Initialize the virtual function table.
307  */
308  newObject->IPicture_iface.lpVtbl = &OLEPictureImpl_VTable;
312 
313  newObject->pCP = NULL;
315  &newObject->pCP);
316  if (!newObject->pCP)
317  {
318  HeapFree(GetProcessHeap(), 0, newObject);
319  return NULL;
320  }
321 
322  /*
323  * Start with one reference count. The caller of this function
324  * must release the interface pointer when it is done.
325  */
326  newObject->ref = 1;
327  newObject->hDCCur = 0;
328 
329  newObject->fOwn = fOwn;
330 
331  /* dunno about original value */
332  newObject->keepOrigFormat = TRUE;
333 
334  newObject->hbmMask = NULL;
335  newObject->hbmXor = NULL;
336  newObject->loadtime_magic = 0xdeadbeef;
337  newObject->loadtime_format = 0;
338  newObject->bIsDirty = FALSE;
339 
340  if (pictDesc) {
341  newObject->desc = *pictDesc;
342 
343  switch(pictDesc->picType) {
344  case PICTYPE_BITMAP:
345  OLEPictureImpl_SetBitmap(newObject);
346  break;
347 
348  case PICTYPE_METAFILE:
349  TRACE("metafile handle %p\n", pictDesc->u.wmf.hmeta);
350  newObject->himetricWidth = pictDesc->u.wmf.xExt;
351  newObject->himetricHeight = pictDesc->u.wmf.yExt;
352  break;
353 
354  case PICTYPE_NONE:
355  /* not sure what to do here */
356  newObject->himetricWidth = newObject->himetricHeight = 0;
357  break;
358 
359  case PICTYPE_ICON:
360  OLEPictureImpl_SetIcon(newObject);
361  break;
362 
363  case PICTYPE_ENHMETAFILE:
364  OLEPictureImpl_SetEMF(newObject);
365  break;
366 
367  default:
368  FIXME("Unsupported type %d\n", pictDesc->picType);
369  newObject->himetricWidth = newObject->himetricHeight = 0;
370  break;
371  }
372  } else {
373  newObject->desc.picType = PICTYPE_UNINITIALIZED;
374  }
375 
376  TRACE("returning %p\n", newObject);
377  return newObject;
378 }
379 
380 /************************************************************************
381  * OLEPictureImpl_Destroy
382  *
383  * This method is called by the Release method when the reference
384  * count goes down to 0. It will free all resources used by
385  * this object. */
387 {
388  TRACE("(%p)\n", Obj);
389 
390  if (Obj->pCP)
391  IConnectionPoint_Release(Obj->pCP);
392 
393  if(Obj->fOwn) { /* We need to destroy the picture */
394  switch(Obj->desc.picType) {
395  case PICTYPE_BITMAP:
396  DeleteObject(Obj->desc.u.bmp.hbitmap);
397  if (Obj->hbmMask != NULL) DeleteObject(Obj->hbmMask);
398  if (Obj->hbmXor != NULL) DeleteObject(Obj->hbmXor);
399  break;
400  case PICTYPE_METAFILE:
401  DeleteMetaFile(Obj->desc.u.wmf.hmeta);
402  break;
403  case PICTYPE_ICON:
404  DestroyIcon(Obj->desc.u.icon.hicon);
405  break;
406  case PICTYPE_ENHMETAFILE:
407  DeleteEnhMetaFile(Obj->desc.u.emf.hemf);
408  break;
409  case PICTYPE_NONE:
411  /* Nothing to do */
412  break;
413  default:
414  FIXME("Unsupported type %d - unable to delete\n", Obj->desc.picType);
415  break;
416  }
417  }
418  HeapFree(GetProcessHeap(), 0, Obj->data);
419  HeapFree(GetProcessHeap(), 0, Obj);
420 }
421 
422 
423 /************************************************************************
424  * OLEPictureImpl_AddRef (IUnknown)
425  *
426  * See Windows documentation for more details on IUnknown methods.
427  */
429  IPicture* iface)
430 {
432  ULONG refCount = InterlockedIncrement(&This->ref);
433 
434  TRACE("(%p)->(ref before=%d)\n", This, refCount - 1);
435 
436  return refCount;
437 }
438 
439 /************************************************************************
440  * OLEPictureImpl_Release (IUnknown)
441  *
442  * See Windows documentation for more details on IUnknown methods.
443  */
445  IPicture* iface)
446 {
448  ULONG refCount = InterlockedDecrement(&This->ref);
449 
450  TRACE("(%p)->(ref before=%d)\n", This, refCount + 1);
451 
452  /*
453  * If the reference count goes down to 0, perform suicide.
454  */
455  if (!refCount) OLEPictureImpl_Destroy(This);
456 
457  return refCount;
458 }
459 
460 /************************************************************************
461  * OLEPictureImpl_QueryInterface (IUnknown)
462  *
463  * See Windows documentation for more details on IUnknown methods.
464  */
466  IPicture* iface,
467  REFIID riid,
468  void** ppvObject)
469 {
471 
472  TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppvObject);
473 
474  if (!ppvObject)
475  return E_INVALIDARG;
476 
477  *ppvObject = 0;
478 
480  *ppvObject = &This->IPicture_iface;
481  else if (IsEqualIID(&IID_IDispatch, riid))
482  *ppvObject = &This->IDispatch_iface;
483  else if (IsEqualIID(&IID_IPictureDisp, riid))
484  *ppvObject = &This->IDispatch_iface;
486  *ppvObject = &This->IPersistStream_iface;
488  *ppvObject = &This->IConnectionPointContainer_iface;
489 
490  if (!*ppvObject)
491  {
492  FIXME("() : asking for unsupported interface %s\n",debugstr_guid(riid));
493  return E_NOINTERFACE;
494  }
495 
496  IPicture_AddRef(iface);
497 
498  return S_OK;
499 }
500 
501 /***********************************************************************
502  * OLEPicture_SendNotify (internal)
503  *
504  * Sends notification messages of changed properties to any interested
505  * connections.
506  */
507 static void OLEPicture_SendNotify(OLEPictureImpl* this, DISPID dispID)
508 {
509  IEnumConnections *pEnum;
510  CONNECTDATA CD;
511 
512  if (IConnectionPoint_EnumConnections(this->pCP, &pEnum) != S_OK)
513  return;
514  while(IEnumConnections_Next(pEnum, 1, &CD, NULL) == S_OK) {
516 
517  IUnknown_QueryInterface(CD.pUnk, &IID_IPropertyNotifySink, (LPVOID)&sink);
518  IPropertyNotifySink_OnChanged(sink, dispID);
519  IPropertyNotifySink_Release(sink);
520  IUnknown_Release(CD.pUnk);
521  }
522  IEnumConnections_Release(pEnum);
523 }
524 
525 /************************************************************************
526  * OLEPictureImpl_get_Handle
527  */
529  OLE_HANDLE *phandle)
530 {
532  TRACE("(%p)->(%p)\n", This, phandle);
533 
534  if(!phandle)
535  return E_POINTER;
536 
537  switch(This->desc.picType) {
538  case PICTYPE_NONE:
540  *phandle = 0;
541  break;
542  case PICTYPE_BITMAP:
543  *phandle = HandleToUlong(This->desc.u.bmp.hbitmap);
544  break;
545  case PICTYPE_METAFILE:
546  *phandle = HandleToUlong(This->desc.u.wmf.hmeta);
547  break;
548  case PICTYPE_ICON:
549  *phandle = HandleToUlong(This->desc.u.icon.hicon);
550  break;
551  case PICTYPE_ENHMETAFILE:
552  *phandle = HandleToUlong(This->desc.u.emf.hemf);
553  break;
554  default:
555  FIXME("Unimplemented type %d\n", This->desc.picType);
556  return E_NOTIMPL;
557  }
558  TRACE("returning handle %08x\n", *phandle);
559  return S_OK;
560 }
561 
562 /************************************************************************
563  * OLEPictureImpl_get_hPal
564  */
566  OLE_HANDLE *phandle)
567 {
569  HRESULT hres;
570  TRACE("(%p)->(%p)\n", This, phandle);
571 
572  if (!phandle)
573  return E_POINTER;
574 
575  switch (This->desc.picType) {
577  case PICTYPE_NONE:
578  *phandle = 0;
579  hres = S_FALSE;
580  break;
581  case PICTYPE_BITMAP:
582  *phandle = HandleToUlong(This->desc.u.bmp.hpal);
583  hres = S_OK;
584  break;
585  case PICTYPE_METAFILE:
586  hres = E_FAIL;
587  break;
588  case PICTYPE_ICON:
589  case PICTYPE_ENHMETAFILE:
590  default:
591  FIXME("unimplemented for type %d. Returning 0 palette.\n",
592  This->desc.picType);
593  *phandle = 0;
594  hres = S_OK;
595  }
596 
597  TRACE("returning 0x%08x, palette handle %08x\n", hres, *phandle);
598  return hres;
599 }
600 
601 /************************************************************************
602  * OLEPictureImpl_get_Type
603  */
605  short *ptype)
606 {
608  TRACE("(%p)->(%p): type is %d\n", This, ptype, This->desc.picType);
609 
610  if(!ptype)
611  return E_POINTER;
612 
613  *ptype = This->desc.picType;
614  return S_OK;
615 }
616 
617 /************************************************************************
618  * OLEPictureImpl_get_Width
619  */
622 {
624  TRACE("(%p)->(%p): width is %d\n", This, pwidth, This->himetricWidth);
625  *pwidth = This->himetricWidth;
626  return S_OK;
627 }
628 
629 /************************************************************************
630  * OLEPictureImpl_get_Height
631  */
634 {
636  TRACE("(%p)->(%p): height is %d\n", This, pheight, This->himetricHeight);
637  *pheight = This->himetricHeight;
638  return S_OK;
639 }
640 
641 /************************************************************************
642  * OLEPictureImpl_Render
643  */
645  LONG x, LONG y, LONG cx, LONG cy,
646  OLE_XPOS_HIMETRIC xSrc,
647  OLE_YPOS_HIMETRIC ySrc,
648  OLE_XSIZE_HIMETRIC cxSrc,
649  OLE_YSIZE_HIMETRIC cySrc,
650  LPCRECT prcWBounds)
651 {
653  TRACE("(%p)->(%p, (%d,%d), (%d,%d) <- (%d,%d), (%d,%d), %p)\n",
654  This, hdc, x, y, cx, cy, xSrc, ySrc, cxSrc, cySrc, prcWBounds);
655  if(prcWBounds)
656  TRACE("prcWBounds %s\n", wine_dbgstr_rect(prcWBounds));
657 
658  if(cx == 0 || cy == 0 || cxSrc == 0 || cySrc == 0){
660  }
661 
662  /*
663  * While the documentation suggests this to be here (or after rendering?)
664  * it does cause an endless recursion in my sample app. -MM 20010804
665  OLEPicture_SendNotify(This,DISPID_PICT_RENDER);
666  */
667 
668  switch(This->desc.picType) {
670  case PICTYPE_NONE:
671  /* nothing to do */
672  return S_OK;
673  case PICTYPE_BITMAP:
674  {
676  HDC hdcBmp;
677 
678  /* Set a mapping mode that maps bitmap pixels into HIMETRIC units.
679  NB y-axis gets flipped */
680 
681  hdcBmp = CreateCompatibleDC(0);
682  SetMapMode(hdcBmp, MM_ANISOTROPIC);
683  SetWindowOrgEx(hdcBmp, 0, 0, NULL);
684  SetWindowExtEx(hdcBmp, This->himetricWidth, This->himetricHeight, NULL);
685  SetViewportOrgEx(hdcBmp, 0, This->origHeight, NULL);
686  SetViewportExtEx(hdcBmp, This->origWidth, -This->origHeight, NULL);
687 
688  if (This->hbmMask) {
689  HDC hdcMask = CreateCompatibleDC(0);
690  HBITMAP hOldbm = SelectObject(hdcMask, This->hbmMask);
691 
692  hbmpOld = SelectObject(hdcBmp, This->hbmXor);
693 
694  SetMapMode(hdcMask, MM_ANISOTROPIC);
695  SetWindowOrgEx(hdcMask, 0, 0, NULL);
696  SetWindowExtEx(hdcMask, This->himetricWidth, This->himetricHeight, NULL);
697  SetViewportOrgEx(hdcMask, 0, This->origHeight, NULL);
698  SetViewportExtEx(hdcMask, This->origWidth, -This->origHeight, NULL);
699 
700  SetBkColor(hdc, RGB(255, 255, 255));
701  SetTextColor(hdc, RGB(0, 0, 0));
702  StretchBlt(hdc, x, y, cx, cy, hdcMask, xSrc, ySrc, cxSrc, cySrc, SRCAND);
703  StretchBlt(hdc, x, y, cx, cy, hdcBmp, xSrc, ySrc, cxSrc, cySrc, SRCPAINT);
704 
705  SelectObject(hdcMask, hOldbm);
706  DeleteDC(hdcMask);
707  } else {
708  hbmpOld = SelectObject(hdcBmp, This->desc.u.bmp.hbitmap);
709  StretchBlt(hdc, x, y, cx, cy, hdcBmp, xSrc, ySrc, cxSrc, cySrc, SRCCOPY);
710  }
711 
712  SelectObject(hdcBmp, hbmpOld);
713  DeleteDC(hdcBmp);
714  }
715  break;
716  case PICTYPE_ICON:
717  FIXME("Not quite correct implementation of rendering icons...\n");
718  DrawIconEx(hdc, x, y, This->desc.u.icon.hicon, cx, cy, 0, NULL, DI_NORMAL);
719  break;
720 
721  case PICTYPE_METAFILE:
722  {
723  POINT prevOrg, prevWndOrg;
724  SIZE prevExt, prevWndExt;
725  int oldmode;
726 
727  /* Render the WMF to the appropriate location by setting the
728  appropriate ratio between "device units" and "logical units" */
729  oldmode = SetMapMode(hdc, MM_ANISOTROPIC);
730  /* For the "source rectangle" the y-axis must be inverted */
731  SetWindowOrgEx(hdc, xSrc, This->himetricHeight-ySrc, &prevWndOrg);
732  SetWindowExtEx(hdc, cxSrc, -cySrc, &prevWndExt);
733  /* For the "destination rectangle" no inversion is necessary */
734  SetViewportOrgEx(hdc, x, y, &prevOrg);
735  SetViewportExtEx(hdc, cx, cy, &prevExt);
736 
737  if (!PlayMetaFile(hdc, This->desc.u.wmf.hmeta))
738  ERR("PlayMetaFile failed!\n");
739 
740  /* We're done, restore the DC to the previous settings for converting
741  logical units to device units */
742  SetWindowExtEx(hdc, prevWndExt.cx, prevWndExt.cy, NULL);
743  SetWindowOrgEx(hdc, prevWndOrg.x, prevWndOrg.y, NULL);
744  SetViewportExtEx(hdc, prevExt.cx, prevExt.cy, NULL);
745  SetViewportOrgEx(hdc, prevOrg.x, prevOrg.y, NULL);
746  SetMapMode(hdc, oldmode);
747  break;
748  }
749 
750  case PICTYPE_ENHMETAFILE:
751  {
752  RECT rc = { x, y, x + cx, y + cy };
753  PlayEnhMetaFile(hdc, This->desc.u.emf.hemf, &rc);
754  break;
755  }
756 
757  default:
758  FIXME("type %d not implemented\n", This->desc.picType);
759  return E_NOTIMPL;
760  }
761  return S_OK;
762 }
763 
764 /************************************************************************
765  * OLEPictureImpl_set_hPal
766  */
768  OLE_HANDLE hpal)
769 {
771  FIXME("(%p)->(%08x): stub\n", This, hpal);
773  return E_NOTIMPL;
774 }
775 
776 /************************************************************************
777  * OLEPictureImpl_get_CurDC
778  */
780  HDC *phdc)
781 {
783  TRACE("(%p), returning %p\n", This, This->hDCCur);
784  if (phdc) *phdc = This->hDCCur;
785  return S_OK;
786 }
787 
788 /************************************************************************
789  * OLEPictureImpl_SelectPicture
790  */
792  HDC hdcIn,
793  HDC *phdcOut,
794  OLE_HANDLE *phbmpOut)
795 {
797  TRACE("(%p)->(%p, %p, %p)\n", This, hdcIn, phdcOut, phbmpOut);
798  if (This->desc.picType == PICTYPE_BITMAP) {
799  if (phdcOut)
800  *phdcOut = This->hDCCur;
801  if (This->hDCCur) SelectObject(This->hDCCur,This->stock_bitmap);
802  if (hdcIn) SelectObject(hdcIn,This->desc.u.bmp.hbitmap);
803  This->hDCCur = hdcIn;
804  if (phbmpOut)
805  *phbmpOut = HandleToUlong(This->desc.u.bmp.hbitmap);
806  return S_OK;
807  } else {
808  FIXME("Don't know how to select picture type %d\n",This->desc.picType);
809  return E_FAIL;
810  }
811 }
812 
813 /************************************************************************
814  * OLEPictureImpl_get_KeepOriginalFormat
815  */
817  BOOL *pfKeep)
818 {
820  TRACE("(%p)->(%p)\n", This, pfKeep);
821  if (!pfKeep)
822  return E_POINTER;
823  *pfKeep = This->keepOrigFormat;
824  return S_OK;
825 }
826 
827 /************************************************************************
828  * OLEPictureImpl_put_KeepOriginalFormat
829  */
831  BOOL keep)
832 {
834  TRACE("(%p)->(%d)\n", This, keep);
835  This->keepOrigFormat = keep;
836  /* FIXME: what DISPID notification here? */
837  return S_OK;
838 }
839 
840 /************************************************************************
841  * OLEPictureImpl_PictureChanged
842  */
844 {
846  TRACE("(%p)->()\n", This);
848  This->bIsDirty = TRUE;
849  return S_OK;
850 }
851 
852 /************************************************************************
853  * OLEPictureImpl_get_Attributes
854  */
856  DWORD *pdwAttr)
857 {
859  TRACE("(%p)->(%p).\n", This, pdwAttr);
860 
861  if(!pdwAttr)
862  return E_POINTER;
863 
864  *pdwAttr = 0;
865  switch (This->desc.picType) {
867  case PICTYPE_NONE: break;
868  case PICTYPE_BITMAP: if (This->hbmMask) *pdwAttr = PICTURE_TRANSPARENT; break; /* not 'truly' scalable, see MSDN. */
869  case PICTYPE_ICON: *pdwAttr = PICTURE_TRANSPARENT;break;
870  case PICTYPE_ENHMETAFILE: /* fall through */
871  case PICTYPE_METAFILE: *pdwAttr = PICTURE_TRANSPARENT|PICTURE_SCALABLE;break;
872  default:FIXME("Unknown pictype %d\n",This->desc.picType);break;
873  }
874  return S_OK;
875 }
876 
877 
878 /************************************************************************
879  * IConnectionPointContainer
880  */
883  REFIID riid,
884  VOID** ppvoid)
885 {
887 
888  return IPicture_QueryInterface(&This->IPicture_iface,riid,ppvoid);
889 }
890 
893 {
895 
896  return IPicture_AddRef(&This->IPicture_iface);
897 }
898 
901 {
903 
904  return IPicture_Release(&This->IPicture_iface);
905 }
906 
909  IEnumConnectionPoints** ppEnum)
910 {
912 
913  FIXME("(%p,%p), stub!\n",This,ppEnum);
914  return E_NOTIMPL;
915 }
916 
919  REFIID riid,
920  IConnectionPoint **ppCP)
921 {
923  TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppCP);
924  if (!ppCP)
925  return E_POINTER;
926  *ppCP = NULL;
928  return IConnectionPoint_QueryInterface(This->pCP, &IID_IConnectionPoint, (void**)ppCP);
929  FIXME("no connection point for %s\n",debugstr_guid(riid));
930  return CONNECT_E_NOCONNECTION;
931 }
932 
933 
934 /************************************************************************
935  * IPersistStream
936  */
937 
938 /************************************************************************
939  * OLEPictureImpl_IPersistStream_QueryInterface (IUnknown)
940  *
941  * See Windows documentation for more details on IUnknown methods.
942  */
944  IPersistStream* iface,
945  REFIID riid,
946  VOID** ppvoid)
947 {
949 
950  return IPicture_QueryInterface(&This->IPicture_iface, riid, ppvoid);
951 }
952 
953 /************************************************************************
954  * OLEPictureImpl_IPersistStream_AddRef (IUnknown)
955  *
956  * See Windows documentation for more details on IUnknown methods.
957  */
959  IPersistStream* iface)
960 {
962 
963  return IPicture_AddRef(&This->IPicture_iface);
964 }
965 
966 /************************************************************************
967  * OLEPictureImpl_IPersistStream_Release (IUnknown)
968  *
969  * See Windows documentation for more details on IUnknown methods.
970  */
972  IPersistStream* iface)
973 {
975 
976  return IPicture_Release(&This->IPicture_iface);
977 }
978 
979 /************************************************************************
980  * OLEPictureImpl_IPersistStream_GetClassID
981  */
983  IPersistStream* iface,CLSID* pClassID)
984 {
985  TRACE("(%p)\n", pClassID);
986  *pClassID = CLSID_StdPicture;
987  return S_OK;
988 }
989 
990 /************************************************************************
991  * OLEPictureImpl_IPersistStream_IsDirty
992  */
994  IPersistStream* iface)
995 {
997  FIXME("(%p),stub!\n",This);
998  return E_NOTIMPL;
999 }
1000 
1002 {
1003  HRESULT hr;
1004  BITMAPINFOHEADER bih;
1005  UINT width, height;
1006  UINT stride, buffersize;
1007  BYTE *bits, *mask = NULL;
1008  WICRect rc;
1009  IWICBitmapSource *real_source;
1010  UINT x, y;
1011  COLORREF white = RGB(255, 255, 255), black = RGB(0, 0, 0);
1012  BOOL has_alpha=FALSE;
1013 
1014  hr = WICConvertBitmapSource(&GUID_WICPixelFormat32bppBGRA, src, &real_source);
1015  if (FAILED(hr)) return hr;
1016 
1017  hr = IWICBitmapSource_GetSize(real_source, &width, &height);
1018  if (FAILED(hr)) goto end;
1019 
1020  bih.biSize = sizeof(bih);
1021  bih.biWidth = width;
1022  bih.biHeight = -height;
1023  bih.biPlanes = 1;
1024  bih.biBitCount = 32;
1025  bih.biCompression = BI_RGB;
1026  bih.biSizeImage = 0;
1027  bih.biXPelsPerMeter = 4085; /* olepicture ignores the stored resolution */
1028  bih.biYPelsPerMeter = 4085;
1029  bih.biClrUsed = 0;
1030  bih.biClrImportant = 0;
1031 
1032  stride = 4 * width;
1033  buffersize = stride * height;
1034 
1035  mask = HeapAlloc(GetProcessHeap(), 0, buffersize);
1036  if (!mask)
1037  {
1038  hr = E_OUTOFMEMORY;
1039  goto end;
1040  }
1041 
1042  This->desc.u.bmp.hbitmap = CreateDIBSection(0, (BITMAPINFO*)&bih, DIB_RGB_COLORS, (void **)&bits, NULL, 0);
1043  if (This->desc.u.bmp.hbitmap == 0)
1044  {
1045  hr = E_FAIL;
1046  goto end;
1047  }
1048 
1049  rc.X = 0;
1050  rc.Y = 0;
1051  rc.Width = width;
1052  rc.Height = height;
1053  hr = IWICBitmapSource_CopyPixels(real_source, &rc, stride, buffersize, bits);
1054  if (FAILED(hr))
1055  {
1056  DeleteObject(This->desc.u.bmp.hbitmap);
1057  goto end;
1058  }
1059 
1060  This->desc.picType = PICTYPE_BITMAP;
1062 
1063  /* set transparent pixels to black, all others to white */
1064  for(y = 0; y < height; y++){
1065  for(x = 0; x < width; x++){
1066  DWORD *pixel = (DWORD*)(bits + stride*y + 4*x);
1067  if((*pixel & 0x80000000) == 0)
1068  {
1069  has_alpha = TRUE;
1070  *(DWORD *)(mask + stride * y + 4 * x) = black;
1071  }
1072  else
1073  *(DWORD *)(mask + stride * y + 4 * x) = white;
1074  }
1075  }
1076 
1077  if (has_alpha)
1078  {
1079  HDC hdcref, hdcBmp, hdcXor, hdcMask;
1080  HBITMAP hbmoldBmp, hbmoldXor, hbmoldMask;
1081 
1082  hdcref = GetDC(0);
1083 
1084  This->hbmXor = CreateDIBitmap(
1085  hdcref,
1086  &bih,
1087  CBM_INIT,
1088  mask,
1089  (BITMAPINFO*)&bih,
1091  );
1092 
1093  This->hbmMask = CreateBitmap(width,-height,1,1,NULL);
1094  hdcBmp = CreateCompatibleDC(NULL);
1095  hdcXor = CreateCompatibleDC(NULL);
1096  hdcMask = CreateCompatibleDC(NULL);
1097 
1098  hbmoldBmp = SelectObject(hdcBmp,This->desc.u.bmp.hbitmap);
1099  hbmoldXor = SelectObject(hdcXor,This->hbmXor);
1100  hbmoldMask = SelectObject(hdcMask,This->hbmMask);
1101 
1102  SetBkColor(hdcXor,black);
1103  BitBlt(hdcMask,0,0,width,height,hdcXor,0,0,SRCCOPY);
1104  BitBlt(hdcXor,0,0,width,height,hdcBmp,0,0,SRCAND);
1105 
1106  SelectObject(hdcBmp,hbmoldBmp);
1107  SelectObject(hdcXor,hbmoldXor);
1108  SelectObject(hdcMask,hbmoldMask);
1109 
1110  DeleteDC(hdcBmp);
1111  DeleteDC(hdcXor);
1112  DeleteDC(hdcMask);
1113  ReleaseDC(0, hdcref);
1114  }
1115 
1116 end:
1117  HeapFree(GetProcessHeap(), 0, mask);
1118  IWICBitmapSource_Release(real_source);
1119  return hr;
1120 }
1121 
1123 {
1124  HRESULT hr;
1126  IWICBitmapDecoder *decoder;
1127  IWICBitmapFrameDecode *framedecode;
1128  HRESULT initresult;
1129  IWICStream *stream;
1130 
1131  initresult = CoInitialize(NULL);
1132 
1133  hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
1134  &IID_IWICImagingFactory, (void**)&factory);
1135  if (SUCCEEDED(hr)) /* created factory */
1136  {
1137  hr = IWICImagingFactory_CreateStream(factory, &stream);
1138  IWICImagingFactory_Release(factory);
1139  }
1140 
1141  if (SUCCEEDED(hr)) /* created stream */
1142  {
1143  hr = IWICStream_InitializeFromMemory(stream, xbuf, xread);
1144 
1145  if (SUCCEEDED(hr)) /* initialized stream */
1146  {
1147  hr = CoCreateInstance(decoder_clsid, NULL, CLSCTX_INPROC_SERVER,
1148  &IID_IWICBitmapDecoder, (void**)&decoder);
1149  if (SUCCEEDED(hr)) /* created decoder */
1150  {
1151  hr = IWICBitmapDecoder_Initialize(decoder, (IStream*)stream, WICDecodeMetadataCacheOnLoad);
1152 
1153  if (SUCCEEDED(hr)) /* initialized decoder */
1154  hr = IWICBitmapDecoder_GetFrame(decoder, 0, &framedecode);
1155 
1156  IWICBitmapDecoder_Release(decoder);
1157  }
1158  }
1159 
1160  IWICStream_Release(stream);
1161  }
1162 
1163  if (SUCCEEDED(hr)) /* got framedecode */
1164  {
1165  hr = OLEPictureImpl_LoadWICSource(This, (IWICBitmapSource*)framedecode);
1166  IWICBitmapFrameDecode_Release(framedecode);
1167  }
1168 
1169  if (SUCCEEDED(initresult)) CoUninitialize();
1170  return hr;
1171 }
1172 
1173 /*****************************************************
1174 * start of Icon-specific code
1175 */
1176 
1178 {
1179  HICON hicon;
1180  CURSORICONFILEDIR *cifd = (CURSORICONFILEDIR*)xbuf;
1181  HDC hdcRef;
1182  int i;
1183 
1184  TRACE("(this %p, xbuf %p, xread %u)\n", This, xbuf, xread);
1185 
1186  /*
1187  FIXME("icon.idReserved=%d\n",cifd->idReserved);
1188  FIXME("icon.idType=%d\n",cifd->idType);
1189  FIXME("icon.idCount=%d\n",cifd->idCount);
1190 
1191  for (i=0;i<cifd->idCount;i++) {
1192  FIXME("[%d] width %d\n",i,cifd->idEntries[i].bWidth);
1193  FIXME("[%d] height %d\n",i,cifd->idEntries[i].bHeight);
1194  FIXME("[%d] bColorCount %d\n",i,cifd->idEntries[i].bColorCount);
1195  FIXME("[%d] bReserved %d\n",i,cifd->idEntries[i].bReserved);
1196  FIXME("[%d] xHotspot %d\n",i,cifd->idEntries[i].xHotspot);
1197  FIXME("[%d] yHotspot %d\n",i,cifd->idEntries[i].yHotspot);
1198  FIXME("[%d] dwDIBSize %d\n",i,cifd->idEntries[i].dwDIBSize);
1199  FIXME("[%d] dwDIBOffset %d\n",i,cifd->idEntries[i].dwDIBOffset);
1200  }
1201  */
1202 
1203  /* Need at least one icon to do something. */
1204  if (!cifd->idCount)
1205  {
1206  ERR("Invalid icon count of zero.\n");
1207  return E_FAIL;
1208  }
1209  i=0;
1210  /* If we have more than one icon, try to find the best.
1211  * this currently means '32 pixel wide'.
1212  */
1213  if (cifd->idCount!=1) {
1214  for (i=0;i<cifd->idCount;i++) {
1215  if (cifd->idEntries[i].bWidth == 32)
1216  break;
1217  }
1218  if (i==cifd->idCount) i=0;
1219  }
1220  if (xread < cifd->idEntries[i].dwDIBOffset + cifd->idEntries[i].dwDIBSize)
1221  {
1222  ERR("Icon data address %u is over %u bytes available.\n",
1223  cifd->idEntries[i].dwDIBOffset + cifd->idEntries[i].dwDIBSize, xread);
1224  return E_FAIL;
1225  }
1226  if (cifd->idType == 2)
1227  {
1228  LPBYTE buf = HeapAlloc(GetProcessHeap(), 0, cifd->idEntries[i].dwDIBSize + 4);
1229  memcpy(buf, &cifd->idEntries[i].xHotspot, 4);
1230  memcpy(buf + 4, xbuf+cifd->idEntries[i].dwDIBOffset, cifd->idEntries[i].dwDIBSize);
1231  hicon = CreateIconFromResourceEx(
1232  buf,
1233  cifd->idEntries[i].dwDIBSize + 4,
1234  FALSE, /* is cursor */
1235  0x00030000,
1236  cifd->idEntries[i].bWidth,
1237  cifd->idEntries[i].bHeight,
1238  0
1239  );
1240  HeapFree(GetProcessHeap(), 0, buf);
1241  }
1242  else
1243  {
1244  hicon = CreateIconFromResourceEx(
1245  xbuf+cifd->idEntries[i].dwDIBOffset,
1246  cifd->idEntries[i].dwDIBSize,
1247  TRUE, /* is icon */
1248  0x00030000,
1249  cifd->idEntries[i].bWidth,
1250  cifd->idEntries[i].bHeight,
1251  0
1252  );
1253  }
1254  if (!hicon) {
1255  ERR("CreateIcon failed.\n");
1256  return E_FAIL;
1257  } else {
1258  This->desc.picType = PICTYPE_ICON;
1259  This->desc.u.icon.hicon = hicon;
1260  This->origWidth = cifd->idEntries[i].bWidth;
1261  This->origHeight = cifd->idEntries[i].bHeight;
1262  hdcRef = CreateCompatibleDC(0);
1263  This->himetricWidth = xpixels_to_himetric(cifd->idEntries[i].bWidth, hdcRef);
1264  This->himetricHeight= ypixels_to_himetric(cifd->idEntries[i].bHeight, hdcRef);
1265  DeleteDC(hdcRef);
1266  return S_OK;
1267  }
1268 }
1269 
1271  const BYTE *data, ULONG size)
1272 {
1273  HENHMETAFILE hemf;
1275 
1276  hemf = SetEnhMetaFileBits(size, data);
1277  if (!hemf) return E_FAIL;
1278 
1279  GetEnhMetaFileHeader(hemf, sizeof(hdr), &hdr);
1280 
1281  This->desc.picType = PICTYPE_ENHMETAFILE;
1282  This->desc.u.emf.hemf = hemf;
1283 
1284  This->origWidth = 0;
1285  This->origHeight = 0;
1286  This->himetricWidth = hdr.rclFrame.right - hdr.rclFrame.left;
1287  This->himetricHeight = hdr.rclFrame.bottom - hdr.rclFrame.top;
1288 
1289  return S_OK;
1290 }
1291 
1293  const BYTE *data, ULONG size)
1294 {
1295  const APM_HEADER *header = (const APM_HEADER *)data;
1296  HMETAFILE hmf;
1297 
1298  if (size < sizeof(APM_HEADER))
1299  return E_FAIL;
1300  if (header->key != 0x9ac6cdd7)
1301  return E_FAIL;
1302 
1303  /* SetMetaFileBitsEx performs data check on its own */
1304  hmf = SetMetaFileBitsEx(size - sizeof(*header), data + sizeof(*header));
1305  if (!hmf) return E_FAIL;
1306 
1307  This->desc.picType = PICTYPE_METAFILE;
1308  This->desc.u.wmf.hmeta = hmf;
1309  This->desc.u.wmf.xExt = 0;
1310  This->desc.u.wmf.yExt = 0;
1311 
1312  This->origWidth = 0;
1313  This->origHeight = 0;
1314  This->himetricWidth = MulDiv((INT)header->right - header->left, 2540, header->inch);
1315  This->himetricHeight = MulDiv((INT)header->bottom - header->top, 2540, header->inch);
1316  return S_OK;
1317 }
1318 
1319 /************************************************************************
1320  * OLEPictureImpl_IPersistStream_Load (IUnknown)
1321  *
1322  * Loads the binary data from the IStream. Starts at current position.
1323  * There appears to be an 2 DWORD header:
1324  * DWORD magic;
1325  * DWORD len;
1326  *
1327  * Currently implemented: BITMAP, ICON, CURSOR, JPEG, GIF, WMF, EMF
1328  */
1330  HRESULT hr;
1331  BOOL headerisdata;
1332  BOOL statfailed = FALSE;
1333  ULONG xread, toread;
1334  ULONG headerread;
1335  BYTE *xbuf;
1336  DWORD header[2];
1337  WORD magic;
1338  STATSTG statstg;
1340 
1341  TRACE("(%p,%p)\n",This,pStm);
1342 
1343  /****************************************************************************************
1344  * Part 1: Load the data
1345  */
1346  /* Sometimes we have a header, sometimes we don't. Apply some guesses to find
1347  * out whether we do.
1348  *
1349  * UPDATE: the IStream can be mapped to a plain file instead of a stream in a
1350  * compound file. This may explain most, if not all, of the cases of "no
1351  * header", and the header validation should take this into account.
1352  * At least in Visual Basic 6, resource streams, valid headers are
1353  * header[0] == "lt\0\0",
1354  * header[1] == length_of_stream.
1355  *
1356  * Also handle streams where we do not have a working "Stat" method by
1357  * reading all data until the end of the stream.
1358  */
1359  hr = IStream_Stat(pStm,&statstg,STATFLAG_NONAME);
1360  if (hr != S_OK) {
1361  TRACE("stat failed with hres %x, proceeding to read all data.\n",hr);
1362  statfailed = TRUE;
1363  /* we will read at least 8 byte ... just right below */
1364  statstg.cbSize.QuadPart = 8;
1365  }
1366 
1367  toread = 0;
1368  headerread = 0;
1369  headerisdata = FALSE;
1370  do {
1371  hr = IStream_Read(pStm, header, 8, &xread);
1372  if (hr != S_OK || xread!=8) {
1373  ERR("Failure while reading picture header (hr is %x, nread is %d).\n",hr,xread);
1374  return (hr?hr:E_FAIL);
1375  }
1376  headerread += xread;
1377  xread = 0;
1378 
1379  if (!memcmp(&(header[0]),"lt\0\0", 4) && (statfailed || (header[1] + headerread <= statstg.cbSize.QuadPart))) {
1380  if (toread != 0 && toread != header[1])
1381  FIXME("varying lengths of image data (prev=%u curr=%u), only last one will be used\n",
1382  toread, header[1]);
1383  toread = header[1];
1384  if (statfailed)
1385  {
1386  statstg.cbSize.QuadPart = header[1] + 8;
1387  statfailed = FALSE;
1388  }
1389  if (toread == 0) break;
1390  } else {
1391  if (!memcmp(&(header[0]), "GIF8", 4) || /* GIF header */
1392  !memcmp(&(header[0]), "BM", 2) || /* BMP header */
1393  !memcmp(&(header[0]), "\xff\xd8", 2) || /* JPEG header */
1394  (header[0] == EMR_HEADER) || /* EMF header */
1395  (header[0] == 0x10000) || /* icon: idReserved 0, idType 1 */
1396  (header[0] == 0x20000) || /* cursor: idReserved 0, idType 2 */
1397  (header[1] > statstg.cbSize.QuadPart)|| /* invalid size */
1398  (header[1]==0)
1399  ) {/* Found start of bitmap data */
1400  headerisdata = TRUE;
1401  if (toread == 0)
1402  toread = statstg.cbSize.QuadPart-8;
1403  else toread -= 8;
1404  xread = 8;
1405  } else {
1406  FIXME("Unknown stream header magic: %08x\n", header[0]);
1407  toread = header[1];
1408  }
1409  }
1410  } while (!headerisdata);
1411 
1412  if (statfailed) { /* we don't know the size ... read all we get */
1413  unsigned int sizeinc = 4096;
1414  unsigned int origsize = sizeinc;
1415  ULONG nread = 42;
1416 
1417  TRACE("Reading all data from stream.\n");
1418  xbuf = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, origsize);
1419  if (headerisdata)
1420  memcpy (xbuf, header, 8);
1421  while (1) {
1422  while (xread < origsize) {
1423  hr = IStream_Read(pStm,xbuf+xread,origsize-xread,&nread);
1424  xread += nread;
1425  if (hr != S_OK || !nread)
1426  break;
1427  }
1428  if (!nread || hr != S_OK) /* done, or error */
1429  break;
1430  if (xread == origsize) {
1431  origsize += sizeinc;
1432  sizeinc = 2*sizeinc; /* exponential increase */
1433  xbuf = HeapReAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, xbuf, origsize);
1434  }
1435  }
1436  if (hr != S_OK)
1437  TRACE("hr in no-stat loader case is %08x\n", hr);
1438  TRACE("loaded %d bytes.\n", xread);
1439  This->datalen = xread;
1440  This->data = xbuf;
1441  } else {
1442  This->datalen = toread+(headerisdata?8:0);
1443  xbuf = This->data = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, This->datalen);
1444  if (!xbuf)
1445  return E_OUTOFMEMORY;
1446 
1447  if (headerisdata)
1448  memcpy (xbuf, header, 8);
1449 
1450  while (xread < This->datalen) {
1451  ULONG nread;
1452  hr = IStream_Read(pStm,xbuf+xread,This->datalen-xread,&nread);
1453  xread += nread;
1454  if (hr != S_OK || !nread)
1455  break;
1456  }
1457  if (xread != This->datalen)
1458  ERR("Could only read %d of %d bytes out of stream?\n",xread,This->datalen);
1459  }
1460  if (This->datalen == 0) { /* Marks the "NONE" picture */
1461  This->desc.picType = PICTYPE_NONE;
1462  return S_OK;
1463  }
1464 
1465 
1466  /****************************************************************************************
1467  * Part 2: Process the loaded data
1468  */
1469 
1470  magic = xbuf[0] + (xbuf[1]<<8);
1471  This->loadtime_format = magic;
1472 
1473  switch (magic) {
1474  case BITMAP_FORMAT_GIF: /* GIF */
1475  hr = OLEPictureImpl_LoadWICDecoder(This, &CLSID_WICGifDecoder, xbuf, xread);
1476  break;
1477  case BITMAP_FORMAT_JPEG: /* JPEG */
1478  hr = OLEPictureImpl_LoadWICDecoder(This, &CLSID_WICJpegDecoder, xbuf, xread);
1479  break;
1480  case BITMAP_FORMAT_BMP: /* Bitmap */
1481  hr = OLEPictureImpl_LoadWICDecoder(This, &CLSID_WICBmpDecoder, xbuf, xread);
1482  break;
1483  case BITMAP_FORMAT_PNG: /* PNG */
1484  hr = OLEPictureImpl_LoadWICDecoder(This, &CLSID_WICPngDecoder, xbuf, xread);
1485  break;
1486  case BITMAP_FORMAT_APM: /* APM */
1487  hr = OLEPictureImpl_LoadAPM(This, xbuf, xread);
1488  break;
1489  case 0x0000: { /* ICON or CURSOR, first word is dwReserved */
1490  hr = OLEPictureImpl_LoadIcon(This, xbuf, xread);
1491  break;
1492  }
1493  default:
1494  {
1495  unsigned int i;
1496 
1497  /* let's see if it's a EMF */
1498  hr = OLEPictureImpl_LoadEnhMetafile(This, xbuf, xread);
1499  if (hr == S_OK) break;
1500 
1501  FIXME("Unknown magic %04x, %d read bytes:\n",magic,xread);
1502  hr=E_FAIL;
1503  for (i=0;i<xread+8;i++) {
1504  if (i<8) MESSAGE("%02x ",((unsigned char*)header)[i]);
1505  else MESSAGE("%02x ",xbuf[i-8]);
1506  if (i % 10 == 9) MESSAGE("\n");
1507  }
1508  MESSAGE("\n");
1509  break;
1510  }
1511  }
1512  This->bIsDirty = FALSE;
1513 
1514  /* FIXME: this notify is not really documented */
1515  if (hr==S_OK)
1517  return hr;
1518 }
1519 
1520 static BOOL serializeBMP(HBITMAP hBitmap, void ** ppBuffer, unsigned int * pLength)
1521 {
1522  BOOL success = FALSE;
1523  HDC hDC;
1524  BITMAPINFO * pInfoBitmap;
1525  int iNumPaletteEntries;
1526  unsigned char * pPixelData;
1527  BITMAPFILEHEADER * pFileHeader;
1528  BITMAPINFO * pInfoHeader;
1529 
1530  pInfoBitmap = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
1531  sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
1532 
1533  /* Find out bitmap size and padded length */
1534  hDC = GetDC(0);
1535  pInfoBitmap->bmiHeader.biSize = sizeof(pInfoBitmap->bmiHeader);
1536  GetDIBits(hDC, hBitmap, 0, 0, NULL, pInfoBitmap, DIB_RGB_COLORS);
1537 
1538  /* Fetch bitmap palette & pixel data */
1539 
1540  pPixelData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, pInfoBitmap->bmiHeader.biSizeImage);
1541  GetDIBits(hDC, hBitmap, 0, pInfoBitmap->bmiHeader.biHeight, pPixelData, pInfoBitmap, DIB_RGB_COLORS);
1542 
1543  /* Calculate the total length required for the BMP data */
1544  if (pInfoBitmap->bmiHeader.biClrUsed != 0) {
1545  iNumPaletteEntries = pInfoBitmap->bmiHeader.biClrUsed;
1546  if (iNumPaletteEntries > 256) iNumPaletteEntries = 256;
1547  } else {
1548  if (pInfoBitmap->bmiHeader.biBitCount <= 8)
1549  iNumPaletteEntries = 1 << pInfoBitmap->bmiHeader.biBitCount;
1550  else
1551  iNumPaletteEntries = 0;
1552  }
1553  *pLength =
1554  sizeof(BITMAPFILEHEADER) +
1555  sizeof(BITMAPINFOHEADER) +
1556  iNumPaletteEntries * sizeof(RGBQUAD) +
1557  pInfoBitmap->bmiHeader.biSizeImage;
1559 
1560  /* Fill the BITMAPFILEHEADER */
1561  pFileHeader = *ppBuffer;
1562  pFileHeader->bfType = BITMAP_FORMAT_BMP;
1563  pFileHeader->bfSize = *pLength;
1564  pFileHeader->bfOffBits =
1565  sizeof(BITMAPFILEHEADER) +
1566  sizeof(BITMAPINFOHEADER) +
1567  iNumPaletteEntries * sizeof(RGBQUAD);
1568 
1569  /* Fill the BITMAPINFOHEADER and the palette data */
1570  pInfoHeader = (BITMAPINFO *)((unsigned char *)(*ppBuffer) + sizeof(BITMAPFILEHEADER));
1571  memcpy(pInfoHeader, pInfoBitmap, sizeof(BITMAPINFOHEADER) + iNumPaletteEntries * sizeof(RGBQUAD));
1572  memcpy(
1573  (unsigned char *)(*ppBuffer) +
1574  sizeof(BITMAPFILEHEADER) +
1575  sizeof(BITMAPINFOHEADER) +
1576  iNumPaletteEntries * sizeof(RGBQUAD),
1577  pPixelData, pInfoBitmap->bmiHeader.biSizeImage);
1578  success = TRUE;
1579 
1580  HeapFree(GetProcessHeap(), 0, pPixelData);
1581  HeapFree(GetProcessHeap(), 0, pInfoBitmap);
1582  return success;
1583 }
1584 
1585 static BOOL serializeIcon(HICON hIcon, void ** ppBuffer, unsigned int * pLength)
1586 {
1587  ICONINFO infoIcon;
1588  BOOL success = FALSE;
1589 
1590  *ppBuffer = NULL; *pLength = 0;
1591  if (GetIconInfo(hIcon, &infoIcon)) {
1592  HDC hDC;
1593  BITMAPINFO * pInfoBitmap;
1594  unsigned char * pIconData = NULL;
1595  unsigned int iDataSize = 0;
1596 
1597  pInfoBitmap = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
1598 
1599  /* Find out icon size */
1600  hDC = GetDC(0);
1601  pInfoBitmap->bmiHeader.biSize = sizeof(pInfoBitmap->bmiHeader);
1602  GetDIBits(hDC, infoIcon.hbmColor, 0, 0, NULL, pInfoBitmap, DIB_RGB_COLORS);
1603  if (1) {
1604  /* Auxiliary pointers */
1605  CURSORICONFILEDIR * pIconDir;
1606  CURSORICONFILEDIRENTRY * pIconEntry;
1607  BITMAPINFOHEADER * pIconBitmapHeader;
1608  unsigned int iOffsetPalette;
1609  unsigned int iOffsetColorData;
1610  unsigned int iOffsetMaskData;
1611 
1612  unsigned int iLengthScanLineMask;
1613  unsigned int iNumEntriesPalette;
1614 
1615  iLengthScanLineMask = ((pInfoBitmap->bmiHeader.biWidth + 31) >> 5) << 2;
1616 /*
1617  FIXME("DEBUG: bitmap size is %d x %d\n",
1618  pInfoBitmap->bmiHeader.biWidth,
1619  pInfoBitmap->bmiHeader.biHeight);
1620  FIXME("DEBUG: bitmap bpp is %d\n",
1621  pInfoBitmap->bmiHeader.biBitCount);
1622  FIXME("DEBUG: bitmap nplanes is %d\n",
1623  pInfoBitmap->bmiHeader.biPlanes);
1624  FIXME("DEBUG: bitmap biSizeImage is %u\n",
1625  pInfoBitmap->bmiHeader.biSizeImage);
1626 */
1627  /* Let's start with one CURSORICONFILEDIR and one CURSORICONFILEDIRENTRY */
1628  iDataSize += 3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY) + sizeof(BITMAPINFOHEADER);
1629  pIconData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, iDataSize);
1630 
1631  /* Fill out the CURSORICONFILEDIR */
1632  pIconDir = (CURSORICONFILEDIR *)pIconData;
1633  pIconDir->idType = 1;
1634  pIconDir->idCount = 1;
1635  pIconDir->idReserved = 0;
1636 
1637  /* Fill out the CURSORICONFILEDIRENTRY */
1638  pIconEntry = (CURSORICONFILEDIRENTRY *)(pIconData + 3 * sizeof(WORD));
1639  pIconEntry->bWidth = (unsigned char)pInfoBitmap->bmiHeader.biWidth;
1640  pIconEntry->bHeight = (unsigned char)pInfoBitmap->bmiHeader.biHeight;
1641  pIconEntry->bColorCount =
1642  (pInfoBitmap->bmiHeader.biBitCount < 8)
1643  ? 1 << pInfoBitmap->bmiHeader.biBitCount
1644  : 0;
1645  pIconEntry->xHotspot = pInfoBitmap->bmiHeader.biPlanes;
1646  pIconEntry->yHotspot = pInfoBitmap->bmiHeader.biBitCount;
1647  pIconEntry->dwDIBSize = 0;
1648  pIconEntry->dwDIBOffset = 3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY);
1649 
1650  /* Fill out the BITMAPINFOHEADER */
1651  pIconBitmapHeader = (BITMAPINFOHEADER *)(pIconData + 3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY));
1652  *pIconBitmapHeader = pInfoBitmap->bmiHeader;
1653 
1654  /* Find out whether a palette exists for the bitmap */
1655  if ( (pInfoBitmap->bmiHeader.biBitCount == 16 && pInfoBitmap->bmiHeader.biCompression == BI_RGB)
1656  || (pInfoBitmap->bmiHeader.biBitCount == 24)
1657  || (pInfoBitmap->bmiHeader.biBitCount == 32 && pInfoBitmap->bmiHeader.biCompression == BI_RGB)) {
1658  iNumEntriesPalette = pInfoBitmap->bmiHeader.biClrUsed;
1659  if (iNumEntriesPalette > 256) iNumEntriesPalette = 256;
1660  } else if ((pInfoBitmap->bmiHeader.biBitCount == 16 || pInfoBitmap->bmiHeader.biBitCount == 32)
1661  && pInfoBitmap->bmiHeader.biCompression == BI_BITFIELDS) {
1662  iNumEntriesPalette = 3;
1663  } else if (pInfoBitmap->bmiHeader.biBitCount <= 8) {
1664  iNumEntriesPalette = 1 << pInfoBitmap->bmiHeader.biBitCount;
1665  } else {
1666  iNumEntriesPalette = 0;
1667  }
1668 
1669  /* Add bitmap size and header size to icon data size. */
1670  iOffsetPalette = iDataSize;
1671  iDataSize += iNumEntriesPalette * sizeof(DWORD);
1672  iOffsetColorData = iDataSize;
1673  iDataSize += pIconBitmapHeader->biSizeImage;
1674  iOffsetMaskData = iDataSize;
1675  iDataSize += pIconBitmapHeader->biHeight * iLengthScanLineMask;
1676  pIconBitmapHeader->biSizeImage += pIconBitmapHeader->biHeight * iLengthScanLineMask;
1677  pIconBitmapHeader->biHeight *= 2;
1678  pIconData = HeapReAlloc(GetProcessHeap(), 0, pIconData, iDataSize);
1679  pIconEntry = (CURSORICONFILEDIRENTRY *)(pIconData + 3 * sizeof(WORD));
1680  pIconBitmapHeader = (BITMAPINFOHEADER *)(pIconData + 3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY));
1681  pIconEntry->dwDIBSize = iDataSize - (3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY));
1682 
1683  /* Get the actual bitmap data from the icon bitmap */
1684  GetDIBits(hDC, infoIcon.hbmColor, 0, pInfoBitmap->bmiHeader.biHeight,
1685  pIconData + iOffsetColorData, pInfoBitmap, DIB_RGB_COLORS);
1686  if (iNumEntriesPalette > 0) {
1687  memcpy(pIconData + iOffsetPalette, pInfoBitmap->bmiColors,
1688  iNumEntriesPalette * sizeof(RGBQUAD));
1689  }
1690 
1691  /* Reset all values so that GetDIBits call succeeds */
1692  memset(pIconData + iOffsetMaskData, 0, iDataSize - iOffsetMaskData);
1693  memset(pInfoBitmap, 0, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
1694  pInfoBitmap->bmiHeader.biSize = sizeof(pInfoBitmap->bmiHeader);
1695 /*
1696  if (!(GetDIBits(hDC, infoIcon.hbmMask, 0, 0, NULL, pInfoBitmap, DIB_RGB_COLORS)
1697  && GetDIBits(hDC, infoIcon.hbmMask, 0, pIconEntry->bHeight,
1698  pIconData + iOffsetMaskData, pInfoBitmap, DIB_RGB_COLORS))) {
1699 
1700  printf("ERROR: unable to get bitmap mask (error %u)\n",
1701  GetLastError());
1702 
1703  }
1704 */
1705  GetDIBits(hDC, infoIcon.hbmMask, 0, 0, NULL, pInfoBitmap, DIB_RGB_COLORS);
1706  GetDIBits(hDC, infoIcon.hbmMask, 0, pIconEntry->bHeight, pIconData + iOffsetMaskData, pInfoBitmap, DIB_RGB_COLORS);
1707 
1708  /* Write out everything produced so far to the stream */
1709  *ppBuffer = pIconData; *pLength = iDataSize;
1710  success = TRUE;
1711  } else {
1712 /*
1713  printf("ERROR: unable to get bitmap information via GetDIBits() (error %u)\n",
1714  GetLastError());
1715 */
1716  }
1717  /*
1718  Remarks (from MSDN entry on GetIconInfo):
1719 
1720  GetIconInfo creates bitmaps for the hbmMask and hbmColor
1721  members of ICONINFO. The calling application must manage
1722  these bitmaps and delete them when they are no longer
1723  necessary.
1724  */
1725  if (hDC) ReleaseDC(0, hDC);
1726  DeleteObject(infoIcon.hbmMask);
1727  if (infoIcon.hbmColor) DeleteObject(infoIcon.hbmColor);
1728  HeapFree(GetProcessHeap(), 0, pInfoBitmap);
1729  } else {
1730  printf("ERROR: Unable to get icon information (error %u)\n",
1731  GetLastError());
1732  }
1733  return success;
1734 }
1735 
1736 static BOOL serializeEMF(HENHMETAFILE hemf, void **buf, unsigned *size)
1737 {
1738  *size = GetEnhMetaFileBits(hemf, 0, NULL);
1739  if (!*size) return FALSE;
1740 
1741  *buf = HeapAlloc(GetProcessHeap(), 0, *size);
1742  if (!*buf) return FALSE;
1743 
1744  return GetEnhMetaFileBits(hemf, *size, *buf) != 0;
1745 }
1746 
1748  IPersistStream* iface,IStream*pStm,BOOL fClearDirty)
1749 {
1750  HRESULT hResult = E_NOTIMPL;
1751  void * pIconData;
1752  unsigned int iDataSize;
1753  DWORD header[2];
1754  ULONG dummy;
1755  BOOL serializeResult = FALSE;
1757 
1758  TRACE("%p %p %d\n", This, pStm, fClearDirty);
1759 
1760  switch (This->desc.picType) {
1761  case PICTYPE_NONE:
1762  header[0] = 0x0000746c;
1763  header[1] = 0;
1764  hResult = IStream_Write(pStm, header, 2 * sizeof(DWORD), &dummy);
1765  break;
1766 
1767  case PICTYPE_ICON:
1768  if (This->bIsDirty || !This->data) {
1769  if (!serializeIcon(This->desc.u.icon.hicon, &pIconData, &iDataSize)) {
1770  ERR("(%p,%p,%d), serializeIcon() failed\n", This, pStm, fClearDirty);
1771  hResult = E_FAIL;
1772  break;
1773  }
1774  HeapFree(GetProcessHeap(), 0, This->data);
1775  This->data = pIconData;
1776  This->datalen = iDataSize;
1777  }
1778 
1779  header[0] = (This->loadtime_magic != 0xdeadbeef) ? This->loadtime_magic : 0x0000746c;
1780  header[1] = This->datalen;
1781  IStream_Write(pStm, header, 2 * sizeof(DWORD), &dummy);
1782  IStream_Write(pStm, This->data, This->datalen, &dummy);
1783  hResult = S_OK;
1784  break;
1785  case PICTYPE_BITMAP:
1786  if (This->bIsDirty || !This->data) {
1787  switch (This->keepOrigFormat ? This->loadtime_format : BITMAP_FORMAT_BMP) {
1788  case BITMAP_FORMAT_BMP:
1789  serializeResult = serializeBMP(This->desc.u.bmp.hbitmap, &pIconData, &iDataSize);
1790  break;
1791  case BITMAP_FORMAT_JPEG:
1792  FIXME("(%p,%p,%d), PICTYPE_BITMAP (format JPEG) not implemented!\n",This,pStm,fClearDirty);
1793  break;
1794  case BITMAP_FORMAT_GIF:
1795  FIXME("(%p,%p,%d), PICTYPE_BITMAP (format GIF) not implemented!\n",This,pStm,fClearDirty);
1796  break;
1797  case BITMAP_FORMAT_PNG:
1798  FIXME("(%p,%p,%d), PICTYPE_BITMAP (format PNG) not implemented!\n",This,pStm,fClearDirty);
1799  break;
1800  default:
1801  FIXME("(%p,%p,%d), PICTYPE_BITMAP (format UNKNOWN, using BMP?) not implemented!\n",This,pStm,fClearDirty);
1802  break;
1803  }
1804 
1805  if (!serializeResult)
1806  {
1807  hResult = E_FAIL;
1808  break;
1809  }
1810 
1811  HeapFree(GetProcessHeap(), 0, This->data);
1812  This->data = pIconData;
1813  This->datalen = iDataSize;
1814  }
1815 
1816  header[0] = (This->loadtime_magic != 0xdeadbeef) ? This->loadtime_magic : 0x0000746c;
1817  header[1] = This->datalen;
1818  IStream_Write(pStm, header, 2 * sizeof(DWORD), &dummy);
1819  IStream_Write(pStm, This->data, This->datalen, &dummy);
1820  hResult = S_OK;
1821  break;
1822 
1823  case PICTYPE_ENHMETAFILE:
1824  if (This->bIsDirty || !This->data)
1825  {
1826  serializeResult = serializeEMF(This->desc.u.emf.hemf, &pIconData, &iDataSize);
1827  if (!serializeResult)
1828  {
1829  hResult = E_FAIL;
1830  break;
1831  }
1832 
1833  HeapFree(GetProcessHeap(), 0, This->data);
1834  This->data = pIconData;
1835  This->datalen = iDataSize;
1836  }
1837  header[0] = 0x0000746c;
1838  header[1] = This->datalen;
1839  IStream_Write(pStm, header, 2 * sizeof(DWORD), &dummy);
1840  IStream_Write(pStm, This->data, This->datalen, &dummy);
1841  hResult = S_OK;
1842  break;
1843 
1844  case PICTYPE_METAFILE:
1845  FIXME("(%p,%p,%d), PICTYPE_METAFILE not implemented!\n",This,pStm,fClearDirty);
1846  break;
1847  default:
1848  FIXME("(%p,%p,%d), [unknown type] not implemented!\n",This,pStm,fClearDirty);
1849  break;
1850  }
1851  if (hResult == S_OK && fClearDirty) This->bIsDirty = FALSE;
1852  return hResult;
1853 }
1854 
1856  IPersistStream* iface,ULARGE_INTEGER*pcbSize)
1857 {
1859  FIXME("(%p,%p),stub!\n",This,pcbSize);
1860  return E_NOTIMPL;
1861 }
1862 
1863 /************************************************************************
1864  * OLEPictureImpl_SaveAsFile
1865  */
1867  IStream *stream, BOOL mem_copy, LONG *size)
1868 {
1870  void *data;
1871  unsigned data_size;
1872  ULONG written;
1873  HRESULT hr;
1874 
1875  FIXME("(%p)->(%p,%d,%p): semi-stub\n", This, stream, mem_copy, size);
1876 
1877  switch (This->desc.picType)
1878  {
1879  case PICTYPE_NONE:
1880  return S_OK;
1881 
1882  case PICTYPE_ICON:
1883  if (!mem_copy) return E_FAIL;
1884 
1885  if (This->bIsDirty || !This->data)
1886  {
1887  if (!serializeIcon(This->desc.u.icon.hicon, &data, &data_size))
1888  return E_FAIL;
1889  HeapFree(GetProcessHeap(), 0, This->data);
1890  This->data = data;
1891  This->datalen = data_size;
1892  }
1893  hr = IStream_Write(stream, This->data, This->datalen, &written);
1894  if (hr == S_OK && size) *size = written;
1895  return hr;
1896 
1897  case PICTYPE_BITMAP:
1898  if (!mem_copy) return E_FAIL;
1899 
1900  if (This->bIsDirty || !This->data)
1901  {
1902  switch (This->keepOrigFormat ? This->loadtime_format : BITMAP_FORMAT_BMP)
1903  {
1904  case BITMAP_FORMAT_BMP:
1905  if (!serializeBMP(This->desc.u.bmp.hbitmap, &data, &data_size))
1906  return E_FAIL;
1907  break;
1908  case BITMAP_FORMAT_JPEG:
1909  FIXME("BITMAP_FORMAT_JPEG is not implemented\n");
1910  return E_NOTIMPL;
1911  case BITMAP_FORMAT_GIF:
1912  FIXME("BITMAP_FORMAT_GIF is not implemented\n");
1913  return E_NOTIMPL;
1914  case BITMAP_FORMAT_PNG:
1915  FIXME("BITMAP_FORMAT_PNG is not implemented\n");
1916  return E_NOTIMPL;
1917  default:
1918  FIXME("PICTYPE_BITMAP/%#x is not implemented\n", This->loadtime_format);
1919  return E_NOTIMPL;
1920  }
1921 
1922  HeapFree(GetProcessHeap(), 0, This->data);
1923  This->data = data;
1924  This->datalen = data_size;
1925  }
1926  hr = IStream_Write(stream, This->data, This->datalen, &written);
1927  if (hr == S_OK && size) *size = written;
1928  return hr;
1929 
1930  case PICTYPE_METAFILE:
1931  FIXME("PICTYPE_METAFILE is not implemented\n");
1932  return E_NOTIMPL;
1933 
1934  case PICTYPE_ENHMETAFILE:
1935  if (!mem_copy) return E_FAIL;
1936 
1937  if (This->bIsDirty || !This->data)
1938  {
1939  if (!serializeEMF(This->desc.u.emf.hemf, &data, &data_size))
1940  return E_FAIL;
1941  HeapFree(GetProcessHeap(), 0, This->data);
1942  This->data = data;
1943  This->datalen = data_size;
1944  }
1945  hr = IStream_Write(stream, This->data, This->datalen, &written);
1946  if (hr == S_OK && size) *size = written;
1947  return hr;
1948 
1949  default:
1950  FIXME("%#x is not implemented\n", This->desc.picType);
1951  break;
1952  }
1953  return E_NOTIMPL;
1954 }
1955 
1956 /************************************************************************
1957  * IDispatch
1958  */
1959 
1960 /************************************************************************
1961  * OLEPictureImpl_IDispatch_QueryInterface (IUnknown)
1962  *
1963  * See Windows documentation for more details on IUnknown methods.
1964  */
1966  IDispatch* iface,
1967  REFIID riid,
1968  VOID** ppvoid)
1969 {
1971 
1972  return IPicture_QueryInterface(&This->IPicture_iface, riid, ppvoid);
1973 }
1974 
1975 /************************************************************************
1976  * OLEPictureImpl_IDispatch_AddRef (IUnknown)
1977  *
1978  * See Windows documentation for more details on IUnknown methods.
1979  */
1981  IDispatch* iface)
1982 {
1984 
1985  return IPicture_AddRef(&This->IPicture_iface);
1986 }
1987 
1988 /************************************************************************
1989  * OLEPictureImpl_IDispatch_Release (IUnknown)
1990  *
1991  * See Windows documentation for more details on IUnknown methods.
1992  */
1994  IDispatch* iface)
1995 {
1997 
1998  return IPicture_Release(&This->IPicture_iface);
1999 }
2000 
2001 /************************************************************************
2002  * OLEPictureImpl_GetTypeInfoCount (IDispatch)
2003  *
2004  * See Windows documentation for more details on IDispatch methods.
2005  */
2007  IDispatch* iface,
2008  unsigned int* pctinfo)
2009 {
2010  TRACE("(%p)\n", pctinfo);
2011 
2012  *pctinfo = 1;
2013 
2014  return S_OK;
2015 }
2016 
2017 /************************************************************************
2018  * OLEPictureImpl_GetTypeInfo (IDispatch)
2019  *
2020  * See Windows documentation for more details on IDispatch methods.
2021  */
2023  IDispatch* iface,
2024  UINT iTInfo,
2025  LCID lcid,
2026  ITypeInfo** ppTInfo)
2027 {
2028  static const WCHAR stdole2tlb[] = {'s','t','d','o','l','e','2','.','t','l','b',0};
2029  ITypeLib *tl;
2030  HRESULT hres;
2031 
2032  TRACE("(iTInfo=%d, lcid=%04x, %p)\n", iTInfo, (int)lcid, ppTInfo);
2033 
2034  if (iTInfo != 0)
2035  return E_FAIL;
2036 
2037  hres = LoadTypeLib(stdole2tlb, &tl);
2038  if (FAILED(hres))
2039  {
2040  ERR("Could not load stdole2.tlb\n");
2041  return hres;
2042  }
2043 
2044  hres = ITypeLib_GetTypeInfoOfGuid(tl, &IID_IPictureDisp, ppTInfo);
2045  if (FAILED(hres))
2046  ERR("Did not get IPictureDisp typeinfo from typelib, hres %x\n", hres);
2047 
2048  return hres;
2049 }
2050 
2051 /************************************************************************
2052  * OLEPictureImpl_GetIDsOfNames (IDispatch)
2053  *
2054  * See Windows documentation for more details on IDispatch methods.
2055  */
2057  IDispatch* iface,
2058  REFIID riid,
2059  LPOLESTR* rgszNames,
2060  UINT cNames,
2061  LCID lcid,
2062  DISPID* rgDispId)
2063 {
2064  ITypeInfo * pTInfo;
2065  HRESULT hres;
2066 
2067  TRACE("(%p,%s,%p,cNames=%d,lcid=%04x,%p)\n", iface, debugstr_guid(riid),
2068  rgszNames, cNames, (int)lcid, rgDispId);
2069 
2070  if (cNames == 0)
2071  {
2072  return E_INVALIDARG;
2073  }
2074  else
2075  {
2076  /* retrieve type information */
2077  hres = OLEPictureImpl_GetTypeInfo(iface, 0, lcid, &pTInfo);
2078 
2079  if (FAILED(hres))
2080  {
2081  ERR("GetTypeInfo failed.\n");
2082  return hres;
2083  }
2084 
2085  /* convert names to DISPIDs */
2086  hres = DispGetIDsOfNames (pTInfo, rgszNames, cNames, rgDispId);
2087  ITypeInfo_Release(pTInfo);
2088 
2089  return hres;
2090  }
2091 }
2092 
2093 /************************************************************************
2094  * OLEPictureImpl_Invoke (IDispatch)
2095  *
2096  * See Windows documentation for more details on IDispatch methods.
2097  */
2099  IDispatch* iface,
2100  DISPID dispIdMember,
2101  REFIID riid,
2102  LCID lcid,
2103  WORD wFlags,
2104  DISPPARAMS* pDispParams,
2105  VARIANT* pVarResult,
2106  EXCEPINFO* pExepInfo,
2107  UINT* puArgErr)
2108 {
2110  HRESULT hr;
2111 
2112  /* validate parameters */
2113 
2114  if (!IsEqualIID(riid, &IID_NULL))
2115  {
2116  ERR("riid was %s instead of IID_NULL\n", debugstr_guid(riid));
2117  return DISP_E_UNKNOWNNAME;
2118  }
2119 
2120  if (!pDispParams)
2121  {
2122  ERR("null pDispParams not allowed\n");
2123  return DISP_E_PARAMNOTOPTIONAL;
2124  }
2125 
2127  {
2128  if (pDispParams->cArgs != 0)
2129  {
2130  ERR("param count for DISPATCH_PROPERTYGET was %d instead of 0\n", pDispParams->cArgs);
2131  return DISP_E_BADPARAMCOUNT;
2132  }
2133  if (!pVarResult)
2134  {
2135  ERR("null pVarResult not allowed when DISPATCH_PROPERTYGET specified\n");
2136  return DISP_E_PARAMNOTOPTIONAL;
2137  }
2138  }
2139  else if (wFlags & DISPATCH_PROPERTYPUT)
2140  {
2141  if (pDispParams->cArgs != 1)
2142  {
2143  ERR("param count for DISPATCH_PROPERTYPUT was %d instead of 1\n", pDispParams->cArgs);
2144  return DISP_E_BADPARAMCOUNT;
2145  }
2146  }
2147 
2148  switch (dispIdMember)
2149  {
2150  case DISPID_PICT_HANDLE:
2152  {
2153  TRACE("DISPID_PICT_HANDLE\n");
2154  V_VT(pVarResult) = VT_I4;
2155  return IPicture_get_Handle(&This->IPicture_iface, &V_UINT(pVarResult));
2156  }
2157  break;
2158  case DISPID_PICT_HPAL:
2160  {
2161  TRACE("DISPID_PICT_HPAL\n");
2162  V_VT(pVarResult) = VT_I4;
2163  return IPicture_get_hPal(&This->IPicture_iface, &V_UINT(pVarResult));
2164  }
2165  else if (wFlags & DISPATCH_PROPERTYPUT)
2166  {
2167  VARIANTARG vararg;
2168 
2169  TRACE("DISPID_PICT_HPAL\n");
2170 
2171  VariantInit(&vararg);
2172  hr = VariantChangeTypeEx(&vararg, &pDispParams->rgvarg[0], lcid, 0, VT_I4);
2173  if (FAILED(hr))
2174  return hr;
2175 
2176  hr = IPicture_set_hPal(&This->IPicture_iface, V_I4(&vararg));
2177 
2178  VariantClear(&vararg);
2179  return hr;
2180  }
2181  break;
2182  case DISPID_PICT_TYPE:
2184  {
2185  TRACE("DISPID_PICT_TYPE\n");
2186  V_VT(pVarResult) = VT_I2;
2187  return OLEPictureImpl_get_Type(&This->IPicture_iface, &V_I2(pVarResult));
2188  }
2189  break;
2190  case DISPID_PICT_WIDTH:
2192  {
2193  TRACE("DISPID_PICT_WIDTH\n");
2194  V_VT(pVarResult) = VT_I4;
2195  return IPicture_get_Width(&This->IPicture_iface, &V_I4(pVarResult));
2196  }
2197  break;
2198  case DISPID_PICT_HEIGHT:
2200  {
2201  TRACE("DISPID_PICT_HEIGHT\n");
2202  V_VT(pVarResult) = VT_I4;
2203  return IPicture_get_Height(&This->IPicture_iface, &V_I4(pVarResult));
2204  }
2205  break;
2206  case DISPID_PICT_RENDER:
2207  if (wFlags & DISPATCH_METHOD)
2208  {
2209  VARIANTARG *args = pDispParams->rgvarg;
2210  int i;
2211 
2212  TRACE("DISPID_PICT_RENDER\n");
2213 
2214  if (pDispParams->cArgs != 10)
2215  return DISP_E_BADPARAMCOUNT;
2216 
2217  /* All parameters are supposed to be VT_I4 (on 64 bits too). */
2218  for (i = 0; i < pDispParams->cArgs; i++)
2219  if (V_VT(&args[i]) != VT_I4)
2220  {
2221  ERR("DISPID_PICT_RENDER: wrong argument type %d:%d\n", i, V_VT(&args[i]));
2222  return DISP_E_TYPEMISMATCH;
2223  }
2224 
2225  /* FIXME: rectangle pointer argument handling seems broken on 64 bits,
2226  currently Render() doesn't use it at all so for now NULL is passed. */
2227  return IPicture_Render(&This->IPicture_iface,
2228  LongToHandle(V_I4(&args[9])),
2229  V_I4(&args[8]),
2230  V_I4(&args[7]),
2231  V_I4(&args[6]),
2232  V_I4(&args[5]),
2233  V_I4(&args[4]),
2234  V_I4(&args[3]),
2235  V_I4(&args[2]),
2236  V_I4(&args[1]),
2237  NULL);
2238  }
2239  break;
2240  }
2241 
2242  ERR("invalid dispid 0x%x or wFlags 0x%x\n", dispIdMember, wFlags);
2243  return DISP_E_MEMBERNOTFOUND;
2244 }
2245 
2246 
2247 static const IPictureVtbl OLEPictureImpl_VTable =
2248 {
2266 };
2267 
2268 static const IDispatchVtbl OLEPictureImpl_IDispatch_VTable =
2269 {
2277 };
2278 
2279 static const IPersistStreamVtbl OLEPictureImpl_IPersistStream_VTable =
2280 {
2289 };
2290 
2291 static const IConnectionPointContainerVtbl OLEPictureImpl_IConnectionPointContainer_VTable =
2292 {
2298 };
2299 
2300 /***********************************************************************
2301  * OleCreatePictureIndirect (OLEAUT32.419)
2302  */
2304  BOOL Own, void **ppvObj )
2305 {
2306  OLEPictureImpl* newPict;
2307  HRESULT hr;
2308 
2309  TRACE("(%p,%s,%d,%p)\n", lpPictDesc, debugstr_guid(riid), Own, ppvObj);
2310 
2311  *ppvObj = NULL;
2312 
2313  newPict = OLEPictureImpl_Construct(lpPictDesc, Own);
2314 
2315  if (newPict == NULL)
2316  return E_OUTOFMEMORY;
2317 
2318  /*
2319  * Make sure it supports the interface required by the caller.
2320  */
2321  hr = IPicture_QueryInterface(&newPict->IPicture_iface, riid, ppvObj);
2322 
2323  /*
2324  * Release the reference obtained in the constructor. If
2325  * the QueryInterface was unsuccessful, it will free the class.
2326  */
2327  IPicture_Release(&newPict->IPicture_iface);
2328 
2329  return hr;
2330 }
2331 
2332 
2333 /***********************************************************************
2334  * OleLoadPicture (OLEAUT32.418)
2335  */
2336 HRESULT WINAPI OleLoadPicture( LPSTREAM lpstream, LONG lSize, BOOL fRunmode,
2337  REFIID riid, LPVOID *ppvObj )
2338 {
2339  LPPERSISTSTREAM ps;
2340  IPicture *newpic;
2341  HRESULT hr;
2342 
2343  TRACE("(%p,%d,%d,%s,%p), partially implemented.\n",
2344  lpstream, lSize, fRunmode, debugstr_guid(riid), ppvObj);
2345 
2346  hr = OleCreatePictureIndirect(NULL,riid,!fRunmode,(LPVOID*)&newpic);
2347  if (hr != S_OK)
2348  return hr;
2349  hr = IPicture_QueryInterface(newpic,&IID_IPersistStream, (LPVOID*)&ps);
2350  if (hr != S_OK) {
2351  ERR("Could not get IPersistStream iface from Ole Picture?\n");
2352  IPicture_Release(newpic);
2353  *ppvObj = NULL;
2354  return hr;
2355  }
2356  hr = IPersistStream_Load(ps,lpstream);
2357  IPersistStream_Release(ps);
2358  if (FAILED(hr))
2359  {
2360  ERR("IPersistStream_Load failed\n");
2361  IPicture_Release(newpic);
2362  *ppvObj = NULL;
2363  return hr;
2364  }
2365  hr = IPicture_QueryInterface(newpic,riid,ppvObj);
2366  if (hr != S_OK)
2367  ERR("Failed to get interface %s from IPicture.\n",debugstr_guid(riid));
2368  IPicture_Release(newpic);
2369  return hr;
2370 }
2371 
2372 /***********************************************************************
2373  * OleLoadPictureEx (OLEAUT32.401)
2374  */
2375 HRESULT WINAPI OleLoadPictureEx( LPSTREAM lpstream, LONG lSize, BOOL fRunmode,
2376  REFIID riid, DWORD xsiz, DWORD ysiz, DWORD flags, LPVOID *ppvObj )
2377 {
2378  LPPERSISTSTREAM ps;
2379  IPicture *newpic;
2380  HRESULT hr;
2381 
2382  FIXME("(%p,%d,%d,%s,x=%d,y=%d,f=%x,%p), partially implemented.\n",
2383  lpstream, lSize, fRunmode, debugstr_guid(riid), xsiz, ysiz, flags, ppvObj);
2384 
2385  hr = OleCreatePictureIndirect(NULL,riid,!fRunmode,(LPVOID*)&newpic);
2386  if (hr != S_OK)
2387  return hr;
2388  hr = IPicture_QueryInterface(newpic,&IID_IPersistStream, (LPVOID*)&ps);
2389  if (hr != S_OK) {
2390  ERR("Could not get IPersistStream iface from Ole Picture?\n");
2391  IPicture_Release(newpic);
2392  *ppvObj = NULL;
2393  return hr;
2394  }
2395  hr = IPersistStream_Load(ps,lpstream);
2396  IPersistStream_Release(ps);
2397  if (FAILED(hr))
2398  {
2399  ERR("IPersistStream_Load failed\n");
2400  IPicture_Release(newpic);
2401  *ppvObj = NULL;
2402  return hr;
2403  }
2404  hr = IPicture_QueryInterface(newpic,riid,ppvObj);
2405  if (hr != S_OK)
2406  ERR("Failed to get interface %s from IPicture.\n",debugstr_guid(riid));
2407  IPicture_Release(newpic);
2408  return hr;
2409 }
2410 
2412 {
2413  HANDLE hFile;
2414  DWORD dwFileSize;
2415  HGLOBAL hGlobal = NULL;
2416  DWORD dwBytesRead;
2417  HRESULT hr = S_OK;
2418 
2420  if (hFile == INVALID_HANDLE_VALUE)
2421  return HRESULT_FROM_WIN32(GetLastError());
2422 
2425  {
2426  hGlobal = GlobalAlloc(GMEM_FIXED, dwFileSize);
2427  if (!hGlobal)
2428  hr = E_OUTOFMEMORY;
2429  else
2430  {
2431  if (!ReadFile(hFile, hGlobal, dwFileSize, &dwBytesRead, NULL))
2432  {
2433  GlobalFree(hGlobal);
2435  }
2436  }
2437  }
2438 
2439  CloseHandle(hFile);
2440 
2441  if (FAILED(hr)) return hr;
2442 
2443  hr = CreateStreamOnHGlobal(hGlobal, TRUE, stream);
2444  if (FAILED(hr))
2445  GlobalFree(hGlobal);
2446 
2447  return hr;
2448 }
2449 
2450 /***********************************************************************
2451  * OleLoadPictureFile (OLEAUT32.422)
2452  */
2454 {
2455  IStream *stream;
2456  HRESULT hr;
2457 
2458  TRACE("(%s,%p)\n", wine_dbgstr_variant(&filename), picture);
2459 
2460  if (V_VT(&filename) != VT_BSTR)
2461  return CTL_E_FILENOTFOUND;
2462 
2463  hr = create_stream(V_BSTR(&filename), &stream);
2464  if (hr != S_OK)
2465  {
2467  return CTL_E_FILENOTFOUND;
2468 
2470  }
2471 
2472  hr = OleLoadPicture(stream, 0, FALSE, &IID_IDispatch, (void **)picture);
2473  IStream_Release(stream);
2474  return hr;
2475 }
2476 
2477 /***********************************************************************
2478  * OleSavePictureFile (OLEAUT32.423)
2479  */
2481 {
2482  FIXME("(%p %s): stub\n", picture, debugstr_w(filename));
2483  return CTL_E_FILENOTFOUND;
2484 }
2485 
2486 /***********************************************************************
2487  * OleLoadPicturePath (OLEAUT32.424)
2488  */
2490  DWORD dwReserved, OLE_COLOR clrReserved, REFIID riid,
2491  LPVOID *ppvRet )
2492 {
2493  static const WCHAR file[] = { 'f','i','l','e',':',0 };
2494  IStream *stream;
2495  HRESULT hRes;
2496  WCHAR *file_candidate;
2497  WCHAR path_buf[MAX_PATH];
2498 
2499  TRACE("(%s,%p,%d,%08x,%s,%p): stub\n",
2500  debugstr_w(szURLorPath), punkCaller, dwReserved, clrReserved,
2501  debugstr_guid(riid), ppvRet);
2502 
2503  if (!szURLorPath || !ppvRet)
2504  return E_INVALIDARG;
2505 
2506  *ppvRet = NULL;
2507 
2508  /* Convert file URLs to DOS paths. */
2509  if (strncmpW(szURLorPath, file, 5) == 0) {
2510  DWORD size;
2511  hRes = CoInternetParseUrl(szURLorPath, PARSE_PATH_FROM_URL, 0, path_buf,
2512  sizeof(path_buf)/sizeof(WCHAR), &size, 0);
2513  if (FAILED(hRes))
2514  return hRes;
2515 
2516  file_candidate = path_buf;
2517  }
2518  else
2519  file_candidate = szURLorPath;
2520 
2521  /* Handle candidate DOS paths separately. */
2522  if (file_candidate[1] == ':') {
2523  hRes = create_stream(file_candidate, &stream);
2524  if (FAILED(hRes))
2525  return INET_E_RESOURCE_NOT_FOUND;
2526  } else {
2527  IMoniker *pmnk;
2528  IBindCtx *pbc;
2529 
2530  hRes = CreateBindCtx(0, &pbc);
2531  if (SUCCEEDED(hRes))
2532  {
2533  hRes = CreateURLMoniker(NULL, szURLorPath, &pmnk);
2534  if (SUCCEEDED(hRes))
2535  {
2536  hRes = IMoniker_BindToStorage(pmnk, pbc, NULL, &IID_IStream, (LPVOID*)&stream);
2537  IMoniker_Release(pmnk);
2538  }
2539  IBindCtx_Release(pbc);
2540  }
2541  if (FAILED(hRes))
2542  return hRes;
2543  }
2544 
2545  hRes = OleLoadPicture(stream, 0, FALSE, riid, ppvRet);
2546 
2547  IStream_Release(stream);
2548 
2549  return hRes;
2550 }
2551 
2552 /*******************************************************************************
2553  * StdPic ClassFactory
2554  */
2555 typedef struct
2556 {
2557  /* IUnknown fields */
2558  IClassFactory IClassFactory_iface;
2559  LONG ref;
2561 
2563 {
2564  return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
2565 }
2566 
2567 static HRESULT WINAPI
2568 SPCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
2570 
2571  FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
2572  return E_NOINTERFACE;
2573 }
2574 
2575 static ULONG WINAPI
2576 SPCF_AddRef(LPCLASSFACTORY iface) {
2578  return InterlockedIncrement(&This->ref);
2579 }
2580 
2581 static ULONG WINAPI SPCF_Release(LPCLASSFACTORY iface) {
2583  /* static class, won't be freed */
2584  return InterlockedDecrement(&This->ref);
2585 }
2586 
2588  LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj
2589 ) {
2590  /* Creates an uninitialized picture */
2591  return OleCreatePictureIndirect(NULL,riid,TRUE,ppobj);
2592 
2593 }
2594 
2595 static HRESULT WINAPI SPCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
2597  FIXME("(%p)->(%d),stub!\n",This,dolock);
2598  return S_OK;
2599 }
2600 
2601 static const IClassFactoryVtbl SPCF_Vtbl = {
2603  SPCF_AddRef,
2604  SPCF_Release,
2607 };
2609 
#define SRCPAINT
Definition: wingdi.h:333
unsigned int loadtime_magic
Definition: olepicture.c:160
#define CTL_E_FILENOTFOUND
Definition: olectl.h:274
DWORD * pLength
Definition: msvc.h:79
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515
#define HDC
Definition: msvc.h:22
static const IDispatchVtbl OLEPictureImpl_IDispatch_VTable
Definition: olepicture.c:188
HMETAFILE WINAPI SetMetaFileBitsEx(_In_ UINT cbBuffer, _In_reads_bytes_(cbBuffer) CONST BYTE *lpData)
GLint GLint GLsizei width
Definition: gl.h:1546
#define PICTYPE_UNINITIALIZED
Definition: olectl.h:131
#define LOGPIXELSX
Definition: wingdi.h:717
BOOL WINAPI SetViewportOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:648
static HRESULT WINAPI OLEPictureImpl_IDispatch_QueryInterface(IDispatch *iface, REFIID riid, VOID **ppvoid)
Definition: olepicture.c:1965
static HICON
Definition: imagelist.c:84
#define TRUE
Definition: types.h:120
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
#define CloseHandle
Definition: compat.h:398
#define DISPID_PICT_HPAL
Definition: olectl.h:439
BOOL WINAPI SetWindowExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
static OLE_YSIZE_HIMETRIC ypixels_to_himetric(INT pixels, HDC hdc)
Definition: olepicture.c:198
char hdr[14]
Definition: iptest.cpp:33
#define E_NOINTERFACE
Definition: winerror.h:2364
static OLE_XSIZE_HIMETRIC xpixels_to_himetric(INT pixels, HDC hdc)
Definition: olepicture.c:193
Definition: compat.h:1932
#define DISPATCH_PROPERTYGET
Definition: oleauto.h:1007
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
Definition: id3.c:18
#define HBITMAP
Definition: msvc.h:28
static HRESULT WINAPI OLEPictureImpl_QueryInterface(IPicture *iface, REFIID riid, void **ppvObject)
Definition: olepicture.c:465
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
OLE_XSIZE_HIMETRIC himetricWidth
Definition: olepicture.c:142
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1454
long y
Definition: polytest.cpp:48
static IClassFactoryImpl STDPIC_CF
Definition: olepicture.c:2608
#define MESSAGE
Definition: options.h:86
DWORD biClrImportant
Definition: amvideo.idl:40
long x
Definition: polytest.cpp:48
static HRESULT WINAPI OLEPictureImpl_get_KeepOriginalFormat(IPicture *iface, BOOL *pfKeep)
Definition: olepicture.c:816
static HRESULT WINAPI OLEPictureImpl_SelectPicture(IPicture *iface, HDC hdcIn, HDC *phdcOut, OLE_HANDLE *phbmpOut)
Definition: olepicture.c:791
static ULONG WINAPI OLEPictureImpl_IConnectionPointContainer_Release(IConnectionPointContainer *iface)
Definition: olepicture.c:899
HDC WINAPI GetDC(_In_opt_ HWND)
SHORT right
Definition: olepicture.c:85
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
__wchar_t WCHAR
Definition: xmlstorage.h:180
static ULONG WINAPI OLEPictureImpl_IPersistStream_Release(IPersistStream *iface)
Definition: olepicture.c:971
const GUID IID_IPictureDisp
REFIID riid
Definition: precomp.h:44
#define BITMAP_FORMAT_JPEG
Definition: olepicture.c:71
#define REFCLSID
Definition: guiddef.h:112
LONG biXPelsPerMeter
Definition: amvideo.idl:37
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
const GUID IID_IPersist
Definition: proxy.cpp:14
#define CONNECT_E_NOCONNECTION
Definition: olectl.h:251
DWORD dwFileSize
Definition: more.c:36
#define BITMAP_FORMAT_GIF
Definition: olepicture.c:72
#define HandleToUlong(h)
Definition: basetsd.h:79
#define V_I2(A)
Definition: oleauto.h:245
static ULONG WINAPI SPCF_Release(LPCLASSFACTORY iface)
Definition: olepicture.c:2581
#define DISP_E_MEMBERNOTFOUND
Definition: winerror.h:2512
REFIID LPVOID * ppv
Definition: atlbase.h:39
const GUID IID_IConnectionPointContainer
long bottom
Definition: polytest.cpp:53
unsigned long OLE_COLOR
Definition: olepro.idl:37
static ULONG WINAPI OLEPictureImpl_IPersistStream_AddRef(IPersistStream *iface)
Definition: olepicture.c:958
u32_t magic(void)
HENHMETAFILE WINAPI SetEnhMetaFileBits(_In_ UINT nSize, _In_reads_bytes_(nSize) const BYTE *pb)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
HBITMAP hbmMask
Definition: olepicture.c:152
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
struct _APM_HEADER APM_HEADER
HRESULT WINAPI LoadTypeLib(const OLECHAR *szFile, ITypeLib **pptLib)
Definition: typelib.c:461
static HRESULT WINAPI OLEPictureImpl_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: olepicture.c:2022
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM *ppstm)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
interface IStream * LPSTREAM
Definition: objfwd.h:10
DWORD LCID
Definition: nls.h:13
WINE_DEFAULT_DEBUG_CHANNEL(olepicture)
GLuint GLuint end
Definition: gl.h:1545
HRESULT WINAPI CoInternetParseUrl(LPCWSTR pwzUrl, PARSEACTION ParseAction, DWORD dwFlags, LPWSTR pszResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
Definition: internet.c:392
#define INVALID_FILE_SIZE
Definition: winbase.h:529
OLECHAR * BSTR
Definition: compat.h:1927
CURSORICONFILEDIRENTRY idEntries[1]
Definition: olepicture.c:108
static HRESULT WINAPI OLEPictureImpl_get_hPal(IPicture *iface, OLE_HANDLE *phandle)
Definition: olepicture.c:565
static void OLEPictureImpl_Destroy(OLEPictureImpl *Obj)
Definition: olepicture.c:386
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:571
static HRESULT WINAPI OLEPictureImpl_Save(IPersistStream *iface, IStream *pStm, BOOL fClearDirty)
Definition: olepicture.c:1747
static HRESULT WINAPI OLEPictureImpl_get_Handle(IPicture *iface, OLE_HANDLE *phandle)
Definition: olepicture.c:528
HRESULT WINAPI DispGetIDsOfNames(ITypeInfo *ptinfo, OLECHAR **rgszNames, UINT cNames, DISPID *rgdispid)
Definition: dispatch.c:94
int const JOCTET unsigned int datalen
Definition: jpeglib.h:1027
IPicture IPicture_iface
Definition: olepicture.c:123
WORD handle
Definition: olepicture.c:82
const char * filename
Definition: ioapi.h:135
static HRESULT WINAPI OLEPictureImpl_set_hPal(IPicture *iface, OLE_HANDLE hpal)
Definition: olepicture.c:767
static LPOLESTR
Definition: stg_prop.c:33
LONG biYPelsPerMeter
Definition: amvideo.idl:38
DWORD reserved
Definition: olepicture.c:88
static HRESULT WINAPI OLEPictureImpl_SaveAsFile(IPicture *iface, IStream *stream, BOOL mem_copy, LONG *size)
Definition: olepicture.c:1866
#define E_FAIL
Definition: ddrawi.h:102
Definition: match.c:390
static VOID NTAPI BitBlt(IN ULONG Left, IN ULONG Top, IN ULONG Width, IN ULONG Height, IN PUCHAR Buffer, IN ULONG BitsPerPixel, IN ULONG Delta)
Definition: vga.c:416
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
int32_t INT
Definition: typedefs.h:56
BOOL WINAPI GetIconInfo(_In_ HICON, _Out_ PICONINFO)
Definition: cursoricon.c:2014
static LPVOID *static DWORD
Definition: olepicture.c:59
static HRESULT WINAPI OLEPictureImpl_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, LPCRECT prcWBounds)
Definition: olepicture.c:644
#define BI_BITFIELDS
Definition: mmreg.h:507
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
HRESULT WINAPI VariantClear(VARIANTARG *pVarg)
Definition: variant.c:651
static HRESULT WINAPI OLEPictureImpl_get_Height(IPicture *iface, OLE_YSIZE_HIMETRIC *pheight)
Definition: olepicture.c:632
GLsizei GLenum GLboolean sink
Definition: glext.h:5672
#define V_I4(A)
Definition: oleauto.h:247
WINE_UNICODE_INLINE int strncmpW(const WCHAR *str1, const WCHAR *str2, int n)
Definition: unicode.h:235
#define DISPATCH_METHOD
Definition: oleauto.h:1006
static void OLEPictureImpl_SetIcon(OLEPictureImpl *This)
Definition: olepicture.c:237
struct tagIClassFactoryImpl IClassFactoryImpl
INT INT y
Definition: msvc.h:62
#define CBM_INIT
Definition: wingdi.h:364
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:975
static HRESULT WINAPI OLEPictureImpl_Load(IPersistStream *iface, IStream *pStm)
Definition: olepicture.c:1329
static HRESULT OLEPictureImpl_LoadIcon(OLEPictureImpl *This, BYTE *xbuf, ULONG xread)
Definition: olepicture.c:1177
long right
Definition: polytest.cpp:53
static HRESULT WINAPI OLEPictureImpl_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: olepicture.c:2056
UINT WINAPI GetEnhMetaFileBits(_In_ HENHMETAFILE hEMF, _In_ UINT nSize, _Out_writes_bytes_opt_(nSize) LPBYTE lpData)
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
GLenum GLint GLuint mask
Definition: glext.h:6028
HRESULT WINAPI OleLoadPictureFile(VARIANT filename, IDispatch **picture)
Definition: olepicture.c:2453
WORD checksum
Definition: olepicture.c:89
unsigned char * LPBYTE
Definition: typedefs.h:52
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static ULONG WINAPI OLEPictureImpl_Release(IPicture *iface)
Definition: olepicture.c:444
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
HANDLE hbmpOld
Definition: magnifier.c:55
long LONG
Definition: pedump.c:60
Definition: main.c:440
static HRESULT WINAPI OLEPictureImpl_EnumConnectionPoints(IConnectionPointContainer *iface, IEnumConnectionPoints **ppEnum)
Definition: olepicture.c:907
int WINAPI SetMapMode(_In_ HDC, _In_ int)
static ULONG WINAPI OLEPictureImpl_IDispatch_Release(IDispatch *iface)
Definition: olepicture.c:1993
static OLEPictureImpl * OLEPictureImpl_Construct(LPPICTDESC pictDesc, BOOL fOwn)
Definition: olepicture.c:290
#define PICTYPE_METAFILE
Definition: olectl.h:134
SHORT left
Definition: olepicture.c:83
short SHORT
Definition: pedump.c:59
static LPUNKNOWN
Definition: ndr_ole.c:49
static const IClassFactoryVtbl SPCF_Vtbl
Definition: olepicture.c:2601
long top
Definition: polytest.cpp:53
#define debugstr_w
Definition: kernel32.h:32
HBITMAP hbmMask
Definition: winuser.h:3079
GLenum GLint ref
Definition: glext.h:6028
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define FIXME(fmt,...)
Definition: debug.h:110
#define BITMAP_FORMAT_BMP
Definition: olepicture.c:70
DWORD biCompression
Definition: amvideo.idl:35
#define S_FALSE
Definition: winerror.h:2357
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
#define E_INVALIDARG
Definition: ddrawi.h:101
static const IPersistStreamVtbl OLEPictureImpl_IPersistStream_VTable
Definition: olepicture.c:189
HDC hdc
Definition: msvc.h:53
HRESULT WINAPI OleLoadPictureEx(LPSTREAM lpstream, LONG lSize, BOOL fRunmode, REFIID riid, DWORD xsiz, DWORD ysiz, DWORD flags, LPVOID *ppvObj)
Definition: olepicture.c:2375
DWORD HDC HDC DVTARGETDEVICE DWORD const SIZEL LONG LONG * pheight
Definition: msvc.h:106
HRESULT WINAPI OleLoadPicture(LPSTREAM lpstream, LONG lSize, BOOL fRunmode, REFIID riid, LPVOID *ppvObj)
Definition: olepicture.c:2336
smooth NULL
Definition: ftsmooth.c:416
unsigned char
Definition: typeof.h:27
static HRESULT WINAPI OLEPictureImpl_get_Width(IPicture *iface, OLE_XSIZE_HIMETRIC *pwidth)
Definition: olepicture.c:620
LONG cx
Definition: windef.h:319
HBITMAP hbmColor
Definition: winuser.h:3080
static BOOL serializeBMP(HBITMAP hBitmap, void **ppBuffer, unsigned int *pLength)
Definition: olepicture.c:1520
#define DISPID_PICT_RENDER
Definition: olectl.h:443
BOOL WINAPI DeleteEnhMetaFile(_In_opt_ HENHMETAFILE)
static HRESULT OLEPictureImpl_LoadWICSource(OLEPictureImpl *This, IWICBitmapSource *src)
Definition: olepicture.c:1001
INT Height
Definition: wincodec.idl:239
#define debugstr_guid
Definition: kernel32.h:35
#define DISPATCH_PROPERTYPUT
Definition: oleauto.h:1008
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
long left
Definition: polytest.cpp:53
static OLEPictureImpl * impl_from_IConnectionPointContainer(IConnectionPointContainer *iface)
Definition: olepicture.c:179
#define OPEN_EXISTING
Definition: compat.h:426
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static OLEPictureImpl * impl_from_IDispatch(IDispatch *iface)
Definition: olepicture.c:169
static REFIID
Definition: olepicture.c:58
PICTDESC desc
Definition: olepicture.c:135
static HRESULT WINAPI OLEPictureImpl_GetTypeInfoCount(IDispatch *iface, unsigned int *pctinfo)
Definition: olepicture.c:2006
struct OLEPictureImpl OLEPictureImpl
static HRESULT WINAPI OLEPictureImpl_PictureChanged(IPicture *iface)
Definition: olepicture.c:843
IConnectionPoint * pCP
Definition: olepicture.c:145
struct tagRGBQUAD RGBQUAD
int OLE_HANDLE
Definition: olepro.idl:76
#define DISP_E_TYPEMISMATCH
Definition: winerror.h:2514
#define TRACE(s)
Definition: solgame.cpp:4
GLsizei stride
Definition: glext.h:5848
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizeiptr size
Definition: glext.h:5919
HRESULT hres
Definition: protocol.c:465
RECTL rclFrame
Definition: wingdi.h:2301
DWORD origHeight
Definition: olepicture.c:139
static BOOL serializeEMF(HENHMETAFILE hemf, void **buf, unsigned *size)
Definition: olepicture.c:1736
#define GetProcessHeap()
Definition: compat.h:395
#define PICTYPE_ENHMETAFILE
Definition: olectl.h:136
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HRESULT WINAPI CreateBindCtx(DWORD reserved, LPBC *ppbc)
Definition: bindctx.c:556
COLORREF rgbTrans
Definition: olepicture.c:154
RGBQUAD bmiColors[1]
Definition: wingdi.h:1455
static ULONG WINAPI OLEPictureImpl_IConnectionPointContainer_AddRef(IConnectionPointContainer *iface)
Definition: olepicture.c:891
BOOL WINAPI DrawIconEx(_In_ HDC, _In_ int, _In_ int, _In_ HICON, _In_ int, _In_ int, _In_ UINT, _In_opt_ HBRUSH, _In_ UINT)
Definition: cursoricon.c:1997
LONG HRESULT
Definition: typedefs.h:77
HBITMAP hbmXor
Definition: olepicture.c:153
static HRESULT WINAPI SPCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
Definition: olepicture.c:2587
IDispatch IDispatch_iface
Definition: olepicture.c:124
BOOL WINAPI PlayEnhMetaFile(_In_ HDC, _In_ HENHMETAFILE, _In_ LPCRECT)
const GUID IID_IUnknown
static OLEPictureImpl * impl_from_IPicture(IPicture *iface)
Definition: olepicture.c:164
static HRESULT WINAPI OLEPictureImpl_IPersistStream_QueryInterface(IPersistStream *iface, REFIID riid, VOID **ppvoid)
Definition: olepicture.c:943
#define MAX_PATH
Definition: compat.h:26
#define RGB(r, g, b)
Definition: wingdi.h:2918
unsigned int UINT
Definition: ndis.h:50
const char * wine_dbgstr_rect(const RECT *rect)
unsigned short WORD
Definition: ntddk_ex.h:93
IConnectionPointContainer IConnectionPointContainer_iface
Definition: olepicture.c:126
unsigned long DWORD
Definition: ntddk_ex.h:95
#define PICTYPE_NONE
Definition: olectl.h:132
HICON WINAPI CreateIconFromResourceEx(_In_reads_bytes_(dwResSize) PBYTE presbits, _In_ DWORD dwResSize, _In_ BOOL fIcon, _In_ DWORD dwVer, _In_ int cxDesired, _In_ int cyDesired, _In_ UINT Flags)
DWORD biSizeImage
Definition: amvideo.idl:36
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:481
#define success(from, fromstr, to, tostr)
static HRESULT WINAPI OLEPictureImpl_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExepInfo, UINT *puArgErr)
Definition: olepicture.c:2098
#define PICTYPE_ICON
Definition: olectl.h:135
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static HRESULT WINAPI OLEPictureImpl_put_KeepOriginalFormat(IPicture *iface, BOOL keep)
Definition: olepicture.c:830
GLbitfield flags
Definition: glext.h:7161
const GUID IID_IPersistStream
Definition: proxy.cpp:13
HBITMAP WINAPI CreateDIBitmap(_In_ HDC hdc, _In_opt_ const BITMAPINFOHEADER *pbmih, _In_ DWORD fdwInit, _In_opt_ const VOID *pvInit, _In_opt_ const BITMAPINFO *pbmi, _In_ UINT uUsage)
const GUID IID_IDispatch
#define DISPID_PICT_TYPE
Definition: olectl.h:440
UINT WINAPI GetEnhMetaFileHeader(_In_ HENHMETAFILE hemf, _In_ UINT nSize, _Out_writes_bytes_opt_(nSize) LPENHMETAHEADER lpEnhMetaHeader)
static ULONG WINAPI SPCF_AddRef(LPCLASSFACTORY iface)
Definition: olepicture.c:2576
HRESULT WINAPI OleCreatePictureIndirect(LPPICTDESC lpPictDesc, REFIID riid, BOOL Own, void **ppvObj)
Definition: olepicture.c:2303
#define IID_NULL
Definition: guiddef.h:93
#define InterlockedDecrement
Definition: armddk.h:52
Definition: parse.h:22
#define GMEM_FIXED
Definition: winbase.h:290
GLuint GLuint stream
Definition: glext.h:7522
struct tagPICTDESC::@3038::@3040 wmf
#define MM_ANISOTROPIC
Definition: wingdi.h:866
#define EMR_HEADER
Definition: wingdi.h:75
#define DISP_E_PARAMNOTOPTIONAL
Definition: winerror.h:2524
const GUID IID_IPicture
#define V_VT(A)
Definition: oleauto.h:211
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
OLE_YSIZE_HIMETRIC himetricHeight
Definition: olepicture.c:143
#define LongToHandle(h)
Definition: basetsd.h:82
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define DI_NORMAL
Definition: wingdi.h:72
unsigned char BYTE
Definition: mem.h:68
HBITMAP stock_bitmap
Definition: olepicture.c:149
REFIID LPVOID * ppvObject
Definition: precomp.h:44
HRESULT WINAPI OleSavePictureFile(IDispatch *picture, BSTR filename)
Definition: olepicture.c:2480
long OLE_YSIZE_HIMETRIC
Definition: olepro.idl:61
static ULONG WINAPI OLEPictureImpl_AddRef(IPicture *iface)
Definition: olepicture.c:428
#define GENERIC_READ
Definition: compat.h:124
GLenum src
Definition: glext.h:6340
_In_ HANDLE hFile
Definition: mswsock.h:90
#define WINAPI
Definition: msvc.h:20
#define V_BSTR(A)
Definition: oleauto.h:226
static BOOL serializeIcon(HICON hIcon, void **ppBuffer, unsigned int *pLength)
Definition: olepicture.c:1585
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define DISPID_PICT_HANDLE
Definition: olectl.h:438
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3237
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:519
#define ERR(fmt,...)
Definition: debug.h:109
DWORD key
Definition: olepicture.c:81
static void OLEPicture_SendNotify(OLEPictureImpl *this, DISPID dispID)
Definition: olepicture.c:507
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:784
static HDC hDC
Definition: 3dtext.c:33
static HRESULT OLEPictureImpl_LoadEnhMetafile(OLEPictureImpl *This, const BYTE *data, ULONG size)
Definition: olepicture.c:1270
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define BITMAP_FORMAT_APM
Definition: olepicture.c:74
const GUID IID_IConnectionPoint
struct stdole::EXCEPINFO EXCEPINFO
static HRESULT WINAPI OLEPictureImpl_get_Type(IPicture *iface, short *ptype)
Definition: olepicture.c:604
static VARIANTARG static DISPID
Definition: ordinal.c:49
#define S_OK
Definition: intsafe.h:59
HRESULT WINAPI OleLoadPicturePath(LPOLESTR szURLorPath, LPUNKNOWN punkCaller, DWORD dwReserved, OLE_COLOR clrReserved, REFIID riid, LPVOID *ppvRet)
Definition: olepicture.c:2489
#define PICTYPE_BITMAP
Definition: olectl.h:133
#define InterlockedIncrement
Definition: armddk.h:53
long OLE_YPOS_HIMETRIC
Definition: olepro.idl:55
BOOL WINAPI DeleteDC(_In_ HDC)
interface IPersistStream * LPPERSISTSTREAM
Definition: objfwd.h:16
INT x
Definition: msvc.h:62
HICON hIcon
Definition: msconfig.c:44
SHORT top
Definition: olepicture.c:84
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1994
unsigned char dummy
Definition: maze.c:118
struct tagBITMAPFILEHEADER BITMAPFILEHEADER
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:197
static OLEPictureImpl * impl_from_IPersistStream(IPersistStream *iface)
Definition: olepicture.c:174
Definition: bl.h:1331
#define HeapReAlloc
Definition: compat.h:393
static HRESULT WINAPI SPCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
Definition: olepicture.c:2595
#define E_NOTIMPL
Definition: ddrawi.h:99
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: gl.h:1546
static HRESULT WINAPI OLEPictureImpl_get_Attributes(IPicture *iface, DWORD *pdwAttr)
Definition: olepicture.c:855
const GUID IID_IPropertyNotifySink
void _get_STDPIC_CF(LPVOID *ppv)
Definition: olepicture.c:2610
unsigned int loadtime_format
Definition: olepicture.c:161
#define SRCAND
Definition: wingdi.h:329
UINT picType
Definition: olectl.h:140
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4024
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define DISP_E_BADPARAMCOUNT
Definition: winerror.h:2523
#define BITMAP_FORMAT_PNG
Definition: olepicture.c:73
HRESULT CreateConnectionPoint(IUnknown *pUnk, REFIID riid, IConnectionPoint **pCP)
Definition: connpt.c:572
#define CreateFileW
Definition: compat.h:400
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1900
INT Width
Definition: wincodec.idl:238
_Out_opt_ int * cx
Definition: commctrl.h:570
DWORD HDC HDC DVTARGETDEVICE DWORD const SIZEL LONG * pwidth
Definition: msvc.h:106
int WINAPI GetDIBits(_In_ HDC hdc, _In_ HBITMAP hbm, _In_ UINT start, _In_ UINT cLines, _Out_opt_ LPVOID lpvBits, _At_((LPBITMAPINFOHEADER) lpbmi, _Inout_) LPBITMAPINFO lpbmi, _In_ UINT usage)
static HRESULT WINAPI OLEPictureImpl_get_CurDC(IPicture *iface, HDC *phdc)
Definition: olepicture.c:779
struct stdole::DISPPARAMS DISPPARAMS
static HRESULT OLEPictureImpl_LoadAPM(OLEPictureImpl *This, const BYTE *data, ULONG size)
Definition: olepicture.c:1292
static HRESULT WINAPI OLEPictureImpl_IsDirty(IPersistStream *iface)
Definition: olepicture.c:993
long OLE_XSIZE_HIMETRIC
Definition: olepro.idl:58
#define DISPID_PICT_WIDTH
Definition: olectl.h:441
static HRESULT WINAPI OLEPictureImpl_GetSizeMax(IPersistStream *iface, ULARGE_INTEGER *pcbSize)
Definition: olepicture.c:1855
static HRESULT WINAPI OLEPictureImpl_IConnectionPointContainer_QueryInterface(IConnectionPointContainer *iface, REFIID riid, VOID **ppvoid)
Definition: olepicture.c:881
unsigned int ULONG
Definition: retypes.h:1
BOOL WINAPI SetWindowOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:526
static ClassFactoryImpl factory
Definition: ole_server.c:237
#define CTL_E_INVALIDPROPERTYVALUE
Definition: olectl.h:292
HRESULT WINAPI CreateURLMoniker(IMoniker *pmkContext, LPCWSTR szURL, IMoniker **ppmk)
Definition: umon.c:732
BOOL WINAPI DeleteMetaFile(_In_ HMETAFILE)
#define DISPID_PICT_HEIGHT
Definition: olectl.h:442
HRESULT WINAPI WICConvertBitmapSource(REFWICPixelFormatGUID dstFormat, IWICBitmapSource *pISrc, IWICBitmapSource **ppIDst)
Definition: info.c:2474
#define LOGPIXELSY
Definition: wingdi.h:718
static const IConnectionPointContainerVtbl OLEPictureImpl_IConnectionPointContainer_VTable
Definition: olepicture.c:190
const GUID CLSID_StdPicture
static void OLEPictureImpl_SetEMF(OLEPictureImpl *This)
Definition: olepicture.c:269
BOOL WINAPI SetViewportExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
Definition: coord.c:462
#define V_UINT(A)
Definition: oleauto.h:264
#define DIB_RGB_COLORS
Definition: wingdi.h:366
#define E_POINTER
Definition: winerror.h:2365
BOOL keepOrigFormat
Definition: olepicture.c:147
static void OLEPictureImpl_SetBitmap(OLEPictureImpl *This)
Definition: olepicture.c:207
DWORD COLORREF
Definition: windef.h:285
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
#define memset(x, y, z)
Definition: compat.h:39
long OLE_XPOS_HIMETRIC
Definition: olepro.idl:52
static HRESULT WINAPI OLEPictureImpl_FindConnectionPoint(IConnectionPointContainer *iface, REFIID riid, IConnectionPoint **ppCP)
Definition: olepicture.c:917
LONG cy
Definition: windef.h:320
static HRESULT WINAPI SPCF_QueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj)
Definition: olepicture.c:2568
#define BI_RGB
Definition: precomp.h:35
static HBITMAP hBitmap
Definition: timezone.c:34
#define OBJ_BITMAP
Definition: objidl.idl:1415
#define HeapFree(x, y, z)
Definition: compat.h:394
#define MulDiv(x, y, z)
Definition: gdifloat.h:86
static HRESULT WINAPI OLEPictureImpl_GetClassID(IPersistStream *iface, CLSID *pClassID)
Definition: olepicture.c:982
BOOL WINAPI PlayMetaFile(_In_ HDC, _In_ HMETAFILE)
#define SRCCOPY
Definition: wingdi.h:332
struct CFHEADER header
Definition: fdi.c:109
SHORT bottom
Definition: olepicture.c:86
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:90
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
Definition: dc.c:439
#define CTL_E_PATHFILEACCESSERROR
Definition: olectl.h:287
Definition: compat.h:1931
IPersistStream IPersistStream_iface
Definition: olepicture.c:125
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static const IPictureVtbl OLEPictureImpl_VTable
Definition: olepicture.c:187
static HRESULT OLEPictureImpl_LoadWICDecoder(OLEPictureImpl *This, REFCLSID decoder_clsid, BYTE *xbuf, ULONG xread)
Definition: olepicture.c:1122
static IClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: olepicture.c:2562
static HRESULT create_stream(const WCHAR *filename, IStream **stream)
Definition: olepicture.c:2411
HRESULT WINAPI VariantChangeTypeEx(VARIANTARG *pvargDest, VARIANTARG *pvargSrc, LCID lcid, USHORT wFlags, VARTYPE vt)
Definition: variant.c:991
#define printf
Definition: config.h:203
static ULONG WINAPI OLEPictureImpl_IDispatch_AddRef(IDispatch *iface)
Definition: olepicture.c:1980
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
Definition: fci.c:126