Synchronize with trunk r58606.
[reactos.git] / dll / win32 / 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 #define WIN32_NO_STATUS
20 #define _INC_WINDOWS
21 #define COM_NO_WINDOWS_H
22
23 #include <config.h>
24
25 #include <stdarg.h>
26
27 #define COBJMACROS
28
29 #include <windef.h>
30 #include <winbase.h>
31 //#include "winreg.h"
32 #include <objbase.h>
33 //#include "shellapi.h"
34 //#include "wincodec.h"
35 #include <wincodecsdk.h>
36
37 #include "wincodecs_private.h"
38
39 #include <wine/debug.h>
40
41 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
42
43 typedef struct {
44 IWICComponentFactory IWICComponentFactory_iface;
45 LONG ref;
46 } ComponentFactory;
47
48 static inline ComponentFactory *impl_from_IWICComponentFactory(IWICComponentFactory *iface)
49 {
50 return CONTAINING_RECORD(iface, ComponentFactory, IWICComponentFactory_iface);
51 }
52
53 static HRESULT WINAPI ComponentFactory_QueryInterface(IWICComponentFactory *iface, REFIID iid,
54 void **ppv)
55 {
56 ComponentFactory *This = impl_from_IWICComponentFactory(iface);
57 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
58
59 if (!ppv) return E_INVALIDARG;
60
61 if (IsEqualIID(&IID_IUnknown, iid) ||
62 IsEqualIID(&IID_IWICImagingFactory, iid) ||
63 IsEqualIID(&IID_IWICComponentFactory, iid))
64 {
65 *ppv = &This->IWICComponentFactory_iface;
66 }
67 else
68 {
69 *ppv = NULL;
70 return E_NOINTERFACE;
71 }
72
73 IUnknown_AddRef((IUnknown*)*ppv);
74 return S_OK;
75 }
76
77 static ULONG WINAPI ComponentFactory_AddRef(IWICComponentFactory *iface)
78 {
79 ComponentFactory *This = impl_from_IWICComponentFactory(iface);
80 ULONG ref = InterlockedIncrement(&This->ref);
81
82 TRACE("(%p) refcount=%u\n", iface, ref);
83
84 return ref;
85 }
86
87 static ULONG WINAPI ComponentFactory_Release(IWICComponentFactory *iface)
88 {
89 ComponentFactory *This = impl_from_IWICComponentFactory(iface);
90 ULONG ref = InterlockedDecrement(&This->ref);
91
92 TRACE("(%p) refcount=%u\n", iface, ref);
93
94 if (ref == 0)
95 HeapFree(GetProcessHeap(), 0, This);
96
97 return ref;
98 }
99
100 static HRESULT WINAPI ComponentFactory_CreateDecoderFromFilename(
101 IWICComponentFactory *iface, LPCWSTR wzFilename, const GUID *pguidVendor,
102 DWORD dwDesiredAccess, WICDecodeOptions metadataOptions,
103 IWICBitmapDecoder **ppIDecoder)
104 {
105 IWICStream *stream;
106 HRESULT hr;
107
108 TRACE("(%p,%s,%s,%u,%u,%p)\n", iface, debugstr_w(wzFilename),
109 debugstr_guid(pguidVendor), dwDesiredAccess, metadataOptions, ppIDecoder);
110
111 hr = StreamImpl_Create(&stream);
112 if (SUCCEEDED(hr))
113 {
114 hr = IWICStream_InitializeFromFilename(stream, wzFilename, dwDesiredAccess);
115
116 if (SUCCEEDED(hr))
117 {
118 hr = IWICComponentFactory_CreateDecoderFromStream(iface, (IStream*)stream,
119 pguidVendor, metadataOptions, ppIDecoder);
120 }
121
122 IWICStream_Release(stream);
123 }
124
125 return hr;
126 }
127
128 static IWICBitmapDecoder *find_decoder(IStream *pIStream, const GUID *pguidVendor,
129 WICDecodeOptions metadataOptions)
130 {
131 IEnumUnknown *enumdecoders;
132 IUnknown *unkdecoderinfo;
133 IWICBitmapDecoderInfo *decoderinfo;
134 IWICBitmapDecoder *decoder = NULL;
135 GUID vendor;
136 HRESULT res;
137 ULONG num_fetched;
138 BOOL matches;
139
140 res = CreateComponentEnumerator(WICDecoder, WICComponentEnumerateDefault, &enumdecoders);
141 if (FAILED(res)) return NULL;
142
143 while (!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 if (pguidVendor)
154 {
155 res = IWICBitmapDecoderInfo_GetVendorGUID(decoderinfo, &vendor);
156 if (FAILED(res) || !IsEqualIID(&vendor, pguidVendor))
157 {
158 IWICBitmapDecoderInfo_Release(decoderinfo);
159 IUnknown_Release(unkdecoderinfo);
160 continue;
161 }
162 }
163
164 res = IWICBitmapDecoderInfo_MatchesPattern(decoderinfo, pIStream, &matches);
165
166 if (SUCCEEDED(res) && matches)
167 {
168 res = IWICBitmapDecoderInfo_CreateInstance(decoderinfo, &decoder);
169
170 /* FIXME: should use QueryCapability to choose a decoder */
171
172 if (SUCCEEDED(res))
173 {
174 res = IWICBitmapDecoder_Initialize(decoder, pIStream, metadataOptions);
175
176 if (FAILED(res))
177 {
178 IWICBitmapDecoder_Release(decoder);
179 decoder = NULL;
180 }
181 }
182 }
183
184 IWICBitmapDecoderInfo_Release(decoderinfo);
185 }
186
187 IUnknown_Release(unkdecoderinfo);
188 }
189 else
190 break;
191 }
192
193 IEnumUnknown_Release(enumdecoders);
194
195 return decoder;
196 }
197
198 static HRESULT WINAPI ComponentFactory_CreateDecoderFromStream(
199 IWICComponentFactory *iface, IStream *pIStream, const GUID *pguidVendor,
200 WICDecodeOptions metadataOptions, IWICBitmapDecoder **ppIDecoder)
201 {
202 HRESULT res;
203 IWICBitmapDecoder *decoder = NULL;
204
205 TRACE("(%p,%p,%s,%u,%p)\n", iface, pIStream, debugstr_guid(pguidVendor),
206 metadataOptions, ppIDecoder);
207
208 if (pguidVendor)
209 decoder = find_decoder(pIStream, pguidVendor, metadataOptions);
210 if (!decoder)
211 decoder = find_decoder(pIStream, NULL, metadataOptions);
212
213 if (decoder)
214 {
215 *ppIDecoder = decoder;
216 return S_OK;
217 }
218 else
219 {
220 if (WARN_ON(wincodecs))
221 {
222 LARGE_INTEGER seek;
223 BYTE data[4];
224 ULONG bytesread;
225
226 WARN("failed to load from a stream\n");
227
228 seek.QuadPart = 0;
229 res = IStream_Seek(pIStream, seek, STREAM_SEEK_SET, NULL);
230 if (SUCCEEDED(res))
231 res = IStream_Read(pIStream, data, 4, &bytesread);
232 if (SUCCEEDED(res))
233 WARN("first %i bytes of stream=%x %x %x %x\n", bytesread, data[0], data[1], data[2], data[3]);
234 }
235 *ppIDecoder = NULL;
236 return WINCODEC_ERR_COMPONENTNOTFOUND;
237 }
238 }
239
240 static HRESULT WINAPI ComponentFactory_CreateDecoderFromFileHandle(
241 IWICComponentFactory *iface, ULONG_PTR hFile, const GUID *pguidVendor,
242 WICDecodeOptions metadataOptions, IWICBitmapDecoder **ppIDecoder)
243 {
244 FIXME("(%p,%lx,%s,%u,%p): stub\n", iface, hFile, debugstr_guid(pguidVendor),
245 metadataOptions, ppIDecoder);
246 return E_NOTIMPL;
247 }
248
249 static HRESULT WINAPI ComponentFactory_CreateComponentInfo(IWICComponentFactory *iface,
250 REFCLSID clsidComponent, IWICComponentInfo **ppIInfo)
251 {
252 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(clsidComponent), ppIInfo);
253 return CreateComponentInfo(clsidComponent, ppIInfo);
254 }
255
256 static HRESULT WINAPI ComponentFactory_CreateDecoder(IWICComponentFactory *iface,
257 REFGUID guidContainerFormat, const GUID *pguidVendor,
258 IWICBitmapDecoder **ppIDecoder)
259 {
260 IEnumUnknown *enumdecoders;
261 IUnknown *unkdecoderinfo;
262 IWICBitmapDecoderInfo *decoderinfo;
263 IWICBitmapDecoder *decoder = NULL, *preferred_decoder = NULL;
264 GUID vendor;
265 HRESULT res;
266 ULONG num_fetched;
267
268 TRACE("(%p,%s,%s,%p)\n", iface, debugstr_guid(guidContainerFormat),
269 debugstr_guid(pguidVendor), ppIDecoder);
270
271 if (!guidContainerFormat || !ppIDecoder) return E_INVALIDARG;
272
273 res = CreateComponentEnumerator(WICDecoder, WICComponentEnumerateDefault, &enumdecoders);
274 if (FAILED(res)) return res;
275
276 while (!preferred_decoder)
277 {
278 res = IEnumUnknown_Next(enumdecoders, 1, &unkdecoderinfo, &num_fetched);
279 if (res != S_OK) break;
280
281 res = IUnknown_QueryInterface(unkdecoderinfo, &IID_IWICBitmapDecoderInfo, (void **)&decoderinfo);
282 if (SUCCEEDED(res))
283 {
284 GUID container_guid;
285
286 res = IWICBitmapDecoderInfo_GetContainerFormat(decoderinfo, &container_guid);
287 if (SUCCEEDED(res) && IsEqualIID(&container_guid, guidContainerFormat))
288 {
289 IWICBitmapDecoder *new_decoder;
290
291 res = IWICBitmapDecoderInfo_CreateInstance(decoderinfo, &new_decoder);
292 if (SUCCEEDED(res))
293 {
294 if (pguidVendor)
295 {
296 res = IWICBitmapDecoderInfo_GetVendorGUID(decoderinfo, &vendor);
297 if (SUCCEEDED(res) && IsEqualIID(&vendor, pguidVendor))
298 {
299 preferred_decoder = new_decoder;
300 new_decoder = NULL;
301 }
302 }
303
304 if (new_decoder && !decoder)
305 {
306 decoder = new_decoder;
307 new_decoder = NULL;
308 }
309
310 if (new_decoder) IWICBitmapDecoder_Release(new_decoder);
311 }
312 }
313
314 IWICBitmapDecoderInfo_Release(decoderinfo);
315 }
316
317 IUnknown_Release(unkdecoderinfo);
318 }
319
320 IEnumUnknown_Release(enumdecoders);
321
322 if (preferred_decoder)
323 {
324 *ppIDecoder = preferred_decoder;
325 if (decoder) IWICBitmapDecoder_Release(decoder);
326 return S_OK;
327 }
328
329 if (decoder)
330 {
331 *ppIDecoder = decoder;
332 return S_OK;
333 }
334
335 *ppIDecoder = NULL;
336 return WINCODEC_ERR_COMPONENTNOTFOUND;
337 }
338
339 static HRESULT WINAPI ComponentFactory_CreateEncoder(IWICComponentFactory *iface,
340 REFGUID guidContainerFormat, const GUID *pguidVendor,
341 IWICBitmapEncoder **ppIEncoder)
342 {
343 static int fixme=0;
344 IEnumUnknown *enumencoders;
345 IUnknown *unkencoderinfo;
346 IWICBitmapEncoderInfo *encoderinfo;
347 IWICBitmapEncoder *encoder=NULL;
348 HRESULT res=S_OK;
349 ULONG num_fetched;
350 GUID actual_containerformat;
351
352 TRACE("(%p,%s,%s,%p)\n", iface, debugstr_guid(guidContainerFormat),
353 debugstr_guid(pguidVendor), ppIEncoder);
354
355 if (pguidVendor && !fixme++)
356 FIXME("ignoring vendor GUID\n");
357
358 res = CreateComponentEnumerator(WICEncoder, WICComponentEnumerateDefault, &enumencoders);
359 if (FAILED(res)) return res;
360
361 while (!encoder)
362 {
363 res = IEnumUnknown_Next(enumencoders, 1, &unkencoderinfo, &num_fetched);
364
365 if (res == S_OK)
366 {
367 res = IUnknown_QueryInterface(unkencoderinfo, &IID_IWICBitmapEncoderInfo, (void**)&encoderinfo);
368
369 if (SUCCEEDED(res))
370 {
371 res = IWICBitmapEncoderInfo_GetContainerFormat(encoderinfo, &actual_containerformat);
372
373 if (SUCCEEDED(res) && IsEqualGUID(guidContainerFormat, &actual_containerformat))
374 {
375 res = IWICBitmapEncoderInfo_CreateInstance(encoderinfo, &encoder);
376 if (FAILED(res))
377 encoder = NULL;
378 }
379
380 IWICBitmapEncoderInfo_Release(encoderinfo);
381 }
382
383 IUnknown_Release(unkencoderinfo);
384 }
385 else
386 break;
387 }
388
389 IEnumUnknown_Release(enumencoders);
390
391 if (encoder)
392 {
393 *ppIEncoder = encoder;
394 return S_OK;
395 }
396 else
397 {
398 WARN("failed to create encoder\n");
399 *ppIEncoder = NULL;
400 return WINCODEC_ERR_COMPONENTNOTFOUND;
401 }
402 }
403
404 static HRESULT WINAPI ComponentFactory_CreatePalette(IWICComponentFactory *iface,
405 IWICPalette **ppIPalette)
406 {
407 TRACE("(%p,%p)\n", iface, ppIPalette);
408 return PaletteImpl_Create(ppIPalette);
409 }
410
411 static HRESULT WINAPI ComponentFactory_CreateFormatConverter(IWICComponentFactory *iface,
412 IWICFormatConverter **ppIFormatConverter)
413 {
414 return FormatConverter_CreateInstance(NULL, &IID_IWICFormatConverter, (void**)ppIFormatConverter);
415 }
416
417 static HRESULT WINAPI ComponentFactory_CreateBitmapScaler(IWICComponentFactory *iface,
418 IWICBitmapScaler **ppIBitmapScaler)
419 {
420 TRACE("(%p,%p)\n", iface, ppIBitmapScaler);
421
422 return BitmapScaler_Create(ppIBitmapScaler);
423 }
424
425 static HRESULT WINAPI ComponentFactory_CreateBitmapClipper(IWICComponentFactory *iface,
426 IWICBitmapClipper **ppIBitmapClipper)
427 {
428 FIXME("(%p,%p): stub\n", iface, ppIBitmapClipper);
429 return E_NOTIMPL;
430 }
431
432 static HRESULT WINAPI ComponentFactory_CreateBitmapFlipRotator(IWICComponentFactory *iface,
433 IWICBitmapFlipRotator **ppIBitmapFlipRotator)
434 {
435 TRACE("(%p,%p)\n", iface, ppIBitmapFlipRotator);
436 return FlipRotator_Create(ppIBitmapFlipRotator);
437 }
438
439 static HRESULT WINAPI ComponentFactory_CreateStream(IWICComponentFactory *iface,
440 IWICStream **ppIWICStream)
441 {
442 TRACE("(%p,%p)\n", iface, ppIWICStream);
443 return StreamImpl_Create(ppIWICStream);
444 }
445
446 static HRESULT WINAPI ComponentFactory_CreateColorContext(IWICComponentFactory *iface,
447 IWICColorContext **ppIColorContext)
448 {
449 TRACE("(%p,%p)\n", iface, ppIColorContext);
450 return ColorContext_Create(ppIColorContext);
451 }
452
453 static HRESULT WINAPI ComponentFactory_CreateColorTransformer(IWICComponentFactory *iface,
454 IWICColorTransform **ppIColorTransform)
455 {
456 FIXME("(%p,%p): stub\n", iface, ppIColorTransform);
457 return E_NOTIMPL;
458 }
459
460 static HRESULT WINAPI ComponentFactory_CreateBitmap(IWICComponentFactory *iface,
461 UINT uiWidth, UINT uiHeight, REFWICPixelFormatGUID pixelFormat,
462 WICBitmapCreateCacheOption option, IWICBitmap **ppIBitmap)
463 {
464 TRACE("(%p,%u,%u,%s,%u,%p)\n", iface, uiWidth, uiHeight,
465 debugstr_guid(pixelFormat), option, ppIBitmap);
466 return BitmapImpl_Create(uiWidth, uiHeight, pixelFormat, option, ppIBitmap);
467 }
468
469 static HRESULT WINAPI ComponentFactory_CreateBitmapFromSource(IWICComponentFactory *iface,
470 IWICBitmapSource *piBitmapSource, WICBitmapCreateCacheOption option,
471 IWICBitmap **ppIBitmap)
472 {
473 IWICBitmap *result;
474 IWICBitmapLock *lock;
475 IWICPalette *palette;
476 UINT width, height;
477 WICPixelFormatGUID pixelformat = {0};
478 HRESULT hr;
479 WICRect rc;
480 double dpix, dpiy;
481 IWICComponentInfo *info;
482 IWICPixelFormatInfo2 *formatinfo;
483 WICPixelFormatNumericRepresentation format_type;
484
485 TRACE("(%p,%p,%u,%p)\n", iface, piBitmapSource, option, ppIBitmap);
486
487 if (!piBitmapSource || !ppIBitmap)
488 return E_INVALIDARG;
489
490 hr = IWICBitmapSource_GetSize(piBitmapSource, &width, &height);
491
492 if (SUCCEEDED(hr))
493 hr = IWICBitmapSource_GetPixelFormat(piBitmapSource, &pixelformat);
494
495 if (SUCCEEDED(hr))
496 hr = CreateComponentInfo(&pixelformat, &info);
497
498 if (SUCCEEDED(hr))
499 {
500 hr = IWICComponentInfo_QueryInterface(info, &IID_IWICPixelFormatInfo2, (void**)&formatinfo);
501
502 if (SUCCEEDED(hr))
503 {
504 hr = IWICPixelFormatInfo2_GetNumericRepresentation(formatinfo, &format_type);
505
506 IWICPixelFormatInfo2_Release(formatinfo);
507 }
508
509 IWICComponentInfo_Release(info);
510 }
511
512 if (SUCCEEDED(hr))
513 hr = BitmapImpl_Create(width, height, &pixelformat, option, &result);
514
515 if (SUCCEEDED(hr))
516 {
517 hr = IWICBitmap_Lock(result, NULL, WICBitmapLockWrite, &lock);
518 if (SUCCEEDED(hr))
519 {
520 UINT stride, buffersize;
521 BYTE *buffer;
522 rc.X = rc.Y = 0;
523 rc.Width = width;
524 rc.Height = height;
525
526 hr = IWICBitmapLock_GetStride(lock, &stride);
527
528 if (SUCCEEDED(hr))
529 hr = IWICBitmapLock_GetDataPointer(lock, &buffersize, &buffer);
530
531 if (SUCCEEDED(hr))
532 hr = IWICBitmapSource_CopyPixels(piBitmapSource, &rc, stride,
533 buffersize, buffer);
534
535 IWICBitmapLock_Release(lock);
536 }
537
538 if (SUCCEEDED(hr))
539 hr = PaletteImpl_Create(&palette);
540
541 if (SUCCEEDED(hr) && (format_type == WICPixelFormatNumericRepresentationUnspecified ||
542 format_type == WICPixelFormatNumericRepresentationIndexed))
543 {
544 hr = IWICBitmapSource_CopyPalette(piBitmapSource, palette);
545
546 if (SUCCEEDED(hr))
547 hr = IWICBitmap_SetPalette(result, palette);
548 else
549 hr = S_OK;
550
551 IWICPalette_Release(palette);
552 }
553
554 if (SUCCEEDED(hr))
555 {
556 hr = IWICBitmapSource_GetResolution(piBitmapSource, &dpix, &dpiy);
557
558 if (SUCCEEDED(hr))
559 hr = IWICBitmap_SetResolution(result, dpix, dpiy);
560 else
561 hr = S_OK;
562 }
563
564 if (SUCCEEDED(hr))
565 *ppIBitmap = result;
566 else
567 IWICBitmap_Release(result);
568 }
569
570 return hr;
571 }
572
573 static HRESULT WINAPI ComponentFactory_CreateBitmapFromSourceRect(IWICComponentFactory *iface,
574 IWICBitmapSource *piBitmapSource, UINT x, UINT y, UINT width, UINT height,
575 IWICBitmap **ppIBitmap)
576 {
577 FIXME("(%p,%p,%u,%u,%u,%u,%p): stub\n", iface, piBitmapSource, x, y, width,
578 height, ppIBitmap);
579 return E_NOTIMPL;
580 }
581
582 static HRESULT WINAPI ComponentFactory_CreateBitmapFromMemory(IWICComponentFactory *iface,
583 UINT uiWidth, UINT uiHeight, REFWICPixelFormatGUID pixelFormat, UINT cbStride,
584 UINT cbBufferSize, BYTE *pbBuffer, IWICBitmap **ppIBitmap)
585 {
586 FIXME("(%p,%u,%u,%s,%u,%u,%p,%p): stub\n", iface, uiWidth, uiHeight,
587 debugstr_guid(pixelFormat), cbStride, cbBufferSize, pbBuffer, ppIBitmap);
588 return E_NOTIMPL;
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 }