widl: Always check the runtimeclass interfaces presence.
[wine/zf.git] / dlls / windowscodecs / info.c
blobcbe8aae572d040fd4d065e3a9d7df0d0d437011f
1 /*
2 * Copyright 2009 Vincent Povirk for CodeWeavers
3 * Copyright 2012 Dmitry Timoshkov
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.
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.
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
20 #include <stdarg.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winreg.h"
27 #include "objbase.h"
29 #include "wincodecs_private.h"
31 #include "wine/debug.h"
32 #include "wine/list.h"
33 #include "wine/rbtree.h"
34 #include "wine/heap.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
38 typedef struct {
39 IWICComponentInfo IWICComponentInfo_iface;
40 LONG ref;
41 CLSID clsid;
42 struct wine_rb_entry entry;
43 } ComponentInfo;
45 static HRESULT ComponentInfo_GetStringValue(HKEY classkey, LPCWSTR value,
46 UINT buffer_size, WCHAR *buffer, UINT *actual_size)
48 LONG ret;
49 DWORD cbdata=buffer_size * sizeof(WCHAR);
51 if (!actual_size)
52 return E_INVALIDARG;
54 ret = RegGetValueW(classkey, NULL, value, RRF_RT_REG_SZ|RRF_NOEXPAND, NULL,
55 buffer, &cbdata);
57 if (ret == ERROR_FILE_NOT_FOUND)
59 *actual_size = 0;
60 return S_OK;
63 if (ret == 0 || ret == ERROR_MORE_DATA)
64 *actual_size = cbdata/sizeof(WCHAR);
66 if (!buffer && buffer_size != 0)
67 /* Yes, native returns the correct size in this case. */
68 return E_INVALIDARG;
70 if (ret == ERROR_MORE_DATA)
71 return WINCODEC_ERR_INSUFFICIENTBUFFER;
73 return HRESULT_FROM_WIN32(ret);
76 static HRESULT ComponentInfo_GetGUIDValue(HKEY classkey, LPCWSTR value,
77 GUID *result)
79 LONG ret;
80 WCHAR guid_string[39];
81 DWORD cbdata = sizeof(guid_string);
82 HRESULT hr;
84 if (!result)
85 return E_INVALIDARG;
87 ret = RegGetValueW(classkey, NULL, value, RRF_RT_REG_SZ|RRF_NOEXPAND, NULL,
88 guid_string, &cbdata);
90 if (ret != ERROR_SUCCESS)
91 return HRESULT_FROM_WIN32(ret);
93 if (cbdata < sizeof(guid_string))
95 ERR("incomplete GUID value\n");
96 return E_FAIL;
99 hr = CLSIDFromString(guid_string, result);
101 return hr;
104 static HRESULT ComponentInfo_GetDWORDValue(HKEY classkey, LPCWSTR value,
105 DWORD *result)
107 LONG ret;
108 DWORD cbdata = sizeof(DWORD);
110 if (!result)
111 return E_INVALIDARG;
113 ret = RegGetValueW(classkey, NULL, value, RRF_RT_DWORD, NULL,
114 result, &cbdata);
116 if (ret == ERROR_FILE_NOT_FOUND)
118 *result = 0;
119 return S_OK;
122 return HRESULT_FROM_WIN32(ret);
125 static HRESULT ComponentInfo_GetGuidList(HKEY classkey, LPCWSTR subkeyname,
126 UINT buffersize, GUID *buffer, UINT *actual_size)
128 LONG ret;
129 HKEY subkey;
130 UINT items_returned;
131 WCHAR guid_string[39];
132 DWORD guid_string_size;
133 HRESULT hr=S_OK;
135 if (!actual_size)
136 return E_INVALIDARG;
138 ret = RegOpenKeyExW(classkey, subkeyname, 0, KEY_READ, &subkey);
139 if (ret == ERROR_FILE_NOT_FOUND)
141 *actual_size = 0;
142 return S_OK;
144 else if (ret != ERROR_SUCCESS) return HRESULT_FROM_WIN32(ret);
146 if (buffer)
148 items_returned = 0;
149 guid_string_size = 39;
150 while (items_returned < buffersize)
152 ret = RegEnumKeyExW(subkey, items_returned, guid_string,
153 &guid_string_size, NULL, NULL, NULL, NULL);
155 if (ret != ERROR_SUCCESS)
157 hr = HRESULT_FROM_WIN32(ret);
158 break;
161 if (guid_string_size != 38)
163 hr = E_FAIL;
164 break;
167 hr = CLSIDFromString(guid_string, &buffer[items_returned]);
168 if (FAILED(hr))
169 break;
171 items_returned++;
172 guid_string_size = 39;
175 if (ret == ERROR_NO_MORE_ITEMS)
176 hr = S_OK;
178 *actual_size = items_returned;
180 else
182 ret = RegQueryInfoKeyW(subkey, NULL, NULL, NULL, actual_size, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
183 if (ret != ERROR_SUCCESS)
184 hr = HRESULT_FROM_WIN32(ret);
187 RegCloseKey(subkey);
189 return hr;
192 typedef struct {
193 ComponentInfo base;
194 HKEY classkey;
195 WICBitmapPattern *patterns;
196 UINT pattern_count;
197 UINT patterns_size;
198 } BitmapDecoderInfo;
200 static inline BitmapDecoderInfo *impl_from_IWICBitmapDecoderInfo(IWICBitmapDecoderInfo *iface)
202 return CONTAINING_RECORD(iface, BitmapDecoderInfo, base.IWICComponentInfo_iface);
205 static HRESULT WINAPI BitmapDecoderInfo_QueryInterface(IWICBitmapDecoderInfo *iface, REFIID iid,
206 void **ppv)
208 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
209 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
211 if (!ppv) return E_INVALIDARG;
213 if (IsEqualIID(&IID_IUnknown, iid) ||
214 IsEqualIID(&IID_IWICComponentInfo, iid) ||
215 IsEqualIID(&IID_IWICBitmapCodecInfo, iid) ||
216 IsEqualIID(&IID_IWICBitmapDecoderInfo ,iid))
218 *ppv = &This->base.IWICComponentInfo_iface;
220 else
222 *ppv = NULL;
223 return E_NOINTERFACE;
226 IUnknown_AddRef((IUnknown*)*ppv);
227 return S_OK;
230 static ULONG WINAPI BitmapDecoderInfo_AddRef(IWICBitmapDecoderInfo *iface)
232 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
233 ULONG ref = InterlockedIncrement(&This->base.ref);
235 TRACE("(%p) refcount=%u\n", iface, ref);
237 return ref;
240 static ULONG WINAPI BitmapDecoderInfo_Release(IWICBitmapDecoderInfo *iface)
242 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
243 ULONG ref = InterlockedDecrement(&This->base.ref);
245 TRACE("(%p) refcount=%u\n", iface, ref);
247 if (ref == 0)
249 RegCloseKey(This->classkey);
250 heap_free(This->patterns);
251 HeapFree(GetProcessHeap(), 0, This);
254 return ref;
257 static HRESULT WINAPI BitmapDecoderInfo_GetComponentType(IWICBitmapDecoderInfo *iface,
258 WICComponentType *pType)
260 TRACE("(%p,%p)\n", iface, pType);
261 if (!pType) return E_INVALIDARG;
262 *pType = WICDecoder;
263 return S_OK;
266 static HRESULT WINAPI BitmapDecoderInfo_GetCLSID(IWICBitmapDecoderInfo *iface, CLSID *pclsid)
268 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
269 TRACE("(%p,%p)\n", iface, pclsid);
271 if (!pclsid)
272 return E_INVALIDARG;
274 *pclsid = This->base.clsid;
275 return S_OK;
278 static HRESULT WINAPI BitmapDecoderInfo_GetSigningStatus(IWICBitmapDecoderInfo *iface, DWORD *pStatus)
280 FIXME("(%p,%p): stub\n", iface, pStatus);
281 return E_NOTIMPL;
284 static HRESULT WINAPI BitmapDecoderInfo_GetAuthor(IWICBitmapDecoderInfo *iface, UINT cchAuthor,
285 WCHAR *wzAuthor, UINT *pcchActual)
287 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
289 TRACE("(%p,%u,%p,%p)\n", iface, cchAuthor, wzAuthor, pcchActual);
291 return ComponentInfo_GetStringValue(This->classkey, L"Author", cchAuthor, wzAuthor, pcchActual);
294 static HRESULT WINAPI BitmapDecoderInfo_GetVendorGUID(IWICBitmapDecoderInfo *iface, GUID *pguidVendor)
296 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
298 TRACE("(%p,%p)\n", iface, pguidVendor);
300 return ComponentInfo_GetGUIDValue(This->classkey, L"Vendor", pguidVendor);
303 static HRESULT WINAPI BitmapDecoderInfo_GetVersion(IWICBitmapDecoderInfo *iface, UINT cchVersion,
304 WCHAR *wzVersion, UINT *pcchActual)
306 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
308 TRACE("(%p,%u,%p,%p)\n", iface, cchVersion, wzVersion, pcchActual);
310 return ComponentInfo_GetStringValue(This->classkey, L"Version",
311 cchVersion, wzVersion, pcchActual);
314 static HRESULT WINAPI BitmapDecoderInfo_GetSpecVersion(IWICBitmapDecoderInfo *iface, UINT cchSpecVersion,
315 WCHAR *wzSpecVersion, UINT *pcchActual)
317 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
319 TRACE("(%p,%u,%p,%p)\n", iface, cchSpecVersion, wzSpecVersion, pcchActual);
321 return ComponentInfo_GetStringValue(This->classkey, L"SpecVersion",
322 cchSpecVersion, wzSpecVersion, pcchActual);
325 static HRESULT WINAPI BitmapDecoderInfo_GetFriendlyName(IWICBitmapDecoderInfo *iface, UINT cchFriendlyName,
326 WCHAR *wzFriendlyName, UINT *pcchActual)
328 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
330 TRACE("(%p,%u,%p,%p)\n", iface, cchFriendlyName, wzFriendlyName, pcchActual);
332 return ComponentInfo_GetStringValue(This->classkey, L"FriendlyName",
333 cchFriendlyName, wzFriendlyName, pcchActual);
336 static HRESULT WINAPI BitmapDecoderInfo_GetContainerFormat(IWICBitmapDecoderInfo *iface,
337 GUID *pguidContainerFormat)
339 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
340 TRACE("(%p,%p)\n", iface, pguidContainerFormat);
341 return ComponentInfo_GetGUIDValue(This->classkey, L"ContainerFormat", pguidContainerFormat);
344 static HRESULT WINAPI BitmapDecoderInfo_GetPixelFormats(IWICBitmapDecoderInfo *iface,
345 UINT cFormats, GUID *pguidPixelFormats, UINT *pcActual)
347 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
348 TRACE("(%p,%u,%p,%p)\n", iface, cFormats, pguidPixelFormats, pcActual);
349 return ComponentInfo_GetGuidList(This->classkey, L"Formats", cFormats, pguidPixelFormats, pcActual);
352 static HRESULT WINAPI BitmapDecoderInfo_GetColorManagementVersion(IWICBitmapDecoderInfo *iface,
353 UINT cchColorManagementVersion, WCHAR *wzColorManagementVersion, UINT *pcchActual)
355 FIXME("(%p,%u,%p,%p): stub\n", iface, cchColorManagementVersion, wzColorManagementVersion, pcchActual);
356 return E_NOTIMPL;
359 static HRESULT WINAPI BitmapDecoderInfo_GetDeviceManufacturer(IWICBitmapDecoderInfo *iface,
360 UINT cchDeviceManufacturer, WCHAR *wzDeviceManufacturer, UINT *pcchActual)
362 FIXME("(%p,%u,%p,%p): stub\n", iface, cchDeviceManufacturer, wzDeviceManufacturer, pcchActual);
363 return E_NOTIMPL;
366 static HRESULT WINAPI BitmapDecoderInfo_GetDeviceModels(IWICBitmapDecoderInfo *iface,
367 UINT cchDeviceModels, WCHAR *wzDeviceModels, UINT *pcchActual)
369 FIXME("(%p,%u,%p,%p): stub\n", iface, cchDeviceModels, wzDeviceModels, pcchActual);
370 return E_NOTIMPL;
373 static HRESULT WINAPI BitmapDecoderInfo_GetMimeTypes(IWICBitmapDecoderInfo *iface,
374 UINT cchMimeTypes, WCHAR *wzMimeTypes, UINT *pcchActual)
376 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
378 TRACE("(%p,%u,%p,%p)\n", iface, cchMimeTypes, wzMimeTypes, pcchActual);
380 return ComponentInfo_GetStringValue(This->classkey, L"MimeTypes",
381 cchMimeTypes, wzMimeTypes, pcchActual);
384 static HRESULT WINAPI BitmapDecoderInfo_GetFileExtensions(IWICBitmapDecoderInfo *iface,
385 UINT cchFileExtensions, WCHAR *wzFileExtensions, UINT *pcchActual)
387 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
389 TRACE("(%p,%u,%p,%p)\n", iface, cchFileExtensions, wzFileExtensions, pcchActual);
391 return ComponentInfo_GetStringValue(This->classkey, L"FileExtensions",
392 cchFileExtensions, wzFileExtensions, pcchActual);
395 static HRESULT WINAPI BitmapDecoderInfo_DoesSupportAnimation(IWICBitmapDecoderInfo *iface,
396 BOOL *pfSupportAnimation)
398 FIXME("(%p,%p): stub\n", iface, pfSupportAnimation);
399 return E_NOTIMPL;
402 static HRESULT WINAPI BitmapDecoderInfo_DoesSupportChromaKey(IWICBitmapDecoderInfo *iface,
403 BOOL *pfSupportChromaKey)
405 FIXME("(%p,%p): stub\n", iface, pfSupportChromaKey);
406 return E_NOTIMPL;
409 static HRESULT WINAPI BitmapDecoderInfo_DoesSupportLossless(IWICBitmapDecoderInfo *iface,
410 BOOL *pfSupportLossless)
412 FIXME("(%p,%p): stub\n", iface, pfSupportLossless);
413 return E_NOTIMPL;
416 static HRESULT WINAPI BitmapDecoderInfo_DoesSupportMultiframe(IWICBitmapDecoderInfo *iface,
417 BOOL *pfSupportMultiframe)
419 FIXME("(%p,%p): stub\n", iface, pfSupportMultiframe);
420 return E_NOTIMPL;
423 static HRESULT WINAPI BitmapDecoderInfo_MatchesMimeType(IWICBitmapDecoderInfo *iface,
424 LPCWSTR wzMimeType, BOOL *pfMatches)
426 FIXME("(%p,%s,%p): stub\n", iface, debugstr_w(wzMimeType), pfMatches);
427 return E_NOTIMPL;
430 static HRESULT WINAPI BitmapDecoderInfo_GetPatterns(IWICBitmapDecoderInfo *iface,
431 UINT cbSizePatterns, WICBitmapPattern *pPatterns, UINT *pcPatterns, UINT *pcbPatternsActual)
433 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
435 TRACE("(%p,%i,%p,%p,%p)\n", iface, cbSizePatterns, pPatterns, pcPatterns, pcbPatternsActual);
437 if (!pcPatterns || !pcbPatternsActual) return E_INVALIDARG;
439 *pcPatterns = This->pattern_count;
440 *pcbPatternsActual = This->patterns_size;
441 if (pPatterns)
443 if (This->patterns_size && cbSizePatterns < This->patterns_size)
444 return WINCODEC_ERR_INSUFFICIENTBUFFER;
445 memcpy(pPatterns, This->patterns, This->patterns_size);
447 return S_OK;
450 static HRESULT WINAPI BitmapDecoderInfo_MatchesPattern(IWICBitmapDecoderInfo *iface,
451 IStream *pIStream, BOOL *pfMatches)
453 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
454 HRESULT hr;
455 UINT i;
456 ULONG pos;
457 BYTE *data=NULL;
458 ULONG datasize=0;
459 ULONG bytesread;
460 LARGE_INTEGER seekpos;
462 TRACE("(%p,%p,%p)\n", iface, pIStream, pfMatches);
464 for (i=0; i < This->pattern_count; i++)
466 if (datasize < This->patterns[i].Length)
468 HeapFree(GetProcessHeap(), 0, data);
469 datasize = This->patterns[i].Length;
470 data = HeapAlloc(GetProcessHeap(), 0, This->patterns[i].Length);
471 if (!data)
473 hr = E_OUTOFMEMORY;
474 break;
478 if (This->patterns[i].EndOfStream)
479 seekpos.QuadPart = -This->patterns[i].Position.QuadPart;
480 else
481 seekpos.QuadPart = This->patterns[i].Position.QuadPart;
482 hr = IStream_Seek(pIStream, seekpos, This->patterns[i].EndOfStream ? STREAM_SEEK_END : STREAM_SEEK_SET, NULL);
483 if (hr == STG_E_INVALIDFUNCTION) continue; /* before start of stream */
484 if (FAILED(hr)) break;
486 hr = IStream_Read(pIStream, data, This->patterns[i].Length, &bytesread);
487 if (hr == S_FALSE || (hr == S_OK && bytesread != This->patterns[i].Length)) /* past end of stream */
488 continue;
489 if (FAILED(hr)) break;
491 for (pos=0; pos < This->patterns[i].Length; pos++)
493 if ((data[pos] & This->patterns[i].Mask[pos]) != This->patterns[i].Pattern[pos])
494 break;
496 if (pos == This->patterns[i].Length) /* matches pattern */
498 hr = S_OK;
499 *pfMatches = TRUE;
500 break;
504 if (i == This->pattern_count) /* does not match any pattern */
506 hr = S_OK;
507 *pfMatches = FALSE;
510 HeapFree(GetProcessHeap(), 0, data);
511 return hr;
514 static HRESULT WINAPI BitmapDecoderInfo_CreateInstance(IWICBitmapDecoderInfo *iface,
515 IWICBitmapDecoder **ppIBitmapDecoder)
517 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
519 TRACE("(%p,%p)\n", iface, ppIBitmapDecoder);
521 return create_instance(&This->base.clsid, &IID_IWICBitmapDecoder, (void**)ppIBitmapDecoder);
524 static const IWICBitmapDecoderInfoVtbl BitmapDecoderInfo_Vtbl = {
525 BitmapDecoderInfo_QueryInterface,
526 BitmapDecoderInfo_AddRef,
527 BitmapDecoderInfo_Release,
528 BitmapDecoderInfo_GetComponentType,
529 BitmapDecoderInfo_GetCLSID,
530 BitmapDecoderInfo_GetSigningStatus,
531 BitmapDecoderInfo_GetAuthor,
532 BitmapDecoderInfo_GetVendorGUID,
533 BitmapDecoderInfo_GetVersion,
534 BitmapDecoderInfo_GetSpecVersion,
535 BitmapDecoderInfo_GetFriendlyName,
536 BitmapDecoderInfo_GetContainerFormat,
537 BitmapDecoderInfo_GetPixelFormats,
538 BitmapDecoderInfo_GetColorManagementVersion,
539 BitmapDecoderInfo_GetDeviceManufacturer,
540 BitmapDecoderInfo_GetDeviceModels,
541 BitmapDecoderInfo_GetMimeTypes,
542 BitmapDecoderInfo_GetFileExtensions,
543 BitmapDecoderInfo_DoesSupportAnimation,
544 BitmapDecoderInfo_DoesSupportChromaKey,
545 BitmapDecoderInfo_DoesSupportLossless,
546 BitmapDecoderInfo_DoesSupportMultiframe,
547 BitmapDecoderInfo_MatchesMimeType,
548 BitmapDecoderInfo_GetPatterns,
549 BitmapDecoderInfo_MatchesPattern,
550 BitmapDecoderInfo_CreateInstance
553 static void read_bitmap_patterns(BitmapDecoderInfo *info)
555 UINT pattern_count=0, patterns_size=0;
556 WCHAR subkeyname[11];
557 LONG res;
558 HKEY patternskey, patternkey;
559 UINT i;
560 WICBitmapPattern *patterns;
561 BYTE *patterns_ptr;
562 DWORD length, valuesize;
564 res = RegOpenKeyExW(info->classkey, L"Patterns", 0, KEY_READ, &patternskey);
565 if (res != ERROR_SUCCESS) return;
567 res = RegQueryInfoKeyW(patternskey, NULL, NULL, NULL, &pattern_count, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
568 if (res != ERROR_SUCCESS)
570 RegCloseKey(patternskey);
571 return;
574 patterns_size = pattern_count * sizeof(WICBitmapPattern);
575 patterns = heap_alloc(patterns_size);
576 if (!patterns)
578 RegCloseKey(patternskey);
579 return;
582 for (i=0; res == ERROR_SUCCESS && i < pattern_count; i++)
584 swprintf(subkeyname, 11, L"%u", i);
585 res = RegOpenKeyExW(patternskey, subkeyname, 0, KEY_READ, &patternkey);
586 if (res != ERROR_SUCCESS) break;
588 valuesize = sizeof(ULONG);
589 res = RegGetValueW(patternkey, NULL, L"Length", RRF_RT_DWORD, NULL, &length, &valuesize);
590 if (res == ERROR_SUCCESS)
592 patterns_size += length*2;
593 patterns[i].Length = length;
595 valuesize = sizeof(BOOL);
596 res = RegGetValueW(patternkey, NULL, L"EndOfStream", RRF_RT_DWORD, NULL,
597 &patterns[i].EndOfStream, &valuesize);
598 if (res) patterns[i].EndOfStream = 0;
600 patterns[i].Position.QuadPart = 0;
601 valuesize = sizeof(ULARGE_INTEGER);
602 res = RegGetValueW(patternkey, NULL, L"Position", RRF_RT_DWORD|RRF_RT_QWORD, NULL,
603 &patterns[i].Position, &valuesize);
606 RegCloseKey(patternkey);
609 if (res != ERROR_SUCCESS || !(patterns_ptr = heap_realloc(patterns, patterns_size)))
611 heap_free(patterns);
612 RegCloseKey(patternskey);
613 return;
615 patterns = (WICBitmapPattern*)patterns_ptr;
616 patterns_ptr += pattern_count * sizeof(*patterns);
618 for (i=0; res == ERROR_SUCCESS && i < pattern_count; i++)
620 swprintf(subkeyname, 11, L"%u", i);
621 res = RegOpenKeyExW(patternskey, subkeyname, 0, KEY_READ, &patternkey);
622 if (res != ERROR_SUCCESS) break;
624 length = patterns[i].Length;
625 patterns[i].Pattern = patterns_ptr;
626 valuesize = length;
627 res = RegGetValueW(patternkey, NULL, L"Pattern", RRF_RT_REG_BINARY, NULL,
628 patterns[i].Pattern, &valuesize);
629 patterns_ptr += length;
631 if (res == ERROR_SUCCESS)
633 patterns[i].Mask = patterns_ptr;
634 valuesize = length;
635 res = RegGetValueW(patternkey, NULL, L"Mask", RRF_RT_REG_BINARY, NULL,
636 patterns[i].Mask, &valuesize);
637 patterns_ptr += length;
640 RegCloseKey(patternkey);
643 RegCloseKey(patternskey);
645 if (res != ERROR_SUCCESS)
647 heap_free(patterns);
648 return;
651 info->pattern_count = pattern_count;
652 info->patterns_size = patterns_size;
653 info->patterns = patterns;
656 static HRESULT BitmapDecoderInfo_Constructor(HKEY classkey, REFCLSID clsid, ComponentInfo **ret)
658 BitmapDecoderInfo *This;
660 This = heap_alloc_zero(sizeof(BitmapDecoderInfo));
661 if (!This)
663 RegCloseKey(classkey);
664 return E_OUTOFMEMORY;
667 This->base.IWICComponentInfo_iface.lpVtbl = (const IWICComponentInfoVtbl*)&BitmapDecoderInfo_Vtbl;
668 This->base.ref = 1;
669 This->classkey = classkey;
670 This->base.clsid = *clsid;
672 read_bitmap_patterns(This);
674 *ret = &This->base;
675 return S_OK;
678 typedef struct {
679 ComponentInfo base;
680 HKEY classkey;
681 } BitmapEncoderInfo;
683 static inline BitmapEncoderInfo *impl_from_IWICBitmapEncoderInfo(IWICBitmapEncoderInfo *iface)
685 return CONTAINING_RECORD(iface, BitmapEncoderInfo, base.IWICComponentInfo_iface);
688 static HRESULT WINAPI BitmapEncoderInfo_QueryInterface(IWICBitmapEncoderInfo *iface, REFIID iid,
689 void **ppv)
691 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
692 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
694 if (!ppv) return E_INVALIDARG;
696 if (IsEqualIID(&IID_IUnknown, iid) ||
697 IsEqualIID(&IID_IWICComponentInfo, iid) ||
698 IsEqualIID(&IID_IWICBitmapCodecInfo, iid) ||
699 IsEqualIID(&IID_IWICBitmapEncoderInfo ,iid))
701 *ppv = &This->base.IWICComponentInfo_iface;
703 else
705 *ppv = NULL;
706 return E_NOINTERFACE;
709 IUnknown_AddRef((IUnknown*)*ppv);
710 return S_OK;
713 static ULONG WINAPI BitmapEncoderInfo_AddRef(IWICBitmapEncoderInfo *iface)
715 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
716 ULONG ref = InterlockedIncrement(&This->base.ref);
718 TRACE("(%p) refcount=%u\n", iface, ref);
720 return ref;
723 static ULONG WINAPI BitmapEncoderInfo_Release(IWICBitmapEncoderInfo *iface)
725 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
726 ULONG ref = InterlockedDecrement(&This->base.ref);
728 TRACE("(%p) refcount=%u\n", iface, ref);
730 if (ref == 0)
732 RegCloseKey(This->classkey);
733 HeapFree(GetProcessHeap(), 0, This);
736 return ref;
739 static HRESULT WINAPI BitmapEncoderInfo_GetComponentType(IWICBitmapEncoderInfo *iface,
740 WICComponentType *pType)
742 TRACE("(%p,%p)\n", iface, pType);
743 if (!pType) return E_INVALIDARG;
744 *pType = WICEncoder;
745 return S_OK;
748 static HRESULT WINAPI BitmapEncoderInfo_GetCLSID(IWICBitmapEncoderInfo *iface, CLSID *pclsid)
750 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
751 TRACE("(%p,%p)\n", iface, pclsid);
753 if (!pclsid)
754 return E_INVALIDARG;
756 *pclsid = This->base.clsid;
757 return S_OK;
760 static HRESULT WINAPI BitmapEncoderInfo_GetSigningStatus(IWICBitmapEncoderInfo *iface, DWORD *pStatus)
762 FIXME("(%p,%p): stub\n", iface, pStatus);
763 return E_NOTIMPL;
766 static HRESULT WINAPI BitmapEncoderInfo_GetAuthor(IWICBitmapEncoderInfo *iface, UINT cchAuthor,
767 WCHAR *wzAuthor, UINT *pcchActual)
769 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
771 TRACE("(%p,%u,%p,%p)\n", iface, cchAuthor, wzAuthor, pcchActual);
773 return ComponentInfo_GetStringValue(This->classkey, L"Author", cchAuthor, wzAuthor, pcchActual);
776 static HRESULT WINAPI BitmapEncoderInfo_GetVendorGUID(IWICBitmapEncoderInfo *iface, GUID *pguidVendor)
778 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
780 TRACE("(%p,%p)\n", iface, pguidVendor);
782 return ComponentInfo_GetGUIDValue(This->classkey, L"Vendor", pguidVendor);
785 static HRESULT WINAPI BitmapEncoderInfo_GetVersion(IWICBitmapEncoderInfo *iface, UINT cchVersion,
786 WCHAR *wzVersion, UINT *pcchActual)
788 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
790 TRACE("(%p,%u,%p,%p)\n", iface, cchVersion, wzVersion, pcchActual);
792 return ComponentInfo_GetStringValue(This->classkey, L"Version",
793 cchVersion, wzVersion, pcchActual);
796 static HRESULT WINAPI BitmapEncoderInfo_GetSpecVersion(IWICBitmapEncoderInfo *iface, UINT cchSpecVersion,
797 WCHAR *wzSpecVersion, UINT *pcchActual)
799 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
801 TRACE("(%p,%u,%p,%p)\n", iface, cchSpecVersion, wzSpecVersion, pcchActual);
803 return ComponentInfo_GetStringValue(This->classkey, L"SpecVersion",
804 cchSpecVersion, wzSpecVersion, pcchActual);
807 static HRESULT WINAPI BitmapEncoderInfo_GetFriendlyName(IWICBitmapEncoderInfo *iface, UINT cchFriendlyName,
808 WCHAR *wzFriendlyName, UINT *pcchActual)
810 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
812 TRACE("(%p,%u,%p,%p)\n", iface, cchFriendlyName, wzFriendlyName, pcchActual);
814 return ComponentInfo_GetStringValue(This->classkey, L"FriendlyName",
815 cchFriendlyName, wzFriendlyName, pcchActual);
818 static HRESULT WINAPI BitmapEncoderInfo_GetContainerFormat(IWICBitmapEncoderInfo *iface,
819 GUID *pguidContainerFormat)
821 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
822 TRACE("(%p,%p)\n", iface, pguidContainerFormat);
823 return ComponentInfo_GetGUIDValue(This->classkey, L"ContainerFormat", pguidContainerFormat);
826 static HRESULT WINAPI BitmapEncoderInfo_GetPixelFormats(IWICBitmapEncoderInfo *iface,
827 UINT cFormats, GUID *pguidPixelFormats, UINT *pcActual)
829 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
830 TRACE("(%p,%u,%p,%p)\n", iface, cFormats, pguidPixelFormats, pcActual);
831 return ComponentInfo_GetGuidList(This->classkey, L"Formats", cFormats, pguidPixelFormats, pcActual);
834 static HRESULT WINAPI BitmapEncoderInfo_GetColorManagementVersion(IWICBitmapEncoderInfo *iface,
835 UINT cchColorManagementVersion, WCHAR *wzColorManagementVersion, UINT *pcchActual)
837 FIXME("(%p,%u,%p,%p): stub\n", iface, cchColorManagementVersion, wzColorManagementVersion, pcchActual);
838 return E_NOTIMPL;
841 static HRESULT WINAPI BitmapEncoderInfo_GetDeviceManufacturer(IWICBitmapEncoderInfo *iface,
842 UINT cchDeviceManufacturer, WCHAR *wzDeviceManufacturer, UINT *pcchActual)
844 FIXME("(%p,%u,%p,%p): stub\n", iface, cchDeviceManufacturer, wzDeviceManufacturer, pcchActual);
845 return E_NOTIMPL;
848 static HRESULT WINAPI BitmapEncoderInfo_GetDeviceModels(IWICBitmapEncoderInfo *iface,
849 UINT cchDeviceModels, WCHAR *wzDeviceModels, UINT *pcchActual)
851 FIXME("(%p,%u,%p,%p): stub\n", iface, cchDeviceModels, wzDeviceModels, pcchActual);
852 return E_NOTIMPL;
855 static HRESULT WINAPI BitmapEncoderInfo_GetMimeTypes(IWICBitmapEncoderInfo *iface,
856 UINT cchMimeTypes, WCHAR *wzMimeTypes, UINT *pcchActual)
858 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
860 TRACE("(%p,%u,%p,%p)\n", iface, cchMimeTypes, wzMimeTypes, pcchActual);
862 return ComponentInfo_GetStringValue(This->classkey, L"MimeTypes",
863 cchMimeTypes, wzMimeTypes, pcchActual);
866 static HRESULT WINAPI BitmapEncoderInfo_GetFileExtensions(IWICBitmapEncoderInfo *iface,
867 UINT cchFileExtensions, WCHAR *wzFileExtensions, UINT *pcchActual)
869 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
871 TRACE("(%p,%u,%p,%p)\n", iface, cchFileExtensions, wzFileExtensions, pcchActual);
873 return ComponentInfo_GetStringValue(This->classkey, L"FileExtensions",
874 cchFileExtensions, wzFileExtensions, pcchActual);
877 static HRESULT WINAPI BitmapEncoderInfo_DoesSupportAnimation(IWICBitmapEncoderInfo *iface,
878 BOOL *pfSupportAnimation)
880 FIXME("(%p,%p): stub\n", iface, pfSupportAnimation);
881 return E_NOTIMPL;
884 static HRESULT WINAPI BitmapEncoderInfo_DoesSupportChromaKey(IWICBitmapEncoderInfo *iface,
885 BOOL *pfSupportChromaKey)
887 FIXME("(%p,%p): stub\n", iface, pfSupportChromaKey);
888 return E_NOTIMPL;
891 static HRESULT WINAPI BitmapEncoderInfo_DoesSupportLossless(IWICBitmapEncoderInfo *iface,
892 BOOL *pfSupportLossless)
894 FIXME("(%p,%p): stub\n", iface, pfSupportLossless);
895 return E_NOTIMPL;
898 static HRESULT WINAPI BitmapEncoderInfo_DoesSupportMultiframe(IWICBitmapEncoderInfo *iface,
899 BOOL *pfSupportMultiframe)
901 FIXME("(%p,%p): stub\n", iface, pfSupportMultiframe);
902 return E_NOTIMPL;
905 static HRESULT WINAPI BitmapEncoderInfo_MatchesMimeType(IWICBitmapEncoderInfo *iface,
906 LPCWSTR wzMimeType, BOOL *pfMatches)
908 FIXME("(%p,%s,%p): stub\n", iface, debugstr_w(wzMimeType), pfMatches);
909 return E_NOTIMPL;
912 static HRESULT WINAPI BitmapEncoderInfo_CreateInstance(IWICBitmapEncoderInfo *iface,
913 IWICBitmapEncoder **ppIBitmapEncoder)
915 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
917 TRACE("(%p,%p)\n", iface, ppIBitmapEncoder);
919 return create_instance(&This->base.clsid, &IID_IWICBitmapEncoder, (void**)ppIBitmapEncoder);
922 static const IWICBitmapEncoderInfoVtbl BitmapEncoderInfo_Vtbl = {
923 BitmapEncoderInfo_QueryInterface,
924 BitmapEncoderInfo_AddRef,
925 BitmapEncoderInfo_Release,
926 BitmapEncoderInfo_GetComponentType,
927 BitmapEncoderInfo_GetCLSID,
928 BitmapEncoderInfo_GetSigningStatus,
929 BitmapEncoderInfo_GetAuthor,
930 BitmapEncoderInfo_GetVendorGUID,
931 BitmapEncoderInfo_GetVersion,
932 BitmapEncoderInfo_GetSpecVersion,
933 BitmapEncoderInfo_GetFriendlyName,
934 BitmapEncoderInfo_GetContainerFormat,
935 BitmapEncoderInfo_GetPixelFormats,
936 BitmapEncoderInfo_GetColorManagementVersion,
937 BitmapEncoderInfo_GetDeviceManufacturer,
938 BitmapEncoderInfo_GetDeviceModels,
939 BitmapEncoderInfo_GetMimeTypes,
940 BitmapEncoderInfo_GetFileExtensions,
941 BitmapEncoderInfo_DoesSupportAnimation,
942 BitmapEncoderInfo_DoesSupportChromaKey,
943 BitmapEncoderInfo_DoesSupportLossless,
944 BitmapEncoderInfo_DoesSupportMultiframe,
945 BitmapEncoderInfo_MatchesMimeType,
946 BitmapEncoderInfo_CreateInstance
949 static HRESULT BitmapEncoderInfo_Constructor(HKEY classkey, REFCLSID clsid, ComponentInfo **ret)
951 BitmapEncoderInfo *This;
953 This = HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapEncoderInfo));
954 if (!This)
956 RegCloseKey(classkey);
957 return E_OUTOFMEMORY;
960 This->base.IWICComponentInfo_iface.lpVtbl = (const IWICComponentInfoVtbl*)&BitmapEncoderInfo_Vtbl;
961 This->base.ref = 1;
962 This->classkey = classkey;
963 This->base.clsid = *clsid;
965 *ret = &This->base;
966 return S_OK;
969 typedef struct {
970 ComponentInfo base;
971 HKEY classkey;
972 } FormatConverterInfo;
974 static inline FormatConverterInfo *impl_from_IWICFormatConverterInfo(IWICFormatConverterInfo *iface)
976 return CONTAINING_RECORD(iface, FormatConverterInfo, base.IWICComponentInfo_iface);
979 static HRESULT WINAPI FormatConverterInfo_QueryInterface(IWICFormatConverterInfo *iface, REFIID iid,
980 void **ppv)
982 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
983 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
985 if (!ppv) return E_INVALIDARG;
987 if (IsEqualIID(&IID_IUnknown, iid) ||
988 IsEqualIID(&IID_IWICComponentInfo, iid) ||
989 IsEqualIID(&IID_IWICFormatConverterInfo ,iid))
991 *ppv = &This->base.IWICComponentInfo_iface;
993 else
995 *ppv = NULL;
996 return E_NOINTERFACE;
999 IUnknown_AddRef((IUnknown*)*ppv);
1000 return S_OK;
1003 static ULONG WINAPI FormatConverterInfo_AddRef(IWICFormatConverterInfo *iface)
1005 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
1006 ULONG ref = InterlockedIncrement(&This->base.ref);
1008 TRACE("(%p) refcount=%u\n", iface, ref);
1010 return ref;
1013 static ULONG WINAPI FormatConverterInfo_Release(IWICFormatConverterInfo *iface)
1015 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
1016 ULONG ref = InterlockedDecrement(&This->base.ref);
1018 TRACE("(%p) refcount=%u\n", iface, ref);
1020 if (ref == 0)
1022 RegCloseKey(This->classkey);
1023 HeapFree(GetProcessHeap(), 0, This);
1026 return ref;
1029 static HRESULT WINAPI FormatConverterInfo_GetComponentType(IWICFormatConverterInfo *iface,
1030 WICComponentType *pType)
1032 TRACE("(%p,%p)\n", iface, pType);
1033 if (!pType) return E_INVALIDARG;
1034 *pType = WICPixelFormatConverter;
1035 return S_OK;
1038 static HRESULT WINAPI FormatConverterInfo_GetCLSID(IWICFormatConverterInfo *iface, CLSID *pclsid)
1040 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
1041 TRACE("(%p,%p)\n", iface, pclsid);
1043 if (!pclsid)
1044 return E_INVALIDARG;
1046 *pclsid = This->base.clsid;
1047 return S_OK;
1050 static HRESULT WINAPI FormatConverterInfo_GetSigningStatus(IWICFormatConverterInfo *iface, DWORD *pStatus)
1052 FIXME("(%p,%p): stub\n", iface, pStatus);
1053 return E_NOTIMPL;
1056 static HRESULT WINAPI FormatConverterInfo_GetAuthor(IWICFormatConverterInfo *iface, UINT cchAuthor,
1057 WCHAR *wzAuthor, UINT *pcchActual)
1059 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
1061 TRACE("(%p,%u,%p,%p)\n", iface, cchAuthor, wzAuthor, pcchActual);
1063 return ComponentInfo_GetStringValue(This->classkey, L"Author", cchAuthor, wzAuthor, pcchActual);
1066 static HRESULT WINAPI FormatConverterInfo_GetVendorGUID(IWICFormatConverterInfo *iface, GUID *pguidVendor)
1068 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
1070 TRACE("(%p,%p)\n", iface, pguidVendor);
1072 return ComponentInfo_GetGUIDValue(This->classkey, L"Vendor", pguidVendor);
1075 static HRESULT WINAPI FormatConverterInfo_GetVersion(IWICFormatConverterInfo *iface, UINT cchVersion,
1076 WCHAR *wzVersion, UINT *pcchActual)
1078 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
1080 TRACE("(%p,%u,%p,%p)\n", iface, cchVersion, wzVersion, pcchActual);
1082 return ComponentInfo_GetStringValue(This->classkey, L"Version",
1083 cchVersion, wzVersion, pcchActual);
1086 static HRESULT WINAPI FormatConverterInfo_GetSpecVersion(IWICFormatConverterInfo *iface, UINT cchSpecVersion,
1087 WCHAR *wzSpecVersion, UINT *pcchActual)
1089 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
1091 TRACE("(%p,%u,%p,%p)\n", iface, cchSpecVersion, wzSpecVersion, pcchActual);
1093 return ComponentInfo_GetStringValue(This->classkey, L"SpecVersion",
1094 cchSpecVersion, wzSpecVersion, pcchActual);
1097 static HRESULT WINAPI FormatConverterInfo_GetFriendlyName(IWICFormatConverterInfo *iface, UINT cchFriendlyName,
1098 WCHAR *wzFriendlyName, UINT *pcchActual)
1100 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
1102 TRACE("(%p,%u,%p,%p)\n", iface, cchFriendlyName, wzFriendlyName, pcchActual);
1104 return ComponentInfo_GetStringValue(This->classkey, L"FriendlyName",
1105 cchFriendlyName, wzFriendlyName, pcchActual);
1108 static HRESULT WINAPI FormatConverterInfo_GetPixelFormats(IWICFormatConverterInfo *iface,
1109 UINT cFormats, GUID *pguidPixelFormats, UINT *pcActual)
1111 FIXME("(%p,%u,%p,%p): stub\n", iface, cFormats, pguidPixelFormats, pcActual);
1112 return E_NOTIMPL;
1115 static HRESULT WINAPI FormatConverterInfo_CreateInstance(IWICFormatConverterInfo *iface,
1116 IWICFormatConverter **ppIFormatConverter)
1118 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
1120 TRACE("(%p,%p)\n", iface, ppIFormatConverter);
1122 return create_instance(&This->base.clsid, &IID_IWICFormatConverter,
1123 (void**)ppIFormatConverter);
1126 static BOOL ConverterSupportsFormat(IWICFormatConverterInfo *iface, const WCHAR *formatguid)
1128 LONG res;
1129 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
1130 HKEY formats_key, guid_key;
1132 /* Avoid testing using IWICFormatConverter_GetPixelFormats because that
1133 would be O(n). A registry test should do better. */
1135 res = RegOpenKeyExW(This->classkey, L"PixelFormats", 0, KEY_READ, &formats_key);
1136 if (res != ERROR_SUCCESS) return FALSE;
1138 res = RegOpenKeyExW(formats_key, formatguid, 0, KEY_READ, &guid_key);
1139 if (res == ERROR_SUCCESS) RegCloseKey(guid_key);
1141 RegCloseKey(formats_key);
1143 return (res == ERROR_SUCCESS);
1146 static const IWICFormatConverterInfoVtbl FormatConverterInfo_Vtbl = {
1147 FormatConverterInfo_QueryInterface,
1148 FormatConverterInfo_AddRef,
1149 FormatConverterInfo_Release,
1150 FormatConverterInfo_GetComponentType,
1151 FormatConverterInfo_GetCLSID,
1152 FormatConverterInfo_GetSigningStatus,
1153 FormatConverterInfo_GetAuthor,
1154 FormatConverterInfo_GetVendorGUID,
1155 FormatConverterInfo_GetVersion,
1156 FormatConverterInfo_GetSpecVersion,
1157 FormatConverterInfo_GetFriendlyName,
1158 FormatConverterInfo_GetPixelFormats,
1159 FormatConverterInfo_CreateInstance
1162 static HRESULT FormatConverterInfo_Constructor(HKEY classkey, REFCLSID clsid, ComponentInfo **ret)
1164 FormatConverterInfo *This;
1166 This = HeapAlloc(GetProcessHeap(), 0, sizeof(FormatConverterInfo));
1167 if (!This)
1169 RegCloseKey(classkey);
1170 return E_OUTOFMEMORY;
1173 This->base.IWICComponentInfo_iface.lpVtbl = (const IWICComponentInfoVtbl*)&FormatConverterInfo_Vtbl;
1174 This->base.ref = 1;
1175 This->classkey = classkey;
1176 This->base.clsid = *clsid;
1178 *ret = &This->base;
1179 return S_OK;
1182 typedef struct {
1183 ComponentInfo base;
1184 HKEY classkey;
1185 } PixelFormatInfo;
1187 static inline PixelFormatInfo *impl_from_IWICPixelFormatInfo2(IWICPixelFormatInfo2 *iface)
1189 return CONTAINING_RECORD(iface, PixelFormatInfo, base.IWICComponentInfo_iface);
1192 static HRESULT WINAPI PixelFormatInfo_QueryInterface(IWICPixelFormatInfo2 *iface, REFIID iid,
1193 void **ppv)
1195 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1196 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
1198 if (!ppv) return E_INVALIDARG;
1200 if (IsEqualIID(&IID_IUnknown, iid) ||
1201 IsEqualIID(&IID_IWICComponentInfo, iid) ||
1202 IsEqualIID(&IID_IWICPixelFormatInfo, iid) ||
1203 IsEqualIID(&IID_IWICPixelFormatInfo2 ,iid))
1205 *ppv = &This->base.IWICComponentInfo_iface;
1207 else
1209 *ppv = NULL;
1210 return E_NOINTERFACE;
1213 IUnknown_AddRef((IUnknown*)*ppv);
1214 return S_OK;
1217 static ULONG WINAPI PixelFormatInfo_AddRef(IWICPixelFormatInfo2 *iface)
1219 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1220 ULONG ref = InterlockedIncrement(&This->base.ref);
1222 TRACE("(%p) refcount=%u\n", iface, ref);
1224 return ref;
1227 static ULONG WINAPI PixelFormatInfo_Release(IWICPixelFormatInfo2 *iface)
1229 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1230 ULONG ref = InterlockedDecrement(&This->base.ref);
1232 TRACE("(%p) refcount=%u\n", iface, ref);
1234 if (ref == 0)
1236 RegCloseKey(This->classkey);
1237 HeapFree(GetProcessHeap(), 0, This);
1240 return ref;
1243 static HRESULT WINAPI PixelFormatInfo_GetComponentType(IWICPixelFormatInfo2 *iface,
1244 WICComponentType *pType)
1246 TRACE("(%p,%p)\n", iface, pType);
1247 if (!pType) return E_INVALIDARG;
1248 *pType = WICPixelFormat;
1249 return S_OK;
1252 static HRESULT WINAPI PixelFormatInfo_GetCLSID(IWICPixelFormatInfo2 *iface, CLSID *pclsid)
1254 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1255 TRACE("(%p,%p)\n", iface, pclsid);
1257 if (!pclsid)
1258 return E_INVALIDARG;
1260 *pclsid = This->base.clsid;
1261 return S_OK;
1264 static HRESULT WINAPI PixelFormatInfo_GetSigningStatus(IWICPixelFormatInfo2 *iface, DWORD *pStatus)
1266 TRACE("(%p,%p)\n", iface, pStatus);
1268 if (!pStatus)
1269 return E_INVALIDARG;
1271 /* Pixel formats don't require code, so they are considered signed. */
1272 *pStatus = WICComponentSigned;
1274 return S_OK;
1277 static HRESULT WINAPI PixelFormatInfo_GetAuthor(IWICPixelFormatInfo2 *iface, UINT cchAuthor,
1278 WCHAR *wzAuthor, UINT *pcchActual)
1280 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1282 TRACE("(%p,%u,%p,%p)\n", iface, cchAuthor, wzAuthor, pcchActual);
1284 return ComponentInfo_GetStringValue(This->classkey, L"Author", cchAuthor, wzAuthor, pcchActual);
1287 static HRESULT WINAPI PixelFormatInfo_GetVendorGUID(IWICPixelFormatInfo2 *iface, GUID *pguidVendor)
1289 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1291 TRACE("(%p,%p)\n", iface, pguidVendor);
1293 return ComponentInfo_GetGUIDValue(This->classkey, L"Vendor", pguidVendor);
1296 static HRESULT WINAPI PixelFormatInfo_GetVersion(IWICPixelFormatInfo2 *iface, UINT cchVersion,
1297 WCHAR *wzVersion, UINT *pcchActual)
1299 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1301 TRACE("(%p,%u,%p,%p)\n", iface, cchVersion, wzVersion, pcchActual);
1303 return ComponentInfo_GetStringValue(This->classkey, L"Version",
1304 cchVersion, wzVersion, pcchActual);
1307 static HRESULT WINAPI PixelFormatInfo_GetSpecVersion(IWICPixelFormatInfo2 *iface, UINT cchSpecVersion,
1308 WCHAR *wzSpecVersion, UINT *pcchActual)
1310 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1312 TRACE("(%p,%u,%p,%p)\n", iface, cchSpecVersion, wzSpecVersion, pcchActual);
1314 return ComponentInfo_GetStringValue(This->classkey, L"SpecVersion",
1315 cchSpecVersion, wzSpecVersion, pcchActual);
1318 static HRESULT WINAPI PixelFormatInfo_GetFriendlyName(IWICPixelFormatInfo2 *iface, UINT cchFriendlyName,
1319 WCHAR *wzFriendlyName, UINT *pcchActual)
1321 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1323 TRACE("(%p,%u,%p,%p)\n", iface, cchFriendlyName, wzFriendlyName, pcchActual);
1325 return ComponentInfo_GetStringValue(This->classkey, L"FriendlyName",
1326 cchFriendlyName, wzFriendlyName, pcchActual);
1329 static HRESULT WINAPI PixelFormatInfo_GetFormatGUID(IWICPixelFormatInfo2 *iface,
1330 GUID *pFormat)
1332 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1333 TRACE("(%p,%p)\n", iface, pFormat);
1335 if (!pFormat)
1336 return E_INVALIDARG;
1338 *pFormat = This->base.clsid;
1339 return S_OK;
1342 static HRESULT WINAPI PixelFormatInfo_GetColorContext(IWICPixelFormatInfo2 *iface,
1343 IWICColorContext **ppIColorContext)
1345 FIXME("(%p,%p): stub\n", iface, ppIColorContext);
1346 return E_NOTIMPL;
1349 static HRESULT WINAPI PixelFormatInfo_GetBitsPerPixel(IWICPixelFormatInfo2 *iface,
1350 UINT *puiBitsPerPixel)
1352 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1354 TRACE("(%p,%p)\n", iface, puiBitsPerPixel);
1356 return ComponentInfo_GetDWORDValue(This->classkey, L"BitLength", puiBitsPerPixel);
1359 static HRESULT WINAPI PixelFormatInfo_GetChannelCount(IWICPixelFormatInfo2 *iface,
1360 UINT *puiChannelCount)
1362 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1364 TRACE("(%p,%p)\n", iface, puiChannelCount);
1366 return ComponentInfo_GetDWORDValue(This->classkey, L"ChannelCount", puiChannelCount);
1369 static HRESULT WINAPI PixelFormatInfo_GetChannelMask(IWICPixelFormatInfo2 *iface,
1370 UINT uiChannelIndex, UINT cbMaskBuffer, BYTE *pbMaskBuffer, UINT *pcbActual)
1372 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1373 UINT channel_count;
1374 HRESULT hr;
1375 LONG ret;
1376 WCHAR valuename[11];
1377 DWORD cbData;
1379 TRACE("(%p,%u,%u,%p,%p)\n", iface, uiChannelIndex, cbMaskBuffer, pbMaskBuffer, pcbActual);
1381 if (!pcbActual)
1382 return E_INVALIDARG;
1384 hr = PixelFormatInfo_GetChannelCount(iface, &channel_count);
1386 if (SUCCEEDED(hr) && uiChannelIndex >= channel_count)
1387 hr = E_INVALIDARG;
1389 if (SUCCEEDED(hr))
1391 swprintf(valuename, 11, L"%u", uiChannelIndex);
1393 cbData = cbMaskBuffer;
1395 ret = RegGetValueW(This->classkey, L"ChannelMasks", valuename, RRF_RT_REG_BINARY, NULL, pbMaskBuffer, &cbData);
1397 if (ret == ERROR_SUCCESS || ret == ERROR_MORE_DATA)
1398 *pcbActual = cbData;
1400 if (ret == ERROR_MORE_DATA)
1401 hr = E_INVALIDARG;
1402 else
1403 hr = HRESULT_FROM_WIN32(ret);
1406 return hr;
1409 static HRESULT WINAPI PixelFormatInfo_SupportsTransparency(IWICPixelFormatInfo2 *iface,
1410 BOOL *pfSupportsTransparency)
1412 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1414 TRACE("(%p,%p)\n", iface, pfSupportsTransparency);
1416 return ComponentInfo_GetDWORDValue(This->classkey, L"SupportsTransparency", (DWORD*)pfSupportsTransparency);
1419 static HRESULT WINAPI PixelFormatInfo_GetNumericRepresentation(IWICPixelFormatInfo2 *iface,
1420 WICPixelFormatNumericRepresentation *pNumericRepresentation)
1422 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1424 TRACE("(%p,%p)\n", iface, pNumericRepresentation);
1426 return ComponentInfo_GetDWORDValue(This->classkey, L"NumericRepresentation", pNumericRepresentation);
1429 static const IWICPixelFormatInfo2Vtbl PixelFormatInfo_Vtbl = {
1430 PixelFormatInfo_QueryInterface,
1431 PixelFormatInfo_AddRef,
1432 PixelFormatInfo_Release,
1433 PixelFormatInfo_GetComponentType,
1434 PixelFormatInfo_GetCLSID,
1435 PixelFormatInfo_GetSigningStatus,
1436 PixelFormatInfo_GetAuthor,
1437 PixelFormatInfo_GetVendorGUID,
1438 PixelFormatInfo_GetVersion,
1439 PixelFormatInfo_GetSpecVersion,
1440 PixelFormatInfo_GetFriendlyName,
1441 PixelFormatInfo_GetFormatGUID,
1442 PixelFormatInfo_GetColorContext,
1443 PixelFormatInfo_GetBitsPerPixel,
1444 PixelFormatInfo_GetChannelCount,
1445 PixelFormatInfo_GetChannelMask,
1446 PixelFormatInfo_SupportsTransparency,
1447 PixelFormatInfo_GetNumericRepresentation
1450 static HRESULT PixelFormatInfo_Constructor(HKEY classkey, REFCLSID clsid, ComponentInfo **ret)
1452 PixelFormatInfo *This;
1454 This = HeapAlloc(GetProcessHeap(), 0, sizeof(PixelFormatInfo));
1455 if (!This)
1457 RegCloseKey(classkey);
1458 return E_OUTOFMEMORY;
1461 This->base.IWICComponentInfo_iface.lpVtbl = (const IWICComponentInfoVtbl*)&PixelFormatInfo_Vtbl;
1462 This->base.ref = 1;
1463 This->classkey = classkey;
1464 This->base.clsid = *clsid;
1466 *ret = &This->base;
1467 return S_OK;
1470 struct metadata_container
1472 WICMetadataPattern *patterns;
1473 UINT pattern_count;
1474 UINT patterns_size;
1477 typedef struct
1479 ComponentInfo base;
1480 HKEY classkey;
1481 GUID *container_formats;
1482 struct metadata_container *containers;
1483 UINT container_count;
1484 } MetadataReaderInfo;
1486 static struct metadata_container *get_metadata_container(MetadataReaderInfo *info, const GUID *guid)
1488 unsigned i;
1490 for (i = 0; i < info->container_count; i++)
1491 if (IsEqualGUID(info->container_formats + i, guid))
1492 return info->containers + i;
1494 return NULL;
1497 static inline MetadataReaderInfo *impl_from_IWICMetadataReaderInfo(IWICMetadataReaderInfo *iface)
1499 return CONTAINING_RECORD(iface, MetadataReaderInfo, base.IWICComponentInfo_iface);
1502 static HRESULT WINAPI MetadataReaderInfo_QueryInterface(IWICMetadataReaderInfo *iface,
1503 REFIID riid, void **ppv)
1505 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1507 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(riid), ppv);
1509 if (!ppv) return E_INVALIDARG;
1511 if (IsEqualIID(&IID_IUnknown, riid) ||
1512 IsEqualIID(&IID_IWICComponentInfo, riid) ||
1513 IsEqualIID(&IID_IWICMetadataHandlerInfo, riid) ||
1514 IsEqualIID(&IID_IWICMetadataReaderInfo, riid))
1516 *ppv = &This->base.IWICComponentInfo_iface;
1518 else
1520 *ppv = NULL;
1521 return E_NOINTERFACE;
1524 IUnknown_AddRef((IUnknown *)*ppv);
1525 return S_OK;
1528 static ULONG WINAPI MetadataReaderInfo_AddRef(IWICMetadataReaderInfo *iface)
1530 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1531 ULONG ref = InterlockedIncrement(&This->base.ref);
1533 TRACE("(%p) refcount=%u\n", iface, ref);
1534 return ref;
1537 static ULONG WINAPI MetadataReaderInfo_Release(IWICMetadataReaderInfo *iface)
1539 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1540 ULONG ref = InterlockedDecrement(&This->base.ref);
1542 TRACE("(%p) refcount=%u\n", iface, ref);
1544 if (!ref)
1546 unsigned i;
1547 RegCloseKey(This->classkey);
1548 for (i = 0; i < This->container_count; i++)
1549 heap_free(This->containers[i].patterns);
1550 heap_free(This->containers);
1551 heap_free(This->container_formats);
1552 HeapFree(GetProcessHeap(), 0, This);
1554 return ref;
1557 static HRESULT WINAPI MetadataReaderInfo_GetComponentType(IWICMetadataReaderInfo *iface,
1558 WICComponentType *type)
1560 TRACE("(%p,%p)\n", iface, type);
1562 if (!type) return E_INVALIDARG;
1563 *type = WICMetadataReader;
1564 return S_OK;
1567 static HRESULT WINAPI MetadataReaderInfo_GetCLSID(IWICMetadataReaderInfo *iface,
1568 CLSID *clsid)
1570 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1572 TRACE("(%p,%p)\n", iface, clsid);
1574 if (!clsid) return E_INVALIDARG;
1575 *clsid = This->base.clsid;
1576 return S_OK;
1579 static HRESULT WINAPI MetadataReaderInfo_GetSigningStatus(IWICMetadataReaderInfo *iface,
1580 DWORD *status)
1582 FIXME("(%p,%p): stub\n", iface, status);
1583 return E_NOTIMPL;
1586 static HRESULT WINAPI MetadataReaderInfo_GetAuthor(IWICMetadataReaderInfo *iface,
1587 UINT length, WCHAR *author, UINT *actual_length)
1589 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1591 TRACE("(%p,%u,%p,%p)\n", iface, length, author, actual_length);
1593 return ComponentInfo_GetStringValue(This->classkey, L"Author", length, author, actual_length);
1596 static HRESULT WINAPI MetadataReaderInfo_GetVendorGUID(IWICMetadataReaderInfo *iface,
1597 GUID *vendor)
1599 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1601 TRACE("(%p,%p)\n", iface, vendor);
1603 return ComponentInfo_GetGUIDValue(This->classkey, L"Vendor", vendor);
1606 static HRESULT WINAPI MetadataReaderInfo_GetVersion(IWICMetadataReaderInfo *iface,
1607 UINT length, WCHAR *version, UINT *actual_length)
1609 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1611 TRACE("(%p,%u,%p,%p)\n", iface, length, version, actual_length);
1613 return ComponentInfo_GetStringValue(This->classkey, L"Version", length, version, actual_length);
1616 static HRESULT WINAPI MetadataReaderInfo_GetSpecVersion(IWICMetadataReaderInfo *iface,
1617 UINT length, WCHAR *version, UINT *actual_length)
1619 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1621 TRACE("(%p,%u,%p,%p)\n", iface, length, version, actual_length);
1623 return ComponentInfo_GetStringValue(This->classkey, L"SpecVersion",
1624 length, version, actual_length);
1627 static HRESULT WINAPI MetadataReaderInfo_GetFriendlyName(IWICMetadataReaderInfo *iface,
1628 UINT length, WCHAR *name, UINT *actual_length)
1630 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1632 TRACE("(%p,%u,%p,%p)\n", iface, length, name, actual_length);
1634 return ComponentInfo_GetStringValue(This->classkey, L"FriendlyName",
1635 length, name, actual_length);
1638 static HRESULT WINAPI MetadataReaderInfo_GetMetadataFormat(IWICMetadataReaderInfo *iface,
1639 GUID *format)
1641 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1642 TRACE("(%p,%p)\n", iface, format);
1643 return ComponentInfo_GetGUIDValue(This->classkey, L"MetadataFormat", format);
1646 static HRESULT WINAPI MetadataReaderInfo_GetContainerFormats(IWICMetadataReaderInfo *iface,
1647 UINT length, GUID *formats, UINT *actual_length)
1649 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1651 TRACE("(%p,%u,%p,%p)\n", iface, length, formats, actual_length);
1653 if (!actual_length)
1654 return E_INVALIDARG;
1656 *actual_length = This->container_count;
1657 if (formats)
1659 if (This->container_count && length < This->container_count)
1660 return WINCODEC_ERR_INSUFFICIENTBUFFER;
1661 memcpy(formats, This->container_formats, This->container_count * sizeof(*formats));
1663 return S_OK;
1666 static HRESULT WINAPI MetadataReaderInfo_GetDeviceManufacturer(IWICMetadataReaderInfo *iface,
1667 UINT length, WCHAR *manufacturer, UINT *actual_length)
1669 FIXME("(%p,%u,%p,%p): stub\n", iface, length, manufacturer, actual_length);
1670 return E_NOTIMPL;
1673 static HRESULT WINAPI MetadataReaderInfo_GetDeviceModels(IWICMetadataReaderInfo *iface,
1674 UINT length, WCHAR *models, UINT *actual_length)
1676 FIXME("(%p,%u,%p,%p): stub\n", iface, length, models, actual_length);
1677 return E_NOTIMPL;
1680 static HRESULT WINAPI MetadataReaderInfo_DoesRequireFullStream(IWICMetadataReaderInfo *iface,
1681 BOOL *param)
1683 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1684 TRACE("(%p,%p)\n", iface, param);
1685 return ComponentInfo_GetDWORDValue(This->classkey, L"RequiresFullStream", (DWORD *)param);
1688 static HRESULT WINAPI MetadataReaderInfo_DoesSupportPadding(IWICMetadataReaderInfo *iface,
1689 BOOL *param)
1691 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1692 TRACE("(%p,%p)\n", iface, param);
1693 return ComponentInfo_GetDWORDValue(This->classkey, L"SupportsPadding", (DWORD *)param);
1696 static HRESULT WINAPI MetadataReaderInfo_DoesRequireFixedSize(IWICMetadataReaderInfo *iface,
1697 BOOL *param)
1699 FIXME("(%p,%p): stub\n", iface, param);
1700 return E_NOTIMPL;
1703 static HRESULT WINAPI MetadataReaderInfo_GetPatterns(IWICMetadataReaderInfo *iface,
1704 REFGUID container_guid, UINT length, WICMetadataPattern *patterns, UINT *count, UINT *actual_length)
1706 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1707 struct metadata_container *container;
1709 TRACE("(%p,%s,%u,%p,%p,%p)\n", iface, debugstr_guid(container_guid), length, patterns, count, actual_length);
1711 if (!actual_length || !container_guid) return E_INVALIDARG;
1713 if (!(container = get_metadata_container(This, container_guid)))
1714 return WINCODEC_ERR_COMPONENTNOTFOUND;
1716 *count = container->pattern_count;
1717 *actual_length = container->patterns_size;
1718 if (patterns)
1720 if (container->patterns_size && length < container->patterns_size)
1721 return WINCODEC_ERR_INSUFFICIENTBUFFER;
1722 memcpy(patterns, container->patterns, container->patterns_size);
1724 return S_OK;
1727 static HRESULT WINAPI MetadataReaderInfo_MatchesPattern(IWICMetadataReaderInfo *iface,
1728 REFGUID container_guid, IStream *stream, BOOL *matches)
1730 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1731 struct metadata_container *container;
1732 HRESULT hr;
1733 ULONG datasize=0;
1734 BYTE *data=NULL;
1735 ULONG bytesread;
1736 UINT i;
1737 LARGE_INTEGER seekpos;
1738 ULONG pos;
1740 TRACE("(%p,%s,%p,%p)\n", iface, debugstr_guid(container_guid), stream, matches);
1742 if (!(container = get_metadata_container(This, container_guid)))
1743 return WINCODEC_ERR_COMPONENTNOTFOUND;
1745 for (i=0; i < container->pattern_count; i++)
1747 if (datasize < container->patterns[i].Length)
1749 HeapFree(GetProcessHeap(), 0, data);
1750 datasize = container->patterns[i].Length;
1751 data = HeapAlloc(GetProcessHeap(), 0, container->patterns[i].Length);
1752 if (!data)
1754 hr = E_OUTOFMEMORY;
1755 break;
1759 seekpos.QuadPart = container->patterns[i].Position.QuadPart;
1760 hr = IStream_Seek(stream, seekpos, STREAM_SEEK_SET, NULL);
1761 if (FAILED(hr)) break;
1763 hr = IStream_Read(stream, data, container->patterns[i].Length, &bytesread);
1764 if (hr == S_FALSE || (hr == S_OK && bytesread != container->patterns[i].Length)) /* past end of stream */
1765 continue;
1766 if (FAILED(hr)) break;
1768 for (pos=0; pos < container->patterns[i].Length; pos++)
1770 if ((data[pos] & container->patterns[i].Mask[pos]) != container->patterns[i].Pattern[pos])
1771 break;
1773 if (pos == container->patterns[i].Length) /* matches pattern */
1775 hr = S_OK;
1776 *matches = TRUE;
1777 break;
1781 if (i == container->pattern_count) /* does not match any pattern */
1783 hr = S_OK;
1784 *matches = FALSE;
1787 HeapFree(GetProcessHeap(), 0, data);
1789 return hr;
1792 static HRESULT WINAPI MetadataReaderInfo_CreateInstance(IWICMetadataReaderInfo *iface,
1793 IWICMetadataReader **reader)
1795 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1797 TRACE("(%p,%p)\n", iface, reader);
1799 return create_instance(&This->base.clsid, &IID_IWICMetadataReader, (void **)reader);
1802 static const IWICMetadataReaderInfoVtbl MetadataReaderInfo_Vtbl = {
1803 MetadataReaderInfo_QueryInterface,
1804 MetadataReaderInfo_AddRef,
1805 MetadataReaderInfo_Release,
1806 MetadataReaderInfo_GetComponentType,
1807 MetadataReaderInfo_GetCLSID,
1808 MetadataReaderInfo_GetSigningStatus,
1809 MetadataReaderInfo_GetAuthor,
1810 MetadataReaderInfo_GetVendorGUID,
1811 MetadataReaderInfo_GetVersion,
1812 MetadataReaderInfo_GetSpecVersion,
1813 MetadataReaderInfo_GetFriendlyName,
1814 MetadataReaderInfo_GetMetadataFormat,
1815 MetadataReaderInfo_GetContainerFormats,
1816 MetadataReaderInfo_GetDeviceManufacturer,
1817 MetadataReaderInfo_GetDeviceModels,
1818 MetadataReaderInfo_DoesRequireFullStream,
1819 MetadataReaderInfo_DoesSupportPadding,
1820 MetadataReaderInfo_DoesRequireFixedSize,
1821 MetadataReaderInfo_GetPatterns,
1822 MetadataReaderInfo_MatchesPattern,
1823 MetadataReaderInfo_CreateInstance
1826 static void read_metadata_patterns(MetadataReaderInfo *info, GUID *container_guid,
1827 struct metadata_container *container)
1829 UINT pattern_count=0, patterns_size=0;
1830 WCHAR subkeyname[11], guidkeyname[39];
1831 LONG res;
1832 HKEY containers_key, guid_key, patternkey;
1833 UINT i;
1834 WICMetadataPattern *patterns;
1835 BYTE *patterns_ptr;
1836 DWORD length, valuesize;
1838 res = RegOpenKeyExW(info->classkey, L"Containers", 0, KEY_READ, &containers_key);
1839 if (res != ERROR_SUCCESS) return;
1841 StringFromGUID2(container_guid, guidkeyname, 39);
1842 res = RegOpenKeyExW(containers_key, guidkeyname, 0, KEY_READ, &guid_key);
1843 RegCloseKey(containers_key);
1844 if (res != ERROR_SUCCESS) return;
1846 res = RegQueryInfoKeyW(guid_key, NULL, NULL, NULL, &pattern_count,
1847 NULL, NULL, NULL, NULL, NULL, NULL, NULL);
1848 if (res != ERROR_SUCCESS)
1850 RegCloseKey(guid_key);
1851 return;
1854 patterns_size = pattern_count * sizeof(WICMetadataPattern);
1855 patterns = heap_alloc(patterns_size);
1856 if (!patterns)
1858 RegCloseKey(guid_key);
1859 return;
1862 for (i=0; res == ERROR_SUCCESS && i < pattern_count; i++)
1864 swprintf(subkeyname, 11, L"%u", i);
1865 res = RegOpenKeyExW(guid_key, subkeyname, 0, KEY_READ, &patternkey);
1866 if (res != ERROR_SUCCESS) break;
1868 res = RegGetValueW(patternkey, NULL, L"Pattern", RRF_RT_REG_BINARY, NULL, NULL, &length);
1869 if (res == ERROR_SUCCESS)
1871 patterns_size += length*2;
1872 patterns[i].Length = length;
1874 valuesize = sizeof(DWORD64);
1875 res = RegGetValueW(patternkey, NULL, L"DataOffset", RRF_RT_DWORD|RRF_RT_QWORD, NULL,
1876 &patterns[i].DataOffset, &valuesize);
1877 if (res) patterns[i].DataOffset.QuadPart = 0;
1879 patterns[i].Position.QuadPart = 0;
1880 valuesize = sizeof(DWORD64);
1881 res = RegGetValueW(patternkey, NULL, L"Position", RRF_RT_DWORD|RRF_RT_QWORD, NULL,
1882 &patterns[i].Position, &valuesize);
1885 RegCloseKey(patternkey);
1888 if (res != ERROR_SUCCESS || !(patterns_ptr = heap_realloc(patterns, patterns_size)))
1890 heap_free(patterns);
1891 RegCloseKey(guid_key);
1892 return;
1894 patterns = (WICMetadataPattern*)patterns_ptr;
1895 patterns_ptr += pattern_count * sizeof(*patterns);
1897 for (i=0; res == ERROR_SUCCESS && i < pattern_count; i++)
1899 swprintf(subkeyname, 11, L"%u", i);
1900 res = RegOpenKeyExW(guid_key, subkeyname, 0, KEY_READ, &patternkey);
1901 if (res != ERROR_SUCCESS) break;
1903 length = patterns[i].Length;
1904 patterns[i].Pattern = patterns_ptr;
1905 valuesize = length;
1906 res = RegGetValueW(patternkey, NULL, L"Pattern", RRF_RT_REG_BINARY, NULL,
1907 patterns[i].Pattern, &valuesize);
1908 patterns_ptr += length;
1910 if (res == ERROR_SUCCESS)
1912 patterns[i].Mask = patterns_ptr;
1913 valuesize = length;
1914 res = RegGetValueW(patternkey, NULL, L"Mask", RRF_RT_REG_BINARY, NULL,
1915 patterns[i].Mask, &valuesize);
1916 patterns_ptr += length;
1919 RegCloseKey(patternkey);
1922 RegCloseKey(guid_key);
1924 if (res != ERROR_SUCCESS)
1926 heap_free(patterns);
1927 return;
1930 container->pattern_count = pattern_count;
1931 container->patterns_size = patterns_size;
1932 container->patterns = patterns;
1935 static BOOL read_metadata_info(MetadataReaderInfo *info)
1937 UINT format_count;
1938 GUID *formats;
1939 HRESULT hr;
1941 hr = ComponentInfo_GetGuidList(info->classkey, L"Containers", 0, NULL, &format_count);
1942 if (FAILED(hr)) return TRUE;
1944 formats = heap_calloc(format_count, sizeof(*formats));
1945 if (!formats) return FALSE;
1947 hr = ComponentInfo_GetGuidList(info->classkey, L"Containers", format_count, formats,
1948 &format_count);
1949 if (FAILED(hr))
1951 heap_free(formats);
1952 return FALSE;
1955 info->container_formats = formats;
1956 info->container_count = format_count;
1958 if (format_count)
1960 unsigned i;
1962 info->containers = heap_calloc(format_count, sizeof(*info->containers));
1963 if (!info->containers) return FALSE;
1965 for (i = 0; i < format_count; i++)
1966 read_metadata_patterns(info, info->container_formats + i, info->containers + i);
1969 return TRUE;
1972 static HRESULT MetadataReaderInfo_Constructor(HKEY classkey, REFCLSID clsid, ComponentInfo **info)
1974 MetadataReaderInfo *This;
1976 This = heap_alloc_zero(sizeof(*This));
1977 if (!This)
1979 RegCloseKey(classkey);
1980 return E_OUTOFMEMORY;
1983 This->base.IWICComponentInfo_iface.lpVtbl = (const IWICComponentInfoVtbl*)&MetadataReaderInfo_Vtbl;
1984 This->base.ref = 1;
1985 This->classkey = classkey;
1986 This->base.clsid = *clsid;
1988 if (!read_metadata_info(This))
1990 IWICComponentInfo_Release(&This->base.IWICComponentInfo_iface);
1991 return WINCODEC_ERR_COMPONENTNOTFOUND;
1994 *info = &This->base;
1995 return S_OK;
1998 struct category {
1999 WICComponentType type;
2000 const GUID *catid;
2001 HRESULT (*constructor)(HKEY,REFCLSID,ComponentInfo**);
2004 static const struct category categories[] = {
2005 {WICDecoder, &CATID_WICBitmapDecoders, BitmapDecoderInfo_Constructor},
2006 {WICEncoder, &CATID_WICBitmapEncoders, BitmapEncoderInfo_Constructor},
2007 {WICPixelFormatConverter, &CATID_WICFormatConverters, FormatConverterInfo_Constructor},
2008 {WICPixelFormat, &CATID_WICPixelFormats, PixelFormatInfo_Constructor},
2009 {WICMetadataReader, &CATID_WICMetadataReader, MetadataReaderInfo_Constructor},
2013 static int ComponentInfo_Compare(const void *key, const struct wine_rb_entry *entry)
2015 ComponentInfo *info = WINE_RB_ENTRY_VALUE(entry, ComponentInfo, entry);
2016 return memcmp(key, &info->clsid, sizeof(info->clsid));
2019 static struct wine_rb_tree component_info_cache = { ComponentInfo_Compare };
2021 static CRITICAL_SECTION component_info_cache_cs;
2022 static CRITICAL_SECTION_DEBUG component_info_cache_cs_dbg =
2024 0, 0, &component_info_cache_cs,
2025 { &component_info_cache_cs_dbg.ProcessLocksList, &component_info_cache_cs_dbg.ProcessLocksList },
2026 0, 0, { (DWORD_PTR)(__FILE__ ": component_info_cache") }
2028 static CRITICAL_SECTION component_info_cache_cs = { &component_info_cache_cs_dbg, -1, 0, 0, 0, 0 };
2030 HRESULT CreateComponentInfo(REFCLSID clsid, IWICComponentInfo **ppIInfo)
2032 struct wine_rb_entry *cache_entry;
2033 ComponentInfo *info;
2034 HKEY clsidkey;
2035 HKEY classkey;
2036 HKEY catidkey;
2037 HKEY instancekey;
2038 WCHAR guidstring[39];
2039 LONG res;
2040 const struct category *category;
2041 BOOL found = FALSE;
2042 HRESULT hr;
2044 EnterCriticalSection(&component_info_cache_cs);
2046 cache_entry = wine_rb_get(&component_info_cache, clsid);
2047 if(cache_entry)
2049 info = WINE_RB_ENTRY_VALUE(cache_entry, ComponentInfo, entry);
2050 IWICComponentInfo_AddRef(*ppIInfo = &info->IWICComponentInfo_iface);
2051 LeaveCriticalSection(&component_info_cache_cs);
2052 return S_OK;
2055 res = RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_READ, &clsidkey);
2056 if (res != ERROR_SUCCESS)
2058 LeaveCriticalSection(&component_info_cache_cs);
2059 return HRESULT_FROM_WIN32(res);
2062 for (category=categories; category->type; category++)
2064 StringFromGUID2(category->catid, guidstring, 39);
2065 res = RegOpenKeyExW(clsidkey, guidstring, 0, KEY_READ, &catidkey);
2066 if (res == ERROR_SUCCESS)
2068 res = RegOpenKeyExW(catidkey, L"Instance", 0, KEY_READ, &instancekey);
2069 if (res == ERROR_SUCCESS)
2071 StringFromGUID2(clsid, guidstring, 39);
2072 res = RegOpenKeyExW(instancekey, guidstring, 0, KEY_READ, &classkey);
2073 if (res == ERROR_SUCCESS)
2075 RegCloseKey(classkey);
2076 found = TRUE;
2078 RegCloseKey(instancekey);
2080 RegCloseKey(catidkey);
2082 if (found) break;
2085 if (found)
2087 res = RegOpenKeyExW(clsidkey, guidstring, 0, KEY_READ, &classkey);
2088 if (res == ERROR_SUCCESS)
2089 hr = category->constructor(classkey, clsid, &info);
2090 else
2091 hr = HRESULT_FROM_WIN32(res);
2093 else
2095 FIXME("%s is not supported\n", wine_dbgstr_guid(clsid));
2096 hr = E_FAIL;
2099 RegCloseKey(clsidkey);
2101 if (SUCCEEDED(hr))
2103 wine_rb_put(&component_info_cache, clsid, &info->entry);
2104 IWICComponentInfo_AddRef(*ppIInfo = &info->IWICComponentInfo_iface);
2106 LeaveCriticalSection(&component_info_cache_cs);
2107 return hr;
2110 void ReleaseComponentInfos(void)
2112 ComponentInfo *info, *next_info;
2113 WINE_RB_FOR_EACH_ENTRY_DESTRUCTOR(info, next_info, &component_info_cache, ComponentInfo, entry)
2114 IWICComponentInfo_Release(&info->IWICComponentInfo_iface);
2117 HRESULT get_decoder_info(REFCLSID clsid, IWICBitmapDecoderInfo **info)
2119 IWICComponentInfo *compinfo;
2120 HRESULT hr;
2122 hr = CreateComponentInfo(clsid, &compinfo);
2123 if (FAILED(hr)) return hr;
2125 hr = IWICComponentInfo_QueryInterface(compinfo, &IID_IWICBitmapDecoderInfo,
2126 (void **)info);
2128 IWICComponentInfo_Release(compinfo);
2130 return hr;
2133 typedef struct {
2134 IEnumUnknown IEnumUnknown_iface;
2135 LONG ref;
2136 struct list objects;
2137 struct list *cursor;
2138 CRITICAL_SECTION lock; /* Must be held when reading or writing cursor */
2139 } ComponentEnum;
2141 static inline ComponentEnum *impl_from_IEnumUnknown(IEnumUnknown *iface)
2143 return CONTAINING_RECORD(iface, ComponentEnum, IEnumUnknown_iface);
2146 typedef struct {
2147 struct list entry;
2148 IUnknown *unk;
2149 } ComponentEnumItem;
2151 static const IEnumUnknownVtbl ComponentEnumVtbl;
2153 static HRESULT WINAPI ComponentEnum_QueryInterface(IEnumUnknown *iface, REFIID iid,
2154 void **ppv)
2156 ComponentEnum *This = impl_from_IEnumUnknown(iface);
2157 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
2159 if (!ppv) return E_INVALIDARG;
2161 if (IsEqualIID(&IID_IUnknown, iid) ||
2162 IsEqualIID(&IID_IEnumUnknown, iid))
2164 *ppv = &This->IEnumUnknown_iface;
2166 else
2168 *ppv = NULL;
2169 return E_NOINTERFACE;
2172 IUnknown_AddRef((IUnknown*)*ppv);
2173 return S_OK;
2176 static ULONG WINAPI ComponentEnum_AddRef(IEnumUnknown *iface)
2178 ComponentEnum *This = impl_from_IEnumUnknown(iface);
2179 ULONG ref = InterlockedIncrement(&This->ref);
2181 TRACE("(%p) refcount=%u\n", iface, ref);
2183 return ref;
2186 static ULONG WINAPI ComponentEnum_Release(IEnumUnknown *iface)
2188 ComponentEnum *This = impl_from_IEnumUnknown(iface);
2189 ULONG ref = InterlockedDecrement(&This->ref);
2190 ComponentEnumItem *cursor, *cursor2;
2192 TRACE("(%p) refcount=%u\n", iface, ref);
2194 if (ref == 0)
2196 LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, &This->objects, ComponentEnumItem, entry)
2198 IUnknown_Release(cursor->unk);
2199 list_remove(&cursor->entry);
2200 HeapFree(GetProcessHeap(), 0, cursor);
2202 This->lock.DebugInfo->Spare[0] = 0;
2203 DeleteCriticalSection(&This->lock);
2204 HeapFree(GetProcessHeap(), 0, This);
2207 return ref;
2210 static HRESULT WINAPI ComponentEnum_Next(IEnumUnknown *iface, ULONG celt,
2211 IUnknown **rgelt, ULONG *pceltFetched)
2213 ComponentEnum *This = impl_from_IEnumUnknown(iface);
2214 ULONG num_fetched=0;
2215 ComponentEnumItem *item;
2216 HRESULT hr=S_OK;
2218 TRACE("(%p,%u,%p,%p)\n", iface, celt, rgelt, pceltFetched);
2220 EnterCriticalSection(&This->lock);
2221 while (num_fetched<celt)
2223 if (!This->cursor)
2225 hr = S_FALSE;
2226 break;
2228 item = LIST_ENTRY(This->cursor, ComponentEnumItem, entry);
2229 IUnknown_AddRef(item->unk);
2230 rgelt[num_fetched] = item->unk;
2231 num_fetched++;
2232 This->cursor = list_next(&This->objects, This->cursor);
2234 LeaveCriticalSection(&This->lock);
2235 if (pceltFetched)
2236 *pceltFetched = num_fetched;
2237 return hr;
2240 static HRESULT WINAPI ComponentEnum_Skip(IEnumUnknown *iface, ULONG celt)
2242 ComponentEnum *This = impl_from_IEnumUnknown(iface);
2243 ULONG i;
2244 HRESULT hr=S_OK;
2246 TRACE("(%p,%u)\n", iface, celt);
2248 EnterCriticalSection(&This->lock);
2249 for (i=0; i<celt; i++)
2251 if (!This->cursor)
2253 hr = S_FALSE;
2254 break;
2256 This->cursor = list_next(&This->objects, This->cursor);
2258 LeaveCriticalSection(&This->lock);
2259 return hr;
2262 static HRESULT WINAPI ComponentEnum_Reset(IEnumUnknown *iface)
2264 ComponentEnum *This = impl_from_IEnumUnknown(iface);
2266 TRACE("(%p)\n", iface);
2268 EnterCriticalSection(&This->lock);
2269 This->cursor = list_head(&This->objects);
2270 LeaveCriticalSection(&This->lock);
2271 return S_OK;
2274 static HRESULT WINAPI ComponentEnum_Clone(IEnumUnknown *iface, IEnumUnknown **ppenum)
2276 ComponentEnum *This = impl_from_IEnumUnknown(iface);
2277 ComponentEnum *new_enum;
2278 ComponentEnumItem *old_item, *new_item;
2279 HRESULT ret=S_OK;
2280 struct list *old_cursor;
2282 new_enum = HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnum));
2283 if (!new_enum)
2285 *ppenum = NULL;
2286 return E_OUTOFMEMORY;
2289 new_enum->IEnumUnknown_iface.lpVtbl = &ComponentEnumVtbl;
2290 new_enum->ref = 1;
2291 new_enum->cursor = NULL;
2292 list_init(&new_enum->objects);
2293 InitializeCriticalSection(&new_enum->lock);
2294 new_enum->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": ComponentEnum.lock");
2296 EnterCriticalSection(&This->lock);
2297 old_cursor = This->cursor;
2298 LeaveCriticalSection(&This->lock);
2300 LIST_FOR_EACH_ENTRY(old_item, &This->objects, ComponentEnumItem, entry)
2302 new_item = HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnumItem));
2303 if (!new_item)
2305 ret = E_OUTOFMEMORY;
2306 break;
2308 new_item->unk = old_item->unk;
2309 list_add_tail(&new_enum->objects, &new_item->entry);
2310 IUnknown_AddRef(new_item->unk);
2311 if (&old_item->entry == old_cursor) new_enum->cursor = &new_item->entry;
2314 if (FAILED(ret))
2316 IEnumUnknown_Release(&new_enum->IEnumUnknown_iface);
2317 *ppenum = NULL;
2319 else
2320 *ppenum = &new_enum->IEnumUnknown_iface;
2322 return ret;
2325 static const IEnumUnknownVtbl ComponentEnumVtbl = {
2326 ComponentEnum_QueryInterface,
2327 ComponentEnum_AddRef,
2328 ComponentEnum_Release,
2329 ComponentEnum_Next,
2330 ComponentEnum_Skip,
2331 ComponentEnum_Reset,
2332 ComponentEnum_Clone
2335 HRESULT CreateComponentEnumerator(DWORD componentTypes, DWORD options, IEnumUnknown **ppIEnumUnknown)
2337 ComponentEnum *This;
2338 ComponentEnumItem *item;
2339 const struct category *category;
2340 HKEY clsidkey, catidkey, instancekey;
2341 WCHAR guidstring[39];
2342 LONG res;
2343 int i;
2344 HRESULT hr=S_OK;
2345 CLSID clsid;
2347 if (options) FIXME("ignoring flags %x\n", options);
2349 res = RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_READ, &clsidkey);
2350 if (res != ERROR_SUCCESS)
2351 return HRESULT_FROM_WIN32(res);
2353 This = HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnum));
2354 if (!This)
2356 RegCloseKey(clsidkey);
2357 return E_OUTOFMEMORY;
2360 This->IEnumUnknown_iface.lpVtbl = &ComponentEnumVtbl;
2361 This->ref = 1;
2362 list_init(&This->objects);
2363 InitializeCriticalSection(&This->lock);
2364 This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": ComponentEnum.lock");
2366 for (category=categories; category->type && hr == S_OK; category++)
2368 if ((category->type & componentTypes) == 0) continue;
2369 StringFromGUID2(category->catid, guidstring, 39);
2370 res = RegOpenKeyExW(clsidkey, guidstring, 0, KEY_READ, &catidkey);
2371 if (res == ERROR_SUCCESS)
2373 res = RegOpenKeyExW(catidkey, L"Instance", 0, KEY_READ, &instancekey);
2374 if (res == ERROR_SUCCESS)
2376 i=0;
2377 for (;;i++)
2379 DWORD guidstring_size = 39;
2380 res = RegEnumKeyExW(instancekey, i, guidstring, &guidstring_size, NULL, NULL, NULL, NULL);
2381 if (res != ERROR_SUCCESS) break;
2383 item = HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnumItem));
2384 if (!item) { hr = E_OUTOFMEMORY; break; }
2386 hr = CLSIDFromString(guidstring, &clsid);
2387 if (SUCCEEDED(hr))
2389 hr = CreateComponentInfo(&clsid, (IWICComponentInfo**)&item->unk);
2390 if (SUCCEEDED(hr))
2391 list_add_tail(&This->objects, &item->entry);
2394 if (FAILED(hr))
2396 HeapFree(GetProcessHeap(), 0, item);
2397 hr = S_OK;
2400 RegCloseKey(instancekey);
2402 RegCloseKey(catidkey);
2404 if (res != ERROR_SUCCESS && res != ERROR_NO_MORE_ITEMS)
2405 hr = HRESULT_FROM_WIN32(res);
2407 RegCloseKey(clsidkey);
2409 if (SUCCEEDED(hr))
2411 IEnumUnknown_Reset(&This->IEnumUnknown_iface);
2412 *ppIEnumUnknown = &This->IEnumUnknown_iface;
2414 else
2416 *ppIEnumUnknown = NULL;
2417 IEnumUnknown_Release(&This->IEnumUnknown_iface);
2420 return hr;
2423 static BOOL is_1bpp_format(const WICPixelFormatGUID *format)
2425 return IsEqualGUID(format, &GUID_WICPixelFormatBlackWhite) ||
2426 IsEqualGUID(format, &GUID_WICPixelFormat1bppIndexed);
2429 HRESULT WINAPI WICConvertBitmapSource(REFWICPixelFormatGUID dstFormat, IWICBitmapSource *pISrc, IWICBitmapSource **ppIDst)
2431 HRESULT res;
2432 IEnumUnknown *enumconverters;
2433 IUnknown *unkconverterinfo;
2434 IWICFormatConverterInfo *converterinfo=NULL;
2435 IWICFormatConverter *converter=NULL;
2436 GUID srcFormat;
2437 WCHAR srcformatstr[39], dstformatstr[39];
2438 BOOL canconvert;
2439 ULONG num_fetched;
2441 TRACE("%s,%p,%p\n", debugstr_guid(dstFormat), pISrc, ppIDst);
2443 res = IWICBitmapSource_GetPixelFormat(pISrc, &srcFormat);
2444 if (FAILED(res)) return res;
2446 if (IsEqualGUID(&srcFormat, dstFormat) || (is_1bpp_format(&srcFormat) && is_1bpp_format(dstFormat)))
2448 IWICBitmapSource_AddRef(pISrc);
2449 *ppIDst = pISrc;
2450 return S_OK;
2453 StringFromGUID2(&srcFormat, srcformatstr, 39);
2454 StringFromGUID2(dstFormat, dstformatstr, 39);
2456 res = CreateComponentEnumerator(WICPixelFormatConverter, 0, &enumconverters);
2457 if (FAILED(res)) return res;
2459 while (!converter)
2461 res = IEnumUnknown_Next(enumconverters, 1, &unkconverterinfo, &num_fetched);
2463 if (res == S_OK)
2465 res = IUnknown_QueryInterface(unkconverterinfo, &IID_IWICFormatConverterInfo, (void**)&converterinfo);
2467 if (SUCCEEDED(res))
2469 canconvert = ConverterSupportsFormat(converterinfo, srcformatstr);
2471 if (canconvert)
2472 canconvert = ConverterSupportsFormat(converterinfo, dstformatstr);
2474 if (canconvert)
2476 res = IWICFormatConverterInfo_CreateInstance(converterinfo, &converter);
2478 if (SUCCEEDED(res))
2479 res = IWICFormatConverter_CanConvert(converter, &srcFormat, dstFormat, &canconvert);
2481 if (SUCCEEDED(res) && canconvert)
2482 res = IWICFormatConverter_Initialize(converter, pISrc, dstFormat, WICBitmapDitherTypeNone,
2483 NULL, 0.0, WICBitmapPaletteTypeMedianCut);
2485 if (FAILED(res) || !canconvert)
2487 if (converter)
2489 IWICFormatConverter_Release(converter);
2490 converter = NULL;
2495 IWICFormatConverterInfo_Release(converterinfo);
2498 IUnknown_Release(unkconverterinfo);
2500 else
2501 break;
2504 IEnumUnknown_Release(enumconverters);
2506 if (converter)
2508 res = IWICFormatConverter_QueryInterface(converter, &IID_IWICBitmapSource, (void **)ppIDst);
2509 IWICFormatConverter_Release(converter);
2510 return res;
2512 else
2514 FIXME("cannot convert %s to %s\n", debugstr_guid(&srcFormat), debugstr_guid(dstFormat));
2515 *ppIDst = NULL;
2516 return WINCODEC_ERR_COMPONENTNOTFOUND;