ReactOS  0.4.13-dev-235-g7373cb3
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;
293  HRESULT hr;
294 
295  if (pictDesc)
296  TRACE("(%p) type = %d\n", pictDesc, pictDesc->picType);
297 
298  /*
299  * Allocate space for the object.
300  */
301  newObject = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(OLEPictureImpl));
302  if (!newObject)
303  return E_OUTOFMEMORY;
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 (hr != S_OK)
317  {
318  HeapFree(GetProcessHeap(), 0, newObject);
319  return hr;
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  WARN("Unsupported type %d\n", pictDesc->picType);
369  IPicture_Release(&newObject->IPicture_iface);
370  return E_UNEXPECTED;
371  }
372  } else {
373  newObject->desc.picType = PICTYPE_UNINITIALIZED;
374  }
375 
376  TRACE("returning %p\n", newObject);
377  *pict = newObject;
378  return S_OK;
379 }
380 
381 /************************************************************************
382  * OLEPictureImpl_Destroy
383  *
384  * This method is called by the Release method when the reference
385  * count goes down to 0. It will free all resources used by
386  * this object. */
388 {
389  TRACE("(%p)\n", Obj);
390 
391  if (Obj->pCP)
392  IConnectionPoint_Release(Obj->pCP);
393 
394  if(Obj->fOwn) { /* We need to destroy the picture */
395  switch(Obj->desc.picType) {
396  case PICTYPE_BITMAP:
397  DeleteObject(Obj->desc.u.bmp.hbitmap);
398  if (Obj->hbmMask != NULL) DeleteObject(Obj->hbmMask);
399  if (Obj->hbmXor != NULL) DeleteObject(Obj->hbmXor);
400  break;
401  case PICTYPE_METAFILE:
402  DeleteMetaFile(Obj->desc.u.wmf.hmeta);
403  break;
404  case PICTYPE_ICON:
405  DestroyIcon(Obj->desc.u.icon.hicon);
406  break;
407  case PICTYPE_ENHMETAFILE:
408  DeleteEnhMetaFile(Obj->desc.u.emf.hemf);
409  break;
410  case PICTYPE_NONE:
412  /* Nothing to do */
413  break;
414  default:
415  FIXME("Unsupported type %d - unable to delete\n", Obj->desc.picType);
416  break;
417  }
418  }
419  HeapFree(GetProcessHeap(), 0, Obj->data);
420  HeapFree(GetProcessHeap(), 0, Obj);
421 }
422 
423 
424 /************************************************************************
425  * OLEPictureImpl_AddRef (IUnknown)
426  *
427  * See Windows documentation for more details on IUnknown methods.
428  */
430  IPicture* iface)
431 {
433  ULONG refCount = InterlockedIncrement(&This->ref);
434 
435  TRACE("(%p)->(ref before=%d)\n", This, refCount - 1);
436 
437  return refCount;
438 }
439 
440 /************************************************************************
441  * OLEPictureImpl_Release (IUnknown)
442  *
443  * See Windows documentation for more details on IUnknown methods.
444  */
446  IPicture* iface)
447 {
449  ULONG refCount = InterlockedDecrement(&This->ref);
450 
451  TRACE("(%p)->(ref before=%d)\n", This, refCount + 1);
452 
453  /*
454  * If the reference count goes down to 0, perform suicide.
455  */
456  if (!refCount) OLEPictureImpl_Destroy(This);
457 
458  return refCount;
459 }
460 
461 /************************************************************************
462  * OLEPictureImpl_QueryInterface (IUnknown)
463  *
464  * See Windows documentation for more details on IUnknown methods.
465  */
467  IPicture* iface,
468  REFIID riid,
469  void** ppvObject)
470 {
472 
473  TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppvObject);
474 
475  if (!ppvObject)
476  return E_INVALIDARG;
477 
478  *ppvObject = 0;
479 
481  *ppvObject = &This->IPicture_iface;
482  else if (IsEqualIID(&IID_IDispatch, riid))
483  *ppvObject = &This->IDispatch_iface;
484  else if (IsEqualIID(&IID_IPictureDisp, riid))
485  *ppvObject = &This->IDispatch_iface;
487  *ppvObject = &This->IPersistStream_iface;
489  *ppvObject = &This->IConnectionPointContainer_iface;
490 
491  if (!*ppvObject)
492  {
493  FIXME("() : asking for unsupported interface %s\n",debugstr_guid(riid));
494  return E_NOINTERFACE;
495  }
496 
497  IPicture_AddRef(iface);
498 
499  return S_OK;
500 }
501 
502 /***********************************************************************
503  * OLEPicture_SendNotify (internal)
504  *
505  * Sends notification messages of changed properties to any interested
506  * connections.
507  */
508 static void OLEPicture_SendNotify(OLEPictureImpl* this, DISPID dispID)
509 {
510  IEnumConnections *pEnum;
511  CONNECTDATA CD;
512 
513  if (IConnectionPoint_EnumConnections(this->pCP, &pEnum) != S_OK)
514  return;
515  while(IEnumConnections_Next(pEnum, 1, &CD, NULL) == S_OK) {
517 
518  IUnknown_QueryInterface(CD.pUnk, &IID_IPropertyNotifySink, (LPVOID)&sink);
519  IPropertyNotifySink_OnChanged(sink, dispID);
520  IPropertyNotifySink_Release(sink);
521  IUnknown_Release(CD.pUnk);
522  }
523  IEnumConnections_Release(pEnum);
524 }
525 
526 /************************************************************************
527  * OLEPictureImpl_get_Handle
528  */
530  OLE_HANDLE *phandle)
531 {
533  TRACE("(%p)->(%p)\n", This, phandle);
534 
535  if(!phandle)
536  return E_POINTER;
537 
538  switch(This->desc.picType) {
539  case PICTYPE_NONE:
541  *phandle = 0;
542  break;
543  case PICTYPE_BITMAP:
544  *phandle = HandleToUlong(This->desc.u.bmp.hbitmap);
545  break;
546  case PICTYPE_METAFILE:
547  *phandle = HandleToUlong(This->desc.u.wmf.hmeta);
548  break;
549  case PICTYPE_ICON:
550  *phandle = HandleToUlong(This->desc.u.icon.hicon);
551  break;
552  case PICTYPE_ENHMETAFILE:
553  *phandle = HandleToUlong(This->desc.u.emf.hemf);
554  break;
555  default:
556  FIXME("Unimplemented type %d\n", This->desc.picType);
557  return E_NOTIMPL;
558  }
559  TRACE("returning handle %08x\n", *phandle);
560  return S_OK;
561 }
562 
563 /************************************************************************
564  * OLEPictureImpl_get_hPal
565  */
567  OLE_HANDLE *phandle)
568 {
570 
571  TRACE("(%p)->(%p)\n", This, phandle);
572 
573  if (!phandle) return E_POINTER;
574 
575  if (This->desc.picType == PICTYPE_BITMAP)
576  {
577  *phandle = HandleToUlong(This->desc.u.bmp.hpal);
578  return S_OK;
579  }
580 
581  return E_FAIL;
582 }
583 
584 /************************************************************************
585  * OLEPictureImpl_get_Type
586  */
588  short *ptype)
589 {
591  TRACE("(%p)->(%p): type is %d\n", This, ptype, This->desc.picType);
592 
593  if(!ptype)
594  return E_POINTER;
595 
596  *ptype = This->desc.picType;
597  return S_OK;
598 }
599 
600 /************************************************************************
601  * OLEPictureImpl_get_Width
602  */
604  OLE_XSIZE_HIMETRIC *pwidth)
605 {
607  TRACE("(%p)->(%p): width is %d\n", This, pwidth, This->himetricWidth);
608  *pwidth = This->himetricWidth;
609  return S_OK;
610 }
611 
612 /************************************************************************
613  * OLEPictureImpl_get_Height
614  */
616  OLE_YSIZE_HIMETRIC *pheight)
617 {
619  TRACE("(%p)->(%p): height is %d\n", This, pheight, This->himetricHeight);
620  *pheight = This->himetricHeight;
621  return S_OK;
622 }
623 
626  OLE_XSIZE_HIMETRIC cxSrc, OLE_YSIZE_HIMETRIC cySrc, HBITMAP hbmMask, HBITMAP hbmXor)
627 {
628  HDC hdcBmp;
629 
630  /* Set a mapping mode that maps bitmap pixels into HIMETRIC units.
631  * NB y-axis gets flipped
632  */
633 
634  hdcBmp = CreateCompatibleDC(0);
635  SetMapMode(hdcBmp, MM_ANISOTROPIC);
636  SetWindowOrgEx(hdcBmp, 0, 0, NULL);
637  SetWindowExtEx(hdcBmp, This->himetricWidth, This->himetricHeight, NULL);
638  SetViewportOrgEx(hdcBmp, 0, This->origHeight, NULL);
639  SetViewportExtEx(hdcBmp, This->origWidth, -This->origHeight, NULL);
640 
641  if (hbmMask)
642  {
643  SetBkColor(hdc, RGB(255, 255, 255));
644  SetTextColor(hdc, RGB(0, 0, 0));
645 
646  SelectObject(hdcBmp, hbmMask);
647  StretchBlt(hdc, x, y, cx, cy, hdcBmp, xSrc, ySrc, cxSrc, cySrc, SRCAND);
648 
649  if (hbmXor)
650  {
651  SelectObject(hdcBmp, hbmXor);
652  StretchBlt(hdc, x, y, cx, cy, hdcBmp, xSrc, ySrc, cxSrc, cySrc, SRCPAINT);
653  }
654  else StretchBlt(hdc, x, y, cx, cy, hdcBmp, xSrc, ySrc - This->himetricHeight,
655  cxSrc, cySrc, SRCPAINT);
656  }
657  else
658  {
659  SelectObject(hdcBmp, hbmXor);
660  StretchBlt(hdc, x, y, cx, cy, hdcBmp, xSrc, ySrc, cxSrc, cySrc, SRCCOPY);
661  }
662 
663  DeleteDC(hdcBmp);
664 }
665 
666 /************************************************************************
667  * OLEPictureImpl_Render
668  */
670  LONG x, LONG y, LONG cx, LONG cy,
671  OLE_XPOS_HIMETRIC xSrc,
672  OLE_YPOS_HIMETRIC ySrc,
673  OLE_XSIZE_HIMETRIC cxSrc,
674  OLE_YSIZE_HIMETRIC cySrc,
675  LPCRECT prcWBounds)
676 {
678  TRACE("(%p)->(%p, (%d,%d), (%d,%d) <- (%d,%d), (%d,%d), %p)\n",
679  This, hdc, x, y, cx, cy, xSrc, ySrc, cxSrc, cySrc, prcWBounds);
680  if(prcWBounds)
681  TRACE("prcWBounds %s\n", wine_dbgstr_rect(prcWBounds));
682 
683  if(cx == 0 || cy == 0 || cxSrc == 0 || cySrc == 0){
685  }
686 
687  /*
688  * While the documentation suggests this to be here (or after rendering?)
689  * it does cause an endless recursion in my sample app. -MM 20010804
690  OLEPicture_SendNotify(This,DISPID_PICT_RENDER);
691  */
692 
693  switch(This->desc.picType) {
695  case PICTYPE_NONE:
696  /* nothing to do */
697  return S_OK;
698  case PICTYPE_BITMAP:
699  {
700  HBITMAP hbmMask, hbmXor;
701 
702  if (This->hbmMask)
703  {
704  hbmMask = This->hbmMask;
705  hbmXor = This->hbmXor;
706  }
707  else
708  {
709  hbmMask = 0;
710  hbmXor = This->desc.u.bmp.hbitmap;
711  }
712 
713  render_masked_bitmap(This, hdc, x, y, cx, cy, xSrc, ySrc, cxSrc, cySrc, hbmMask, hbmXor);
714  break;
715  }
716 
717  case PICTYPE_ICON:
718  {
719  ICONINFO info;
720 
721  if (!GetIconInfo(This->desc.u.icon.hicon, &info))
722  return E_FAIL;
723 
724  render_masked_bitmap(This, hdc, x, y, cx, cy, xSrc, ySrc, cxSrc, cySrc, info.hbmMask, info.hbmColor);
725 
726  DeleteObject(info.hbmMask);
727  if (info.hbmColor) DeleteObject(info.hbmColor);
728  break;
729  }
730 
731  case PICTYPE_METAFILE:
732  {
733  POINT prevOrg, prevWndOrg;
734  SIZE prevExt, prevWndExt;
735  int oldmode;
736 
737  /* Render the WMF to the appropriate location by setting the
738  appropriate ratio between "device units" and "logical units" */
739  oldmode = SetMapMode(hdc, MM_ANISOTROPIC);
740  /* For the "source rectangle" the y-axis must be inverted */
741  SetWindowOrgEx(hdc, xSrc, This->himetricHeight-ySrc, &prevWndOrg);
742  SetWindowExtEx(hdc, cxSrc, -cySrc, &prevWndExt);
743  /* For the "destination rectangle" no inversion is necessary */
744  SetViewportOrgEx(hdc, x, y, &prevOrg);
745  SetViewportExtEx(hdc, cx, cy, &prevExt);
746 
747  if (!PlayMetaFile(hdc, This->desc.u.wmf.hmeta))
748  ERR("PlayMetaFile failed!\n");
749 
750  /* We're done, restore the DC to the previous settings for converting
751  logical units to device units */
752  SetWindowExtEx(hdc, prevWndExt.cx, prevWndExt.cy, NULL);
753  SetWindowOrgEx(hdc, prevWndOrg.x, prevWndOrg.y, NULL);
754  SetViewportExtEx(hdc, prevExt.cx, prevExt.cy, NULL);
755  SetViewportOrgEx(hdc, prevOrg.x, prevOrg.y, NULL);
756  SetMapMode(hdc, oldmode);
757  break;
758  }
759 
760  case PICTYPE_ENHMETAFILE:
761  {
762  RECT rc = { x, y, x + cx, y + cy };
763  PlayEnhMetaFile(hdc, This->desc.u.emf.hemf, &rc);
764  break;
765  }
766 
767  default:
768  FIXME("type %d not implemented\n", This->desc.picType);
769  return E_NOTIMPL;
770  }
771  return S_OK;
772 }
773 
774 /************************************************************************
775  * OLEPictureImpl_set_hPal
776  */
778  OLE_HANDLE hpal)
779 {
781 
782  TRACE("(%p)->(%08x)\n", This, hpal);
783 
784  if (This->desc.picType == PICTYPE_BITMAP)
785  {
786  This->desc.u.bmp.hpal = ULongToHandle(hpal);
788  return S_OK;
789  }
790 
791  return E_FAIL;
792 }
793 
794 /************************************************************************
795  * OLEPictureImpl_get_CurDC
796  */
798  HDC *phdc)
799 {
801  TRACE("(%p), returning %p\n", This, This->hDCCur);
802  if (phdc) *phdc = This->hDCCur;
803  return S_OK;
804 }
805 
806 /************************************************************************
807  * OLEPictureImpl_SelectPicture
808  */
810  HDC hdcIn,
811  HDC *phdcOut,
812  OLE_HANDLE *phbmpOut)
813 {
815  TRACE("(%p)->(%p, %p, %p)\n", This, hdcIn, phdcOut, phbmpOut);
816  if (This->desc.picType == PICTYPE_BITMAP) {
817  if (phdcOut)
818  *phdcOut = This->hDCCur;
819  if (This->hDCCur) SelectObject(This->hDCCur,This->stock_bitmap);
820  if (hdcIn) SelectObject(hdcIn,This->desc.u.bmp.hbitmap);
821  This->hDCCur = hdcIn;
822  if (phbmpOut)
823  *phbmpOut = HandleToUlong(This->desc.u.bmp.hbitmap);
824  return S_OK;
825  } else {
826  FIXME("Don't know how to select picture type %d\n",This->desc.picType);
827  return E_FAIL;
828  }
829 }
830 
831 /************************************************************************
832  * OLEPictureImpl_get_KeepOriginalFormat
833  */
835  BOOL *pfKeep)
836 {
838  TRACE("(%p)->(%p)\n", This, pfKeep);
839  if (!pfKeep)
840  return E_POINTER;
841  *pfKeep = This->keepOrigFormat;
842  return S_OK;
843 }
844 
845 /************************************************************************
846  * OLEPictureImpl_put_KeepOriginalFormat
847  */
849  BOOL keep)
850 {
852  TRACE("(%p)->(%d)\n", This, keep);
853  This->keepOrigFormat = keep;
854  /* FIXME: what DISPID notification here? */
855  return S_OK;
856 }
857 
858 /************************************************************************
859  * OLEPictureImpl_PictureChanged
860  */
862 {
864  TRACE("(%p)->()\n", This);
866  This->bIsDirty = TRUE;
867  return S_OK;
868 }
869 
870 /************************************************************************
871  * OLEPictureImpl_get_Attributes
872  */
874  DWORD *pdwAttr)
875 {
877  TRACE("(%p)->(%p).\n", This, pdwAttr);
878 
879  if(!pdwAttr)
880  return E_POINTER;
881 
882  *pdwAttr = 0;
883  switch (This->desc.picType) {
885  case PICTYPE_NONE: break;
886  case PICTYPE_BITMAP: if (This->hbmMask) *pdwAttr = PICTURE_TRANSPARENT; break; /* not 'truly' scalable, see MSDN. */
887  case PICTYPE_ICON: *pdwAttr = PICTURE_TRANSPARENT;break;
888  case PICTYPE_ENHMETAFILE: /* fall through */
889  case PICTYPE_METAFILE: *pdwAttr = PICTURE_TRANSPARENT|PICTURE_SCALABLE;break;
890  default:FIXME("Unknown pictype %d\n",This->desc.picType);break;
891  }
892  return S_OK;
893 }
894 
895 
896 /************************************************************************
897  * IConnectionPointContainer
898  */
901  REFIID riid,
902  VOID** ppvoid)
903 {
905 
906  return IPicture_QueryInterface(&This->IPicture_iface,riid,ppvoid);
907 }
908 
911 {
913 
914  return IPicture_AddRef(&This->IPicture_iface);
915 }
916 
919 {
921 
922  return IPicture_Release(&This->IPicture_iface);
923 }
924 
927  IEnumConnectionPoints** ppEnum)
928 {
930 
931  FIXME("(%p,%p), stub!\n",This,ppEnum);
932  return E_NOTIMPL;
933 }
934 
937  REFIID riid,
938  IConnectionPoint **ppCP)
939 {
941  TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppCP);
942  if (!ppCP)
943  return E_POINTER;
944  *ppCP = NULL;
946  return IConnectionPoint_QueryInterface(This->pCP, &IID_IConnectionPoint, (void**)ppCP);
947  FIXME("no connection point for %s\n",debugstr_guid(riid));
948  return CONNECT_E_NOCONNECTION;
949 }
950 
951 
952 /************************************************************************
953  * IPersistStream
954  */
955 
956 /************************************************************************
957  * OLEPictureImpl_IPersistStream_QueryInterface (IUnknown)
958  *
959  * See Windows documentation for more details on IUnknown methods.
960  */
962  IPersistStream* iface,
963  REFIID riid,
964  VOID** ppvoid)
965 {
967 
968  return IPicture_QueryInterface(&This->IPicture_iface, riid, ppvoid);
969 }
970 
971 /************************************************************************
972  * OLEPictureImpl_IPersistStream_AddRef (IUnknown)
973  *
974  * See Windows documentation for more details on IUnknown methods.
975  */
977  IPersistStream* iface)
978 {
980 
981  return IPicture_AddRef(&This->IPicture_iface);
982 }
983 
984 /************************************************************************
985  * OLEPictureImpl_IPersistStream_Release (IUnknown)
986  *
987  * See Windows documentation for more details on IUnknown methods.
988  */
990  IPersistStream* iface)
991 {
993 
994  return IPicture_Release(&This->IPicture_iface);
995 }
996 
997 /************************************************************************
998  * OLEPictureImpl_IPersistStream_GetClassID
999  */
1001  IPersistStream* iface,CLSID* pClassID)
1002 {
1003  TRACE("(%p)\n", pClassID);
1004  *pClassID = CLSID_StdPicture;
1005  return S_OK;
1006 }
1007 
1008 /************************************************************************
1009  * OLEPictureImpl_IPersistStream_IsDirty
1010  */
1012  IPersistStream* iface)
1013 {
1015  FIXME("(%p),stub!\n",This);
1016  return E_NOTIMPL;
1017 }
1018 
1020 {
1021  HRESULT hr;
1022  BITMAPINFOHEADER bih;
1023  UINT width, height;
1024  UINT stride, buffersize;
1025  BYTE *bits, *mask = NULL;
1026  WICRect rc;
1027  IWICBitmapSource *real_source;
1028  UINT x, y;
1029  COLORREF white = RGB(255, 255, 255), black = RGB(0, 0, 0);
1030  BOOL has_alpha=FALSE;
1031 
1032  hr = WICConvertBitmapSource(&GUID_WICPixelFormat32bppBGRA, src, &real_source);
1033  if (FAILED(hr)) return hr;
1034 
1035  hr = IWICBitmapSource_GetSize(real_source, &width, &height);
1036  if (FAILED(hr)) goto end;
1037 
1038  bih.biSize = sizeof(bih);
1039  bih.biWidth = width;
1040  bih.biHeight = -height;
1041  bih.biPlanes = 1;
1042  bih.biBitCount = 32;
1043  bih.biCompression = BI_RGB;
1044  bih.biSizeImage = 0;
1045  bih.biXPelsPerMeter = 4085; /* olepicture ignores the stored resolution */
1046  bih.biYPelsPerMeter = 4085;
1047  bih.biClrUsed = 0;
1048  bih.biClrImportant = 0;
1049 
1050  stride = 4 * width;
1051  buffersize = stride * height;
1052 
1053  mask = HeapAlloc(GetProcessHeap(), 0, buffersize);
1054  if (!mask)
1055  {
1056  hr = E_OUTOFMEMORY;
1057  goto end;
1058  }
1059 
1060  This->desc.u.bmp.hbitmap = CreateDIBSection(0, (BITMAPINFO*)&bih, DIB_RGB_COLORS, (void **)&bits, NULL, 0);
1061  if (This->desc.u.bmp.hbitmap == 0)
1062  {
1063  hr = E_FAIL;
1064  goto end;
1065  }
1066 
1067  rc.X = 0;
1068  rc.Y = 0;
1069  rc.Width = width;
1070  rc.Height = height;
1071  hr = IWICBitmapSource_CopyPixels(real_source, &rc, stride, buffersize, bits);
1072  if (FAILED(hr))
1073  {
1074  DeleteObject(This->desc.u.bmp.hbitmap);
1075  goto end;
1076  }
1077 
1078  This->desc.picType = PICTYPE_BITMAP;
1080 
1081  /* set transparent pixels to black, all others to white */
1082  for(y = 0; y < height; y++){
1083  for(x = 0; x < width; x++){
1084  DWORD *pixel = (DWORD*)(bits + stride*y + 4*x);
1085  if((*pixel & 0x80000000) == 0)
1086  {
1087  has_alpha = TRUE;
1088  *(DWORD *)(mask + stride * y + 4 * x) = black;
1089  }
1090  else
1091  *(DWORD *)(mask + stride * y + 4 * x) = white;
1092  }
1093  }
1094 
1095  if (has_alpha)
1096  {
1097  HDC hdcref, hdcBmp, hdcXor, hdcMask;
1098  HBITMAP hbmoldBmp, hbmoldXor, hbmoldMask;
1099 
1100  hdcref = GetDC(0);
1101 
1102  This->hbmXor = CreateDIBitmap(
1103  hdcref,
1104  &bih,
1105  CBM_INIT,
1106  mask,
1107  (BITMAPINFO*)&bih,
1109  );
1110 
1111  This->hbmMask = CreateBitmap(width,-height,1,1,NULL);
1112  hdcBmp = CreateCompatibleDC(NULL);
1113  hdcXor = CreateCompatibleDC(NULL);
1114  hdcMask = CreateCompatibleDC(NULL);
1115 
1116  hbmoldBmp = SelectObject(hdcBmp,This->desc.u.bmp.hbitmap);
1117  hbmoldXor = SelectObject(hdcXor,This->hbmXor);
1118  hbmoldMask = SelectObject(hdcMask,This->hbmMask);
1119 
1120  SetBkColor(hdcXor,black);
1121  BitBlt(hdcMask,0,0,width,height,hdcXor,0,0,SRCCOPY);
1122  BitBlt(hdcXor,0,0,width,height,hdcBmp,0,0,SRCAND);
1123 
1124  SelectObject(hdcBmp,hbmoldBmp);
1125  SelectObject(hdcXor,hbmoldXor);
1126  SelectObject(hdcMask,hbmoldMask);
1127 
1128  DeleteDC(hdcBmp);
1129  DeleteDC(hdcXor);
1130  DeleteDC(hdcMask);
1131  ReleaseDC(0, hdcref);
1132  }
1133 
1134 end:
1135  HeapFree(GetProcessHeap(), 0, mask);
1136  IWICBitmapSource_Release(real_source);
1137  return hr;
1138 }
1139 
1141 {
1142  HRESULT hr;
1144  IWICBitmapDecoder *decoder;
1145  IWICBitmapFrameDecode *framedecode;
1146  HRESULT initresult;
1147  IWICStream *stream;
1148 
1149  initresult = CoInitialize(NULL);
1150 
1151  hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
1152  &IID_IWICImagingFactory, (void**)&factory);
1153  if (SUCCEEDED(hr)) /* created factory */
1154  {
1155  hr = IWICImagingFactory_CreateStream(factory, &stream);
1156  IWICImagingFactory_Release(factory);
1157  }
1158 
1159  if (SUCCEEDED(hr)) /* created stream */
1160  {
1161  hr = IWICStream_InitializeFromMemory(stream, xbuf, xread);
1162 
1163  if (SUCCEEDED(hr)) /* initialized stream */
1164  {
1165  hr = CoCreateInstance(decoder_clsid, NULL, CLSCTX_INPROC_SERVER,
1166  &IID_IWICBitmapDecoder, (void**)&decoder);
1167  if (SUCCEEDED(hr)) /* created decoder */
1168  {
1169  hr = IWICBitmapDecoder_Initialize(decoder, (IStream*)stream, WICDecodeMetadataCacheOnLoad);
1170 
1171  if (SUCCEEDED(hr)) /* initialized decoder */
1172  hr = IWICBitmapDecoder_GetFrame(decoder, 0, &framedecode);
1173 
1174  IWICBitmapDecoder_Release(decoder);
1175  }
1176  }
1177 
1178  IWICStream_Release(stream);
1179  }
1180 
1181  if (SUCCEEDED(hr)) /* got framedecode */
1182  {
1184  IWICBitmapFrameDecode_Release(framedecode);
1185  }
1186 
1187  if (SUCCEEDED(initresult)) CoUninitialize();
1188  return hr;
1189 }
1190 
1191 /*****************************************************
1192 * start of Icon-specific code
1193 */
1194 
1196 {
1197  HICON hicon;
1198  CURSORICONFILEDIR *cifd = (CURSORICONFILEDIR*)xbuf;
1199  HDC hdcRef;
1200  int i;
1201 
1202  TRACE("(this %p, xbuf %p, xread %u)\n", This, xbuf, xread);
1203 
1204  /*
1205  FIXME("icon.idReserved=%d\n",cifd->idReserved);
1206  FIXME("icon.idType=%d\n",cifd->idType);
1207  FIXME("icon.idCount=%d\n",cifd->idCount);
1208 
1209  for (i=0;i<cifd->idCount;i++) {
1210  FIXME("[%d] width %d\n",i,cifd->idEntries[i].bWidth);
1211  FIXME("[%d] height %d\n",i,cifd->idEntries[i].bHeight);
1212  FIXME("[%d] bColorCount %d\n",i,cifd->idEntries[i].bColorCount);
1213  FIXME("[%d] bReserved %d\n",i,cifd->idEntries[i].bReserved);
1214  FIXME("[%d] xHotspot %d\n",i,cifd->idEntries[i].xHotspot);
1215  FIXME("[%d] yHotspot %d\n",i,cifd->idEntries[i].yHotspot);
1216  FIXME("[%d] dwDIBSize %d\n",i,cifd->idEntries[i].dwDIBSize);
1217  FIXME("[%d] dwDIBOffset %d\n",i,cifd->idEntries[i].dwDIBOffset);
1218  }
1219  */
1220 
1221  /* Need at least one icon to do something. */
1222  if (!cifd->idCount)
1223  {
1224  ERR("Invalid icon count of zero.\n");
1225  return E_FAIL;
1226  }
1227  i=0;
1228  /* If we have more than one icon, try to find the best.
1229  * this currently means '32 pixel wide'.
1230  */
1231  if (cifd->idCount!=1) {
1232  for (i=0;i<cifd->idCount;i++) {
1233  if (cifd->idEntries[i].bWidth == 32)
1234  break;
1235  }
1236  if (i==cifd->idCount) i=0;
1237  }
1238  if (xread < cifd->idEntries[i].dwDIBOffset + cifd->idEntries[i].dwDIBSize)
1239  {
1240  ERR("Icon data address %u is over %u bytes available.\n",
1241  cifd->idEntries[i].dwDIBOffset + cifd->idEntries[i].dwDIBSize, xread);
1242  return E_FAIL;
1243  }
1244  if (cifd->idType == 2)
1245  {
1246  LPBYTE buf = HeapAlloc(GetProcessHeap(), 0, cifd->idEntries[i].dwDIBSize + 4);
1247  memcpy(buf, &cifd->idEntries[i].xHotspot, 4);
1248  memcpy(buf + 4, xbuf+cifd->idEntries[i].dwDIBOffset, cifd->idEntries[i].dwDIBSize);
1249  hicon = CreateIconFromResourceEx(
1250  buf,
1251  cifd->idEntries[i].dwDIBSize + 4,
1252  FALSE, /* is cursor */
1253  0x00030000,
1254  cifd->idEntries[i].bWidth,
1255  cifd->idEntries[i].bHeight,
1256  0
1257  );
1258  HeapFree(GetProcessHeap(), 0, buf);
1259  }
1260  else
1261  {
1262  hicon = CreateIconFromResourceEx(
1263  xbuf+cifd->idEntries[i].dwDIBOffset,
1264  cifd->idEntries[i].dwDIBSize,
1265  TRUE, /* is icon */
1266  0x00030000,
1267  cifd->idEntries[i].bWidth,
1268  cifd->idEntries[i].bHeight,
1269  0
1270  );
1271  }
1272  if (!hicon) {
1273  ERR("CreateIcon failed.\n");
1274  return E_FAIL;
1275  } else {
1276  This->desc.picType = PICTYPE_ICON;
1277  This->desc.u.icon.hicon = hicon;
1278  This->origWidth = cifd->idEntries[i].bWidth;
1279  This->origHeight = cifd->idEntries[i].bHeight;
1280  hdcRef = CreateCompatibleDC(0);
1281  This->himetricWidth = xpixels_to_himetric(cifd->idEntries[i].bWidth, hdcRef);
1282  This->himetricHeight= ypixels_to_himetric(cifd->idEntries[i].bHeight, hdcRef);
1283  DeleteDC(hdcRef);
1284  return S_OK;
1285  }
1286 }
1287 
1289  const BYTE *data, ULONG size)
1290 {
1291  HENHMETAFILE hemf;
1293 
1294  hemf = SetEnhMetaFileBits(size, data);
1295  if (!hemf) return E_FAIL;
1296 
1297  GetEnhMetaFileHeader(hemf, sizeof(hdr), &hdr);
1298 
1299  This->desc.picType = PICTYPE_ENHMETAFILE;
1300  This->desc.u.emf.hemf = hemf;
1301 
1302  This->origWidth = 0;
1303  This->origHeight = 0;
1304  This->himetricWidth = hdr.rclFrame.right - hdr.rclFrame.left;
1305  This->himetricHeight = hdr.rclFrame.bottom - hdr.rclFrame.top;
1306 
1307  return S_OK;
1308 }
1309 
1311  const BYTE *data, ULONG size)
1312 {
1313  const APM_HEADER *header = (const APM_HEADER *)data;
1314  HMETAFILE hmf;
1315 
1316  if (size < sizeof(APM_HEADER))
1317  return E_FAIL;
1318  if (header->key != 0x9ac6cdd7)
1319  return E_FAIL;
1320 
1321  /* SetMetaFileBitsEx performs data check on its own */
1322  hmf = SetMetaFileBitsEx(size - sizeof(*header), data + sizeof(*header));
1323  if (!hmf) return E_FAIL;
1324 
1325  This->desc.picType = PICTYPE_METAFILE;
1326  This->desc.u.wmf.hmeta = hmf;
1327  This->desc.u.wmf.xExt = 0;
1328  This->desc.u.wmf.yExt = 0;
1329 
1330  This->origWidth = 0;
1331  This->origHeight = 0;
1332  This->himetricWidth = MulDiv((INT)header->right - header->left, 2540, header->inch);
1333  This->himetricHeight = MulDiv((INT)header->bottom - header->top, 2540, header->inch);
1334  return S_OK;
1335 }
1336 
1337 /************************************************************************
1338  * OLEPictureImpl_IPersistStream_Load (IUnknown)
1339  *
1340  * Loads the binary data from the IStream. Starts at current position.
1341  * There appears to be an 2 DWORD header:
1342  * DWORD magic;
1343  * DWORD len;
1344  *
1345  * Currently implemented: BITMAP, ICON, CURSOR, JPEG, GIF, WMF, EMF
1346  */
1348  HRESULT hr;
1349  BOOL headerisdata;
1350  BOOL statfailed = FALSE;
1351  ULONG xread, toread;
1352  ULONG headerread;
1353  BYTE *xbuf;
1354  DWORD header[2];
1355  WORD magic;
1356  STATSTG statstg;
1358 
1359  TRACE("(%p,%p)\n",This,pStm);
1360 
1361  /****************************************************************************************
1362  * Part 1: Load the data
1363  */
1364  /* Sometimes we have a header, sometimes we don't. Apply some guesses to find
1365  * out whether we do.
1366  *
1367  * UPDATE: the IStream can be mapped to a plain file instead of a stream in a
1368  * compound file. This may explain most, if not all, of the cases of "no
1369  * header", and the header validation should take this into account.
1370  * At least in Visual Basic 6, resource streams, valid headers are
1371  * header[0] == "lt\0\0",
1372  * header[1] == length_of_stream.
1373  *
1374  * Also handle streams where we do not have a working "Stat" method by
1375  * reading all data until the end of the stream.
1376  */
1377  hr = IStream_Stat(pStm,&statstg,STATFLAG_NONAME);
1378  if (hr != S_OK) {
1379  TRACE("stat failed with hres %x, proceeding to read all data.\n",hr);
1380  statfailed = TRUE;
1381  /* we will read at least 8 byte ... just right below */
1382  statstg.cbSize.QuadPart = 8;
1383  }
1384 
1385  toread = 0;
1386  headerread = 0;
1387  headerisdata = FALSE;
1388  do {
1389  hr = IStream_Read(pStm, header, 8, &xread);
1390  if (hr != S_OK || xread!=8) {
1391  ERR("Failure while reading picture header (hr is %x, nread is %d).\n",hr,xread);
1392  return (hr?hr:E_FAIL);
1393  }
1394  headerread += xread;
1395  xread = 0;
1396 
1397  if (!memcmp(&(header[0]),"lt\0\0", 4) && (statfailed || (header[1] + headerread <= statstg.cbSize.QuadPart))) {
1398  if (toread != 0 && toread != header[1])
1399  FIXME("varying lengths of image data (prev=%u curr=%u), only last one will be used\n",
1400  toread, header[1]);
1401  toread = header[1];
1402  if (statfailed)
1403  {
1404  statstg.cbSize.QuadPart = header[1] + 8;
1405  statfailed = FALSE;
1406  }
1407  if (toread == 0) break;
1408  } else {
1409  if (!memcmp(&(header[0]), "GIF8", 4) || /* GIF header */
1410  !memcmp(&(header[0]), "BM", 2) || /* BMP header */
1411  !memcmp(&(header[0]), "\xff\xd8", 2) || /* JPEG header */
1412  (header[0] == EMR_HEADER) || /* EMF header */
1413  (header[0] == 0x10000) || /* icon: idReserved 0, idType 1 */
1414  (header[0] == 0x20000) || /* cursor: idReserved 0, idType 2 */
1415  (header[1] > statstg.cbSize.QuadPart)|| /* invalid size */
1416  (header[1]==0)
1417  ) {/* Found start of bitmap data */
1418  headerisdata = TRUE;
1419  if (toread == 0)
1420  toread = statstg.cbSize.QuadPart-8;
1421  else toread -= 8;
1422  xread = 8;
1423  } else {
1424  FIXME("Unknown stream header magic: %08x\n", header[0]);
1425  toread = header[1];
1426  }
1427  }
1428  } while (!headerisdata);
1429 
1430  if (statfailed) { /* we don't know the size ... read all we get */
1431  unsigned int sizeinc = 4096;
1432  unsigned int origsize = sizeinc;
1433  ULONG nread = 42;
1434 
1435  TRACE("Reading all data from stream.\n");
1436  xbuf = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, origsize);
1437  if (headerisdata)
1438  memcpy (xbuf, header, 8);
1439  while (1) {
1440  while (xread < origsize) {
1441  hr = IStream_Read(pStm,xbuf+xread,origsize-xread,&nread);
1442  xread += nread;
1443  if (hr != S_OK || !nread)
1444  break;
1445  }
1446  if (!nread || hr != S_OK) /* done, or error */
1447  break;
1448  if (xread == origsize) {
1449  origsize += sizeinc;
1450  sizeinc = 2*sizeinc; /* exponential increase */
1451  xbuf = HeapReAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, xbuf, origsize);
1452  }
1453  }
1454  if (hr != S_OK)
1455  TRACE("hr in no-stat loader case is %08x\n", hr);
1456  TRACE("loaded %d bytes.\n", xread);
1457  This->datalen = xread;
1458  This->data = xbuf;
1459  } else {
1460  This->datalen = toread+(headerisdata?8:0);
1461  xbuf = This->data = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, This->datalen);
1462  if (!xbuf)
1463  return E_OUTOFMEMORY;
1464 
1465  if (headerisdata)
1466  memcpy (xbuf, header, 8);
1467 
1468  while (xread < This->datalen) {
1469  ULONG nread;
1470  hr = IStream_Read(pStm,xbuf+xread,This->datalen-xread,&nread);
1471  xread += nread;
1472  if (hr != S_OK || !nread)
1473  break;
1474  }
1475  if (xread != This->datalen)
1476  ERR("Could only read %d of %d bytes out of stream?\n",xread,This->datalen);
1477  }
1478  if (This->datalen == 0) { /* Marks the "NONE" picture */
1479  This->desc.picType = PICTYPE_NONE;
1480  return S_OK;
1481  }
1482 
1483 
1484  /****************************************************************************************
1485  * Part 2: Process the loaded data
1486  */
1487 
1488  magic = xbuf[0] + (xbuf[1]<<8);
1489  This->loadtime_format = magic;
1490 
1491  switch (magic) {
1492  case BITMAP_FORMAT_GIF: /* GIF */
1493  hr = OLEPictureImpl_LoadWICDecoder(This, &CLSID_WICGifDecoder, xbuf, xread);
1494  break;
1495  case BITMAP_FORMAT_JPEG: /* JPEG */
1496  hr = OLEPictureImpl_LoadWICDecoder(This, &CLSID_WICJpegDecoder, xbuf, xread);
1497  break;
1498  case BITMAP_FORMAT_BMP: /* Bitmap */
1499  hr = OLEPictureImpl_LoadWICDecoder(This, &CLSID_WICBmpDecoder, xbuf, xread);
1500  break;
1501  case BITMAP_FORMAT_PNG: /* PNG */
1502  hr = OLEPictureImpl_LoadWICDecoder(This, &CLSID_WICPngDecoder, xbuf, xread);
1503  break;
1504  case BITMAP_FORMAT_APM: /* APM */
1505  hr = OLEPictureImpl_LoadAPM(This, xbuf, xread);
1506  break;
1507  case 0x0000: { /* ICON or CURSOR, first word is dwReserved */
1508  hr = OLEPictureImpl_LoadIcon(This, xbuf, xread);
1509  break;
1510  }
1511  default:
1512  {
1513  unsigned int i;
1514 
1515  /* let's see if it's a EMF */
1516  hr = OLEPictureImpl_LoadEnhMetafile(This, xbuf, xread);
1517  if (hr == S_OK) break;
1518 
1519  FIXME("Unknown magic %04x, %d read bytes:\n",magic,xread);
1520  hr=E_FAIL;
1521  for (i=0;i<xread+8;i++) {
1522  if (i<8) MESSAGE("%02x ",((unsigned char*)header)[i]);
1523  else MESSAGE("%02x ",xbuf[i-8]);
1524  if (i % 10 == 9) MESSAGE("\n");
1525  }
1526  MESSAGE("\n");
1527  break;
1528  }
1529  }
1530  This->bIsDirty = FALSE;
1531 
1532  /* FIXME: this notify is not really documented */
1533  if (hr==S_OK)
1535  return hr;
1536 }
1537 
1538 static BOOL serializeBMP(HBITMAP hBitmap, void ** ppBuffer, unsigned int * pLength)
1539 {
1540  BOOL success = FALSE;
1541  HDC hDC;
1542  BITMAPINFO * pInfoBitmap;
1543  int iNumPaletteEntries;
1544  unsigned char * pPixelData;
1545  BITMAPFILEHEADER * pFileHeader;
1546  BITMAPINFO * pInfoHeader;
1547 
1548  pInfoBitmap = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
1549  sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
1550 
1551  /* Find out bitmap size and padded length */
1552  hDC = GetDC(0);
1553  pInfoBitmap->bmiHeader.biSize = sizeof(pInfoBitmap->bmiHeader);
1554  GetDIBits(hDC, hBitmap, 0, 0, NULL, pInfoBitmap, DIB_RGB_COLORS);
1555 
1556  /* Fetch bitmap palette & pixel data */
1557 
1558  pPixelData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, pInfoBitmap->bmiHeader.biSizeImage);
1559  GetDIBits(hDC, hBitmap, 0, pInfoBitmap->bmiHeader.biHeight, pPixelData, pInfoBitmap, DIB_RGB_COLORS);
1560 
1561  /* Calculate the total length required for the BMP data */
1562  if (pInfoBitmap->bmiHeader.biClrUsed != 0) {
1563  iNumPaletteEntries = pInfoBitmap->bmiHeader.biClrUsed;
1564  if (iNumPaletteEntries > 256) iNumPaletteEntries = 256;
1565  } else {
1566  if (pInfoBitmap->bmiHeader.biBitCount <= 8)
1567  iNumPaletteEntries = 1 << pInfoBitmap->bmiHeader.biBitCount;
1568  else
1569  iNumPaletteEntries = 0;
1570  }
1571  *pLength =
1572  sizeof(BITMAPFILEHEADER) +
1573  sizeof(BITMAPINFOHEADER) +
1574  iNumPaletteEntries * sizeof(RGBQUAD) +
1575  pInfoBitmap->bmiHeader.biSizeImage;
1576  *ppBuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, *pLength);
1577 
1578  /* Fill the BITMAPFILEHEADER */
1579  pFileHeader = *ppBuffer;
1580  pFileHeader->bfType = BITMAP_FORMAT_BMP;
1581  pFileHeader->bfSize = *pLength;
1582  pFileHeader->bfOffBits =
1583  sizeof(BITMAPFILEHEADER) +
1584  sizeof(BITMAPINFOHEADER) +
1585  iNumPaletteEntries * sizeof(RGBQUAD);
1586 
1587  /* Fill the BITMAPINFOHEADER and the palette data */
1588  pInfoHeader = (BITMAPINFO *)((unsigned char *)(*ppBuffer) + sizeof(BITMAPFILEHEADER));
1589  memcpy(pInfoHeader, pInfoBitmap, sizeof(BITMAPINFOHEADER) + iNumPaletteEntries * sizeof(RGBQUAD));
1590  memcpy(
1591  (unsigned char *)(*ppBuffer) +
1592  sizeof(BITMAPFILEHEADER) +
1593  sizeof(BITMAPINFOHEADER) +
1594  iNumPaletteEntries * sizeof(RGBQUAD),
1595  pPixelData, pInfoBitmap->bmiHeader.biSizeImage);
1596  success = TRUE;
1597 
1598  HeapFree(GetProcessHeap(), 0, pPixelData);
1599  HeapFree(GetProcessHeap(), 0, pInfoBitmap);
1600  return success;
1601 }
1602 
1603 static BOOL serializeIcon(HICON hIcon, void ** ppBuffer, unsigned int * pLength)
1604 {
1605  ICONINFO infoIcon;
1606  BOOL success = FALSE;
1607 
1608  *ppBuffer = NULL; *pLength = 0;
1609  if (GetIconInfo(hIcon, &infoIcon)) {
1610  HDC hDC;
1611  BITMAPINFO * pInfoBitmap;
1612  unsigned char * pIconData = NULL;
1613  unsigned int iDataSize = 0;
1614 
1615  pInfoBitmap = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
1616 
1617  /* Find out icon size */
1618  hDC = GetDC(0);
1619  pInfoBitmap->bmiHeader.biSize = sizeof(pInfoBitmap->bmiHeader);
1620  GetDIBits(hDC, infoIcon.hbmColor, 0, 0, NULL, pInfoBitmap, DIB_RGB_COLORS);
1621  if (1) {
1622  /* Auxiliary pointers */
1623  CURSORICONFILEDIR * pIconDir;
1624  CURSORICONFILEDIRENTRY * pIconEntry;
1625  BITMAPINFOHEADER * pIconBitmapHeader;
1626  unsigned int iOffsetPalette;
1627  unsigned int iOffsetColorData;
1628  unsigned int iOffsetMaskData;
1629 
1630  unsigned int iLengthScanLineMask;
1631  unsigned int iNumEntriesPalette;
1632 
1633  iLengthScanLineMask = ((pInfoBitmap->bmiHeader.biWidth + 31) >> 5) << 2;
1634 /*
1635  FIXME("DEBUG: bitmap size is %d x %d\n",
1636  pInfoBitmap->bmiHeader.biWidth,
1637  pInfoBitmap->bmiHeader.biHeight);
1638  FIXME("DEBUG: bitmap bpp is %d\n",
1639  pInfoBitmap->bmiHeader.biBitCount);
1640  FIXME("DEBUG: bitmap nplanes is %d\n",
1641  pInfoBitmap->bmiHeader.biPlanes);
1642  FIXME("DEBUG: bitmap biSizeImage is %u\n",
1643  pInfoBitmap->bmiHeader.biSizeImage);
1644 */
1645  /* Let's start with one CURSORICONFILEDIR and one CURSORICONFILEDIRENTRY */
1646  iDataSize += 3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY) + sizeof(BITMAPINFOHEADER);
1647  pIconData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, iDataSize);
1648 
1649  /* Fill out the CURSORICONFILEDIR */
1650  pIconDir = (CURSORICONFILEDIR *)pIconData;
1651  pIconDir->idType = 1;
1652  pIconDir->idCount = 1;
1653  pIconDir->idReserved = 0;
1654 
1655  /* Fill out the CURSORICONFILEDIRENTRY */
1656  pIconEntry = (CURSORICONFILEDIRENTRY *)(pIconData + 3 * sizeof(WORD));
1657  pIconEntry->bWidth = (unsigned char)pInfoBitmap->bmiHeader.biWidth;
1658  pIconEntry->bHeight = (unsigned char)pInfoBitmap->bmiHeader.biHeight;
1659  pIconEntry->bColorCount =
1660  (pInfoBitmap->bmiHeader.biBitCount < 8)
1661  ? 1 << pInfoBitmap->bmiHeader.biBitCount
1662  : 0;
1663  pIconEntry->xHotspot = pInfoBitmap->bmiHeader.biPlanes;
1664  pIconEntry->yHotspot = pInfoBitmap->bmiHeader.biBitCount;
1665  pIconEntry->dwDIBSize = 0;
1666  pIconEntry->dwDIBOffset = 3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY);
1667 
1668  /* Fill out the BITMAPINFOHEADER */
1669  pIconBitmapHeader = (BITMAPINFOHEADER *)(pIconData + 3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY));
1670  *pIconBitmapHeader = pInfoBitmap->bmiHeader;
1671 
1672  /* Find out whether a palette exists for the bitmap */
1673  if ( (pInfoBitmap->bmiHeader.biBitCount == 16 && pInfoBitmap->bmiHeader.biCompression == BI_RGB)
1674  || (pInfoBitmap->bmiHeader.biBitCount == 24)
1675  || (pInfoBitmap->bmiHeader.biBitCount == 32 && pInfoBitmap->bmiHeader.biCompression == BI_RGB)) {
1676  iNumEntriesPalette = pInfoBitmap->bmiHeader.biClrUsed;
1677  if (iNumEntriesPalette > 256) iNumEntriesPalette = 256;
1678  } else if ((pInfoBitmap->bmiHeader.biBitCount == 16 || pInfoBitmap->bmiHeader.biBitCount == 32)
1679  && pInfoBitmap->bmiHeader.biCompression == BI_BITFIELDS) {
1680  iNumEntriesPalette = 3;
1681  } else if (pInfoBitmap->bmiHeader.biBitCount <= 8) {
1682  iNumEntriesPalette = 1 << pInfoBitmap->bmiHeader.biBitCount;
1683  } else {
1684  iNumEntriesPalette = 0;
1685  }
1686 
1687  /* Add bitmap size and header size to icon data size. */
1688  iOffsetPalette = iDataSize;
1689  iDataSize += iNumEntriesPalette * sizeof(DWORD);
1690  iOffsetColorData = iDataSize;
1691  iDataSize += pIconBitmapHeader->biSizeImage;
1692  iOffsetMaskData = iDataSize;
1693  iDataSize += pIconBitmapHeader->biHeight * iLengthScanLineMask;
1694  pIconBitmapHeader->biSizeImage += pIconBitmapHeader->biHeight * iLengthScanLineMask;
1695  pIconBitmapHeader->biHeight *= 2;
1696  pIconData = HeapReAlloc(GetProcessHeap(), 0, pIconData, iDataSize);
1697  pIconEntry = (CURSORICONFILEDIRENTRY *)(pIconData + 3 * sizeof(WORD));
1698  pIconBitmapHeader = (BITMAPINFOHEADER *)(pIconData + 3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY));
1699  pIconEntry->dwDIBSize = iDataSize - (3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY));
1700 
1701  /* Get the actual bitmap data from the icon bitmap */
1702  GetDIBits(hDC, infoIcon.hbmColor, 0, pInfoBitmap->bmiHeader.biHeight,
1703  pIconData + iOffsetColorData, pInfoBitmap, DIB_RGB_COLORS);
1704  if (iNumEntriesPalette > 0) {
1705  memcpy(pIconData + iOffsetPalette, pInfoBitmap->bmiColors,
1706  iNumEntriesPalette * sizeof(RGBQUAD));
1707  }
1708 
1709  /* Reset all values so that GetDIBits call succeeds */
1710  memset(pIconData + iOffsetMaskData, 0, iDataSize - iOffsetMaskData);
1711  memset(pInfoBitmap, 0, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
1712  pInfoBitmap->bmiHeader.biSize = sizeof(pInfoBitmap->bmiHeader);
1713 /*
1714  if (!(GetDIBits(hDC, infoIcon.hbmMask, 0, 0, NULL, pInfoBitmap, DIB_RGB_COLORS)
1715  && GetDIBits(hDC, infoIcon.hbmMask, 0, pIconEntry->bHeight,
1716  pIconData + iOffsetMaskData, pInfoBitmap, DIB_RGB_COLORS))) {
1717 
1718  printf("ERROR: unable to get bitmap mask (error %u)\n",
1719  GetLastError());
1720 
1721  }
1722 */
1723  GetDIBits(hDC, infoIcon.hbmMask, 0, 0, NULL, pInfoBitmap, DIB_RGB_COLORS);
1724  GetDIBits(hDC, infoIcon.hbmMask, 0, pIconEntry->bHeight, pIconData + iOffsetMaskData, pInfoBitmap, DIB_RGB_COLORS);
1725 
1726  /* Write out everything produced so far to the stream */
1727  *ppBuffer = pIconData; *pLength = iDataSize;
1728  success = TRUE;
1729  } else {
1730 /*
1731  printf("ERROR: unable to get bitmap information via GetDIBits() (error %u)\n",
1732  GetLastError());
1733 */
1734  }
1735  /*
1736  Remarks (from MSDN entry on GetIconInfo):
1737 
1738  GetIconInfo creates bitmaps for the hbmMask and hbmColor
1739  members of ICONINFO. The calling application must manage
1740  these bitmaps and delete them when they are no longer
1741  necessary.
1742  */
1743  if (hDC) ReleaseDC(0, hDC);
1744  DeleteObject(infoIcon.hbmMask);
1745  if (infoIcon.hbmColor) DeleteObject(infoIcon.hbmColor);
1746  HeapFree(GetProcessHeap(), 0, pInfoBitmap);
1747  } else {
1748  printf("ERROR: Unable to get icon information (error %u)\n",
1749  GetLastError());
1750  }
1751  return success;
1752 }
1753 
1754 static BOOL serializeEMF(HENHMETAFILE hemf, void **buf, unsigned *size)
1755 {
1756  *size = GetEnhMetaFileBits(hemf, 0, NULL);
1757  if (!*size) return FALSE;
1758 
1759  *buf = HeapAlloc(GetProcessHeap(), 0, *size);
1760  if (!*buf) return FALSE;
1761 
1762  return GetEnhMetaFileBits(hemf, *size, *buf) != 0;
1763 }
1764 
1766  IPersistStream* iface,IStream*pStm,BOOL fClearDirty)
1767 {
1768  HRESULT hResult = E_NOTIMPL;
1769  void * pIconData;
1770  unsigned int iDataSize;
1771  DWORD header[2];
1772  ULONG dummy;
1773  BOOL serializeResult = FALSE;
1775 
1776  TRACE("%p %p %d\n", This, pStm, fClearDirty);
1777 
1778  switch (This->desc.picType) {
1779  case PICTYPE_NONE:
1780  header[0] = 0x0000746c;
1781  header[1] = 0;
1782  hResult = IStream_Write(pStm, header, 2 * sizeof(DWORD), &dummy);
1783  break;
1784 
1785  case PICTYPE_ICON:
1786  if (This->bIsDirty || !This->data) {
1787  if (!serializeIcon(This->desc.u.icon.hicon, &pIconData, &iDataSize)) {
1788  ERR("(%p,%p,%d), serializeIcon() failed\n", This, pStm, fClearDirty);
1789  hResult = E_FAIL;
1790  break;
1791  }
1792  HeapFree(GetProcessHeap(), 0, This->data);
1793  This->data = pIconData;
1794  This->datalen = iDataSize;
1795  }
1796 
1797  header[0] = (This->loadtime_magic != 0xdeadbeef) ? This->loadtime_magic : 0x0000746c;
1798  header[1] = This->datalen;
1799  IStream_Write(pStm, header, 2 * sizeof(DWORD), &dummy);
1800  IStream_Write(pStm, This->data, This->datalen, &dummy);
1801  hResult = S_OK;
1802  break;
1803  case PICTYPE_BITMAP:
1804  if (This->bIsDirty || !This->data) {
1805  switch (This->keepOrigFormat ? This->loadtime_format : BITMAP_FORMAT_BMP) {
1806  case BITMAP_FORMAT_BMP:
1807  serializeResult = serializeBMP(This->desc.u.bmp.hbitmap, &pIconData, &iDataSize);
1808  break;
1809  case BITMAP_FORMAT_JPEG:
1810  FIXME("(%p,%p,%d), PICTYPE_BITMAP (format JPEG) not implemented!\n",This,pStm,fClearDirty);
1811  break;
1812  case BITMAP_FORMAT_GIF:
1813  FIXME("(%p,%p,%d), PICTYPE_BITMAP (format GIF) not implemented!\n",This,pStm,fClearDirty);
1814  break;
1815  case BITMAP_FORMAT_PNG:
1816  FIXME("(%p,%p,%d), PICTYPE_BITMAP (format PNG) not implemented!\n",This,pStm,fClearDirty);
1817  break;
1818  default:
1819  FIXME("(%p,%p,%d), PICTYPE_BITMAP (format UNKNOWN, using BMP?) not implemented!\n",This,pStm,fClearDirty);
1820  break;
1821  }
1822 
1823  if (!serializeResult)
1824  {
1825  hResult = E_FAIL;
1826  break;
1827  }
1828 
1829  HeapFree(GetProcessHeap(), 0, This->data);
1830  This->data = pIconData;
1831  This->datalen = iDataSize;
1832  }
1833 
1834  header[0] = (This->loadtime_magic != 0xdeadbeef) ? This->loadtime_magic : 0x0000746c;
1835  header[1] = This->datalen;
1836  IStream_Write(pStm, header, 2 * sizeof(DWORD), &dummy);
1837  IStream_Write(pStm, This->data, This->datalen, &dummy);
1838  hResult = S_OK;
1839  break;
1840 
1841  case PICTYPE_ENHMETAFILE:
1842  if (This->bIsDirty || !This->data)
1843  {
1844  serializeResult = serializeEMF(This->desc.u.emf.hemf, &pIconData, &iDataSize);
1845  if (!serializeResult)
1846  {
1847  hResult = E_FAIL;
1848  break;
1849  }
1850 
1851  HeapFree(GetProcessHeap(), 0, This->data);
1852  This->data = pIconData;
1853  This->datalen = iDataSize;
1854  }
1855  header[0] = 0x0000746c;
1856  header[1] = This->datalen;
1857  IStream_Write(pStm, header, 2 * sizeof(DWORD), &dummy);
1858  IStream_Write(pStm, This->data, This->datalen, &dummy);
1859  hResult = S_OK;
1860  break;
1861 
1862  case PICTYPE_METAFILE:
1863  FIXME("(%p,%p,%d), PICTYPE_METAFILE not implemented!\n",This,pStm,fClearDirty);
1864  break;
1865  default:
1866  FIXME("(%p,%p,%d), [unknown type] not implemented!\n",This,pStm,fClearDirty);
1867  break;
1868  }
1869  if (hResult == S_OK && fClearDirty) This->bIsDirty = FALSE;
1870  return hResult;
1871 }
1872 
1874  IPersistStream* iface,ULARGE_INTEGER*pcbSize)
1875 {
1877  FIXME("(%p,%p),stub!\n",This,pcbSize);
1878  return E_NOTIMPL;
1879 }
1880 
1881 /************************************************************************
1882  * OLEPictureImpl_SaveAsFile
1883  */
1885  IStream *stream, BOOL mem_copy, LONG *size)
1886 {
1888  void *data;
1889  unsigned data_size;
1890  ULONG written;
1891  HRESULT hr;
1892 
1893  FIXME("(%p)->(%p,%d,%p): semi-stub\n", This, stream, mem_copy, size);
1894 
1895  switch (This->desc.picType)
1896  {
1897  case PICTYPE_NONE:
1898  return S_OK;
1899 
1900  case PICTYPE_ICON:
1901  if (!mem_copy) return E_FAIL;
1902 
1903  if (This->bIsDirty || !This->data)
1904  {
1905  if (!serializeIcon(This->desc.u.icon.hicon, &data, &data_size))
1906  return E_FAIL;
1907  HeapFree(GetProcessHeap(), 0, This->data);
1908  This->data = data;
1909  This->datalen = data_size;
1910  }
1911  hr = IStream_Write(stream, This->data, This->datalen, &written);
1912  if (hr == S_OK && size) *size = written;
1913  return hr;
1914 
1915  case PICTYPE_BITMAP:
1916  if (!mem_copy) return E_FAIL;
1917 
1918  if (This->bIsDirty || !This->data)
1919  {
1920  switch (This->keepOrigFormat ? This->loadtime_format : BITMAP_FORMAT_BMP)
1921  {
1922  case BITMAP_FORMAT_BMP:
1923  if (!serializeBMP(This->desc.u.bmp.hbitmap, &data, &data_size))
1924  return E_FAIL;
1925  break;
1926  case BITMAP_FORMAT_JPEG:
1927  FIXME("BITMAP_FORMAT_JPEG is not implemented\n");
1928  return E_NOTIMPL;
1929  case BITMAP_FORMAT_GIF:
1930  FIXME("BITMAP_FORMAT_GIF is not implemented\n");
1931  return E_NOTIMPL;
1932  case BITMAP_FORMAT_PNG:
1933  FIXME("BITMAP_FORMAT_PNG is not implemented\n");
1934  return E_NOTIMPL;
1935  default:
1936  FIXME("PICTYPE_BITMAP/%#x is not implemented\n", This->loadtime_format);
1937  return E_NOTIMPL;
1938  }
1939 
1940  HeapFree(GetProcessHeap(), 0, This->data);
1941  This->data = data;
1942  This->datalen = data_size;
1943  }
1944  hr = IStream_Write(stream, This->data, This->datalen, &written);
1945  if (hr == S_OK && size) *size = written;
1946  return hr;
1947 
1948  case PICTYPE_METAFILE:
1949  FIXME("PICTYPE_METAFILE is not implemented\n");
1950  return E_NOTIMPL;
1951 
1952  case PICTYPE_ENHMETAFILE:
1953  if (!mem_copy) return E_FAIL;
1954 
1955  if (This->bIsDirty || !This->data)
1956  {
1957  if (!serializeEMF(This->desc.u.emf.hemf, &data, &data_size))
1958  return E_FAIL;
1959  HeapFree(GetProcessHeap(), 0, This->data);
1960  This->data = data;
1961  This->datalen = data_size;
1962  }
1963  hr = IStream_Write(stream, This->data, This->datalen, &written);
1964  if (hr == S_OK && size) *size = written;
1965  return hr;
1966 
1967  default:
1968  FIXME("%#x is not implemented\n", This->desc.picType);
1969  break;
1970  }
1971  return E_NOTIMPL;
1972 }
1973 
1974 /************************************************************************
1975  * IDispatch
1976  */
1977 
1978 /************************************************************************
1979  * OLEPictureImpl_IDispatch_QueryInterface (IUnknown)
1980  *
1981  * See Windows documentation for more details on IUnknown methods.
1982  */
1984  IDispatch* iface,
1985  REFIID riid,
1986  VOID** ppvoid)
1987 {
1989 
1990  return IPicture_QueryInterface(&This->IPicture_iface, riid, ppvoid);
1991 }
1992 
1993 /************************************************************************
1994  * OLEPictureImpl_IDispatch_AddRef (IUnknown)
1995  *
1996  * See Windows documentation for more details on IUnknown methods.
1997  */
1999  IDispatch* iface)
2000 {
2002 
2003  return IPicture_AddRef(&This->IPicture_iface);
2004 }
2005 
2006 /************************************************************************
2007  * OLEPictureImpl_IDispatch_Release (IUnknown)
2008  *
2009  * See Windows documentation for more details on IUnknown methods.
2010  */
2012  IDispatch* iface)
2013 {
2015 
2016  return IPicture_Release(&This->IPicture_iface);
2017 }
2018 
2019 /************************************************************************
2020  * OLEPictureImpl_GetTypeInfoCount (IDispatch)
2021  *
2022  * See Windows documentation for more details on IDispatch methods.
2023  */
2025  IDispatch* iface,
2026  unsigned int* pctinfo)
2027 {
2028  TRACE("(%p)\n", pctinfo);
2029 
2030  *pctinfo = 1;
2031 
2032  return S_OK;
2033 }
2034 
2035 /************************************************************************
2036  * OLEPictureImpl_GetTypeInfo (IDispatch)
2037  *
2038  * See Windows documentation for more details on IDispatch methods.
2039  */
2041  IDispatch* iface,
2042  UINT iTInfo,
2043  LCID lcid,
2044  ITypeInfo** ppTInfo)
2045 {
2046  static const WCHAR stdole2tlb[] = {'s','t','d','o','l','e','2','.','t','l','b',0};
2047  ITypeLib *tl;
2048  HRESULT hres;
2049 
2050  TRACE("(iTInfo=%d, lcid=%04x, %p)\n", iTInfo, (int)lcid, ppTInfo);
2051 
2052  if (iTInfo != 0)
2053  return E_FAIL;
2054 
2055  hres = LoadTypeLib(stdole2tlb, &tl);
2056  if (FAILED(hres))
2057  {
2058  ERR("Could not load stdole2.tlb\n");
2059  return hres;
2060  }
2061 
2062  hres = ITypeLib_GetTypeInfoOfGuid(tl, &IID_IPictureDisp, ppTInfo);
2063  if (FAILED(hres))
2064  ERR("Did not get IPictureDisp typeinfo from typelib, hres %x\n", hres);
2065 
2066  return hres;
2067 }
2068 
2069 /************************************************************************
2070  * OLEPictureImpl_GetIDsOfNames (IDispatch)
2071  *
2072  * See Windows documentation for more details on IDispatch methods.
2073  */
2075  IDispatch* iface,
2076  REFIID riid,
2077  LPOLESTR* rgszNames,
2078  UINT cNames,
2079  LCID lcid,
2080  DISPID* rgDispId)
2081 {
2082  ITypeInfo * pTInfo;
2083  HRESULT hres;
2084 
2085  TRACE("(%p,%s,%p,cNames=%d,lcid=%04x,%p)\n", iface, debugstr_guid(riid),
2086  rgszNames, cNames, (int)lcid, rgDispId);
2087 
2088  if (cNames == 0)
2089  {
2090  return E_INVALIDARG;
2091  }
2092  else
2093  {
2094  /* retrieve type information */
2095  hres = OLEPictureImpl_GetTypeInfo(iface, 0, lcid, &pTInfo);
2096 
2097  if (FAILED(hres))
2098  {
2099  ERR("GetTypeInfo failed.\n");
2100  return hres;
2101  }
2102 
2103  /* convert names to DISPIDs */
2104  hres = DispGetIDsOfNames (pTInfo, rgszNames, cNames, rgDispId);
2105  ITypeInfo_Release(pTInfo);
2106 
2107  return hres;
2108  }
2109 }
2110 
2111 /************************************************************************
2112  * OLEPictureImpl_Invoke (IDispatch)
2113  *
2114  * See Windows documentation for more details on IDispatch methods.
2115  */
2117  IDispatch* iface,
2118  DISPID dispIdMember,
2119  REFIID riid,
2120  LCID lcid,
2121  WORD wFlags,
2122  DISPPARAMS* pDispParams,
2123  VARIANT* pVarResult,
2124  EXCEPINFO* pExepInfo,
2125  UINT* puArgErr)
2126 {
2128  HRESULT hr;
2129 
2130  /* validate parameters */
2131 
2132  if (!IsEqualIID(riid, &IID_NULL))
2133  {
2134  ERR("riid was %s instead of IID_NULL\n", debugstr_guid(riid));
2135  return DISP_E_UNKNOWNNAME;
2136  }
2137 
2138  if (!pDispParams)
2139  {
2140  ERR("null pDispParams not allowed\n");
2141  return DISP_E_PARAMNOTOPTIONAL;
2142  }
2143 
2145  {
2146  if (pDispParams->cArgs != 0)
2147  {
2148  ERR("param count for DISPATCH_PROPERTYGET was %d instead of 0\n", pDispParams->cArgs);
2149  return DISP_E_BADPARAMCOUNT;
2150  }
2151  if (!pVarResult)
2152  {
2153  ERR("null pVarResult not allowed when DISPATCH_PROPERTYGET specified\n");
2154  return DISP_E_PARAMNOTOPTIONAL;
2155  }
2156  }
2157  else if (wFlags & DISPATCH_PROPERTYPUT)
2158  {
2159  if (pDispParams->cArgs != 1)
2160  {
2161  ERR("param count for DISPATCH_PROPERTYPUT was %d instead of 1\n", pDispParams->cArgs);
2162  return DISP_E_BADPARAMCOUNT;
2163  }
2164  }
2165 
2166  switch (dispIdMember)
2167  {
2168  case DISPID_PICT_HANDLE:
2170  {
2171  TRACE("DISPID_PICT_HANDLE\n");
2172  V_VT(pVarResult) = VT_I4;
2173  return IPicture_get_Handle(&This->IPicture_iface, &V_UINT(pVarResult));
2174  }
2175  break;
2176  case DISPID_PICT_HPAL:
2178  {
2179  TRACE("DISPID_PICT_HPAL\n");
2180  V_VT(pVarResult) = VT_I4;
2181  return IPicture_get_hPal(&This->IPicture_iface, &V_UINT(pVarResult));
2182  }
2183  else if (wFlags & DISPATCH_PROPERTYPUT)
2184  {
2185  VARIANTARG vararg;
2186 
2187  TRACE("DISPID_PICT_HPAL\n");
2188 
2189  VariantInit(&vararg);
2190  hr = VariantChangeTypeEx(&vararg, &pDispParams->rgvarg[0], lcid, 0, VT_I4);
2191  if (FAILED(hr))
2192  return hr;
2193 
2194  hr = IPicture_set_hPal(&This->IPicture_iface, V_I4(&vararg));
2195 
2196  VariantClear(&vararg);
2197  return hr;
2198  }
2199  break;
2200  case DISPID_PICT_TYPE:
2202  {
2203  TRACE("DISPID_PICT_TYPE\n");
2204  V_VT(pVarResult) = VT_I2;
2205  return OLEPictureImpl_get_Type(&This->IPicture_iface, &V_I2(pVarResult));
2206  }
2207  break;
2208  case DISPID_PICT_WIDTH:
2210  {
2211  TRACE("DISPID_PICT_WIDTH\n");
2212  V_VT(pVarResult) = VT_I4;
2213  return IPicture_get_Width(&This->IPicture_iface, &V_I4(pVarResult));
2214  }
2215  break;
2216  case DISPID_PICT_HEIGHT:
2218  {
2219  TRACE("DISPID_PICT_HEIGHT\n");
2220  V_VT(pVarResult) = VT_I4;
2221  return IPicture_get_Height(&This->IPicture_iface, &V_I4(pVarResult));
2222  }
2223  break;
2224  case DISPID_PICT_RENDER:
2225  if (wFlags & DISPATCH_METHOD)
2226  {
2227  VARIANTARG *args = pDispParams->rgvarg;
2228  int i;
2229 
2230  TRACE("DISPID_PICT_RENDER\n");
2231 
2232  if (pDispParams->cArgs != 10)
2233  return DISP_E_BADPARAMCOUNT;
2234 
2235  /* All parameters are supposed to be VT_I4 (on 64 bits too). */
2236  for (i = 0; i < pDispParams->cArgs; i++)
2237  if (V_VT(&args[i]) != VT_I4)
2238  {
2239  ERR("DISPID_PICT_RENDER: wrong argument type %d:%d\n", i, V_VT(&args[i]));
2240  return DISP_E_TYPEMISMATCH;
2241  }
2242 
2243  /* FIXME: rectangle pointer argument handling seems broken on 64 bits,
2244  currently Render() doesn't use it at all so for now NULL is passed. */
2245  return IPicture_Render(&This->IPicture_iface,
2246  LongToHandle(V_I4(&args[9])),
2247  V_I4(&args[8]),
2248  V_I4(&args[7]),
2249  V_I4(&args[6]),
2250  V_I4(&args[5]),
2251  V_I4(&args[4]),
2252  V_I4(&args[3]),
2253  V_I4(&args[2]),
2254  V_I4(&args[1]),
2255  NULL);
2256  }
2257  break;
2258  }
2259 
2260  ERR("invalid dispid 0x%x or wFlags 0x%x\n", dispIdMember, wFlags);
2261  return DISP_E_MEMBERNOTFOUND;
2262 }
2263 
2264 
2265 static const IPictureVtbl OLEPictureImpl_VTable =
2266 {
2284 };
2285 
2286 static const IDispatchVtbl OLEPictureImpl_IDispatch_VTable =
2287 {
2295 };
2296 
2297 static const IPersistStreamVtbl OLEPictureImpl_IPersistStream_VTable =
2298 {
2307 };
2308 
2309 static const IConnectionPointContainerVtbl OLEPictureImpl_IConnectionPointContainer_VTable =
2310 {
2316 };
2317 
2318 /***********************************************************************
2319  * OleCreatePictureIndirect (OLEAUT32.419)
2320  */
2322  BOOL Own, void **ppvObj )
2323 {
2324  OLEPictureImpl* newPict;
2325  HRESULT hr;
2326 
2327  TRACE("(%p,%s,%d,%p)\n", lpPictDesc, debugstr_guid(riid), Own, ppvObj);
2328 
2329  *ppvObj = NULL;
2330 
2331  hr = OLEPictureImpl_Construct(lpPictDesc, Own, &newPict);
2332  if (hr != S_OK) return hr;
2333 
2334  /*
2335  * Make sure it supports the interface required by the caller.
2336  */
2337  hr = IPicture_QueryInterface(&newPict->IPicture_iface, riid, ppvObj);
2338 
2339  /*
2340  * Release the reference obtained in the constructor. If
2341  * the QueryInterface was unsuccessful, it will free the class.
2342  */
2343  IPicture_Release(&newPict->IPicture_iface);
2344 
2345  return hr;
2346 }
2347 
2348 
2349 /***********************************************************************
2350  * OleLoadPicture (OLEAUT32.418)
2351  */
2352 HRESULT WINAPI OleLoadPicture( LPSTREAM lpstream, LONG lSize, BOOL fRunmode,
2353  REFIID riid, LPVOID *ppvObj )
2354 {
2355  LPPERSISTSTREAM ps;
2356  IPicture *newpic;
2357  HRESULT hr;
2358 
2359  TRACE("(%p,%d,%d,%s,%p), partially implemented.\n",
2360  lpstream, lSize, fRunmode, debugstr_guid(riid), ppvObj);
2361 
2362  hr = OleCreatePictureIndirect(NULL,riid,!fRunmode,(LPVOID*)&newpic);
2363  if (hr != S_OK)
2364  return hr;
2365  hr = IPicture_QueryInterface(newpic,&IID_IPersistStream, (LPVOID*)&ps);
2366  if (hr != S_OK) {
2367  ERR("Could not get IPersistStream iface from Ole Picture?\n");
2368  IPicture_Release(newpic);
2369  *ppvObj = NULL;
2370  return hr;
2371  }
2372  hr = IPersistStream_Load(ps,lpstream);
2373  IPersistStream_Release(ps);
2374  if (FAILED(hr))
2375  {
2376  ERR("IPersistStream_Load failed\n");
2377  IPicture_Release(newpic);
2378  *ppvObj = NULL;
2379  return hr;
2380  }
2381  hr = IPicture_QueryInterface(newpic,riid,ppvObj);
2382  if (hr != S_OK)
2383  ERR("Failed to get interface %s from IPicture.\n",debugstr_guid(riid));
2384  IPicture_Release(newpic);
2385  return hr;
2386 }
2387 
2388 /***********************************************************************
2389  * OleLoadPictureEx (OLEAUT32.401)
2390  */
2391 HRESULT WINAPI OleLoadPictureEx( LPSTREAM lpstream, LONG lSize, BOOL fRunmode,
2392  REFIID riid, DWORD xsiz, DWORD ysiz, DWORD flags, LPVOID *ppvObj )
2393 {
2394  LPPERSISTSTREAM ps;
2395  IPicture *newpic;
2396  HRESULT hr;
2397 
2398  FIXME("(%p,%d,%d,%s,x=%d,y=%d,f=%x,%p), partially implemented.\n",
2399  lpstream, lSize, fRunmode, debugstr_guid(riid), xsiz, ysiz, flags, ppvObj);
2400 
2401  hr = OleCreatePictureIndirect(NULL,riid,!fRunmode,(LPVOID*)&newpic);
2402  if (hr != S_OK)
2403  return hr;
2404  hr = IPicture_QueryInterface(newpic,&IID_IPersistStream, (LPVOID*)&ps);
2405  if (hr != S_OK) {
2406  ERR("Could not get IPersistStream iface from Ole Picture?\n");
2407  IPicture_Release(newpic);
2408  *ppvObj = NULL;
2409  return hr;
2410  }
2411  hr = IPersistStream_Load(ps,lpstream);
2412  IPersistStream_Release(ps);
2413  if (FAILED(hr))
2414  {
2415  ERR("IPersistStream_Load failed\n");
2416  IPicture_Release(newpic);
2417  *ppvObj = NULL;
2418  return hr;
2419  }
2420  hr = IPicture_QueryInterface(newpic,riid,ppvObj);
2421  if (hr != S_OK)
2422  ERR("Failed to get interface %s from IPicture.\n",debugstr_guid(riid));
2423  IPicture_Release(newpic);
2424  return hr;
2425 }
2426 
2428 {
2429  HANDLE hFile;
2430  DWORD dwFileSize;
2431  HGLOBAL hGlobal = NULL;
2432  DWORD dwBytesRead;
2433  HRESULT hr = S_OK;
2434 
2436  if (hFile == INVALID_HANDLE_VALUE)
2437  return HRESULT_FROM_WIN32(GetLastError());
2438 
2441  {
2442  hGlobal = GlobalAlloc(GMEM_FIXED, dwFileSize);
2443  if (!hGlobal)
2444  hr = E_OUTOFMEMORY;
2445  else
2446  {
2447  if (!ReadFile(hFile, hGlobal, dwFileSize, &dwBytesRead, NULL))
2448  {
2449  GlobalFree(hGlobal);
2451  }
2452  }
2453  }
2454 
2455  CloseHandle(hFile);
2456 
2457  if (FAILED(hr)) return hr;
2458 
2459  hr = CreateStreamOnHGlobal(hGlobal, TRUE, stream);
2460  if (FAILED(hr))
2461  GlobalFree(hGlobal);
2462 
2463  return hr;
2464 }
2465 
2466 /***********************************************************************
2467  * OleLoadPictureFile (OLEAUT32.422)
2468  */
2470 {
2471  IStream *stream;
2472  HRESULT hr;
2473 
2474  TRACE("(%s,%p)\n", wine_dbgstr_variant(&filename), picture);
2475 
2476  if (V_VT(&filename) != VT_BSTR)
2477  return CTL_E_FILENOTFOUND;
2478 
2480  if (hr != S_OK)
2481  {
2483  return CTL_E_FILENOTFOUND;
2484 
2486  }
2487 
2488  hr = OleLoadPicture(stream, 0, FALSE, &IID_IDispatch, (void **)picture);
2489  IStream_Release(stream);
2490  return hr;
2491 }
2492 
2493 /***********************************************************************
2494  * OleSavePictureFile (OLEAUT32.423)
2495  */
2497 {
2498  FIXME("(%p %s): stub\n", picture, debugstr_w(filename));
2499  return CTL_E_FILENOTFOUND;
2500 }
2501 
2502 /***********************************************************************
2503  * OleLoadPicturePath (OLEAUT32.424)
2504  */
2506  DWORD dwReserved, OLE_COLOR clrReserved, REFIID riid,
2507  LPVOID *ppvRet )
2508 {
2509  static const WCHAR file[] = { 'f','i','l','e',':',0 };
2510  IStream *stream;
2511  HRESULT hRes;
2512  WCHAR *file_candidate;
2513  WCHAR path_buf[MAX_PATH];
2514 
2515  TRACE("(%s,%p,%d,%08x,%s,%p): stub\n",
2516  debugstr_w(szURLorPath), punkCaller, dwReserved, clrReserved,
2517  debugstr_guid(riid), ppvRet);
2518 
2519  if (!szURLorPath || !ppvRet)
2520  return E_INVALIDARG;
2521 
2522  *ppvRet = NULL;
2523 
2524  /* Convert file URLs to DOS paths. */
2525  if (strncmpW(szURLorPath, file, 5) == 0) {
2526  DWORD size;
2527  hRes = CoInternetParseUrl(szURLorPath, PARSE_PATH_FROM_URL, 0, path_buf,
2528  ARRAY_SIZE(path_buf), &size, 0);
2529  if (FAILED(hRes))
2530  return hRes;
2531 
2532  file_candidate = path_buf;
2533  }
2534  else
2535  file_candidate = szURLorPath;
2536 
2537  /* Handle candidate DOS paths separately. */
2538  if (file_candidate[1] == ':') {
2539  hRes = create_stream(file_candidate, &stream);
2540  if (FAILED(hRes))
2541  return INET_E_RESOURCE_NOT_FOUND;
2542  } else {
2543  IMoniker *pmnk;
2544  IBindCtx *pbc;
2545 
2546  hRes = CreateBindCtx(0, &pbc);
2547  if (SUCCEEDED(hRes))
2548  {
2549  hRes = CreateURLMoniker(NULL, szURLorPath, &pmnk);
2550  if (SUCCEEDED(hRes))
2551  {
2552  hRes = IMoniker_BindToStorage(pmnk, pbc, NULL, &IID_IStream, (LPVOID*)&stream);
2553  IMoniker_Release(pmnk);
2554  }
2555  IBindCtx_Release(pbc);
2556  }
2557  if (FAILED(hRes))
2558  return hRes;
2559  }
2560 
2561  hRes = OleLoadPicture(stream, 0, FALSE, riid, ppvRet);
2562 
2563  IStream_Release(stream);
2564 
2565  return hRes;
2566 }
2567 
2568 /*******************************************************************************
2569  * StdPic ClassFactory
2570  */
2571 typedef struct
2572 {
2573  /* IUnknown fields */
2574  IClassFactory IClassFactory_iface;
2575  LONG ref;
2577 
2579 {
2580  return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
2581 }
2582 
2583 static HRESULT WINAPI
2584 SPCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
2586 
2587  FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
2588  return E_NOINTERFACE;
2589 }
2590 
2591 static ULONG WINAPI
2592 SPCF_AddRef(LPCLASSFACTORY iface) {
2594  return InterlockedIncrement(&This->ref);
2595 }
2596 
2597 static ULONG WINAPI SPCF_Release(LPCLASSFACTORY iface) {
2599  /* static class, won't be freed */
2600  return InterlockedDecrement(&This->ref);
2601 }
2602 
2604  LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj
2605 ) {
2606  /* Creates an uninitialized picture */
2607  return OleCreatePictureIndirect(NULL,riid,TRUE,ppobj);
2608 
2609 }
2610 
2611 static HRESULT WINAPI SPCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
2613  FIXME("(%p)->(%d),stub!\n",This,dolock);
2614  return S_OK;
2615 }
2616 
2617 static const IClassFactoryVtbl SPCF_Vtbl = {
2619  SPCF_AddRef,
2620  SPCF_Release,
2623 };
2625 
#define SRCPAINT
Definition: wingdi.h:333
unsigned int loadtime_magic
Definition: olepicture.c:160
#define CTL_E_FILENOTFOUND
Definition: olectl.h:274
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515
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 ULongToHandle(h)
Definition: basetsd.h:81
#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:655
static HRESULT WINAPI OLEPictureImpl_IDispatch_QueryInterface(IDispatch *iface, REFIID riid, VOID **ppvoid)
Definition: olepicture.c:1983
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:1939
#define DISPATCH_PROPERTYGET
Definition: oleauto.h:1007
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
Definition: id3.c:18
static HRESULT WINAPI OLEPictureImpl_QueryInterface(IPicture *iface, REFIID riid, void **ppvObject)
Definition: olepicture.c:466
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:2624
HRESULT hr
Definition: shlfolder.c:183
#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:834
static HRESULT WINAPI OLEPictureImpl_SelectPicture(IPicture *iface, HDC hdcIn, HDC *phdcOut, OLE_HANDLE *phbmpOut)
Definition: olepicture.c:809
static ULONG WINAPI OLEPictureImpl_IConnectionPointContainer_Release(IConnectionPointContainer *iface)
Definition: olepicture.c:917
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
static ULONG WINAPI OLEPictureImpl_IPersistStream_Release(IPersistStream *iface)
Definition: olepicture.c:989
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 WARN(fmt,...)
Definition: debug.h:111
#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:2597
static HDC
Definition: imagelist.c:92
#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:976
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
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
static HRESULT WINAPI OLEPictureImpl_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: olepicture.c:2040
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:1934
CURSORICONFILEDIRENTRY idEntries[1]
Definition: olepicture.c:108
static HRESULT WINAPI OLEPictureImpl_get_hPal(IPicture *iface, OLE_HANDLE *phandle)
Definition: olepicture.c:566
static void OLEPictureImpl_Destroy(OLEPictureImpl *Obj)
Definition: olepicture.c:387
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:571
static HRESULT WINAPI OLEPictureImpl_Save(IPersistStream *iface, IStream *pStm, BOOL fClearDirty)
Definition: olepicture.c:1765
static HRESULT WINAPI OLEPictureImpl_get_Handle(IPicture *iface, OLE_HANDLE *phandle)
Definition: olepicture.c:529
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:777
static LPOLESTR
Definition: stg_prop.c:27
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:1884
#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:669
#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)
static HRESULT WINAPI OLEPictureImpl_get_Height(IPicture *iface, OLE_YSIZE_HIMETRIC *pheight)
Definition: olepicture.c:615
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 _test_info info[]
Definition: SetCursorPos.c:19
struct tagIClassFactoryImpl IClassFactoryImpl
#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:1347
static HRESULT OLEPictureImpl_LoadIcon(OLEPictureImpl *This, BYTE *xbuf, ULONG xread)
Definition: olepicture.c:1195
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:2074
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:2469
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:445
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
Definition: main.c:440
static HRESULT WINAPI OLEPictureImpl_EnumConnectionPoints(IConnectionPointContainer *iface, IEnumConnectionPoints **ppEnum)
Definition: olepicture.c:925
int WINAPI SetMapMode(_In_ HDC, _In_ int)
static ULONG WINAPI OLEPictureImpl_IDispatch_Release(IDispatch *iface)
Definition: olepicture.c:2011
#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:2617
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
_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
HRESULT WINAPI OleLoadPictureEx(LPSTREAM lpstream, LONG lSize, BOOL fRunmode, REFIID riid, DWORD xsiz, DWORD ysiz, DWORD flags, LPVOID *ppvObj)
Definition: olepicture.c:2391
HRESULT WINAPI OleLoadPicture(LPSTREAM lpstream, LONG lSize, BOOL fRunmode, REFIID riid, LPVOID *ppvObj)
Definition: olepicture.c:2352
smooth NULL
Definition: ftsmooth.c:416
unsigned char
Definition: typeof.h:29
static HRESULT WINAPI OLEPictureImpl_get_Width(IPicture *iface, OLE_XSIZE_HIMETRIC *pwidth)
Definition: olepicture.c:603
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:1538
#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:1019
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:2024
struct OLEPictureImpl OLEPictureImpl
static HRESULT WINAPI OLEPictureImpl_PictureChanged(IPicture *iface)
Definition: olepicture.c:861
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
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:1754
#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
__wchar_t WCHAR
Definition: xmlstorage.h:180
static ULONG WINAPI OLEPictureImpl_IConnectionPointContainer_AddRef(IConnectionPointContainer *iface)
Definition: olepicture.c:909
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:2603
DWORD COLORREF
Definition: windef.h:285
IDispatch IDispatch_iface
Definition: olepicture.c:124
static void render_masked_bitmap(OLEPictureImpl *This, 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, HBITMAP hbmMask, HBITMAP hbmXor)
Definition: olepicture.c:624
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:961
#define MAX_PATH
Definition: compat.h:26
#define RGB(r, g, b)
Definition: wingdi.h:2918
#define WINAPI
Definition: msvc.h:8
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:2116
#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:848
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:2592
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:651
HRESULT WINAPI OleCreatePictureIndirect(LPPICTDESC lpPictDesc, REFIID riid, BOOL Own, void **ppvObj)
Definition: olepicture.c:2321
#define IID_NULL
Definition: guiddef.h:93
#define InterlockedDecrement
Definition: armddk.h:52
Definition: parse.h:22
HDC hdc
Definition: main.c:9
#define GMEM_FIXED
Definition: winbase.h:290
GLuint GLuint stream
Definition: glext.h:7522
#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
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:2496
long OLE_YSIZE_HIMETRIC
Definition: olepro.idl:61
static ULONG WINAPI OLEPictureImpl_AddRef(IPicture *iface)
Definition: olepicture.c:429
#define GENERIC_READ
Definition: compat.h:124
GLenum src
Definition: glext.h:6340
_In_ HANDLE hFile
Definition: mswsock.h:90
#define V_BSTR(A)
Definition: oleauto.h:226
static BOOL serializeIcon(HICON hIcon, void **ppBuffer, unsigned int *pLength)
Definition: olepicture.c:1603
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:3234
_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:508
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:886
static HDC hDC
Definition: 3dtext.c:33
static HRESULT OLEPictureImpl_LoadEnhMetafile(OLEPictureImpl *This, const BYTE *data, ULONG size)
Definition: olepicture.c:1288
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:587
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:2505
#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
HICON hIcon
Definition: msconfig.c:44
SHORT top
Definition: olepicture.c:84
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1991
#define ARRAY_SIZE(a)
Definition: main.h:24
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:2611
#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:873
const GUID IID_IPropertyNotifySink
void _get_STDPIC_CF(LPVOID *ppv)
Definition: olepicture.c:2626
unsigned int loadtime_format
Definition: olepicture.c:161
#define SRCAND
Definition: wingdi.h:329
UINT picType
Definition: olectl.h:140
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define DISP_E_BADPARAMCOUNT
Definition: winerror.h:2523
#define BITMAP_FORMAT_PNG
Definition: olepicture.c:73
#define E_UNEXPECTED
Definition: winerror.h:2456
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:1897
INT Width
Definition: wincodec.idl:238
_Out_opt_ int * cx
Definition: commctrl.h:570
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:797
struct stdole::DISPPARAMS DISPPARAMS
struct tagPICTDESC::@3046::@3048 wmf
static HRESULT OLEPictureImpl_LoadAPM(OLEPictureImpl *This, const BYTE *data, ULONG size)
Definition: olepicture.c:1310
static HRESULT WINAPI OLEPictureImpl_IsDirty(IPersistStream *iface)
Definition: olepicture.c:1011
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:1873
static HRESULT WINAPI OLEPictureImpl_IConnectionPointContainer_QueryInterface(IConnectionPointContainer *iface, REFIID riid, VOID **ppvoid)
Definition: olepicture.c:899
unsigned int ULONG
Definition: retypes.h:1
BOOL WINAPI SetWindowOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:532
static ClassFactoryImpl factory
Definition: ole_server.c:234
#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
static HBITMAP
Definition: button.c:44
const GUID CLSID_StdPicture
static HRESULT OLEPictureImpl_Construct(LPPICTDESC pictDesc, BOOL fOwn, OLEPictureImpl **pict)
Definition: olepicture.c:290
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:465
#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
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:935
LONG cy
Definition: windef.h:320
static HRESULT WINAPI SPCF_QueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj)
Definition: olepicture.c:2584
#define BI_RGB
Definition: precomp.h:35
static HBITMAP hBitmap
Definition: timezone.c:35
#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:1000
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:1938
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:1140
static IClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: olepicture.c:2578
static HRESULT create_stream(const WCHAR *filename, IStream **stream)
Definition: olepicture.c:2427
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:1998
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
Definition: fci.c:126