include: Assorted spelling fixes.
[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->IWICComponentFactory_iface;
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 IWICBitmapDecoder *find_decoder(IStream *pIStream, const GUID *pguidVendor,
125                                        WICDecodeOptions metadataOptions)
126 {
127     IEnumUnknown *enumdecoders;
128     IUnknown *unkdecoderinfo;
129     IWICBitmapDecoderInfo *decoderinfo;
130     IWICBitmapDecoder *decoder = NULL;
131     GUID vendor;
132     HRESULT res;
133     ULONG num_fetched;
134     BOOL matches;
135
136     res = CreateComponentEnumerator(WICDecoder, WICComponentEnumerateDefault, &enumdecoders);
137     if (FAILED(res)) return NULL;
138
139     while (!decoder)
140     {
141         res = IEnumUnknown_Next(enumdecoders, 1, &unkdecoderinfo, &num_fetched);
142
143         if (res == S_OK)
144         {
145             res = IUnknown_QueryInterface(unkdecoderinfo, &IID_IWICBitmapDecoderInfo, (void**)&decoderinfo);
146
147             if (SUCCEEDED(res))
148             {
149                 if (pguidVendor)
150                 {
151                     res = IWICBitmapDecoderInfo_GetVendorGUID(decoderinfo, &vendor);
152                     if (FAILED(res) || !IsEqualIID(&vendor, pguidVendor))
153                     {
154                         IWICBitmapDecoderInfo_Release(decoderinfo);
155                         IUnknown_Release(unkdecoderinfo);
156                         continue;
157                     }
158                 }
159
160                 res = IWICBitmapDecoderInfo_MatchesPattern(decoderinfo, pIStream, &matches);
161
162                 if (SUCCEEDED(res) && matches)
163                 {
164                     res = IWICBitmapDecoderInfo_CreateInstance(decoderinfo, &decoder);
165
166                     /* FIXME: should use QueryCapability to choose a decoder */
167
168                     if (SUCCEEDED(res))
169                     {
170                         res = IWICBitmapDecoder_Initialize(decoder, pIStream, metadataOptions);
171
172                         if (FAILED(res))
173                         {
174                             IWICBitmapDecoder_Release(decoder);
175                             decoder = NULL;
176                         }
177                     }
178                 }
179
180                 IWICBitmapDecoderInfo_Release(decoderinfo);
181             }
182
183             IUnknown_Release(unkdecoderinfo);
184         }
185         else
186             break;
187     }
188
189     IEnumUnknown_Release(enumdecoders);
190
191     return decoder;
192 }
193
194 static HRESULT WINAPI ComponentFactory_CreateDecoderFromStream(
195     IWICComponentFactory *iface, IStream *pIStream, const GUID *pguidVendor,
196     WICDecodeOptions metadataOptions, IWICBitmapDecoder **ppIDecoder)
197 {
198     HRESULT res;
199     IWICBitmapDecoder *decoder = NULL;
200
201     TRACE("(%p,%p,%s,%u,%p)\n", iface, pIStream, debugstr_guid(pguidVendor),
202         metadataOptions, ppIDecoder);
203
204     if (pguidVendor)
205         decoder = find_decoder(pIStream, pguidVendor, metadataOptions);
206     if (!decoder)
207         decoder = find_decoder(pIStream, NULL, metadataOptions);
208
209     if (decoder)
210     {
211         *ppIDecoder = decoder;
212         return S_OK;
213     }
214     else
215     {
216         if (WARN_ON(wincodecs))
217         {
218             LARGE_INTEGER seek;
219             BYTE data[4];
220             ULONG bytesread;
221
222             WARN("failed to load from a stream\n");
223
224             seek.QuadPart = 0;
225             res = IStream_Seek(pIStream, seek, STREAM_SEEK_SET, NULL);
226             if (SUCCEEDED(res))
227                 res = IStream_Read(pIStream, data, 4, &bytesread);
228             if (SUCCEEDED(res))
229                 WARN("first %i bytes of stream=%x %x %x %x\n", bytesread, data[0], data[1], data[2], data[3]);
230         }
231         *ppIDecoder = NULL;
232         return WINCODEC_ERR_COMPONENTNOTFOUND;
233     }
234 }
235
236 static HRESULT WINAPI ComponentFactory_CreateDecoderFromFileHandle(
237     IWICComponentFactory *iface, ULONG_PTR hFile, const GUID *pguidVendor,
238     WICDecodeOptions metadataOptions, IWICBitmapDecoder **ppIDecoder)
239 {
240     FIXME("(%p,%lx,%s,%u,%p): stub\n", iface, hFile, debugstr_guid(pguidVendor),
241         metadataOptions, ppIDecoder);
242     return E_NOTIMPL;
243 }
244
245 static HRESULT WINAPI ComponentFactory_CreateComponentInfo(IWICComponentFactory *iface,
246     REFCLSID clsidComponent, IWICComponentInfo **ppIInfo)
247 {
248     TRACE("(%p,%s,%p)\n", iface, debugstr_guid(clsidComponent), ppIInfo);
249     return CreateComponentInfo(clsidComponent, ppIInfo);
250 }
251
252 static HRESULT WINAPI ComponentFactory_CreateDecoder(IWICComponentFactory *iface,
253     REFGUID guidContainerFormat, const GUID *pguidVendor,
254     IWICBitmapDecoder **ppIDecoder)
255 {
256     IEnumUnknown *enumdecoders;
257     IUnknown *unkdecoderinfo;
258     IWICBitmapDecoderInfo *decoderinfo;
259     IWICBitmapDecoder *decoder = NULL, *preferred_decoder = NULL;
260     GUID vendor;
261     HRESULT res;
262     ULONG num_fetched;
263
264     TRACE("(%p,%s,%s,%p)\n", iface, debugstr_guid(guidContainerFormat),
265         debugstr_guid(pguidVendor), ppIDecoder);
266
267     if (!guidContainerFormat || !ppIDecoder) return E_INVALIDARG;
268
269     res = CreateComponentEnumerator(WICDecoder, WICComponentEnumerateDefault, &enumdecoders);
270     if (FAILED(res)) return res;
271
272     while (!preferred_decoder)
273     {
274         res = IEnumUnknown_Next(enumdecoders, 1, &unkdecoderinfo, &num_fetched);
275         if (res != S_OK) break;
276
277         res = IUnknown_QueryInterface(unkdecoderinfo, &IID_IWICBitmapDecoderInfo, (void **)&decoderinfo);
278         if (SUCCEEDED(res))
279         {
280             GUID container_guid;
281
282             res = IWICBitmapDecoderInfo_GetContainerFormat(decoderinfo, &container_guid);
283             if (SUCCEEDED(res) && IsEqualIID(&container_guid, guidContainerFormat))
284             {
285                 IWICBitmapDecoder *new_decoder;
286
287                 res = IWICBitmapDecoderInfo_CreateInstance(decoderinfo, &new_decoder);
288                 if (SUCCEEDED(res))
289                 {
290                     if (pguidVendor)
291                     {
292                         res = IWICBitmapDecoderInfo_GetVendorGUID(decoderinfo, &vendor);
293                         if (SUCCEEDED(res) && IsEqualIID(&vendor, pguidVendor))
294                         {
295                             preferred_decoder = new_decoder;
296                             new_decoder = NULL;
297                         }
298                     }
299
300                     if (new_decoder && !decoder)
301                     {
302                         decoder = new_decoder;
303                         new_decoder = NULL;
304                     }
305
306                     if (new_decoder) IWICBitmapDecoder_Release(new_decoder);
307                 }
308             }
309
310             IWICBitmapDecoderInfo_Release(decoderinfo);
311         }
312
313         IUnknown_Release(unkdecoderinfo);
314     }
315
316     IEnumUnknown_Release(enumdecoders);
317
318     if (preferred_decoder)
319     {
320         *ppIDecoder = preferred_decoder;
321         if (decoder) IWICBitmapDecoder_Release(decoder);
322         return S_OK;
323     }
324
325     if (decoder)
326     {
327         *ppIDecoder = decoder;
328         return S_OK;
329     }
330
331     *ppIDecoder = NULL;
332     return WINCODEC_ERR_COMPONENTNOTFOUND;
333 }
334
335 static HRESULT WINAPI ComponentFactory_CreateEncoder(IWICComponentFactory *iface,
336     REFGUID guidContainerFormat, const GUID *pguidVendor,
337     IWICBitmapEncoder **ppIEncoder)
338 {
339     static int fixme=0;
340     IEnumUnknown *enumencoders;
341     IUnknown *unkencoderinfo;
342     IWICBitmapEncoderInfo *encoderinfo;
343     IWICBitmapEncoder *encoder=NULL;
344     HRESULT res=S_OK;
345     ULONG num_fetched;
346     GUID actual_containerformat;
347
348     TRACE("(%p,%s,%s,%p)\n", iface, debugstr_guid(guidContainerFormat),
349         debugstr_guid(pguidVendor), ppIEncoder);
350
351     if (pguidVendor && !fixme++)
352         FIXME("ignoring vendor GUID\n");
353
354     res = CreateComponentEnumerator(WICEncoder, WICComponentEnumerateDefault, &enumencoders);
355     if (FAILED(res)) return res;
356
357     while (!encoder)
358     {
359         res = IEnumUnknown_Next(enumencoders, 1, &unkencoderinfo, &num_fetched);
360
361         if (res == S_OK)
362         {
363             res = IUnknown_QueryInterface(unkencoderinfo, &IID_IWICBitmapEncoderInfo, (void**)&encoderinfo);
364
365             if (SUCCEEDED(res))
366             {
367                 res = IWICBitmapEncoderInfo_GetContainerFormat(encoderinfo, &actual_containerformat);
368
369                 if (SUCCEEDED(res) && IsEqualGUID(guidContainerFormat, &actual_containerformat))
370                 {
371                     res = IWICBitmapEncoderInfo_CreateInstance(encoderinfo, &encoder);
372                     if (FAILED(res))
373                         encoder = NULL;
374                 }
375
376                 IWICBitmapEncoderInfo_Release(encoderinfo);
377             }
378
379             IUnknown_Release(unkencoderinfo);
380         }
381         else
382             break;
383     }
384
385     IEnumUnknown_Release(enumencoders);
386
387     if (encoder)
388     {
389         *ppIEncoder = encoder;
390         return S_OK;
391     }
392     else
393     {
394         WARN("failed to create encoder\n");
395         *ppIEncoder = NULL;
396         return WINCODEC_ERR_COMPONENTNOTFOUND;
397     }
398 }
399
400 static HRESULT WINAPI ComponentFactory_CreatePalette(IWICComponentFactory *iface,
401     IWICPalette **ppIPalette)
402 {
403     TRACE("(%p,%p)\n", iface, ppIPalette);
404     return PaletteImpl_Create(ppIPalette);
405 }
406
407 static HRESULT WINAPI ComponentFactory_CreateFormatConverter(IWICComponentFactory *iface,
408     IWICFormatConverter **ppIFormatConverter)
409 {
410     return FormatConverter_CreateInstance(NULL, &IID_IWICFormatConverter, (void**)ppIFormatConverter);
411 }
412
413 static HRESULT WINAPI ComponentFactory_CreateBitmapScaler(IWICComponentFactory *iface,
414     IWICBitmapScaler **ppIBitmapScaler)
415 {
416     TRACE("(%p,%p)\n", iface, ppIBitmapScaler);
417
418     return BitmapScaler_Create(ppIBitmapScaler);
419 }
420
421 static HRESULT WINAPI ComponentFactory_CreateBitmapClipper(IWICComponentFactory *iface,
422     IWICBitmapClipper **ppIBitmapClipper)
423 {
424     FIXME("(%p,%p): stub\n", iface, ppIBitmapClipper);
425     return E_NOTIMPL;
426 }
427
428 static HRESULT WINAPI ComponentFactory_CreateBitmapFlipRotator(IWICComponentFactory *iface,
429     IWICBitmapFlipRotator **ppIBitmapFlipRotator)
430 {
431     TRACE("(%p,%p)\n", iface, ppIBitmapFlipRotator);
432     return FlipRotator_Create(ppIBitmapFlipRotator);
433 }
434
435 static HRESULT WINAPI ComponentFactory_CreateStream(IWICComponentFactory *iface,
436     IWICStream **ppIWICStream)
437 {
438     TRACE("(%p,%p)\n", iface, ppIWICStream);
439     return StreamImpl_Create(ppIWICStream);
440 }
441
442 static HRESULT WINAPI ComponentFactory_CreateColorContext(IWICComponentFactory *iface,
443     IWICColorContext **ppIColorContext)
444 {
445     TRACE("(%p,%p)\n", iface, ppIColorContext);
446     return ColorContext_Create(ppIColorContext);
447 }
448
449 static HRESULT WINAPI ComponentFactory_CreateColorTransformer(IWICComponentFactory *iface,
450     IWICColorTransform **ppIColorTransform)
451 {
452     FIXME("(%p,%p): stub\n", iface, ppIColorTransform);
453     return E_NOTIMPL;
454 }
455
456 static HRESULT WINAPI ComponentFactory_CreateBitmap(IWICComponentFactory *iface,
457     UINT uiWidth, UINT uiHeight, REFWICPixelFormatGUID pixelFormat,
458     WICBitmapCreateCacheOption option, IWICBitmap **ppIBitmap)
459 {
460     TRACE("(%p,%u,%u,%s,%u,%p)\n", iface, uiWidth, uiHeight,
461         debugstr_guid(pixelFormat), option, ppIBitmap);
462     return BitmapImpl_Create(uiWidth, uiHeight, pixelFormat, option, ppIBitmap);
463 }
464
465 static HRESULT WINAPI ComponentFactory_CreateBitmapFromSource(IWICComponentFactory *iface,
466     IWICBitmapSource *piBitmapSource, WICBitmapCreateCacheOption option,
467     IWICBitmap **ppIBitmap)
468 {
469     IWICBitmap *result;
470     IWICBitmapLock *lock;
471     IWICPalette *palette;
472     UINT width, height;
473     WICPixelFormatGUID pixelformat = {0};
474     HRESULT hr;
475     WICRect rc;
476     double dpix, dpiy;
477     IWICComponentInfo *info;
478     IWICPixelFormatInfo2 *formatinfo;
479     WICPixelFormatNumericRepresentation format_type;
480
481     TRACE("(%p,%p,%u,%p)\n", iface, piBitmapSource, option, ppIBitmap);
482
483     if (!piBitmapSource || !ppIBitmap)
484         return E_INVALIDARG;
485
486     hr = IWICBitmapSource_GetSize(piBitmapSource, &width, &height);
487
488     if (SUCCEEDED(hr))
489         hr = IWICBitmapSource_GetPixelFormat(piBitmapSource, &pixelformat);
490
491     if (SUCCEEDED(hr))
492         hr = CreateComponentInfo(&pixelformat, &info);
493
494     if (SUCCEEDED(hr))
495     {
496         hr = IWICComponentInfo_QueryInterface(info, &IID_IWICPixelFormatInfo2, (void**)&formatinfo);
497
498         if (SUCCEEDED(hr))
499         {
500             hr = IWICPixelFormatInfo2_GetNumericRepresentation(formatinfo, &format_type);
501
502             IWICPixelFormatInfo2_Release(formatinfo);
503         }
504
505         IWICComponentInfo_Release(info);
506     }
507
508     if (SUCCEEDED(hr))
509         hr = BitmapImpl_Create(width, height, &pixelformat, option, &result);
510
511     if (SUCCEEDED(hr))
512     {
513         hr = IWICBitmap_Lock(result, NULL, WICBitmapLockWrite, &lock);
514         if (SUCCEEDED(hr))
515         {
516             UINT stride, buffersize;
517             BYTE *buffer;
518             rc.X = rc.Y = 0;
519             rc.Width = width;
520             rc.Height = height;
521
522             hr = IWICBitmapLock_GetStride(lock, &stride);
523
524             if (SUCCEEDED(hr))
525                 hr = IWICBitmapLock_GetDataPointer(lock, &buffersize, &buffer);
526
527             if (SUCCEEDED(hr))
528                 hr = IWICBitmapSource_CopyPixels(piBitmapSource, &rc, stride,
529                     buffersize, buffer);
530
531             IWICBitmapLock_Release(lock);
532         }
533
534         if (SUCCEEDED(hr))
535             hr = PaletteImpl_Create(&palette);
536
537         if (SUCCEEDED(hr) && (format_type == WICPixelFormatNumericRepresentationUnspecified ||
538                               format_type == WICPixelFormatNumericRepresentationIndexed))
539         {
540             hr = IWICBitmapSource_CopyPalette(piBitmapSource, palette);
541
542             if (SUCCEEDED(hr))
543                 hr = IWICBitmap_SetPalette(result, palette);
544             else
545                 hr = S_OK;
546
547             IWICPalette_Release(palette);
548         }
549
550         if (SUCCEEDED(hr))
551         {
552             hr = IWICBitmapSource_GetResolution(piBitmapSource, &dpix, &dpiy);
553
554             if (SUCCEEDED(hr))
555                 hr = IWICBitmap_SetResolution(result, dpix, dpiy);
556             else
557                 hr = S_OK;
558         }
559
560         if (SUCCEEDED(hr))
561             *ppIBitmap = result;
562         else
563             IWICBitmap_Release(result);
564     }
565
566     return hr;
567 }
568
569 static HRESULT WINAPI ComponentFactory_CreateBitmapFromSourceRect(IWICComponentFactory *iface,
570     IWICBitmapSource *piBitmapSource, UINT x, UINT y, UINT width, UINT height,
571     IWICBitmap **ppIBitmap)
572 {
573     FIXME("(%p,%p,%u,%u,%u,%u,%p): stub\n", iface, piBitmapSource, x, y, width,
574         height, ppIBitmap);
575     return E_NOTIMPL;
576 }
577
578 static HRESULT WINAPI ComponentFactory_CreateBitmapFromMemory(IWICComponentFactory *iface,
579     UINT uiWidth, UINT uiHeight, REFWICPixelFormatGUID pixelFormat, UINT cbStride,
580     UINT cbBufferSize, BYTE *pbBuffer, IWICBitmap **ppIBitmap)
581 {
582     FIXME("(%p,%u,%u,%s,%u,%u,%p,%p): stub\n", iface, uiWidth, uiHeight,
583         debugstr_guid(pixelFormat), cbStride, cbBufferSize, pbBuffer, ppIBitmap);
584     return E_NOTIMPL;
585 }
586
587 static HRESULT WINAPI ComponentFactory_CreateBitmapFromHBITMAP(IWICComponentFactory *iface,
588     HBITMAP hBitmap, HPALETTE hPalette, WICBitmapAlphaChannelOption options,
589     IWICBitmap **ppIBitmap)
590 {
591     FIXME("(%p,%p,%p,%u,%p): stub\n", iface, hBitmap, hPalette, options, ppIBitmap);
592     return E_NOTIMPL;
593 }
594
595 static HRESULT WINAPI ComponentFactory_CreateBitmapFromHICON(IWICComponentFactory *iface,
596     HICON hIcon, IWICBitmap **ppIBitmap)
597 {
598     FIXME("(%p,%p,%p): stub\n", iface, hIcon, ppIBitmap);
599     return E_NOTIMPL;
600 }
601
602 static HRESULT WINAPI ComponentFactory_CreateComponentEnumerator(IWICComponentFactory *iface,
603     DWORD componentTypes, DWORD options, IEnumUnknown **ppIEnumUnknown)
604 {
605     TRACE("(%p,%u,%u,%p)\n", iface, componentTypes, options, ppIEnumUnknown);
606     return CreateComponentEnumerator(componentTypes, options, ppIEnumUnknown);
607 }
608
609 static HRESULT WINAPI ComponentFactory_CreateFastMetadataEncoderFromDecoder(
610     IWICComponentFactory *iface, IWICBitmapDecoder *pIDecoder,
611     IWICFastMetadataEncoder **ppIFastEncoder)
612 {
613     FIXME("(%p,%p,%p): stub\n", iface, pIDecoder, ppIFastEncoder);
614     return E_NOTIMPL;
615 }
616
617 static HRESULT WINAPI ComponentFactory_CreateFastMetadataEncoderFromFrameDecode(
618     IWICComponentFactory *iface, IWICBitmapFrameDecode *pIFrameDecoder,
619     IWICFastMetadataEncoder **ppIFastEncoder)
620 {
621     FIXME("(%p,%p,%p): stub\n", iface, pIFrameDecoder, ppIFastEncoder);
622     return E_NOTIMPL;
623 }
624
625 static HRESULT WINAPI ComponentFactory_CreateQueryWriter(IWICComponentFactory *iface,
626     REFGUID guidMetadataFormat, const GUID *pguidVendor,
627     IWICMetadataQueryWriter **ppIQueryWriter)
628 {
629     FIXME("(%p,%s,%s,%p): stub\n", iface, debugstr_guid(guidMetadataFormat),
630         debugstr_guid(pguidVendor), ppIQueryWriter);
631     return E_NOTIMPL;
632 }
633
634 static HRESULT WINAPI ComponentFactory_CreateQueryWriterFromReader(IWICComponentFactory *iface,
635     IWICMetadataQueryReader *pIQueryReader, const GUID *pguidVendor,
636     IWICMetadataQueryWriter **ppIQueryWriter)
637 {
638     FIXME("(%p,%p,%s,%p): stub\n", iface, pIQueryReader, debugstr_guid(pguidVendor),
639         ppIQueryWriter);
640     return E_NOTIMPL;
641 }
642
643 static HRESULT WINAPI ComponentFactory_CreateMetadataReader(IWICComponentFactory *iface,
644         REFGUID format, const GUID *vendor, DWORD options, IStream *stream, IWICMetadataReader **reader)
645 {
646     FIXME("%p,%s,%s,%x,%p,%p: stub\n", iface, debugstr_guid(format), debugstr_guid(vendor),
647         options, stream, reader);
648     return E_NOTIMPL;
649 }
650
651 static HRESULT WINAPI ComponentFactory_CreateMetadataReaderFromContainer(IWICComponentFactory *iface,
652         REFGUID format, const GUID *vendor, DWORD options, IStream *stream, IWICMetadataReader **reader)
653 {
654     FIXME("%p,%s,%s,%x,%p,%p: stub\n", iface, debugstr_guid(format), debugstr_guid(vendor),
655         options, stream, reader);
656     return E_NOTIMPL;
657 }
658
659 static HRESULT WINAPI ComponentFactory_CreateMetadataWriter(IWICComponentFactory *iface,
660         REFGUID format, const GUID *vendor, DWORD options, IWICMetadataWriter **writer)
661 {
662     FIXME("%p,%s,%s,%x,%p: stub\n", iface, debugstr_guid(format), debugstr_guid(vendor), options, writer);
663     return E_NOTIMPL;
664 }
665
666 static HRESULT WINAPI ComponentFactory_CreateMetadataWriterFromReader(IWICComponentFactory *iface,
667         IWICMetadataReader *reader, const GUID *vendor, IWICMetadataWriter **writer)
668 {
669     FIXME("%p,%p,%s,%p: stub\n", iface, reader, debugstr_guid(vendor), writer);
670     return E_NOTIMPL;
671 }
672
673 static HRESULT WINAPI ComponentFactory_CreateQueryReaderFromBlockReader(IWICComponentFactory *iface,
674         IWICMetadataBlockReader *block_reader, IWICMetadataQueryReader **query_reader)
675 {
676     FIXME("%p,%p,%p: stub\n", iface, block_reader, query_reader);
677     return E_NOTIMPL;
678 }
679
680 static HRESULT WINAPI ComponentFactory_CreateQueryWriterFromBlockWriter(IWICComponentFactory *iface,
681         IWICMetadataBlockWriter *block_writer, IWICMetadataQueryWriter **query_writer)
682 {
683     FIXME("%p,%p,%p: stub\n", iface, block_writer, query_writer);
684     return E_NOTIMPL;
685 }
686
687 static HRESULT WINAPI ComponentFactory_CreateEncoderPropertyBag(IWICComponentFactory *iface,
688         PROPBAG2 *options, UINT count, IPropertyBag2 **property)
689 {
690     FIXME("%p,%p,%u,%p: stub\n", iface, options, count, property);
691     return E_NOTIMPL;
692 }
693
694 static const IWICComponentFactoryVtbl ComponentFactory_Vtbl = {
695     ComponentFactory_QueryInterface,
696     ComponentFactory_AddRef,
697     ComponentFactory_Release,
698     ComponentFactory_CreateDecoderFromFilename,
699     ComponentFactory_CreateDecoderFromStream,
700     ComponentFactory_CreateDecoderFromFileHandle,
701     ComponentFactory_CreateComponentInfo,
702     ComponentFactory_CreateDecoder,
703     ComponentFactory_CreateEncoder,
704     ComponentFactory_CreatePalette,
705     ComponentFactory_CreateFormatConverter,
706     ComponentFactory_CreateBitmapScaler,
707     ComponentFactory_CreateBitmapClipper,
708     ComponentFactory_CreateBitmapFlipRotator,
709     ComponentFactory_CreateStream,
710     ComponentFactory_CreateColorContext,
711     ComponentFactory_CreateColorTransformer,
712     ComponentFactory_CreateBitmap,
713     ComponentFactory_CreateBitmapFromSource,
714     ComponentFactory_CreateBitmapFromSourceRect,
715     ComponentFactory_CreateBitmapFromMemory,
716     ComponentFactory_CreateBitmapFromHBITMAP,
717     ComponentFactory_CreateBitmapFromHICON,
718     ComponentFactory_CreateComponentEnumerator,
719     ComponentFactory_CreateFastMetadataEncoderFromDecoder,
720     ComponentFactory_CreateFastMetadataEncoderFromFrameDecode,
721     ComponentFactory_CreateQueryWriter,
722     ComponentFactory_CreateQueryWriterFromReader,
723     ComponentFactory_CreateMetadataReader,
724     ComponentFactory_CreateMetadataReaderFromContainer,
725     ComponentFactory_CreateMetadataWriter,
726     ComponentFactory_CreateMetadataWriterFromReader,
727     ComponentFactory_CreateQueryReaderFromBlockReader,
728     ComponentFactory_CreateQueryWriterFromBlockWriter,
729     ComponentFactory_CreateEncoderPropertyBag
730 };
731
732 HRESULT ComponentFactory_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
733 {
734     ComponentFactory *This;
735     HRESULT ret;
736
737     TRACE("(%p,%s,%p)\n", pUnkOuter, debugstr_guid(iid), ppv);
738
739     *ppv = NULL;
740
741     if (pUnkOuter) return CLASS_E_NOAGGREGATION;
742
743     This = HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentFactory));
744     if (!This) return E_OUTOFMEMORY;
745
746     This->IWICComponentFactory_iface.lpVtbl = &ComponentFactory_Vtbl;
747     This->ref = 1;
748
749     ret = IWICComponentFactory_QueryInterface(&This->IWICComponentFactory_iface, iid, ppv);
750     IWICComponentFactory_Release(&This->IWICComponentFactory_iface);
751
752     return ret;
753 }