4 * Implementation of OLE IPicture and related interfaces
6 * Copyright 2000 Huw D M Davies for CodeWeavers.
7 * Copyright 2001 Marcus Meissner
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 * Support PICTYPE_BITMAP and PICTYPE_ICON, altough only bitmaps very well..
26 * Lots of methods are just stubs.
29 * NOTES (or things that msdn doesn't tell you)
31 * The width and height properties are returned in HIMETRIC units (0.01mm)
32 * IPicture::Render also uses these to select a region of the src picture.
33 * A bitmap's size is converted into these units by using the screen resolution
34 * thus an 8x8 bitmap on a 96dpi screen has a size of 212x212 (8/96 * 2540).
47 /* Must be before wine includes, the header has things conflicting with
54 #define NONAMELESSUNION
55 #define NONAMELESSSTRUCT
65 #include "wine/debug.h"
67 #include "wine/wingdi16.h"
68 #include "cursoricon.h"
71 /* This is a hack, so jpeglib.h does not redefine INT32 and the like*/
73 #define UINT8 JPEG_UINT8
74 #define UINT16 JPEG_UINT16
82 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
84 /*************************************************************************
85 * Declaration of implementation class
88 typedef struct OLEPictureImpl
{
91 * IPicture handles IUnknown
94 ICOM_VTABLE(IPicture
) *lpvtbl1
;
95 ICOM_VTABLE(IDispatch
) *lpvtbl2
;
96 ICOM_VTABLE(IPersistStream
) *lpvtbl3
;
97 ICOM_VTABLE(IConnectionPointContainer
) *lpvtbl4
;
99 /* Object referenece count */
102 /* We own the object and must destroy it ourselves */
105 /* Picture description */
108 /* These are the pixel size of a bitmap */
112 /* And these are the size of the picture converted into HIMETRIC units */
113 OLE_XSIZE_HIMETRIC himetricWidth
;
114 OLE_YSIZE_HIMETRIC himetricHeight
;
116 IConnectionPoint
*pCP
;
121 /* Bitmap transparency mask */
131 * Macros to retrieve pointer to IUnknown (IPicture) from the other VTables.
133 #define ICOM_THIS_From_IDispatch(impl, name) \
134 impl *This = (impl*)(((char*)name)-sizeof(void*));
135 #define ICOM_THIS_From_IPersistStream(impl, name) \
136 impl *This = (impl*)(((char*)name)-2*sizeof(void*));
137 #define ICOM_THIS_From_IConnectionPointContainer(impl, name) \
138 impl *This = (impl*)(((char*)name)-3*sizeof(void*));
141 * Predeclare VTables. They get initialized at the end.
143 static ICOM_VTABLE(IPicture
) OLEPictureImpl_VTable
;
144 static ICOM_VTABLE(IDispatch
) OLEPictureImpl_IDispatch_VTable
;
145 static ICOM_VTABLE(IPersistStream
) OLEPictureImpl_IPersistStream_VTable
;
146 static ICOM_VTABLE(IConnectionPointContainer
) OLEPictureImpl_IConnectionPointContainer_VTable
;
148 /***********************************************************************
149 * Implementation of the OLEPictureImpl class.
152 static void OLEPictureImpl_SetBitmap(OLEPictureImpl
*This
) {
156 TRACE("bitmap handle %p\n", This
->desc
.u
.bmp
.hbitmap
);
157 if(GetObjectA(This
->desc
.u
.bmp
.hbitmap
, sizeof(bm
), &bm
) != sizeof(bm
)) {
158 ERR("GetObject fails\n");
161 This
->origWidth
= bm
.bmWidth
;
162 This
->origHeight
= bm
.bmHeight
;
163 /* The width and height are stored in HIMETRIC units (0.01 mm),
164 so we take our pixel width divide by pixels per inch and
165 multiply by 25.4 * 100 */
166 /* Should we use GetBitmapDimension if available? */
167 hdcRef
= CreateCompatibleDC(0);
168 This
->himetricWidth
=(bm
.bmWidth
*2540)/GetDeviceCaps(hdcRef
, LOGPIXELSX
);
169 This
->himetricHeight
=(bm
.bmHeight
*2540)/GetDeviceCaps(hdcRef
, LOGPIXELSY
);
173 /************************************************************************
174 * OLEPictureImpl_Construct
176 * This method will construct a new instance of the OLEPictureImpl
179 * The caller of this method must release the object when it's
182 static OLEPictureImpl
* OLEPictureImpl_Construct(LPPICTDESC pictDesc
, BOOL fOwn
)
184 OLEPictureImpl
* newObject
= 0;
187 TRACE("(%p) type = %d\n", pictDesc
, pictDesc
->picType
);
190 * Allocate space for the object.
192 newObject
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(OLEPictureImpl
));
198 * Initialize the virtual function table.
200 newObject
->lpvtbl1
= &OLEPictureImpl_VTable
;
201 newObject
->lpvtbl2
= &OLEPictureImpl_IDispatch_VTable
;
202 newObject
->lpvtbl3
= &OLEPictureImpl_IPersistStream_VTable
;
203 newObject
->lpvtbl4
= &OLEPictureImpl_IConnectionPointContainer_VTable
;
205 CreateConnectionPoint((IUnknown
*)newObject
,&IID_IPropertyNotifySink
,&newObject
->pCP
);
208 * Start with one reference count. The caller of this function
209 * must release the interface pointer when it is done.
212 newObject
->hDCCur
= 0;
214 newObject
->fOwn
= fOwn
;
216 /* dunno about original value */
217 newObject
->keepOrigFormat
= TRUE
;
219 newObject
->hbmMask
= NULL
;
222 if(pictDesc
->cbSizeofstruct
!= sizeof(PICTDESC
)) {
223 FIXME("struct size = %d\n", pictDesc
->cbSizeofstruct
);
225 memcpy(&newObject
->desc
, pictDesc
, sizeof(PICTDESC
));
228 switch(pictDesc
->picType
) {
230 OLEPictureImpl_SetBitmap(newObject
);
233 case PICTYPE_METAFILE
:
234 TRACE("metafile handle %p\n", pictDesc
->u
.wmf
.hmeta
);
235 newObject
->himetricWidth
= pictDesc
->u
.wmf
.xExt
;
236 newObject
->himetricHeight
= pictDesc
->u
.wmf
.yExt
;
240 /* not sure what to do here */
241 newObject
->himetricWidth
= newObject
->himetricHeight
= 0;
245 case PICTYPE_ENHMETAFILE
:
247 FIXME("Unsupported type %d\n", pictDesc
->picType
);
248 newObject
->himetricWidth
= newObject
->himetricHeight
= 0;
252 newObject
->desc
.picType
= PICTYPE_UNINITIALIZED
;
255 TRACE("returning %p\n", newObject
);
259 /************************************************************************
260 * OLEPictureImpl_Destroy
262 * This method is called by the Release method when the reference
263 * count goes down to 0. It will free all resources used by
265 static void OLEPictureImpl_Destroy(OLEPictureImpl
* Obj
)
267 TRACE("(%p)\n", Obj
);
269 if(Obj
->fOwn
) { /* We need to destroy the picture */
270 switch(Obj
->desc
.picType
) {
272 DeleteObject(Obj
->desc
.u
.bmp
.hbitmap
);
274 case PICTYPE_METAFILE
:
275 DeleteMetaFile(Obj
->desc
.u
.wmf
.hmeta
);
278 DestroyIcon(Obj
->desc
.u
.icon
.hicon
);
280 case PICTYPE_ENHMETAFILE
:
281 DeleteEnhMetaFile(Obj
->desc
.u
.emf
.hemf
);
284 FIXME("Unsupported type %d - unable to delete\n", Obj
->desc
.picType
);
288 if (Obj
->data
) HeapFree(GetProcessHeap(), 0, Obj
->data
);
289 HeapFree(GetProcessHeap(), 0, Obj
);
292 static ULONG WINAPI
OLEPictureImpl_AddRef(IPicture
* iface
);
294 /************************************************************************
295 * OLEPictureImpl_QueryInterface (IUnknown)
297 * See Windows documentation for more details on IUnknown methods.
299 static HRESULT WINAPI
OLEPictureImpl_QueryInterface(
304 ICOM_THIS(OLEPictureImpl
, iface
);
305 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), ppvObject
);
308 * Perform a sanity check on the parameters.
310 if ( (This
==0) || (ppvObject
==0) )
314 * Initialize the return parameter.
319 * Compare the riid with the interface IDs implemented by this object.
321 if (memcmp(&IID_IUnknown
, riid
, sizeof(IID_IUnknown
)) == 0)
323 *ppvObject
= (IPicture
*)This
;
325 else if (memcmp(&IID_IPicture
, riid
, sizeof(IID_IPicture
)) == 0)
327 *ppvObject
= (IPicture
*)This
;
329 else if (memcmp(&IID_IDispatch
, riid
, sizeof(IID_IDispatch
)) == 0)
331 *ppvObject
= (IDispatch
*)&(This
->lpvtbl2
);
333 else if (memcmp(&IID_IPictureDisp
, riid
, sizeof(IID_IPictureDisp
)) == 0)
335 *ppvObject
= (IDispatch
*)&(This
->lpvtbl2
);
337 else if (memcmp(&IID_IPersistStream
, riid
, sizeof(IID_IPersistStream
)) == 0)
339 *ppvObject
= (IPersistStream
*)&(This
->lpvtbl3
);
341 else if (memcmp(&IID_IConnectionPointContainer
, riid
, sizeof(IID_IConnectionPointContainer
)) == 0)
343 *ppvObject
= (IConnectionPointContainer
*)&(This
->lpvtbl4
);
346 * Check that we obtained an interface.
350 FIXME("() : asking for un supported interface %s\n",debugstr_guid(riid
));
351 return E_NOINTERFACE
;
355 * Query Interface always increases the reference count by one when it is
358 OLEPictureImpl_AddRef((IPicture
*)This
);
362 /***********************************************************************
363 * OLEPicture_SendNotify (internal)
365 * Sends notification messages of changed properties to any interested
368 static void OLEPicture_SendNotify(OLEPictureImpl
* this, DISPID dispID
)
370 IEnumConnections
*pEnum
;
373 if (IConnectionPoint_EnumConnections(this->pCP
, &pEnum
))
375 while(IEnumConnections_Next(pEnum
, 1, &CD
, NULL
) == S_OK
) {
376 IPropertyNotifySink
*sink
;
378 IUnknown_QueryInterface(CD
.pUnk
, &IID_IPropertyNotifySink
, (LPVOID
)&sink
);
379 IPropertyNotifySink_OnChanged(sink
, dispID
);
380 IPropertyNotifySink_Release(sink
);
381 IUnknown_Release(CD
.pUnk
);
383 IEnumConnections_Release(pEnum
);
387 /************************************************************************
388 * OLEPictureImpl_AddRef (IUnknown)
390 * See Windows documentation for more details on IUnknown methods.
392 static ULONG WINAPI
OLEPictureImpl_AddRef(
395 ICOM_THIS(OLEPictureImpl
, iface
);
396 TRACE("(%p)->(ref=%ld)\n", This
, This
->ref
);
402 /************************************************************************
403 * OLEPictureImpl_Release (IUnknown)
405 * See Windows documentation for more details on IUnknown methods.
407 static ULONG WINAPI
OLEPictureImpl_Release(
410 ICOM_THIS(OLEPictureImpl
, iface
);
411 TRACE("(%p)->(ref=%ld)\n", This
, This
->ref
);
414 * Decrease the reference count on this object.
419 * If the reference count goes down to 0, perform suicide.
423 OLEPictureImpl_Destroy(This
);
432 /************************************************************************
433 * OLEPictureImpl_get_Handle
435 static HRESULT WINAPI
OLEPictureImpl_get_Handle(IPicture
*iface
,
438 ICOM_THIS(OLEPictureImpl
, iface
);
439 TRACE("(%p)->(%p)\n", This
, phandle
);
440 switch(This
->desc
.picType
) {
442 *phandle
= (OLE_HANDLE
)This
->desc
.u
.bmp
.hbitmap
;
444 case PICTYPE_METAFILE
:
445 *phandle
= (OLE_HANDLE
)This
->desc
.u
.wmf
.hmeta
;
448 *phandle
= (OLE_HANDLE
)This
->desc
.u
.icon
.hicon
;
450 case PICTYPE_ENHMETAFILE
:
451 *phandle
= (OLE_HANDLE
)This
->desc
.u
.emf
.hemf
;
454 FIXME("Unimplemented type %d\n", This
->desc
.picType
);
457 TRACE("returning handle %08x\n", *phandle
);
461 /************************************************************************
462 * OLEPictureImpl_get_hPal
464 static HRESULT WINAPI
OLEPictureImpl_get_hPal(IPicture
*iface
,
467 ICOM_THIS(OLEPictureImpl
, iface
);
468 FIXME("(%p)->(%p): stub\n", This
, phandle
);
472 /************************************************************************
473 * OLEPictureImpl_get_Type
475 static HRESULT WINAPI
OLEPictureImpl_get_Type(IPicture
*iface
,
478 ICOM_THIS(OLEPictureImpl
, iface
);
479 TRACE("(%p)->(%p): type is %d\n", This
, ptype
, This
->desc
.picType
);
480 *ptype
= This
->desc
.picType
;
484 /************************************************************************
485 * OLEPictureImpl_get_Width
487 static HRESULT WINAPI
OLEPictureImpl_get_Width(IPicture
*iface
,
488 OLE_XSIZE_HIMETRIC
*pwidth
)
490 ICOM_THIS(OLEPictureImpl
, iface
);
491 TRACE("(%p)->(%p): width is %ld\n", This
, pwidth
, This
->himetricWidth
);
492 *pwidth
= This
->himetricWidth
;
496 /************************************************************************
497 * OLEPictureImpl_get_Height
499 static HRESULT WINAPI
OLEPictureImpl_get_Height(IPicture
*iface
,
500 OLE_YSIZE_HIMETRIC
*pheight
)
502 ICOM_THIS(OLEPictureImpl
, iface
);
503 TRACE("(%p)->(%p): height is %ld\n", This
, pheight
, This
->himetricHeight
);
504 *pheight
= This
->himetricHeight
;
508 /************************************************************************
509 * OLEPictureImpl_Render
511 static HRESULT WINAPI
OLEPictureImpl_Render(IPicture
*iface
, HDC hdc
,
512 long x
, long y
, long cx
, long cy
,
513 OLE_XPOS_HIMETRIC xSrc
,
514 OLE_YPOS_HIMETRIC ySrc
,
515 OLE_XSIZE_HIMETRIC cxSrc
,
516 OLE_YSIZE_HIMETRIC cySrc
,
519 ICOM_THIS(OLEPictureImpl
, iface
);
520 TRACE("(%p)->(%p, (%ld,%ld), (%ld,%ld) <- (%ld,%ld), (%ld,%ld), %p)\n",
521 This
, hdc
, x
, y
, cx
, cy
, xSrc
, ySrc
, cxSrc
, cySrc
, prcWBounds
);
523 TRACE("prcWBounds (%ld,%ld) - (%ld,%ld)\n", prcWBounds
->left
, prcWBounds
->top
,
524 prcWBounds
->right
, prcWBounds
->bottom
);
527 * While the documentation suggests this to be here (or after rendering?)
528 * it does cause an endless recursion in my sample app. -MM 20010804
529 OLEPicture_SendNotify(This,DISPID_PICT_RENDER);
532 switch(This
->desc
.picType
) {
538 /* Set a mapping mode that maps bitmap pixels into HIMETRIC units.
539 NB y-axis gets flipped */
541 hdcBmp
= CreateCompatibleDC(0);
542 SetMapMode(hdcBmp
, MM_ANISOTROPIC
);
543 SetWindowOrgEx(hdcBmp
, 0, 0, NULL
);
544 SetWindowExtEx(hdcBmp
, This
->himetricWidth
, This
->himetricHeight
, NULL
);
545 SetViewportOrgEx(hdcBmp
, 0, This
->origHeight
, NULL
);
546 SetViewportExtEx(hdcBmp
, This
->origWidth
, -This
->origHeight
, NULL
);
548 hbmpOld
= SelectObject(hdcBmp
, This
->desc
.u
.bmp
.hbitmap
);
551 HDC hdcMask
= CreateCompatibleDC(0);
552 HBITMAP hOldbm
= SelectObject(hdcMask
, This
->hbmMask
);
554 SetMapMode(hdcMask
, MM_ANISOTROPIC
);
555 SetWindowOrgEx(hdcMask
, 0, 0, NULL
);
556 SetWindowExtEx(hdcMask
, This
->himetricWidth
, This
->himetricHeight
, NULL
);
557 SetViewportOrgEx(hdcMask
, 0, This
->origHeight
, NULL
);
558 SetViewportExtEx(hdcMask
, This
->origWidth
, -This
->origHeight
, NULL
);
560 SetBkColor(hdc
, RGB(255, 255, 255));
561 SetTextColor(hdc
, RGB(0, 0, 0));
562 StretchBlt(hdc
, x
, y
, cx
, cy
, hdcMask
, xSrc
, ySrc
, cxSrc
, cySrc
, SRCAND
);
563 StretchBlt(hdc
, x
, y
, cx
, cy
, hdcBmp
, xSrc
, ySrc
, cxSrc
, cySrc
, SRCPAINT
);
565 SelectObject(hdcMask
, hOldbm
);
568 StretchBlt(hdc
, x
, y
, cx
, cy
, hdcBmp
, xSrc
, ySrc
, cxSrc
, cySrc
, SRCCOPY
);
570 SelectObject(hdcBmp
, hbmpOld
);
575 FIXME("Not quite correct implementation of rendering icons...\n");
576 DrawIcon(hdc
,x
,y
,This
->desc
.u
.icon
.hicon
);
579 case PICTYPE_METAFILE
:
580 case PICTYPE_ENHMETAFILE
:
582 FIXME("type %d not implemented\n", This
->desc
.picType
);
588 /************************************************************************
589 * OLEPictureImpl_set_hPal
591 static HRESULT WINAPI
OLEPictureImpl_set_hPal(IPicture
*iface
,
594 ICOM_THIS(OLEPictureImpl
, iface
);
595 FIXME("(%p)->(%08x): stub\n", This
, hpal
);
596 OLEPicture_SendNotify(This
,DISPID_PICT_HPAL
);
600 /************************************************************************
601 * OLEPictureImpl_get_CurDC
603 static HRESULT WINAPI
OLEPictureImpl_get_CurDC(IPicture
*iface
,
606 ICOM_THIS(OLEPictureImpl
, iface
);
607 TRACE("(%p), returning %p\n", This
, This
->hDCCur
);
608 if (phdc
) *phdc
= This
->hDCCur
;
612 /************************************************************************
613 * OLEPictureImpl_SelectPicture
615 static HRESULT WINAPI
OLEPictureImpl_SelectPicture(IPicture
*iface
,
618 OLE_HANDLE
*phbmpOut
)
620 ICOM_THIS(OLEPictureImpl
, iface
);
621 TRACE("(%p)->(%p, %p, %p)\n", This
, hdcIn
, phdcOut
, phbmpOut
);
622 if (This
->desc
.picType
== PICTYPE_BITMAP
) {
623 SelectObject(hdcIn
,This
->desc
.u
.bmp
.hbitmap
);
626 *phdcOut
= This
->hDCCur
;
627 This
->hDCCur
= hdcIn
;
629 *phbmpOut
= (OLE_HANDLE
)This
->desc
.u
.bmp
.hbitmap
;
632 FIXME("Don't know how to select picture type %d\n",This
->desc
.picType
);
637 /************************************************************************
638 * OLEPictureImpl_get_KeepOriginalFormat
640 static HRESULT WINAPI
OLEPictureImpl_get_KeepOriginalFormat(IPicture
*iface
,
643 ICOM_THIS(OLEPictureImpl
, iface
);
644 TRACE("(%p)->(%p)\n", This
, pfKeep
);
647 *pfKeep
= This
->keepOrigFormat
;
651 /************************************************************************
652 * OLEPictureImpl_put_KeepOriginalFormat
654 static HRESULT WINAPI
OLEPictureImpl_put_KeepOriginalFormat(IPicture
*iface
,
657 ICOM_THIS(OLEPictureImpl
, iface
);
658 TRACE("(%p)->(%d)\n", This
, keep
);
659 This
->keepOrigFormat
= keep
;
660 /* FIXME: what DISPID notification here? */
664 /************************************************************************
665 * OLEPictureImpl_PictureChanged
667 static HRESULT WINAPI
OLEPictureImpl_PictureChanged(IPicture
*iface
)
669 ICOM_THIS(OLEPictureImpl
, iface
);
670 TRACE("(%p)->()\n", This
);
671 OLEPicture_SendNotify(This
,DISPID_PICT_HANDLE
);
675 /************************************************************************
676 * OLEPictureImpl_SaveAsFile
678 static HRESULT WINAPI
OLEPictureImpl_SaveAsFile(IPicture
*iface
,
683 ICOM_THIS(OLEPictureImpl
, iface
);
684 FIXME("(%p)->(%p, %d, %p), hacked stub.\n", This
, pstream
, SaveMemCopy
, pcbSize
);
685 return IStream_Write(pstream
,This
->data
,This
->datalen
,(ULONG
*)pcbSize
);
688 /************************************************************************
689 * OLEPictureImpl_get_Attributes
691 static HRESULT WINAPI
OLEPictureImpl_get_Attributes(IPicture
*iface
,
694 ICOM_THIS(OLEPictureImpl
, iface
);
695 TRACE("(%p)->(%p).\n", This
, pdwAttr
);
697 switch (This
->desc
.picType
) {
698 case PICTYPE_BITMAP
: break; /* not 'truely' scalable, see MSDN. */
699 case PICTYPE_ICON
: *pdwAttr
= PICTURE_TRANSPARENT
;break;
700 case PICTYPE_METAFILE
: *pdwAttr
= PICTURE_TRANSPARENT
|PICTURE_SCALABLE
;break;
701 default:FIXME("Unknown pictype %d\n",This
->desc
.picType
);break;
707 /************************************************************************
708 * IConnectionPointContainer
711 static HRESULT WINAPI
OLEPictureImpl_IConnectionPointContainer_QueryInterface(
712 IConnectionPointContainer
* iface
,
716 ICOM_THIS_From_IConnectionPointContainer(IPicture
,iface
);
718 return IPicture_QueryInterface(This
,riid
,ppvoid
);
721 static ULONG WINAPI
OLEPictureImpl_IConnectionPointContainer_AddRef(
722 IConnectionPointContainer
* iface
)
724 ICOM_THIS_From_IConnectionPointContainer(IPicture
, iface
);
726 return IPicture_AddRef(This
);
729 static ULONG WINAPI
OLEPictureImpl_IConnectionPointContainer_Release(
730 IConnectionPointContainer
* iface
)
732 ICOM_THIS_From_IConnectionPointContainer(IPicture
, iface
);
734 return IPicture_Release(This
);
737 static HRESULT WINAPI
OLEPictureImpl_EnumConnectionPoints(
738 IConnectionPointContainer
* iface
,
739 IEnumConnectionPoints
** ppEnum
741 ICOM_THIS_From_IConnectionPointContainer(IPicture
, iface
);
743 FIXME("(%p,%p), stub!\n",This
,ppEnum
);
747 static HRESULT WINAPI
OLEPictureImpl_FindConnectionPoint(
748 IConnectionPointContainer
* iface
,
750 IConnectionPoint
**ppCP
752 ICOM_THIS_From_IConnectionPointContainer(OLEPictureImpl
, iface
);
753 TRACE("(%p,%s,%p)\n",This
,debugstr_guid(riid
),ppCP
);
757 if (IsEqualGUID(riid
,&IID_IPropertyNotifySink
))
758 return IConnectionPoint_QueryInterface(This
->pCP
,&IID_IConnectionPoint
,(LPVOID
)ppCP
);
759 FIXME("tried to find connection point on %s?\n",debugstr_guid(riid
));
762 /************************************************************************
765 /************************************************************************
766 * OLEPictureImpl_IPersistStream_QueryInterface (IUnknown)
768 * See Windows documentation for more details on IUnknown methods.
770 static HRESULT WINAPI
OLEPictureImpl_IPersistStream_QueryInterface(
771 IPersistStream
* iface
,
775 ICOM_THIS_From_IPersistStream(IPicture
, iface
);
777 return IPicture_QueryInterface(This
, riid
, ppvoid
);
780 /************************************************************************
781 * OLEPictureImpl_IPersistStream_AddRef (IUnknown)
783 * See Windows documentation for more details on IUnknown methods.
785 static ULONG WINAPI
OLEPictureImpl_IPersistStream_AddRef(
786 IPersistStream
* iface
)
788 ICOM_THIS_From_IPersistStream(IPicture
, iface
);
790 return IPicture_AddRef(This
);
793 /************************************************************************
794 * OLEPictureImpl_IPersistStream_Release (IUnknown)
796 * See Windows documentation for more details on IUnknown methods.
798 static ULONG WINAPI
OLEPictureImpl_IPersistStream_Release(
799 IPersistStream
* iface
)
801 ICOM_THIS_From_IPersistStream(IPicture
, iface
);
803 return IPicture_Release(This
);
806 /************************************************************************
807 * OLEPictureImpl_IPersistStream_GetClassID
809 static HRESULT WINAPI
OLEPictureImpl_GetClassID(
810 IPersistStream
* iface
,CLSID
* pClassID
)
812 ICOM_THIS_From_IPersistStream(IPicture
, iface
);
813 FIXME("(%p),stub!\n",This
);
817 /************************************************************************
818 * OLEPictureImpl_IPersistStream_IsDirty
820 static HRESULT WINAPI
OLEPictureImpl_IsDirty(
821 IPersistStream
* iface
)
823 ICOM_THIS_From_IPersistStream(IPicture
, iface
);
824 FIXME("(%p),stub!\n",This
);
829 /* for the jpeg decompressor source manager. */
830 static void _jpeg_init_source(j_decompress_ptr cinfo
) { }
832 static boolean
_jpeg_fill_input_buffer(j_decompress_ptr cinfo
) {
833 ERR("(), should not get here.\n");
837 static void _jpeg_skip_input_data(j_decompress_ptr cinfo
,long num_bytes
) {
838 TRACE("Skipping %ld bytes...\n", num_bytes
);
839 cinfo
->src
->next_input_byte
+= num_bytes
;
840 cinfo
->src
->bytes_in_buffer
-= num_bytes
;
843 static boolean
_jpeg_resync_to_restart(j_decompress_ptr cinfo
, int desired
) {
844 ERR("(desired=%d), should not get here.\n",desired
);
847 static void _jpeg_term_source(j_decompress_ptr cinfo
) { }
848 #endif /* HAVE_LIBJPEG */
857 static int _gif_inputfunc(GifFileType
*gif
, GifByteType
*data
, int len
) {
858 struct gifdata
*gd
= (struct gifdata
*)gif
->UserData
;
860 if (len
+gd
->curoff
> gd
->len
) {
861 FIXME("Trying to read %d bytes, but only %d available.\n",len
, gd
->len
-gd
->curoff
);
862 len
= gd
->len
- gd
->curoff
;
864 memcpy(data
, gd
->data
+gd
->curoff
, len
);
870 /************************************************************************
871 * OLEPictureImpl_IPersistStream_Load (IUnknown)
873 * Loads the binary data from the IStream. Starts at current position.
874 * There appears to be an 2 DWORD header:
878 * Currently implemented: BITMAP, ICON, JPEG.
880 static HRESULT WINAPI
OLEPictureImpl_Load(IPersistStream
* iface
,IStream
*pStm
) {
887 ICOM_THIS_From_IPersistStream(OLEPictureImpl
, iface
);
889 TRACE("(%p,%p)\n",This
,pStm
);
891 /* Sometimes we have a header, sometimes we don't. Apply some guesses to find
894 hr
=IStream_Stat(pStm
,&statstg
,STATFLAG_NONAME
);
896 FIXME("Stat failed with hres %lx\n",hr
);
897 hr
=IStream_Read(pStm
,header
,8,&xread
);
898 if (hr
|| xread
!=8) {
899 FIXME("Failure while reading picture header (hr is %lx, nread is %ld).\n",hr
,xread
);
902 if (header
[1] > statstg
.cbSize
.QuadPart
|| (header
[1]==0)) {/* Incorrect header, assume none. */
904 xbuf
= This
->data
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,statstg
.cbSize
.QuadPart
);
905 memcpy(xbuf
,&header
,8);
906 This
->datalen
= statstg
.cbSize
.QuadPart
;
907 while (xread
< This
->datalen
) {
909 hr
= IStream_Read(pStm
,xbuf
+xread
,This
->datalen
-xread
,&nread
);
914 if (xread
!= This
->datalen
)
915 FIXME("Could only read %ld of %d bytes in no-header case?\n",xread
,This
->datalen
);
918 xbuf
= This
->data
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,header
[1]);
919 This
->datalen
= header
[1];
920 while (xread
< header
[1]) {
922 hr
= IStream_Read(pStm
,xbuf
+xread
,header
[1]-xread
,&nread
);
927 if (xread
!= header
[1])
928 FIXME("Could only read %ld of %ld bytes?\n",xread
,header
[1]);
930 magic
= xbuf
[0] + (xbuf
[1]<<8);
932 case 0x4947: { /* GIF */
943 int transparent
= -1;
950 gif
= DGifOpen((void*)&gd
, _gif_inputfunc
);
951 ret
= DGifSlurp(gif
);
952 if (ret
== GIF_ERROR
) {
953 FIXME("Failed reading GIF using libgif.\n");
956 TRACE("screen height %d, width %d\n", gif
->SWidth
, gif
->SHeight
);
957 TRACE("color res %d, backgcolor %d\n", gif
->SColorResolution
, gif
->SBackGroundColor
);
958 TRACE("imgcnt %d\n", gif
->ImageCount
);
959 if (gif
->ImageCount
<1) {
960 FIXME("GIF stream does not have images inside?\n");
963 TRACE("curimage: %d x %d, on %dx%d, interlace %d\n",
964 gif
->Image
.Width
, gif
->Image
.Height
,
965 gif
->Image
.Left
, gif
->Image
.Top
,
969 padding
= (gif
->SWidth
+3) & ~3;
970 bmi
= HeapAlloc(GetProcessHeap(),0,sizeof(BITMAPINFOHEADER
)+(1<<gif
->SColorResolution
)*sizeof(RGBQUAD
));
971 bytes
= HeapAlloc(GetProcessHeap(),0,padding
*gif
->SHeight
);
972 si
= gif
->SavedImages
+0;
973 gid
= &(si
->ImageDesc
);
975 if (!cm
) cm
= gif
->SColorMap
;
977 /* look for the transparent color extension */
978 for (i
= 0; i
< si
->ExtensionBlockCount
; ++i
) {
979 eb
= si
->ExtensionBlocks
+ i
;
980 if (eb
->Function
== 0xF9 && eb
->ByteCount
== 4) {
981 if ((eb
->Bytes
[0] & 1) == 1) {
982 transparent
= eb
->Bytes
[3];
987 for (i
=0;i
<(1<<gif
->SColorResolution
);i
++) {
988 bmi
->bmiColors
[i
].rgbRed
= cm
->Colors
[i
].Red
;
989 bmi
->bmiColors
[i
].rgbGreen
= cm
->Colors
[i
].Green
;
990 bmi
->bmiColors
[i
].rgbBlue
= cm
->Colors
[i
].Blue
;
991 if (i
== transparent
) {
992 This
->rgbTrans
= RGB(bmi
->bmiColors
[i
].rgbRed
,
993 bmi
->bmiColors
[i
].rgbGreen
,
994 bmi
->bmiColors
[i
].rgbBlue
);
998 /* Map to in picture coordinates */
999 for (i
=0;i
<gid
->Height
;i
++)
1000 for (j
=0;j
<gid
->Width
;j
++)
1001 bytes
[(gid
->Top
+i
)*(padding
)+gid
->Left
+j
]=si
->RasterBits
[i
*gid
->Width
+j
];
1003 bmi
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
1004 bmi
->bmiHeader
.biWidth
= gif
->SWidth
;
1005 bmi
->bmiHeader
.biHeight
= -gif
->SHeight
;
1006 bmi
->bmiHeader
.biPlanes
= 1;
1007 bmi
->bmiHeader
.biBitCount
= 8;
1008 bmi
->bmiHeader
.biCompression
= BI_RGB
;
1009 bmi
->bmiHeader
.biSizeImage
= padding
*gif
->SHeight
;
1010 bmi
->bmiHeader
.biXPelsPerMeter
= 0;
1011 bmi
->bmiHeader
.biYPelsPerMeter
= 0;
1012 bmi
->bmiHeader
.biClrUsed
= 1 << gif
->SColorResolution
;
1013 bmi
->bmiHeader
.biClrImportant
= 0;
1016 This
->desc
.u
.bmp
.hbitmap
=CreateDIBitmap(
1025 if (transparent
> -1) {
1026 /* Create the Mask */
1027 HDC hdc
= CreateCompatibleDC(0);
1028 HDC hdcMask
= CreateCompatibleDC(0);
1030 HBITMAP hOldbitmapmask
;
1032 This
->hbmMask
= CreateBitmap(bmi
->bmiHeader
.biWidth
, bmi
->bmiHeader
.biHeight
, 1, 1, NULL
);
1034 hOldbitmap
= SelectObject(hdc
,This
->desc
.u
.bmp
.hbitmap
);
1035 hOldbitmapmask
= SelectObject(hdcMask
, This
->hbmMask
);
1036 SetBkColor(hdc
, This
->rgbTrans
);
1037 BitBlt(hdcMask
, 0, 0, bmi
->bmiHeader
.biWidth
, bmi
->bmiHeader
.biHeight
, hdc
, 0, 0, SRCCOPY
);
1039 /* We no longer need the original bitmap, so we apply the first
1040 transformation with the mask to speed up the rendering */
1041 SetBkColor(hdc
, RGB(0,0,0));
1042 SetTextColor(hdc
, RGB(255,255,255));
1043 BitBlt(hdc
, 0, 0, bmi
->bmiHeader
.biWidth
, bmi
->bmiHeader
.biHeight
,
1044 hdcMask
, 0, 0, SRCAND
);
1046 SelectObject(hdc
, hOldbitmap
);
1047 SelectObject(hdcMask
, hOldbitmapmask
);
1053 This
->desc
.picType
= PICTYPE_BITMAP
;
1054 OLEPictureImpl_SetBitmap(This
);
1056 HeapFree(GetProcessHeap(),0,bytes
);
1059 FIXME("Trying to load GIF, but no support for libgif/libungif compiled in.\n");
1064 case 0xd8ff: { /* JPEG */
1066 struct jpeg_decompress_struct jd
;
1067 struct jpeg_error_mgr jerr
;
1070 JSAMPROW samprow
,oldsamprow
;
1071 BITMAPINFOHEADER bmi
;
1074 struct jpeg_source_mgr xjsm
;
1078 /* This is basically so we can use in-memory data for jpeg decompression.
1079 * We need to have all the functions.
1081 xjsm
.next_input_byte
= xbuf
;
1082 xjsm
.bytes_in_buffer
= xread
;
1083 xjsm
.init_source
= _jpeg_init_source
;
1084 xjsm
.fill_input_buffer
= _jpeg_fill_input_buffer
;
1085 xjsm
.skip_input_data
= _jpeg_skip_input_data
;
1086 xjsm
.resync_to_restart
= _jpeg_resync_to_restart
;
1087 xjsm
.term_source
= _jpeg_term_source
;
1089 jd
.err
= jpeg_std_error(&jerr
);
1090 jpeg_create_decompress(&jd
);
1092 ret
=jpeg_read_header(&jd
,TRUE
);
1093 jd
.out_color_space
= JCS_RGB
;
1094 jpeg_start_decompress(&jd
);
1095 if (ret
!= JPEG_HEADER_OK
) {
1096 ERR("Jpeg image in stream has bad format, read header returned %d.\n",ret
);
1097 HeapFree(GetProcessHeap(),0,xbuf
);
1101 bits
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,
1102 (jd
.output_height
+1) * ((jd
.output_width
*jd
.output_components
+ 3) & ~3) );
1103 samprow
=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,jd
.output_width
*jd
.output_components
);
1106 oldsamprow
= samprow
;
1107 while ( jd
.output_scanline
<jd
.output_height
) {
1108 x
= jpeg_read_scanlines(&jd
,&samprow
,1);
1110 FIXME("failed to read current scanline?\n");
1113 /* We have to convert from RGB to BGR, see MSDN/ BITMAPINFOHEADER */
1114 for(i
=0;i
<jd
.output_width
;i
++,samprow
+=jd
.output_components
) {
1115 *(bits
++) = *(samprow
+2);
1116 *(bits
++) = *(samprow
+1);
1117 *(bits
++) = *(samprow
);
1119 bits
= (LPBYTE
)(((UINT_PTR
)bits
+ 3) & ~3);
1120 samprow
= oldsamprow
;
1124 bmi
.biSize
= sizeof(bmi
);
1125 bmi
.biWidth
= jd
.output_width
;
1126 bmi
.biHeight
= -jd
.output_height
;
1128 bmi
.biBitCount
= jd
.output_components
<<3;
1129 bmi
.biCompression
= BI_RGB
;
1130 bmi
.biSizeImage
= jd
.output_height
*jd
.output_width
*jd
.output_components
;
1131 bmi
.biXPelsPerMeter
= 0;
1132 bmi
.biYPelsPerMeter
= 0;
1134 bmi
.biClrImportant
= 0;
1136 HeapFree(GetProcessHeap(),0,samprow
);
1137 jpeg_finish_decompress(&jd
);
1138 jpeg_destroy_decompress(&jd
);
1140 This
->desc
.u
.bmp
.hbitmap
=CreateDIBitmap(
1149 This
->desc
.picType
= PICTYPE_BITMAP
;
1150 OLEPictureImpl_SetBitmap(This
);
1152 HeapFree(GetProcessHeap(),0,bits
);
1154 ERR("Trying to load JPEG picture, but JPEG supported not compiled in.\n");
1159 case 0x4d42: { /* Bitmap */
1160 BITMAPFILEHEADER
*bfh
= (BITMAPFILEHEADER
*)xbuf
;
1161 BITMAPINFO
*bi
= (BITMAPINFO
*)(bfh
+1);
1164 /* Does not matter whether this is a coreheader or not, we only use
1165 * components which are in both
1168 This
->desc
.u
.bmp
.hbitmap
= CreateDIBitmap(
1172 xbuf
+bfh
->bfOffBits
,
1174 (bi
->bmiHeader
.biBitCount
<=8)?DIB_PAL_COLORS
:DIB_RGB_COLORS
1177 This
->desc
.picType
= PICTYPE_BITMAP
;
1178 OLEPictureImpl_SetBitmap(This
);
1182 case 0x0000: { /* ICON , first word is dwReserved */
1184 CURSORICONFILEDIR
*cifd
= (CURSORICONFILEDIR
*)xbuf
;
1188 FIXME("icon.idReserved=%d\n",cifd->idReserved);
1189 FIXME("icon.idType=%d\n",cifd->idType);
1190 FIXME("icon.idCount=%d\n",cifd->idCount);
1192 for (i=0;i<cifd->idCount;i++) {
1193 FIXME("[%d] width %d\n",i,cifd->idEntries[i].bWidth);
1194 FIXME("[%d] height %d\n",i,cifd->idEntries[i].bHeight);
1195 FIXME("[%d] bColorCount %d\n",i,cifd->idEntries[i].bColorCount);
1196 FIXME("[%d] bReserved %d\n",i,cifd->idEntries[i].bReserved);
1197 FIXME("[%d] xHotspot %d\n",i,cifd->idEntries[i].xHotspot);
1198 FIXME("[%d] yHotspot %d\n",i,cifd->idEntries[i].yHotspot);
1199 FIXME("[%d] dwDIBSize %d\n",i,cifd->idEntries[i].dwDIBSize);
1200 FIXME("[%d] dwDIBOffset %d\n",i,cifd->idEntries[i].dwDIBOffset);
1204 /* If we have more than one icon, try to find the best.
1205 * this currently means '32 pixel wide'.
1207 if (cifd
->idCount
!=1) {
1208 for (i
=0;i
<cifd
->idCount
;i
++) {
1209 if (cifd
->idEntries
[i
].bWidth
== 32)
1212 if (i
==cifd
->idCount
) i
=0;
1215 hicon
= CreateIconFromResourceEx(
1216 xbuf
+cifd
->idEntries
[i
].dwDIBOffset
,
1217 cifd
->idEntries
[i
].dwDIBSize
,
1220 cifd
->idEntries
[i
].bWidth
,
1221 cifd
->idEntries
[i
].bHeight
,
1225 FIXME("CreateIcon failed.\n");
1228 This
->desc
.picType
= PICTYPE_ICON
;
1229 This
->desc
.u
.icon
.hicon
= hicon
;
1230 This
->himetricWidth
= cifd
->idEntries
[i
].bWidth
;
1231 This
->himetricHeight
= cifd
->idEntries
[i
].bHeight
;
1239 FIXME("Unknown magic %04x, %ld read bytes:\n",magic
,xread
);
1241 for (i
=0;i
<xread
+8;i
++) {
1242 if (i
<8) MESSAGE("%02x ",((unsigned char*)&header
)[i
]);
1243 else MESSAGE("%02x ",xbuf
[i
-8]);
1244 if (i
% 10 == 9) MESSAGE("\n");
1251 /* FIXME: this notify is not really documented */
1253 OLEPicture_SendNotify(This
,DISPID_PICT_TYPE
);
1257 static HRESULT WINAPI
OLEPictureImpl_Save(
1258 IPersistStream
* iface
,IStream
*pStm
,BOOL fClearDirty
)
1260 ICOM_THIS_From_IPersistStream(IPicture
, iface
);
1261 FIXME("(%p,%p,%d),stub!\n",This
,pStm
,fClearDirty
);
1265 static HRESULT WINAPI
OLEPictureImpl_GetSizeMax(
1266 IPersistStream
* iface
,ULARGE_INTEGER
*pcbSize
)
1268 ICOM_THIS_From_IPersistStream(IPicture
, iface
);
1269 FIXME("(%p,%p),stub!\n",This
,pcbSize
);
1273 /************************************************************************
1276 /************************************************************************
1277 * OLEPictureImpl_IDispatch_QueryInterface (IUnknown)
1279 * See Windows documentation for more details on IUnknown methods.
1281 static HRESULT WINAPI
OLEPictureImpl_IDispatch_QueryInterface(
1286 ICOM_THIS_From_IDispatch(IPicture
, iface
);
1288 return IPicture_QueryInterface(This
, riid
, ppvoid
);
1291 /************************************************************************
1292 * OLEPictureImpl_IDispatch_AddRef (IUnknown)
1294 * See Windows documentation for more details on IUnknown methods.
1296 static ULONG WINAPI
OLEPictureImpl_IDispatch_AddRef(
1299 ICOM_THIS_From_IDispatch(IPicture
, iface
);
1301 return IPicture_AddRef(This
);
1304 /************************************************************************
1305 * OLEPictureImpl_IDispatch_Release (IUnknown)
1307 * See Windows documentation for more details on IUnknown methods.
1309 static ULONG WINAPI
OLEPictureImpl_IDispatch_Release(
1312 ICOM_THIS_From_IDispatch(IPicture
, iface
);
1314 return IPicture_Release(This
);
1317 /************************************************************************
1318 * OLEPictureImpl_GetTypeInfoCount (IDispatch)
1320 * See Windows documentation for more details on IDispatch methods.
1322 static HRESULT WINAPI
OLEPictureImpl_GetTypeInfoCount(
1324 unsigned int* pctinfo
)
1331 /************************************************************************
1332 * OLEPictureImpl_GetTypeInfo (IDispatch)
1334 * See Windows documentation for more details on IDispatch methods.
1336 static HRESULT WINAPI
OLEPictureImpl_GetTypeInfo(
1340 ITypeInfo
** ppTInfo
)
1347 /************************************************************************
1348 * OLEPictureImpl_GetIDsOfNames (IDispatch)
1350 * See Windows documentation for more details on IDispatch methods.
1352 static HRESULT WINAPI
OLEPictureImpl_GetIDsOfNames(
1355 LPOLESTR
* rgszNames
,
1365 /************************************************************************
1366 * OLEPictureImpl_Invoke (IDispatch)
1368 * See Windows documentation for more details on IDispatch methods.
1370 static HRESULT WINAPI
OLEPictureImpl_Invoke(
1372 DISPID dispIdMember
,
1376 DISPPARAMS
* pDispParams
,
1377 VARIANT
* pVarResult
,
1378 EXCEPINFO
* pExepInfo
,
1381 FIXME("(dispid: %ld):Stub\n",dispIdMember
);
1383 VariantInit(pVarResult
);
1384 V_VT(pVarResult
) = VT_BOOL
;
1385 V_UNION(pVarResult
,boolVal
) = FALSE
;
1390 static ICOM_VTABLE(IPicture
) OLEPictureImpl_VTable
=
1392 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1393 OLEPictureImpl_QueryInterface
,
1394 OLEPictureImpl_AddRef
,
1395 OLEPictureImpl_Release
,
1396 OLEPictureImpl_get_Handle
,
1397 OLEPictureImpl_get_hPal
,
1398 OLEPictureImpl_get_Type
,
1399 OLEPictureImpl_get_Width
,
1400 OLEPictureImpl_get_Height
,
1401 OLEPictureImpl_Render
,
1402 OLEPictureImpl_set_hPal
,
1403 OLEPictureImpl_get_CurDC
,
1404 OLEPictureImpl_SelectPicture
,
1405 OLEPictureImpl_get_KeepOriginalFormat
,
1406 OLEPictureImpl_put_KeepOriginalFormat
,
1407 OLEPictureImpl_PictureChanged
,
1408 OLEPictureImpl_SaveAsFile
,
1409 OLEPictureImpl_get_Attributes
1412 static ICOM_VTABLE(IDispatch
) OLEPictureImpl_IDispatch_VTable
=
1414 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1415 OLEPictureImpl_IDispatch_QueryInterface
,
1416 OLEPictureImpl_IDispatch_AddRef
,
1417 OLEPictureImpl_IDispatch_Release
,
1418 OLEPictureImpl_GetTypeInfoCount
,
1419 OLEPictureImpl_GetTypeInfo
,
1420 OLEPictureImpl_GetIDsOfNames
,
1421 OLEPictureImpl_Invoke
1424 static ICOM_VTABLE(IPersistStream
) OLEPictureImpl_IPersistStream_VTable
=
1426 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1427 OLEPictureImpl_IPersistStream_QueryInterface
,
1428 OLEPictureImpl_IPersistStream_AddRef
,
1429 OLEPictureImpl_IPersistStream_Release
,
1430 OLEPictureImpl_GetClassID
,
1431 OLEPictureImpl_IsDirty
,
1432 OLEPictureImpl_Load
,
1433 OLEPictureImpl_Save
,
1434 OLEPictureImpl_GetSizeMax
1437 static ICOM_VTABLE(IConnectionPointContainer
) OLEPictureImpl_IConnectionPointContainer_VTable
=
1439 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1440 OLEPictureImpl_IConnectionPointContainer_QueryInterface
,
1441 OLEPictureImpl_IConnectionPointContainer_AddRef
,
1442 OLEPictureImpl_IConnectionPointContainer_Release
,
1443 OLEPictureImpl_EnumConnectionPoints
,
1444 OLEPictureImpl_FindConnectionPoint
1447 /***********************************************************************
1448 * OleCreatePictureIndirect (OLEAUT32.419)
1450 HRESULT WINAPI
OleCreatePictureIndirect(LPPICTDESC lpPictDesc
, REFIID riid
,
1451 BOOL fOwn
, LPVOID
*ppvObj
)
1453 OLEPictureImpl
* newPict
= NULL
;
1456 TRACE("(%p,%p,%d,%p)\n", lpPictDesc
, riid
, fOwn
, ppvObj
);
1467 * Try to construct a new instance of the class.
1469 newPict
= OLEPictureImpl_Construct(lpPictDesc
, fOwn
);
1471 if (newPict
== NULL
)
1472 return E_OUTOFMEMORY
;
1475 * Make sure it supports the interface required by the caller.
1477 hr
= IPicture_QueryInterface((IPicture
*)newPict
, riid
, ppvObj
);
1480 * Release the reference obtained in the constructor. If
1481 * the QueryInterface was unsuccessful, it will free the class.
1483 IPicture_Release((IPicture
*)newPict
);
1489 /***********************************************************************
1490 * OleLoadPicture (OLEAUT32.418)
1492 HRESULT WINAPI
OleLoadPicture( LPSTREAM lpstream
, LONG lSize
, BOOL fRunmode
,
1493 REFIID riid
, LPVOID
*ppvObj
)
1499 TRACE("(%p,%ld,%d,%s,%p), partially implemented.\n",
1500 lpstream
, lSize
, fRunmode
, debugstr_guid(riid
), ppvObj
);
1502 hr
= OleCreatePictureIndirect(NULL
,riid
,!fRunmode
,(LPVOID
*)&newpic
);
1505 hr
= IPicture_QueryInterface(newpic
,&IID_IPersistStream
, (LPVOID
*)&ps
);
1507 FIXME("Could not get IPersistStream iface from Ole Picture?\n");
1508 IPicture_Release(newpic
);
1512 IPersistStream_Load(ps
,lpstream
);
1513 IPersistStream_Release(ps
);
1514 hr
= IPicture_QueryInterface(newpic
,riid
,ppvObj
);
1516 FIXME("Failed to get interface %s from IPicture.\n",debugstr_guid(riid
));
1517 IPicture_Release(newpic
);
1521 /***********************************************************************
1522 * OleLoadPictureEx (OLEAUT32.401)
1524 HRESULT WINAPI
OleLoadPictureEx( LPSTREAM lpstream
, LONG lSize
, BOOL fRunmode
,
1525 REFIID riid
, DWORD xsiz
, DWORD ysiz
, DWORD flags
, LPVOID
*ppvObj
)
1531 FIXME("(%p,%ld,%d,%s,x=%ld,y=%ld,f=%lx,%p), partially implemented.\n",
1532 lpstream
, lSize
, fRunmode
, debugstr_guid(riid
), xsiz
, ysiz
, flags
, ppvObj
);
1534 hr
= OleCreatePictureIndirect(NULL
,riid
,!fRunmode
,(LPVOID
*)&newpic
);
1537 hr
= IPicture_QueryInterface(newpic
,&IID_IPersistStream
, (LPVOID
*)&ps
);
1539 FIXME("Could not get IPersistStream iface from Ole Picture?\n");
1540 IPicture_Release(newpic
);
1544 IPersistStream_Load(ps
,lpstream
);
1545 IPersistStream_Release(ps
);
1546 hr
= IPicture_QueryInterface(newpic
,riid
,ppvObj
);
1548 FIXME("Failed to get interface %s from IPicture.\n",debugstr_guid(riid
));
1549 IPicture_Release(newpic
);
1553 /*******************************************************************************
1554 * StdPic ClassFactory
1558 /* IUnknown fields */
1559 ICOM_VFIELD(IClassFactory
);
1561 } IClassFactoryImpl
;
1563 static HRESULT WINAPI
1564 SPCF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
) {
1565 ICOM_THIS(IClassFactoryImpl
,iface
);
1567 FIXME("(%p)->(%s,%p),stub!\n",This
,debugstr_guid(riid
),ppobj
);
1568 return E_NOINTERFACE
;
1572 SPCF_AddRef(LPCLASSFACTORY iface
) {
1573 ICOM_THIS(IClassFactoryImpl
,iface
);
1574 return ++(This
->ref
);
1577 static ULONG WINAPI
SPCF_Release(LPCLASSFACTORY iface
) {
1578 ICOM_THIS(IClassFactoryImpl
,iface
);
1579 /* static class, won't be freed */
1580 return --(This
->ref
);
1583 static HRESULT WINAPI
SPCF_CreateInstance(
1584 LPCLASSFACTORY iface
,LPUNKNOWN pOuter
,REFIID riid
,LPVOID
*ppobj
1588 FIXME("(%p,%p,%s,%p), creating stdpic with PICTYPE_NONE.\n",iface
,pOuter
,debugstr_guid(riid
),ppobj
);
1589 pd
.cbSizeofstruct
= sizeof(pd
);
1590 pd
.picType
= PICTYPE_NONE
;
1591 return OleCreatePictureIndirect(&pd
,riid
,TRUE
,ppobj
);
1595 static HRESULT WINAPI
SPCF_LockServer(LPCLASSFACTORY iface
,BOOL dolock
) {
1596 ICOM_THIS(IClassFactoryImpl
,iface
);
1597 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
1601 static ICOM_VTABLE(IClassFactory
) SPCF_Vtbl
= {
1602 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1603 SPCF_QueryInterface
,
1606 SPCF_CreateInstance
,
1609 static IClassFactoryImpl STDPIC_CF
= {&SPCF_Vtbl
, 1 };
1611 void _get_STDPIC_CF(LPVOID
*ppv
) { *ppv
= (LPVOID
)&STDPIC_CF
; }