wbemprox: Implement IEnumWbemClassObject::Clone.
[wine] / dlls / windowscodecs / imgfactory.c
1 /*
2  * Copyright 2009 Vincent Povirk for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "config.h"
20
21 #include <stdarg.h>
22
23 #define COBJMACROS
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winreg.h"
28 #include "objbase.h"
29 #include "shellapi.h"
30 #include "wincodec.h"
31 #include "wincodecsdk.h"
32
33 #include "wincodecs_private.h"
34
35 #include "wine/debug.h"
36
37 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
38
39 typedef struct {
40     IWICComponentFactory IWICComponentFactory_iface;
41     LONG ref;
42 } ComponentFactory;
43
44 static inline ComponentFactory *impl_from_IWICComponentFactory(IWICComponentFactory *iface)
45 {
46     return CONTAINING_RECORD(iface, ComponentFactory, IWICComponentFactory_iface);
47 }
48
49 static HRESULT WINAPI ComponentFactory_QueryInterface(IWICComponentFactory *iface, REFIID iid,
50     void **ppv)
51 {
52     ComponentFactory *This = impl_from_IWICComponentFactory(iface);
53     TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
54
55     if (!ppv) return E_INVALIDARG;
56
57     if (IsEqualIID(&IID_IUnknown, iid) ||
58         IsEqualIID(&IID_IWICImagingFactory, iid) ||
59         IsEqualIID(&IID_IWICComponentFactory, iid))
60     {
61         *ppv = This;
62     }
63     else
64     {
65         *ppv = NULL;
66         return E_NOINTERFACE;
67     }
68
69     IUnknown_AddRef((IUnknown*)*ppv);
70     return S_OK;
71 }
72
73 static ULONG WINAPI ComponentFactory_AddRef(IWICComponentFactory *iface)
74 {
75     ComponentFactory *This = impl_from_IWICComponentFactory(iface);
76     ULONG ref = InterlockedIncrement(&This->ref);
77
78     TRACE("(%p) refcount=%u\n", iface, ref);
79
80     return ref;
81 }
82
83 static ULONG WINAPI ComponentFactory_Release(IWICComponentFactory *iface)
84 {
85     ComponentFactory *This = impl_from_IWICComponentFactory(iface);
86     ULONG ref = InterlockedDecrement(&This->ref);
87
88     TRACE("(%p) refcount=%u\n", iface, ref);
89
90     if (ref == 0)
91         HeapFree(GetProcessHeap(), 0, This);
92
93     return ref;
94 }
95
96 static HRESULT WINAPI ComponentFactory_CreateDecoderFromFilename(
97     IWICComponentFactory *iface, LPCWSTR wzFilename, const GUID *pguidVendor,
98     DWORD dwDesiredAccess, WICDecodeOptions metadataOptions,
99     IWICBitmapDecoder **ppIDecoder)
100 {
101     IWICStream *stream;
102     HRESULT hr;
103
104     TRACE("(%p,%s,%s,%u,%u,%p)\n", iface, debugstr_w(wzFilename),
105         debugstr_guid(pguidVendor), dwDesiredAccess, metadataOptions, ppIDecoder);
106
107     hr = StreamImpl_Create(&stream);
108     if (SUCCEEDED(hr))
109     {
110         hr = IWICStream_InitializeFromFilename(stream, wzFilename, dwDesiredAccess);
111
112         if (SUCCEEDED(hr))
113         {
114             hr = IWICComponentFactory_CreateDecoderFromStream(iface, (IStream*)stream,
115                 pguidVendor, metadataOptions, ppIDecoder);
116         }
117
118         IWICStream_Release(stream);
119     }
120
121     return hr;
122 }
123
124 static HRESULT WINAPI ComponentFactory_CreateDecoderFromStream(
125     IWICComponentFactory *iface, IStream *pIStream, const GUID *pguidVendor,
126     WICDecodeOptions metadataOptions, IWICBitmapDecoder **ppIDecoder)
127 {
128     IEnumUnknown *enumdecoders;
129     IUnknown *unkdecoderinfo;
130     IWICBitmapDecoderInfo *decoderinfo;
131     IWICBitmapDecoder *decoder = NULL, *preferred_decoder = NULL;
132     GUID vendor;
133     HRESULT res=S_OK;
134     ULONG num_fetched;
135     BOOL matches;
136
137     TRACE("(%p,%p,%s,%u,%p)\n", iface, pIStream, debugstr_guid(pguidVendor),
138         metadataOptions, ppIDecoder);
139
140     res = CreateComponentEnumerator(WICDecoder, WICComponentEnumerateDefault, &enumdecoders);
141     if (FAILED(res)) return res;
142
143     while (!preferred_decoder)
144     {
145         res = IEnumUnknown_Next(enumdecoders, 1, &unkdecoderinfo, &num_fetched);
146
147         if (res == S_OK)
148         {
149             res = IUnknown_QueryInterface(unkdecoderinfo, &IID_IWICBitmapDecoderInfo, (void**)&decoderinfo);
150
151             if (SUCCEEDED(res))
152             {
153                 res = IWICBitmapDecoderInfo_MatchesPattern(decoderinfo, pIStream, &matches);
154
155                 if (SUCCEEDED(res) && matches)
156                 {
157                     IWICBitmapDecoder *new_decoder;
158
159                     res = IWICBitmapDecoderInfo_CreateInstance(decoderinfo, &new_decoder);
160
161                     /* FIXME: should use QueryCapability to choose a decoder */
162
163                     if (SUCCEEDED(res))
164                     {
165                         res = IWICBitmapDecoder_Initialize(new_decoder, pIStream, metadataOptions);
166
167                         if (SUCCEEDED(res))
168                         {
169                             if (pguidVendor)
170                             {
171                                 res = IWICBitmapDecoderInfo_GetVendorGUID(decoderinfo, &vendor);
172                                 if (SUCCEEDED(res) && IsEqualIID(&vendor, pguidVendor))
173                                 {
174                                     preferred_decoder = new_decoder;
175                                     new_decoder = NULL;
176                                 }
177                             }
178
179                             if (new_decoder && !decoder)
180                             {
181                                 decoder = new_decoder;
182                                 new_decoder = NULL;
183                             }
184                         }
185
186                         if (new_decoder) IWICBitmapDecoder_Release(new_decoder);
187                     }
188                 }
189
190                 IWICBitmapDecoderInfo_Release(decoderinfo);
191             }
192
193             IUnknown_Release(unkdecoderinfo);
194         }
195         else
196             break;
197     }
198
199     IEnumUnknown_Release(enumdecoders);
200
201     if (preferred_decoder)
202     {
203         *ppIDecoder = preferred_decoder;
204         if (decoder) IWICBitmapDecoder_Release(decoder);
205         return S_OK;
206     }
207
208     if (decoder)
209     {
210         *ppIDecoder = decoder;
211         return S_OK;
212     }
213     else
214     {
215         if (WARN_ON(wincodecs))
216         {
217             LARGE_INTEGER seek;
218             BYTE data[4];
219             ULONG bytesread;
220
221             WARN("failed to load from a stream\n");
222
223             seek.QuadPart = 0;
224             res = IStream_Seek(pIStream, seek, STREAM_SEEK_SET, NULL);
225             if (SUCCEEDED(res))
226                 res = IStream_Read(pIStream, data, 4, &bytesread);
227             if (SUCCEEDED(res))
228                 WARN("first %i bytes of stream=%x %x %x %x\n", bytesread, data[0], data[1], data[2], data[3]);
229         }
230         *ppIDecoder = NULL;
231         return WINCODEC_ERR_COMPONENTNOTFOUND;
232     }
233 }
234
235 static HRESULT WINAPI ComponentFactory_CreateDecoderFromFileHandle(
236     IWICComponentFactory *iface, ULONG_PTR hFile, const GUID *pguidVendor,
237     WICDecodeOptions metadataOptions, IWICBitmapDecoder **ppIDecoder)
238 {
239     FIXME("(%p,%lx,%s,%u,%p): stub\n", iface, hFile, debugstr_guid(pguidVendor),
240         metadataOptions, ppIDecoder);
241     return E_NOTIMPL;
242 }
243
244 static HRESULT WINAPI ComponentFactory_CreateComponentInfo(IWICComponentFactory *iface,
245     REFCLSID clsidComponent, IWICComponentInfo **ppIInfo)
246 {
247     TRACE("(%p,%s,%p)\n", iface, debugstr_guid(clsidComponent), ppIInfo);
248     return CreateComponentInfo(clsidComponent, ppIInfo);
249 }
250
251 static HRESULT WINAPI ComponentFactory_CreateDecoder(IWICComponentFactory *iface,
252     REFGUID guidContainerFormat, const GUID *pguidVendor,
253     IWICBitmapDecoder **ppIDecoder)
254 {
255     IEnumUnknown *enumdecoders;
256     IUnknown *unkdecoderinfo;
257     IWICBitmapDecoderInfo *decoderinfo;
258     IWICBitmapDecoder *decoder = NULL, *preferred_decoder = NULL;
259     GUID vendor;
260     HRESULT res;
261     ULONG num_fetched;
262
263     TRACE("(%p,%s,%s,%p)\n", iface, debugstr_guid(guidContainerFormat),
264         debugstr_guid(pguidVendor), ppIDecoder);
265
266     if (!guidContainerFormat || !ppIDecoder) return E_INVALIDARG;
267
268     res = CreateComponentEnumerator(WICDecoder, WICComponentEnumerateDefault, &enumdecoders);
269     if (FAILED(res)) return res;
270
271     while (!preferred_decoder)
272     {
273         res = IEnumUnknown_Next(enumdecoders, 1, &unkdecoderinfo, &num_fetched);
274         if (res != S_OK) break;
275
276         res = IUnknown_QueryInterface(unkdecoderinfo, &IID_IWICBitmapDecoderInfo, (void **)&decoderinfo);
277         if (SUCCEEDED(res))
278         {
279             GUID container_guid;
280
281             res = IWICBitmapDecoderInfo_GetContainerFormat(decoderinfo, &container_guid);
282             if (SUCCEEDED(res) && IsEqualIID(&container_guid, guidContainerFormat))
283             {
284                 IWICBitmapDecoder *new_decoder;
285
286                 res = IWICBitmapDecoderInfo_CreateInstance(decoderinfo, &new_decoder);
287                 if (SUCCEEDED(res))
288                 {
289                     if (pguidVendor)
290                     {
291                         res = IWICBitmapDecoderInfo_GetVendorGUID(decoderinfo, &vendor);
292                         if (SUCCEEDED(res) && IsEqualIID(&vendor, pguidVendor))
293                         {
294                             preferred_decoder = new_decoder;
295                             new_decoder = NULL;
296                         }
297                     }
298
299                     if (new_decoder && !decoder)
300                     {
301                         decoder = new_decoder;
302                         new_decoder = NULL;
303                     }
304
305                     if (new_decoder) IWICBitmapDecoder_Release(new_decoder);
306                 }
307             }
308
309             IWICBitmapDecoderInfo_Release(decoderinfo);
310         }
311
312         IUnknown_Release(unkdecoderinfo);
313     }
314
315     IEnumUnknown_Release(enumdecoders);
316
317     if (preferred_decoder)
318     {
319         *ppIDecoder = preferred_decoder;
320         if (decoder) IWICBitmapDecoder_Release(decoder);
321         return S_OK;
322     }
323
324     if (decoder)
325     {
326         *ppIDecoder = decoder;
327         return S_OK;
328     }
329
330     *ppIDecoder = NULL;
331     return WINCODEC_ERR_COMPONENTNOTFOUND;
332 }
333
334 static HRESULT WINAPI ComponentFactory_CreateEncoder(IWICComponentFactory *iface,
335     REFGUID guidContainerFormat, const GUID *pguidVendor,
336     IWICBitmapEncoder **ppIEncoder)
337 {
338     static int fixme=0;
339     IEnumUnknown *enumencoders;
340     IUnknown *unkencoderinfo;
341     IWICBitmapEncoderInfo *encoderinfo;
342     IWICBitmapEncoder *encoder=NULL;
343     HRESULT res=S_OK;
344     ULONG num_fetched;
345     GUID actual_containerformat;
346
347     TRACE("(%p,%s,%s,%p)\n", iface, debugstr_guid(guidContainerFormat),
348         debugstr_guid(pguidVendor), ppIEncoder);
349
350     if (pguidVendor && !fixme++)
351         FIXME("ignoring vendor GUID\n");
352
353     res = CreateComponentEnumerator(WICEncoder, WICComponentEnumerateDefault, &enumencoders);
354     if (FAILED(res)) return res;
355
356     while (!encoder)
357     {
358         res = IEnumUnknown_Next(enumencoders, 1, &unkencoderinfo, &num_fetched);
359
360         if (res == S_OK)
361         {
362             res = IUnknown_QueryInterface(unkencoderinfo, &IID_IWICBitmapEncoderInfo, (void**)&encoderinfo);
363
364             if (SUCCEEDED(res))
365             {
366                 res = IWICBitmapEncoderInfo_GetContainerFormat(encoderinfo, &actual_containerformat);
367
368                 if (SUCCEEDED(res) && IsEqualGUID(guidContainerFormat, &actual_containerformat))
369                 {
370                     res = IWICBitmapEncoderInfo_CreateInstance(encoderinfo, &encoder);
371                     if (FAILED(res))
372                         encoder = NULL;
373                 }
374
375                 IWICBitmapEncoderInfo_Release(encoderinfo);
376             }
377
378             IUnknown_Release(unkencoderinfo);
379         }
380         else
381             break;
382     }
383
384     IEnumUnknown_Release(enumencoders);
385
386     if (encoder)
387     {
388         *ppIEncoder = encoder;
389         return S_OK;
390     }
391     else
392     {
393         WARN("failed to create encoder\n");
394         *ppIEncoder = NULL;
395         return WINCODEC_ERR_COMPONENTNOTFOUND;
396     }
397 }
398
399 static HRESULT WINAPI ComponentFactory_CreatePalette(IWICComponentFactory *iface,
400     IWICPalette **ppIPalette)
401 {
402     TRACE("(%p,%p)\n", iface, ppIPalette);
403     return PaletteImpl_Create(ppIPalette);
404 }
405
406 static HRESULT WINAPI ComponentFactory_CreateFormatConverter(IWICComponentFactory *iface,
407     IWICFormatConverter **ppIFormatConverter)
408 {
409     return FormatConverter_CreateInstance(NULL, &IID_IWICFormatConverter, (void**)ppIFormatConverter);
410 }
411
412 static HRESULT WINAPI ComponentFactory_CreateBitmapScaler(IWICComponentFactory *iface,
413     IWICBitmapScaler **ppIBitmapScaler)
414 {
415     TRACE("(%p,%p)\n", iface, ppIBitmapScaler);
416
417     return BitmapScaler_Create(ppIBitmapScaler);
418 }
419
420 static HRESULT WINAPI ComponentFactory_CreateBitmapClipper(IWICComponentFactory *iface,
421     IWICBitmapClipper **ppIBitmapClipper)
422 {
423     FIXME("(%p,%p): stub\n", iface, ppIBitmapClipper);
424     return E_NOTIMPL;
425 }
426
427 static HRESULT WINAPI ComponentFactory_CreateBitmapFlipRotator(IWICComponentFactory *iface,
428     IWICBitmapFlipRotator **ppIBitmapFlipRotator)
429 {
430     TRACE("(%p,%p)\n", iface, ppIBitmapFlipRotator);
431     return FlipRotator_Create(ppIBitmapFlipRotator);
432 }
433
434 static HRESULT WINAPI ComponentFactory_CreateStream(IWICComponentFactory *iface,
435     IWICStream **ppIWICStream)
436 {
437     TRACE("(%p,%p)\n", iface, ppIWICStream);
438     return StreamImpl_Create(ppIWICStream);
439 }
440
441 static HRESULT WINAPI ComponentFactory_CreateColorContext(IWICComponentFactory *iface,
442     IWICColorContext **ppIColorContext)
443 {
444     FIXME("(%p,%p): stub\n", iface, ppIColorContext);
445     return E_NOTIMPL;
446 }
447
448 static HRESULT WINAPI ComponentFactory_CreateColorTransformer(IWICComponentFactory *iface,
449     IWICColorTransform **ppIColorTransform)
450 {
451     FIXME("(%p,%p): stub\n", iface, ppIColorTransform);
452     return E_NOTIMPL;
453 }
454
455 static HRESULT WINAPI ComponentFactory_CreateBitmap(IWICComponentFactory *iface,
456     UINT uiWidth, UINT uiHeight, REFWICPixelFormatGUID pixelFormat,
457     WICBitmapCreateCacheOption option, IWICBitmap **ppIBitmap)
458 {
459     FIXME("(%p,%u,%u,%s,%u,%p): stub\n", iface, uiWidth, uiHeight,
460         debugstr_guid(pixelFormat), option, ppIBitmap);
461     return E_NOTIMPL;
462 }
463
464 static HRESULT WINAPI ComponentFactory_CreateBitmapFromSource(IWICComponentFactory *iface,
465     IWICBitmapSource *piBitmapSource, WICBitmapCreateCacheOption option,
466     IWICBitmap **ppIBitmap)
467 {
468     FIXME("(%p,%p,%u,%p): stub\n", iface, piBitmapSource, option, ppIBitmap);
469     return E_NOTIMPL;
470 }
471
472 static HRESULT WINAPI ComponentFactory_CreateBitmapFromSourceRect(IWICComponentFactory *iface,
473     IWICBitmapSource *piBitmapSource, UINT x, UINT y, UINT width, UINT height,
474     IWICBitmap **ppIBitmap)
475 {
476     FIXME("(%p,%p,%u,%u,%u,%u,%p): stub\n", iface, piBitmapSource, x, y, width,
477         height, ppIBitmap);
478     return E_NOTIMPL;
479 }
480
481 static HRESULT WINAPI ComponentFactory_CreateBitmapFromMemory(IWICComponentFactory *iface,
482     UINT uiWidth, UINT uiHeight, REFWICPixelFormatGUID pixelFormat, UINT cbStride,
483     UINT cbBufferSize, BYTE *pbBuffer, IWICBitmap **ppIBitmap)
484 {
485     FIXME("(%p,%u,%u,%s,%u,%u,%p,%p): stub\n", iface, uiWidth, uiHeight,
486         debugstr_guid(pixelFormat), cbStride, cbBufferSize, pbBuffer, ppIBitmap);
487     return E_NOTIMPL;
488 }
489
490 static HRESULT WINAPI ComponentFactory_CreateBitmapFromHBITMAP(IWICComponentFactory *iface,
491     HBITMAP hBitmap, HPALETTE hPalette, WICBitmapAlphaChannelOption options,
492     IWICBitmap **ppIBitmap)
493 {
494     FIXME("(%p,%p,%p,%u,%p): stub\n", iface, hBitmap, hPalette, options, ppIBitmap);
495     return E_NOTIMPL;
496 }
497
498 static HRESULT WINAPI ComponentFactory_CreateBitmapFromHICON(IWICComponentFactory *iface,
499     HICON hIcon, IWICBitmap **ppIBitmap)
500 {
501     FIXME("(%p,%p,%p): stub\n", iface, hIcon, ppIBitmap);
502     return E_NOTIMPL;
503 }
504
505 static HRESULT WINAPI ComponentFactory_CreateComponentEnumerator(IWICComponentFactory *iface,
506     DWORD componentTypes, DWORD options, IEnumUnknown **ppIEnumUnknown)
507 {
508     TRACE("(%p,%u,%u,%p)\n", iface, componentTypes, options, ppIEnumUnknown);
509     return CreateComponentEnumerator(componentTypes, options, ppIEnumUnknown);
510 }
511
512 static HRESULT WINAPI ComponentFactory_CreateFastMetadataEncoderFromDecoder(
513     IWICComponentFactory *iface, IWICBitmapDecoder *pIDecoder,
514     IWICFastMetadataEncoder **ppIFastEncoder)
515 {
516     FIXME("(%p,%p,%p): stub\n", iface, pIDecoder, ppIFastEncoder);
517     return E_NOTIMPL;
518 }
519
520 static HRESULT WINAPI ComponentFactory_CreateFastMetadataEncoderFromFrameDecode(
521     IWICComponentFactory *iface, IWICBitmapFrameDecode *pIFrameDecoder,
522     IWICFastMetadataEncoder **ppIFastEncoder)
523 {
524     FIXME("(%p,%p,%p): stub\n", iface, pIFrameDecoder, ppIFastEncoder);
525     return E_NOTIMPL;
526 }
527
528 static HRESULT WINAPI ComponentFactory_CreateQueryWriter(IWICComponentFactory *iface,
529     REFGUID guidMetadataFormat, const GUID *pguidVendor,
530     IWICMetadataQueryWriter **ppIQueryWriter)
531 {
532     FIXME("(%p,%s,%s,%p): stub\n", iface, debugstr_guid(guidMetadataFormat),
533         debugstr_guid(pguidVendor), ppIQueryWriter);
534     return E_NOTIMPL;
535 }
536
537 static HRESULT WINAPI ComponentFactory_CreateQueryWriterFromReader(IWICComponentFactory *iface,
538     IWICMetadataQueryReader *pIQueryReader, const GUID *pguidVendor,
539     IWICMetadataQueryWriter **ppIQueryWriter)
540 {
541     FIXME("(%p,%p,%s,%p): stub\n", iface, pIQueryReader, debugstr_guid(pguidVendor),
542         ppIQueryWriter);
543     return E_NOTIMPL;
544 }
545
546 static HRESULT WINAPI ComponentFactory_CreateMetadataReader(IWICComponentFactory *iface,
547         REFGUID format, const GUID *vendor, DWORD options, IStream *stream, IWICMetadataReader **reader)
548 {
549     FIXME("%p,%s,%s,%x,%p,%p: stub\n", iface, debugstr_guid(format), debugstr_guid(vendor),
550         options, stream, reader);
551     return E_NOTIMPL;
552 }
553
554 static HRESULT WINAPI ComponentFactory_CreateMetadataReaderFromContainer(IWICComponentFactory *iface,
555         REFGUID format, const GUID *vendor, DWORD options, IStream *stream, IWICMetadataReader **reader)
556 {
557     FIXME("%p,%s,%s,%x,%p,%p: stub\n", iface, debugstr_guid(format), debugstr_guid(vendor),
558         options, stream, reader);
559     return E_NOTIMPL;
560 }
561
562 static HRESULT WINAPI ComponentFactory_CreateMetadataWriter(IWICComponentFactory *iface,
563         REFGUID format, const GUID *vendor, DWORD options, IWICMetadataWriter **writer)
564 {
565     FIXME("%p,%s,%s,%x,%p: stub\n", iface, debugstr_guid(format), debugstr_guid(vendor), options, writer);
566     return E_NOTIMPL;
567 }
568
569 static HRESULT WINAPI ComponentFactory_CreateMetadataWriterFromReader(IWICComponentFactory *iface,
570         IWICMetadataReader *reader, const GUID *vendor, IWICMetadataWriter **writer)
571 {
572     FIXME("%p,%p,%s,%p: stub\n", iface, reader, debugstr_guid(vendor), writer);
573     return E_NOTIMPL;
574 }
575
576 static HRESULT WINAPI ComponentFactory_CreateQueryReaderFromBlockReader(IWICComponentFactory *iface,
577         IWICMetadataBlockReader *block_reader, IWICMetadataQueryReader **query_reader)
578 {
579     FIXME("%p,%p,%p: stub\n", iface, block_reader, query_reader);
580     return E_NOTIMPL;
581 }
582
583 static HRESULT WINAPI ComponentFactory_CreateQueryWriterFromBlockWriter(IWICComponentFactory *iface,
584         IWICMetadataBlockWriter *block_writer, IWICMetadataQueryWriter **query_writer)
585 {
586     FIXME("%p,%p,%p: stub\n", iface, block_writer, query_writer);
587     return E_NOTIMPL;
588 }
589
590 static HRESULT WINAPI ComponentFactory_CreateEncoderPropertyBag(IWICComponentFactory *iface,
591         PROPBAG2 *options, UINT count, IPropertyBag2 **property)
592 {
593     FIXME("%p,%p,%u,%p: stub\n", iface, options, count, property);
594     return E_NOTIMPL;
595 }
596
597 static const IWICComponentFactoryVtbl ComponentFactory_Vtbl = {
598     ComponentFactory_QueryInterface,
599     ComponentFactory_AddRef,
600     ComponentFactory_Release,
601     ComponentFactory_CreateDecoderFromFilename,
602     ComponentFactory_CreateDecoderFromStream,
603     ComponentFactory_CreateDecoderFromFileHandle,
604     ComponentFactory_CreateComponentInfo,
605     ComponentFactory_CreateDecoder,
606     ComponentFactory_CreateEncoder,
607     ComponentFactory_CreatePalette,
608     ComponentFactory_CreateFormatConverter,
609     ComponentFactory_CreateBitmapScaler,
610     ComponentFactory_CreateBitmapClipper,
611     ComponentFactory_CreateBitmapFlipRotator,
612     ComponentFactory_CreateStream,
613     ComponentFactory_CreateColorContext,
614     ComponentFactory_CreateColorTransformer,
615     ComponentFactory_CreateBitmap,
616     ComponentFactory_CreateBitmapFromSource,
617     ComponentFactory_CreateBitmapFromSourceRect,
618     ComponentFactory_CreateBitmapFromMemory,
619     ComponentFactory_CreateBitmapFromHBITMAP,
620     ComponentFactory_CreateBitmapFromHICON,
621     ComponentFactory_CreateComponentEnumerator,
622     ComponentFactory_CreateFastMetadataEncoderFromDecoder,
623     ComponentFactory_CreateFastMetadataEncoderFromFrameDecode,
624     ComponentFactory_CreateQueryWriter,
625     ComponentFactory_CreateQueryWriterFromReader,
626     ComponentFactory_CreateMetadataReader,
627     ComponentFactory_CreateMetadataReaderFromContainer,
628     ComponentFactory_CreateMetadataWriter,
629     ComponentFactory_CreateMetadataWriterFromReader,
630     ComponentFactory_CreateQueryReaderFromBlockReader,
631     ComponentFactory_CreateQueryWriterFromBlockWriter,
632     ComponentFactory_CreateEncoderPropertyBag
633 };
634
635 HRESULT ComponentFactory_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
636 {
637     ComponentFactory *This;
638     HRESULT ret;
639
640     TRACE("(%p,%s,%p)\n", pUnkOuter, debugstr_guid(iid), ppv);
641
642     *ppv = NULL;
643
644     if (pUnkOuter) return CLASS_E_NOAGGREGATION;
645
646     This = HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentFactory));
647     if (!This) return E_OUTOFMEMORY;
648
649     This->IWICComponentFactory_iface.lpVtbl = &ComponentFactory_Vtbl;
650     This->ref = 1;
651
652     ret = IUnknown_QueryInterface((IUnknown*)This, iid, ppv);
653     IUnknown_Release((IUnknown*)This);
654
655     return ret;
656 }