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