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
31 #include "wincodecsdk.h"
33 #include "wincodecs_private.h"
35 #include "wine/debug.h"
36 #include "wine/unicode.h"
37 #include "wine/list.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
41 static const WCHAR mimetypes_valuename[] = {'M','i','m','e','T','y','p','e','s',0};
42 static const WCHAR author_valuename[] = {'A','u','t','h','o','r',0};
43 static const WCHAR friendlyname_valuename[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
44 static const WCHAR pixelformats_keyname[] = {'P','i','x','e','l','F','o','r','m','a','t','s',0};
45 static const WCHAR containerformat_valuename[] = {'C','o','n','t','a','i','n','e','r','F','o','r','m','a','t',0};
46 static const WCHAR metadataformat_valuename[] = {'M','e','t','a','d','a','t','a','F','o','r','m','a','t',0};
47 static const WCHAR vendor_valuename[] = {'V','e','n','d','o','r',0};
48 static const WCHAR version_valuename[] = {'V','e','r','s','i','o','n',0};
49 static const WCHAR bitsperpixel_valuename[] = {'B','i','t','L','e','n','g','t','h',0};
50 static const WCHAR channelcount_valuename[] = {'C','h','a','n','n','e','l','C','o','u','n','t',0};
51 static const WCHAR channelmasks_keyname[] = {'C','h','a','n','n','e','l','M','a','s','k','s',0};
52 static const WCHAR numericrepresentation_valuename[] = {'N','u','m','e','r','i','c','R','e','p','r','e','s','e','n','t','a','t','i','o','n',0};
53 static const WCHAR supportstransparency_valuename[] = {'S','u','p','p','o','r','t','s','T','r','a','n','s','p','a','r','e','n','c','y',0};
55 static HRESULT ComponentInfo_GetStringValue(HKEY classkey, LPCWSTR value,
56 UINT buffer_size, WCHAR *buffer, UINT *actual_size)
59 DWORD cbdata=buffer_size * sizeof(WCHAR);
64 ret = RegGetValueW(classkey, NULL, value, RRF_RT_REG_SZ|RRF_NOEXPAND, NULL,
67 if (ret == ERROR_FILE_NOT_FOUND)
73 if (ret == 0 || ret == ERROR_MORE_DATA)
74 *actual_size = cbdata/sizeof(WCHAR);
76 if (!buffer && buffer_size != 0)
77 /* Yes, native returns the correct size in this case. */
80 if (ret == ERROR_MORE_DATA)
81 return WINCODEC_ERR_INSUFFICIENTBUFFER;
83 return HRESULT_FROM_WIN32(ret);
86 static HRESULT ComponentInfo_GetGUIDValue(HKEY classkey, LPCWSTR value,
90 WCHAR guid_string[39];
91 DWORD cbdata = sizeof(guid_string);
97 ret = RegGetValueW(classkey, NULL, value, RRF_RT_REG_SZ|RRF_NOEXPAND, NULL,
98 guid_string, &cbdata);
100 if (ret != ERROR_SUCCESS)
101 return HRESULT_FROM_WIN32(ret);
103 if (cbdata < sizeof(guid_string))
105 ERR("incomplete GUID value\n");
109 hr = CLSIDFromString(guid_string, result);
114 static HRESULT ComponentInfo_GetDWORDValue(HKEY classkey, LPCWSTR value,
118 DWORD cbdata = sizeof(DWORD);
123 ret = RegGetValueW(classkey, NULL, value, RRF_RT_DWORD, NULL,
126 if (ret == ERROR_FILE_NOT_FOUND)
132 return HRESULT_FROM_WIN32(ret);
136 IWICBitmapDecoderInfo IWICBitmapDecoderInfo_iface;
142 static inline BitmapDecoderInfo *impl_from_IWICBitmapDecoderInfo(IWICBitmapDecoderInfo *iface)
144 return CONTAINING_RECORD(iface, BitmapDecoderInfo, IWICBitmapDecoderInfo_iface);
147 static HRESULT WINAPI BitmapDecoderInfo_QueryInterface(IWICBitmapDecoderInfo *iface, REFIID iid,
150 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
151 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
153 if (!ppv) return E_INVALIDARG;
155 if (IsEqualIID(&IID_IUnknown, iid) ||
156 IsEqualIID(&IID_IWICComponentInfo, iid) ||
157 IsEqualIID(&IID_IWICBitmapCodecInfo, iid) ||
158 IsEqualIID(&IID_IWICBitmapDecoderInfo ,iid))
165 return E_NOINTERFACE;
168 IUnknown_AddRef((IUnknown*)*ppv);
172 static ULONG WINAPI BitmapDecoderInfo_AddRef(IWICBitmapDecoderInfo *iface)
174 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
175 ULONG ref = InterlockedIncrement(&This->ref);
177 TRACE("(%p) refcount=%u\n", iface, ref);
182 static ULONG WINAPI BitmapDecoderInfo_Release(IWICBitmapDecoderInfo *iface)
184 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
185 ULONG ref = InterlockedDecrement(&This->ref);
187 TRACE("(%p) refcount=%u\n", iface, ref);
191 RegCloseKey(This->classkey);
192 HeapFree(GetProcessHeap(), 0, This);
198 static HRESULT WINAPI BitmapDecoderInfo_GetComponentType(IWICBitmapDecoderInfo *iface,
199 WICComponentType *pType)
201 TRACE("(%p,%p)\n", iface, pType);
202 if (!pType) return E_INVALIDARG;
207 static HRESULT WINAPI BitmapDecoderInfo_GetCLSID(IWICBitmapDecoderInfo *iface, CLSID *pclsid)
209 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
210 TRACE("(%p,%p)\n", iface, pclsid);
215 memcpy(pclsid, &This->clsid, sizeof(CLSID));
220 static HRESULT WINAPI BitmapDecoderInfo_GetSigningStatus(IWICBitmapDecoderInfo *iface, DWORD *pStatus)
222 FIXME("(%p,%p): stub\n", iface, pStatus);
226 static HRESULT WINAPI BitmapDecoderInfo_GetAuthor(IWICBitmapDecoderInfo *iface, UINT cchAuthor,
227 WCHAR *wzAuthor, UINT *pcchActual)
229 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
231 TRACE("(%p,%u,%p,%p)\n", iface, cchAuthor, wzAuthor, pcchActual);
233 return ComponentInfo_GetStringValue(This->classkey, author_valuename,
234 cchAuthor, wzAuthor, pcchActual);
237 static HRESULT WINAPI BitmapDecoderInfo_GetVendorGUID(IWICBitmapDecoderInfo *iface, GUID *pguidVendor)
239 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
241 TRACE("(%p,%p)\n", iface, pguidVendor);
243 return ComponentInfo_GetGUIDValue(This->classkey, vendor_valuename, pguidVendor);
246 static HRESULT WINAPI BitmapDecoderInfo_GetVersion(IWICBitmapDecoderInfo *iface, UINT cchVersion,
247 WCHAR *wzVersion, UINT *pcchActual)
249 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
251 TRACE("(%p,%u,%p,%p)\n", iface, cchVersion, wzVersion, pcchActual);
253 return ComponentInfo_GetStringValue(This->classkey, version_valuename,
254 cchVersion, wzVersion, pcchActual);
257 static HRESULT WINAPI BitmapDecoderInfo_GetSpecVersion(IWICBitmapDecoderInfo *iface, UINT cchSpecVersion,
258 WCHAR *wzSpecVersion, UINT *pcchActual)
260 FIXME("(%p,%u,%p,%p): stub\n", iface, cchSpecVersion, wzSpecVersion, pcchActual);
264 static HRESULT WINAPI BitmapDecoderInfo_GetFriendlyName(IWICBitmapDecoderInfo *iface, UINT cchFriendlyName,
265 WCHAR *wzFriendlyName, UINT *pcchActual)
267 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
269 TRACE("(%p,%u,%p,%p)\n", iface, cchFriendlyName, wzFriendlyName, pcchActual);
271 return ComponentInfo_GetStringValue(This->classkey, friendlyname_valuename,
272 cchFriendlyName, wzFriendlyName, pcchActual);
275 static HRESULT WINAPI BitmapDecoderInfo_GetContainerFormat(IWICBitmapDecoderInfo *iface,
276 GUID *pguidContainerFormat)
278 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
279 TRACE("(%p,%p)\n", iface, pguidContainerFormat);
280 return ComponentInfo_GetGUIDValue(This->classkey, containerformat_valuename, pguidContainerFormat);
283 static HRESULT WINAPI BitmapDecoderInfo_GetPixelFormats(IWICBitmapDecoderInfo *iface,
284 UINT cFormats, GUID *pguidPixelFormats, UINT *pcActual)
286 FIXME("(%p,%u,%p,%p): stub\n", iface, cFormats, pguidPixelFormats, pcActual);
290 static HRESULT WINAPI BitmapDecoderInfo_GetColorManagementVersion(IWICBitmapDecoderInfo *iface,
291 UINT cchColorManagementVersion, WCHAR *wzColorManagementVersion, UINT *pcchActual)
293 FIXME("(%p,%u,%p,%p): stub\n", iface, cchColorManagementVersion, wzColorManagementVersion, pcchActual);
297 static HRESULT WINAPI BitmapDecoderInfo_GetDeviceManufacturer(IWICBitmapDecoderInfo *iface,
298 UINT cchDeviceManufacturer, WCHAR *wzDeviceManufacturer, UINT *pcchActual)
300 FIXME("(%p,%u,%p,%p): stub\n", iface, cchDeviceManufacturer, wzDeviceManufacturer, pcchActual);
304 static HRESULT WINAPI BitmapDecoderInfo_GetDeviceModels(IWICBitmapDecoderInfo *iface,
305 UINT cchDeviceModels, WCHAR *wzDeviceModels, UINT *pcchActual)
307 FIXME("(%p,%u,%p,%p): stub\n", iface, cchDeviceModels, wzDeviceModels, pcchActual);
311 static HRESULT WINAPI BitmapDecoderInfo_GetMimeTypes(IWICBitmapDecoderInfo *iface,
312 UINT cchMimeTypes, WCHAR *wzMimeTypes, UINT *pcchActual)
314 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
316 TRACE("(%p,%u,%p,%p)\n", iface, cchMimeTypes, wzMimeTypes, pcchActual);
318 return ComponentInfo_GetStringValue(This->classkey, mimetypes_valuename,
319 cchMimeTypes, wzMimeTypes, pcchActual);
322 static HRESULT WINAPI BitmapDecoderInfo_GetFileExtensions(IWICBitmapDecoderInfo *iface,
323 UINT cchFileExtensions, WCHAR *wzFileExtensions, UINT *pcchActual)
325 FIXME("(%p,%u,%p,%p): stub\n", iface, cchFileExtensions, wzFileExtensions, pcchActual);
329 static HRESULT WINAPI BitmapDecoderInfo_DoesSupportAnimation(IWICBitmapDecoderInfo *iface,
330 BOOL *pfSupportAnimation)
332 FIXME("(%p,%p): stub\n", iface, pfSupportAnimation);
336 static HRESULT WINAPI BitmapDecoderInfo_DoesSupportChromaKey(IWICBitmapDecoderInfo *iface,
337 BOOL *pfSupportChromaKey)
339 FIXME("(%p,%p): stub\n", iface, pfSupportChromaKey);
343 static HRESULT WINAPI BitmapDecoderInfo_DoesSupportLossless(IWICBitmapDecoderInfo *iface,
344 BOOL *pfSupportLossless)
346 FIXME("(%p,%p): stub\n", iface, pfSupportLossless);
350 static HRESULT WINAPI BitmapDecoderInfo_DoesSupportMultiframe(IWICBitmapDecoderInfo *iface,
351 BOOL *pfSupportMultiframe)
353 FIXME("(%p,%p): stub\n", iface, pfSupportMultiframe);
357 static HRESULT WINAPI BitmapDecoderInfo_MatchesMimeType(IWICBitmapDecoderInfo *iface,
358 LPCWSTR wzMimeType, BOOL *pfMatches)
360 FIXME("(%p,%s,%p): stub\n", iface, debugstr_w(wzMimeType), pfMatches);
364 static HRESULT WINAPI BitmapDecoderInfo_GetPatterns(IWICBitmapDecoderInfo *iface,
365 UINT cbSizePatterns, WICBitmapPattern *pPatterns, UINT *pcPatterns, UINT *pcbPatternsActual)
367 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
368 UINT pattern_count=0, patterns_size=0;
369 WCHAR subkeyname[11];
371 HKEY patternskey, patternkey;
372 static const WCHAR uintformatW[] = {'%','u',0};
373 static const WCHAR patternsW[] = {'P','a','t','t','e','r','n','s',0};
374 static const WCHAR positionW[] = {'P','o','s','i','t','i','o','n',0};
375 static const WCHAR lengthW[] = {'L','e','n','g','t','h',0};
376 static const WCHAR patternW[] = {'P','a','t','t','e','r','n',0};
377 static const WCHAR maskW[] = {'M','a','s','k',0};
378 static const WCHAR endofstreamW[] = {'E','n','d','O','f','S','t','r','e','a','m',0};
381 BYTE *bPatterns=(BYTE*)pPatterns;
382 DWORD length, valuesize;
384 TRACE("(%p,%i,%p,%p,%p)\n", iface, cbSizePatterns, pPatterns, pcPatterns, pcbPatternsActual);
386 res = RegOpenKeyExW(This->classkey, patternsW, 0, KEY_READ, &patternskey);
387 if (res != ERROR_SUCCESS) return HRESULT_FROM_WIN32(res);
389 res = RegQueryInfoKeyW(patternskey, NULL, NULL, NULL, &pattern_count, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
390 if (res == ERROR_SUCCESS)
392 patterns_size = pattern_count * sizeof(WICBitmapPattern);
394 for (i=0; i<pattern_count; i++)
396 snprintfW(subkeyname, 11, uintformatW, i);
397 res = RegOpenKeyExW(patternskey, subkeyname, 0, KEY_READ, &patternkey);
398 if (res == ERROR_SUCCESS)
400 valuesize = sizeof(ULONG);
401 res = RegGetValueW(patternkey, NULL, lengthW, RRF_RT_DWORD, NULL,
402 &length, &valuesize);
403 patterns_size += length*2;
405 if ((cbSizePatterns >= patterns_size) && (res == ERROR_SUCCESS))
407 pPatterns[i].Length = length;
409 pPatterns[i].EndOfStream = 0;
410 valuesize = sizeof(BOOL);
411 RegGetValueW(patternkey, NULL, endofstreamW, RRF_RT_DWORD, NULL,
412 &pPatterns[i].EndOfStream, &valuesize);
414 pPatterns[i].Position.QuadPart = 0;
415 valuesize = sizeof(ULARGE_INTEGER);
416 res = RegGetValueW(patternkey, NULL, positionW, RRF_RT_DWORD|RRF_RT_QWORD, NULL,
417 &pPatterns[i].Position, &valuesize);
419 if (res == ERROR_SUCCESS)
421 pPatterns[i].Pattern = bPatterns+patterns_size-length*2;
423 res = RegGetValueW(patternkey, NULL, patternW, RRF_RT_REG_BINARY, NULL,
424 pPatterns[i].Pattern, &valuesize);
427 if (res == ERROR_SUCCESS)
429 pPatterns[i].Mask = bPatterns+patterns_size-length;
431 res = RegGetValueW(patternkey, NULL, maskW, RRF_RT_REG_BINARY, NULL,
432 pPatterns[i].Mask, &valuesize);
436 RegCloseKey(patternkey);
438 if (res != ERROR_SUCCESS)
440 hr = HRESULT_FROM_WIN32(res);
445 else hr = HRESULT_FROM_WIN32(res);
447 RegCloseKey(patternskey);
451 *pcPatterns = pattern_count;
452 *pcbPatternsActual = patterns_size;
453 if (pPatterns && cbSizePatterns < patterns_size)
454 hr = WINCODEC_ERR_INSUFFICIENTBUFFER;
460 static HRESULT WINAPI BitmapDecoderInfo_MatchesPattern(IWICBitmapDecoderInfo *iface,
461 IStream *pIStream, BOOL *pfMatches)
463 WICBitmapPattern *patterns;
464 UINT pattern_count=0, patterns_size=0;
470 LARGE_INTEGER seekpos;
472 TRACE("(%p,%p,%p)\n", iface, pIStream, pfMatches);
474 hr = BitmapDecoderInfo_GetPatterns(iface, 0, NULL, &pattern_count, &patterns_size);
475 if (FAILED(hr)) return hr;
477 patterns = HeapAlloc(GetProcessHeap(), 0, patterns_size);
478 if (!patterns) return E_OUTOFMEMORY;
480 hr = BitmapDecoderInfo_GetPatterns(iface, patterns_size, patterns, &pattern_count, &patterns_size);
481 if (FAILED(hr)) goto end;
483 for (i=0; i<pattern_count; i++)
485 if (datasize < patterns[i].Length)
487 HeapFree(GetProcessHeap(), 0, data);
488 datasize = patterns[i].Length;
489 data = HeapAlloc(GetProcessHeap(), 0, patterns[i].Length);
497 if (patterns[i].EndOfStream)
498 seekpos.QuadPart = -patterns[i].Position.QuadPart;
500 seekpos.QuadPart = patterns[i].Position.QuadPart;
501 hr = IStream_Seek(pIStream, seekpos, patterns[i].EndOfStream ? STREAM_SEEK_END : STREAM_SEEK_SET, NULL);
502 if (hr == STG_E_INVALIDFUNCTION) continue; /* before start of stream */
503 if (FAILED(hr)) break;
505 hr = IStream_Read(pIStream, data, patterns[i].Length, &bytesread);
506 if (hr == S_FALSE || (hr == S_OK && bytesread != patterns[i].Length)) /* past end of stream */
508 if (FAILED(hr)) break;
510 for (pos=0; pos<patterns[i].Length; pos++)
512 if ((data[pos] & patterns[i].Mask[pos]) != patterns[i].Pattern[pos])
515 if (pos == patterns[i].Length) /* matches pattern */
523 if (i == pattern_count) /* does not match any pattern */
530 HeapFree(GetProcessHeap(), 0, patterns);
531 HeapFree(GetProcessHeap(), 0, data);
536 static HRESULT WINAPI BitmapDecoderInfo_CreateInstance(IWICBitmapDecoderInfo *iface,
537 IWICBitmapDecoder **ppIBitmapDecoder)
539 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
541 TRACE("(%p,%p)\n", iface, ppIBitmapDecoder);
543 return CoCreateInstance(&This->clsid, NULL, CLSCTX_INPROC_SERVER,
544 &IID_IWICBitmapDecoder, (void**)ppIBitmapDecoder);
547 static const IWICBitmapDecoderInfoVtbl BitmapDecoderInfo_Vtbl = {
548 BitmapDecoderInfo_QueryInterface,
549 BitmapDecoderInfo_AddRef,
550 BitmapDecoderInfo_Release,
551 BitmapDecoderInfo_GetComponentType,
552 BitmapDecoderInfo_GetCLSID,
553 BitmapDecoderInfo_GetSigningStatus,
554 BitmapDecoderInfo_GetAuthor,
555 BitmapDecoderInfo_GetVendorGUID,
556 BitmapDecoderInfo_GetVersion,
557 BitmapDecoderInfo_GetSpecVersion,
558 BitmapDecoderInfo_GetFriendlyName,
559 BitmapDecoderInfo_GetContainerFormat,
560 BitmapDecoderInfo_GetPixelFormats,
561 BitmapDecoderInfo_GetColorManagementVersion,
562 BitmapDecoderInfo_GetDeviceManufacturer,
563 BitmapDecoderInfo_GetDeviceModels,
564 BitmapDecoderInfo_GetMimeTypes,
565 BitmapDecoderInfo_GetFileExtensions,
566 BitmapDecoderInfo_DoesSupportAnimation,
567 BitmapDecoderInfo_DoesSupportChromaKey,
568 BitmapDecoderInfo_DoesSupportLossless,
569 BitmapDecoderInfo_DoesSupportMultiframe,
570 BitmapDecoderInfo_MatchesMimeType,
571 BitmapDecoderInfo_GetPatterns,
572 BitmapDecoderInfo_MatchesPattern,
573 BitmapDecoderInfo_CreateInstance
576 static HRESULT BitmapDecoderInfo_Constructor(HKEY classkey, REFCLSID clsid, IWICComponentInfo **ppIInfo)
578 BitmapDecoderInfo *This;
580 This = HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapDecoderInfo));
583 RegCloseKey(classkey);
584 return E_OUTOFMEMORY;
587 This->IWICBitmapDecoderInfo_iface.lpVtbl = &BitmapDecoderInfo_Vtbl;
589 This->classkey = classkey;
590 memcpy(&This->clsid, clsid, sizeof(CLSID));
592 *ppIInfo = (IWICComponentInfo*)This;
597 IWICBitmapEncoderInfo IWICBitmapEncoderInfo_iface;
603 static inline BitmapEncoderInfo *impl_from_IWICBitmapEncoderInfo(IWICBitmapEncoderInfo *iface)
605 return CONTAINING_RECORD(iface, BitmapEncoderInfo, IWICBitmapEncoderInfo_iface);
608 static HRESULT WINAPI BitmapEncoderInfo_QueryInterface(IWICBitmapEncoderInfo *iface, REFIID iid,
611 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
612 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
614 if (!ppv) return E_INVALIDARG;
616 if (IsEqualIID(&IID_IUnknown, iid) ||
617 IsEqualIID(&IID_IWICComponentInfo, iid) ||
618 IsEqualIID(&IID_IWICBitmapCodecInfo, iid) ||
619 IsEqualIID(&IID_IWICBitmapEncoderInfo ,iid))
626 return E_NOINTERFACE;
629 IUnknown_AddRef((IUnknown*)*ppv);
633 static ULONG WINAPI BitmapEncoderInfo_AddRef(IWICBitmapEncoderInfo *iface)
635 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
636 ULONG ref = InterlockedIncrement(&This->ref);
638 TRACE("(%p) refcount=%u\n", iface, ref);
643 static ULONG WINAPI BitmapEncoderInfo_Release(IWICBitmapEncoderInfo *iface)
645 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
646 ULONG ref = InterlockedDecrement(&This->ref);
648 TRACE("(%p) refcount=%u\n", iface, ref);
652 RegCloseKey(This->classkey);
653 HeapFree(GetProcessHeap(), 0, This);
659 static HRESULT WINAPI BitmapEncoderInfo_GetComponentType(IWICBitmapEncoderInfo *iface,
660 WICComponentType *pType)
662 TRACE("(%p,%p)\n", iface, pType);
663 if (!pType) return E_INVALIDARG;
668 static HRESULT WINAPI BitmapEncoderInfo_GetCLSID(IWICBitmapEncoderInfo *iface, CLSID *pclsid)
670 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
671 TRACE("(%p,%p)\n", iface, pclsid);
676 memcpy(pclsid, &This->clsid, sizeof(CLSID));
681 static HRESULT WINAPI BitmapEncoderInfo_GetSigningStatus(IWICBitmapEncoderInfo *iface, DWORD *pStatus)
683 FIXME("(%p,%p): stub\n", iface, pStatus);
687 static HRESULT WINAPI BitmapEncoderInfo_GetAuthor(IWICBitmapEncoderInfo *iface, UINT cchAuthor,
688 WCHAR *wzAuthor, UINT *pcchActual)
690 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
692 TRACE("(%p,%u,%p,%p)\n", iface, cchAuthor, wzAuthor, pcchActual);
694 return ComponentInfo_GetStringValue(This->classkey, author_valuename,
695 cchAuthor, wzAuthor, pcchActual);
698 static HRESULT WINAPI BitmapEncoderInfo_GetVendorGUID(IWICBitmapEncoderInfo *iface, GUID *pguidVendor)
700 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
702 TRACE("(%p,%p)\n", iface, pguidVendor);
704 return ComponentInfo_GetGUIDValue(This->classkey, vendor_valuename, pguidVendor);
707 static HRESULT WINAPI BitmapEncoderInfo_GetVersion(IWICBitmapEncoderInfo *iface, UINT cchVersion,
708 WCHAR *wzVersion, UINT *pcchActual)
710 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
712 TRACE("(%p,%u,%p,%p)\n", iface, cchVersion, wzVersion, pcchActual);
714 return ComponentInfo_GetStringValue(This->classkey, version_valuename,
715 cchVersion, wzVersion, pcchActual);
718 static HRESULT WINAPI BitmapEncoderInfo_GetSpecVersion(IWICBitmapEncoderInfo *iface, UINT cchSpecVersion,
719 WCHAR *wzSpecVersion, UINT *pcchActual)
721 FIXME("(%p,%u,%p,%p): stub\n", iface, cchSpecVersion, wzSpecVersion, pcchActual);
725 static HRESULT WINAPI BitmapEncoderInfo_GetFriendlyName(IWICBitmapEncoderInfo *iface, UINT cchFriendlyName,
726 WCHAR *wzFriendlyName, UINT *pcchActual)
728 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
730 TRACE("(%p,%u,%p,%p)\n", iface, cchFriendlyName, wzFriendlyName, pcchActual);
732 return ComponentInfo_GetStringValue(This->classkey, friendlyname_valuename,
733 cchFriendlyName, wzFriendlyName, pcchActual);
736 static HRESULT WINAPI BitmapEncoderInfo_GetContainerFormat(IWICBitmapEncoderInfo *iface,
737 GUID *pguidContainerFormat)
739 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
740 TRACE("(%p,%p)\n", iface, pguidContainerFormat);
741 return ComponentInfo_GetGUIDValue(This->classkey, containerformat_valuename, pguidContainerFormat);
744 static HRESULT WINAPI BitmapEncoderInfo_GetPixelFormats(IWICBitmapEncoderInfo *iface,
745 UINT cFormats, GUID *pguidPixelFormats, UINT *pcActual)
747 FIXME("(%p,%u,%p,%p): stub\n", iface, cFormats, pguidPixelFormats, pcActual);
751 static HRESULT WINAPI BitmapEncoderInfo_GetColorManagementVersion(IWICBitmapEncoderInfo *iface,
752 UINT cchColorManagementVersion, WCHAR *wzColorManagementVersion, UINT *pcchActual)
754 FIXME("(%p,%u,%p,%p): stub\n", iface, cchColorManagementVersion, wzColorManagementVersion, pcchActual);
758 static HRESULT WINAPI BitmapEncoderInfo_GetDeviceManufacturer(IWICBitmapEncoderInfo *iface,
759 UINT cchDeviceManufacturer, WCHAR *wzDeviceManufacturer, UINT *pcchActual)
761 FIXME("(%p,%u,%p,%p): stub\n", iface, cchDeviceManufacturer, wzDeviceManufacturer, pcchActual);
765 static HRESULT WINAPI BitmapEncoderInfo_GetDeviceModels(IWICBitmapEncoderInfo *iface,
766 UINT cchDeviceModels, WCHAR *wzDeviceModels, UINT *pcchActual)
768 FIXME("(%p,%u,%p,%p): stub\n", iface, cchDeviceModels, wzDeviceModels, pcchActual);
772 static HRESULT WINAPI BitmapEncoderInfo_GetMimeTypes(IWICBitmapEncoderInfo *iface,
773 UINT cchMimeTypes, WCHAR *wzMimeTypes, UINT *pcchActual)
775 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
777 TRACE("(%p,%u,%p,%p)\n", iface, cchMimeTypes, wzMimeTypes, pcchActual);
779 return ComponentInfo_GetStringValue(This->classkey, mimetypes_valuename,
780 cchMimeTypes, wzMimeTypes, pcchActual);
783 static HRESULT WINAPI BitmapEncoderInfo_GetFileExtensions(IWICBitmapEncoderInfo *iface,
784 UINT cchFileExtensions, WCHAR *wzFileExtensions, UINT *pcchActual)
786 FIXME("(%p,%u,%p,%p): stub\n", iface, cchFileExtensions, wzFileExtensions, pcchActual);
790 static HRESULT WINAPI BitmapEncoderInfo_DoesSupportAnimation(IWICBitmapEncoderInfo *iface,
791 BOOL *pfSupportAnimation)
793 FIXME("(%p,%p): stub\n", iface, pfSupportAnimation);
797 static HRESULT WINAPI BitmapEncoderInfo_DoesSupportChromaKey(IWICBitmapEncoderInfo *iface,
798 BOOL *pfSupportChromaKey)
800 FIXME("(%p,%p): stub\n", iface, pfSupportChromaKey);
804 static HRESULT WINAPI BitmapEncoderInfo_DoesSupportLossless(IWICBitmapEncoderInfo *iface,
805 BOOL *pfSupportLossless)
807 FIXME("(%p,%p): stub\n", iface, pfSupportLossless);
811 static HRESULT WINAPI BitmapEncoderInfo_DoesSupportMultiframe(IWICBitmapEncoderInfo *iface,
812 BOOL *pfSupportMultiframe)
814 FIXME("(%p,%p): stub\n", iface, pfSupportMultiframe);
818 static HRESULT WINAPI BitmapEncoderInfo_MatchesMimeType(IWICBitmapEncoderInfo *iface,
819 LPCWSTR wzMimeType, BOOL *pfMatches)
821 FIXME("(%p,%s,%p): stub\n", iface, debugstr_w(wzMimeType), pfMatches);
825 static HRESULT WINAPI BitmapEncoderInfo_CreateInstance(IWICBitmapEncoderInfo *iface,
826 IWICBitmapEncoder **ppIBitmapEncoder)
828 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
830 TRACE("(%p,%p)\n", iface, ppIBitmapEncoder);
832 return CoCreateInstance(&This->clsid, NULL, CLSCTX_INPROC_SERVER,
833 &IID_IWICBitmapEncoder, (void**)ppIBitmapEncoder);
836 static const IWICBitmapEncoderInfoVtbl BitmapEncoderInfo_Vtbl = {
837 BitmapEncoderInfo_QueryInterface,
838 BitmapEncoderInfo_AddRef,
839 BitmapEncoderInfo_Release,
840 BitmapEncoderInfo_GetComponentType,
841 BitmapEncoderInfo_GetCLSID,
842 BitmapEncoderInfo_GetSigningStatus,
843 BitmapEncoderInfo_GetAuthor,
844 BitmapEncoderInfo_GetVendorGUID,
845 BitmapEncoderInfo_GetVersion,
846 BitmapEncoderInfo_GetSpecVersion,
847 BitmapEncoderInfo_GetFriendlyName,
848 BitmapEncoderInfo_GetContainerFormat,
849 BitmapEncoderInfo_GetPixelFormats,
850 BitmapEncoderInfo_GetColorManagementVersion,
851 BitmapEncoderInfo_GetDeviceManufacturer,
852 BitmapEncoderInfo_GetDeviceModels,
853 BitmapEncoderInfo_GetMimeTypes,
854 BitmapEncoderInfo_GetFileExtensions,
855 BitmapEncoderInfo_DoesSupportAnimation,
856 BitmapEncoderInfo_DoesSupportChromaKey,
857 BitmapEncoderInfo_DoesSupportLossless,
858 BitmapEncoderInfo_DoesSupportMultiframe,
859 BitmapEncoderInfo_MatchesMimeType,
860 BitmapEncoderInfo_CreateInstance
863 static HRESULT BitmapEncoderInfo_Constructor(HKEY classkey, REFCLSID clsid, IWICComponentInfo **ppIInfo)
865 BitmapEncoderInfo *This;
867 This = HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapEncoderInfo));
870 RegCloseKey(classkey);
871 return E_OUTOFMEMORY;
874 This->IWICBitmapEncoderInfo_iface.lpVtbl = &BitmapEncoderInfo_Vtbl;
876 This->classkey = classkey;
877 memcpy(&This->clsid, clsid, sizeof(CLSID));
879 *ppIInfo = (IWICComponentInfo*)This;
884 IWICFormatConverterInfo IWICFormatConverterInfo_iface;
888 } FormatConverterInfo;
890 static inline FormatConverterInfo *impl_from_IWICFormatConverterInfo(IWICFormatConverterInfo *iface)
892 return CONTAINING_RECORD(iface, FormatConverterInfo, IWICFormatConverterInfo_iface);
895 static HRESULT WINAPI FormatConverterInfo_QueryInterface(IWICFormatConverterInfo *iface, REFIID iid,
898 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
899 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
901 if (!ppv) return E_INVALIDARG;
903 if (IsEqualIID(&IID_IUnknown, iid) ||
904 IsEqualIID(&IID_IWICComponentInfo, iid) ||
905 IsEqualIID(&IID_IWICFormatConverterInfo ,iid))
912 return E_NOINTERFACE;
915 IUnknown_AddRef((IUnknown*)*ppv);
919 static ULONG WINAPI FormatConverterInfo_AddRef(IWICFormatConverterInfo *iface)
921 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
922 ULONG ref = InterlockedIncrement(&This->ref);
924 TRACE("(%p) refcount=%u\n", iface, ref);
929 static ULONG WINAPI FormatConverterInfo_Release(IWICFormatConverterInfo *iface)
931 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
932 ULONG ref = InterlockedDecrement(&This->ref);
934 TRACE("(%p) refcount=%u\n", iface, ref);
938 RegCloseKey(This->classkey);
939 HeapFree(GetProcessHeap(), 0, This);
945 static HRESULT WINAPI FormatConverterInfo_GetComponentType(IWICFormatConverterInfo *iface,
946 WICComponentType *pType)
948 TRACE("(%p,%p)\n", iface, pType);
949 if (!pType) return E_INVALIDARG;
950 *pType = WICPixelFormatConverter;
954 static HRESULT WINAPI FormatConverterInfo_GetCLSID(IWICFormatConverterInfo *iface, CLSID *pclsid)
956 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
957 TRACE("(%p,%p)\n", iface, pclsid);
962 memcpy(pclsid, &This->clsid, sizeof(CLSID));
967 static HRESULT WINAPI FormatConverterInfo_GetSigningStatus(IWICFormatConverterInfo *iface, DWORD *pStatus)
969 FIXME("(%p,%p): stub\n", iface, pStatus);
973 static HRESULT WINAPI FormatConverterInfo_GetAuthor(IWICFormatConverterInfo *iface, UINT cchAuthor,
974 WCHAR *wzAuthor, UINT *pcchActual)
976 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
978 TRACE("(%p,%u,%p,%p)\n", iface, cchAuthor, wzAuthor, pcchActual);
980 return ComponentInfo_GetStringValue(This->classkey, author_valuename,
981 cchAuthor, wzAuthor, pcchActual);
984 static HRESULT WINAPI FormatConverterInfo_GetVendorGUID(IWICFormatConverterInfo *iface, GUID *pguidVendor)
986 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
988 TRACE("(%p,%p)\n", iface, pguidVendor);
990 return ComponentInfo_GetGUIDValue(This->classkey, vendor_valuename, pguidVendor);
993 static HRESULT WINAPI FormatConverterInfo_GetVersion(IWICFormatConverterInfo *iface, UINT cchVersion,
994 WCHAR *wzVersion, UINT *pcchActual)
996 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
998 TRACE("(%p,%u,%p,%p)\n", iface, cchVersion, wzVersion, pcchActual);
1000 return ComponentInfo_GetStringValue(This->classkey, version_valuename,
1001 cchVersion, wzVersion, pcchActual);
1004 static HRESULT WINAPI FormatConverterInfo_GetSpecVersion(IWICFormatConverterInfo *iface, UINT cchSpecVersion,
1005 WCHAR *wzSpecVersion, UINT *pcchActual)
1007 FIXME("(%p,%u,%p,%p): stub\n", iface, cchSpecVersion, wzSpecVersion, pcchActual);
1011 static HRESULT WINAPI FormatConverterInfo_GetFriendlyName(IWICFormatConverterInfo *iface, UINT cchFriendlyName,
1012 WCHAR *wzFriendlyName, UINT *pcchActual)
1014 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
1016 TRACE("(%p,%u,%p,%p)\n", iface, cchFriendlyName, wzFriendlyName, pcchActual);
1018 return ComponentInfo_GetStringValue(This->classkey, friendlyname_valuename,
1019 cchFriendlyName, wzFriendlyName, pcchActual);
1022 static HRESULT WINAPI FormatConverterInfo_GetPixelFormats(IWICFormatConverterInfo *iface,
1023 UINT cFormats, GUID *pguidPixelFormats, UINT *pcActual)
1025 FIXME("(%p,%u,%p,%p): stub\n", iface, cFormats, pguidPixelFormats, pcActual);
1029 static HRESULT WINAPI FormatConverterInfo_CreateInstance(IWICFormatConverterInfo *iface,
1030 IWICFormatConverter **ppIFormatConverter)
1032 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
1034 TRACE("(%p,%p)\n", iface, ppIFormatConverter);
1036 return CoCreateInstance(&This->clsid, NULL, CLSCTX_INPROC_SERVER,
1037 &IID_IWICFormatConverter, (void**)ppIFormatConverter);
1040 static BOOL ConverterSupportsFormat(IWICFormatConverterInfo *iface, const WCHAR *formatguid)
1043 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
1044 HKEY formats_key, guid_key;
1046 /* Avoid testing using IWICFormatConverter_GetPixelFormats because that
1047 would be O(n). A registry test should do better. */
1049 res = RegOpenKeyExW(This->classkey, pixelformats_keyname, 0, KEY_READ, &formats_key);
1050 if (res != ERROR_SUCCESS) return FALSE;
1052 res = RegOpenKeyExW(formats_key, formatguid, 0, KEY_READ, &guid_key);
1053 if (res == ERROR_SUCCESS) RegCloseKey(guid_key);
1055 RegCloseKey(formats_key);
1057 return (res == ERROR_SUCCESS);
1060 static const IWICFormatConverterInfoVtbl FormatConverterInfo_Vtbl = {
1061 FormatConverterInfo_QueryInterface,
1062 FormatConverterInfo_AddRef,
1063 FormatConverterInfo_Release,
1064 FormatConverterInfo_GetComponentType,
1065 FormatConverterInfo_GetCLSID,
1066 FormatConverterInfo_GetSigningStatus,
1067 FormatConverterInfo_GetAuthor,
1068 FormatConverterInfo_GetVendorGUID,
1069 FormatConverterInfo_GetVersion,
1070 FormatConverterInfo_GetSpecVersion,
1071 FormatConverterInfo_GetFriendlyName,
1072 FormatConverterInfo_GetPixelFormats,
1073 FormatConverterInfo_CreateInstance
1076 static HRESULT FormatConverterInfo_Constructor(HKEY classkey, REFCLSID clsid, IWICComponentInfo **ppIInfo)
1078 FormatConverterInfo *This;
1080 This = HeapAlloc(GetProcessHeap(), 0, sizeof(FormatConverterInfo));
1083 RegCloseKey(classkey);
1084 return E_OUTOFMEMORY;
1087 This->IWICFormatConverterInfo_iface.lpVtbl = &FormatConverterInfo_Vtbl;
1089 This->classkey = classkey;
1090 memcpy(&This->clsid, clsid, sizeof(CLSID));
1092 *ppIInfo = (IWICComponentInfo*)This;
1097 IWICPixelFormatInfo2 IWICPixelFormatInfo2_iface;
1103 static inline PixelFormatInfo *impl_from_IWICPixelFormatInfo2(IWICPixelFormatInfo2 *iface)
1105 return CONTAINING_RECORD(iface, PixelFormatInfo, IWICPixelFormatInfo2_iface);
1108 static HRESULT WINAPI PixelFormatInfo_QueryInterface(IWICPixelFormatInfo2 *iface, REFIID iid,
1111 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1112 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
1114 if (!ppv) return E_INVALIDARG;
1116 if (IsEqualIID(&IID_IUnknown, iid) ||
1117 IsEqualIID(&IID_IWICComponentInfo, iid) ||
1118 IsEqualIID(&IID_IWICPixelFormatInfo, iid) ||
1119 IsEqualIID(&IID_IWICPixelFormatInfo2 ,iid))
1126 return E_NOINTERFACE;
1129 IUnknown_AddRef((IUnknown*)*ppv);
1133 static ULONG WINAPI PixelFormatInfo_AddRef(IWICPixelFormatInfo2 *iface)
1135 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1136 ULONG ref = InterlockedIncrement(&This->ref);
1138 TRACE("(%p) refcount=%u\n", iface, ref);
1143 static ULONG WINAPI PixelFormatInfo_Release(IWICPixelFormatInfo2 *iface)
1145 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1146 ULONG ref = InterlockedDecrement(&This->ref);
1148 TRACE("(%p) refcount=%u\n", iface, ref);
1152 RegCloseKey(This->classkey);
1153 HeapFree(GetProcessHeap(), 0, This);
1159 static HRESULT WINAPI PixelFormatInfo_GetComponentType(IWICPixelFormatInfo2 *iface,
1160 WICComponentType *pType)
1162 TRACE("(%p,%p)\n", iface, pType);
1163 if (!pType) return E_INVALIDARG;
1164 *pType = WICPixelFormat;
1168 static HRESULT WINAPI PixelFormatInfo_GetCLSID(IWICPixelFormatInfo2 *iface, CLSID *pclsid)
1170 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1171 TRACE("(%p,%p)\n", iface, pclsid);
1174 return E_INVALIDARG;
1176 memcpy(pclsid, &This->clsid, sizeof(CLSID));
1181 static HRESULT WINAPI PixelFormatInfo_GetSigningStatus(IWICPixelFormatInfo2 *iface, DWORD *pStatus)
1183 TRACE("(%p,%p)\n", iface, pStatus);
1186 return E_INVALIDARG;
1188 /* Pixel formats don't require code, so they are considered signed. */
1189 *pStatus = WICComponentSigned;
1194 static HRESULT WINAPI PixelFormatInfo_GetAuthor(IWICPixelFormatInfo2 *iface, UINT cchAuthor,
1195 WCHAR *wzAuthor, UINT *pcchActual)
1197 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1199 TRACE("(%p,%u,%p,%p)\n", iface, cchAuthor, wzAuthor, pcchActual);
1201 return ComponentInfo_GetStringValue(This->classkey, author_valuename,
1202 cchAuthor, wzAuthor, pcchActual);
1205 static HRESULT WINAPI PixelFormatInfo_GetVendorGUID(IWICPixelFormatInfo2 *iface, GUID *pguidVendor)
1207 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1209 TRACE("(%p,%p)\n", iface, pguidVendor);
1211 return ComponentInfo_GetGUIDValue(This->classkey, vendor_valuename, pguidVendor);
1214 static HRESULT WINAPI PixelFormatInfo_GetVersion(IWICPixelFormatInfo2 *iface, UINT cchVersion,
1215 WCHAR *wzVersion, UINT *pcchActual)
1217 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1219 TRACE("(%p,%u,%p,%p)\n", iface, cchVersion, wzVersion, pcchActual);
1221 return ComponentInfo_GetStringValue(This->classkey, version_valuename,
1222 cchVersion, wzVersion, pcchActual);
1225 static HRESULT WINAPI PixelFormatInfo_GetSpecVersion(IWICPixelFormatInfo2 *iface, UINT cchSpecVersion,
1226 WCHAR *wzSpecVersion, UINT *pcchActual)
1228 FIXME("(%p,%u,%p,%p): stub\n", iface, cchSpecVersion, wzSpecVersion, pcchActual);
1232 static HRESULT WINAPI PixelFormatInfo_GetFriendlyName(IWICPixelFormatInfo2 *iface, UINT cchFriendlyName,
1233 WCHAR *wzFriendlyName, UINT *pcchActual)
1235 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1237 TRACE("(%p,%u,%p,%p)\n", iface, cchFriendlyName, wzFriendlyName, pcchActual);
1239 return ComponentInfo_GetStringValue(This->classkey, friendlyname_valuename,
1240 cchFriendlyName, wzFriendlyName, pcchActual);
1243 static HRESULT WINAPI PixelFormatInfo_GetFormatGUID(IWICPixelFormatInfo2 *iface,
1246 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1247 TRACE("(%p,%p)\n", iface, pFormat);
1250 return E_INVALIDARG;
1252 *pFormat = This->clsid;
1257 static HRESULT WINAPI PixelFormatInfo_GetColorContext(IWICPixelFormatInfo2 *iface,
1258 IWICColorContext **ppIColorContext)
1260 FIXME("(%p,%p): stub\n", iface, ppIColorContext);
1264 static HRESULT WINAPI PixelFormatInfo_GetBitsPerPixel(IWICPixelFormatInfo2 *iface,
1265 UINT *puiBitsPerPixel)
1267 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1269 TRACE("(%p,%p)\n", iface, puiBitsPerPixel);
1271 return ComponentInfo_GetDWORDValue(This->classkey, bitsperpixel_valuename, puiBitsPerPixel);
1274 static HRESULT WINAPI PixelFormatInfo_GetChannelCount(IWICPixelFormatInfo2 *iface,
1275 UINT *puiChannelCount)
1277 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1279 TRACE("(%p,%p)\n", iface, puiChannelCount);
1281 return ComponentInfo_GetDWORDValue(This->classkey, channelcount_valuename, puiChannelCount);
1284 static HRESULT WINAPI PixelFormatInfo_GetChannelMask(IWICPixelFormatInfo2 *iface,
1285 UINT uiChannelIndex, UINT cbMaskBuffer, BYTE *pbMaskBuffer, UINT *pcbActual)
1287 static const WCHAR uintformatW[] = {'%','u',0};
1288 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1292 WCHAR valuename[11];
1295 TRACE("(%p,%u,%u,%p,%p)\n", iface, uiChannelIndex, cbMaskBuffer, pbMaskBuffer, pcbActual);
1298 return E_INVALIDARG;
1300 hr = PixelFormatInfo_GetChannelCount(iface, &channel_count);
1302 if (SUCCEEDED(hr) && uiChannelIndex >= channel_count)
1307 snprintfW(valuename, 11, uintformatW, uiChannelIndex);
1309 cbData = cbMaskBuffer;
1311 ret = RegGetValueW(This->classkey, channelmasks_keyname, valuename, RRF_RT_REG_BINARY, NULL, pbMaskBuffer, &cbData);
1313 if (ret == ERROR_SUCCESS || ret == ERROR_MORE_DATA)
1314 *pcbActual = cbData;
1316 if (ret == ERROR_MORE_DATA)
1319 hr = HRESULT_FROM_WIN32(ret);
1325 static HRESULT WINAPI PixelFormatInfo_SupportsTransparency(IWICPixelFormatInfo2 *iface,
1326 BOOL *pfSupportsTransparency)
1328 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1330 TRACE("(%p,%p)\n", iface, pfSupportsTransparency);
1332 return ComponentInfo_GetDWORDValue(This->classkey, supportstransparency_valuename, (DWORD*)pfSupportsTransparency);
1335 static HRESULT WINAPI PixelFormatInfo_GetNumericRepresentation(IWICPixelFormatInfo2 *iface,
1336 WICPixelFormatNumericRepresentation *pNumericRepresentation)
1338 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1340 TRACE("(%p,%p)\n", iface, pNumericRepresentation);
1342 return ComponentInfo_GetDWORDValue(This->classkey, numericrepresentation_valuename, pNumericRepresentation);
1345 static const IWICPixelFormatInfo2Vtbl PixelFormatInfo_Vtbl = {
1346 PixelFormatInfo_QueryInterface,
1347 PixelFormatInfo_AddRef,
1348 PixelFormatInfo_Release,
1349 PixelFormatInfo_GetComponentType,
1350 PixelFormatInfo_GetCLSID,
1351 PixelFormatInfo_GetSigningStatus,
1352 PixelFormatInfo_GetAuthor,
1353 PixelFormatInfo_GetVendorGUID,
1354 PixelFormatInfo_GetVersion,
1355 PixelFormatInfo_GetSpecVersion,
1356 PixelFormatInfo_GetFriendlyName,
1357 PixelFormatInfo_GetFormatGUID,
1358 PixelFormatInfo_GetColorContext,
1359 PixelFormatInfo_GetBitsPerPixel,
1360 PixelFormatInfo_GetChannelCount,
1361 PixelFormatInfo_GetChannelMask,
1362 PixelFormatInfo_SupportsTransparency,
1363 PixelFormatInfo_GetNumericRepresentation
1366 static HRESULT PixelFormatInfo_Constructor(HKEY classkey, REFCLSID clsid, IWICComponentInfo **ppIInfo)
1368 PixelFormatInfo *This;
1370 This = HeapAlloc(GetProcessHeap(), 0, sizeof(PixelFormatInfo));
1373 RegCloseKey(classkey);
1374 return E_OUTOFMEMORY;
1377 This->IWICPixelFormatInfo2_iface.lpVtbl = &PixelFormatInfo_Vtbl;
1379 This->classkey = classkey;
1380 memcpy(&This->clsid, clsid, sizeof(CLSID));
1382 *ppIInfo = (IWICComponentInfo*)This;
1388 IWICMetadataReaderInfo IWICMetadataReaderInfo_iface;
1392 } MetadataReaderInfo;
1394 static inline MetadataReaderInfo *impl_from_IWICMetadataReaderInfo(IWICMetadataReaderInfo *iface)
1396 return CONTAINING_RECORD(iface, MetadataReaderInfo, IWICMetadataReaderInfo_iface);
1399 static HRESULT WINAPI MetadataReaderInfo_QueryInterface(IWICMetadataReaderInfo *iface,
1400 REFIID riid, void **ppv)
1402 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1404 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(riid), ppv);
1406 if (!ppv) return E_INVALIDARG;
1408 if (IsEqualIID(&IID_IUnknown, riid) ||
1409 IsEqualIID(&IID_IWICComponentInfo, riid) ||
1410 IsEqualIID(&IID_IWICMetadataHandlerInfo, riid) ||
1411 IsEqualIID(&IID_IWICMetadataReaderInfo, riid))
1418 return E_NOINTERFACE;
1421 IUnknown_AddRef((IUnknown *)*ppv);
1425 static ULONG WINAPI MetadataReaderInfo_AddRef(IWICMetadataReaderInfo *iface)
1427 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1428 ULONG ref = InterlockedIncrement(&This->ref);
1430 TRACE("(%p) refcount=%u\n", iface, ref);
1434 static ULONG WINAPI MetadataReaderInfo_Release(IWICMetadataReaderInfo *iface)
1436 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1437 ULONG ref = InterlockedDecrement(&This->ref);
1439 TRACE("(%p) refcount=%u\n", iface, ref);
1443 RegCloseKey(This->classkey);
1444 HeapFree(GetProcessHeap(), 0, This);
1449 static HRESULT WINAPI MetadataReaderInfo_GetComponentType(IWICMetadataReaderInfo *iface,
1450 WICComponentType *type)
1452 TRACE("(%p,%p)\n", iface, type);
1454 if (!type) return E_INVALIDARG;
1455 *type = WICMetadataReader;
1459 static HRESULT WINAPI MetadataReaderInfo_GetCLSID(IWICMetadataReaderInfo *iface,
1462 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1464 TRACE("(%p,%p)\n", iface, clsid);
1466 if (!clsid) return E_INVALIDARG;
1467 *clsid = This->clsid;
1471 static HRESULT WINAPI MetadataReaderInfo_GetSigningStatus(IWICMetadataReaderInfo *iface,
1474 FIXME("(%p,%p): stub\n", iface, status);
1478 static HRESULT WINAPI MetadataReaderInfo_GetAuthor(IWICMetadataReaderInfo *iface,
1479 UINT length, WCHAR *author, UINT *actual_length)
1481 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1483 TRACE("(%p,%u,%p,%p)\n", iface, length, author, actual_length);
1485 return ComponentInfo_GetStringValue(This->classkey, author_valuename,
1486 length, author, actual_length);
1489 static HRESULT WINAPI MetadataReaderInfo_GetVendorGUID(IWICMetadataReaderInfo *iface,
1492 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1494 TRACE("(%p,%p)\n", iface, vendor);
1496 return ComponentInfo_GetGUIDValue(This->classkey, vendor_valuename, vendor);
1499 static HRESULT WINAPI MetadataReaderInfo_GetVersion(IWICMetadataReaderInfo *iface,
1500 UINT length, WCHAR *version, UINT *actual_length)
1502 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1504 TRACE("(%p,%u,%p,%p)\n", iface, length, version, actual_length);
1506 return ComponentInfo_GetStringValue(This->classkey, version_valuename,
1507 length, version, actual_length);
1510 static HRESULT WINAPI MetadataReaderInfo_GetSpecVersion(IWICMetadataReaderInfo *iface,
1511 UINT length, WCHAR *version, UINT *actual_length)
1513 FIXME("(%p,%u,%p,%p): stub\n", iface, length, version, actual_length);
1517 static HRESULT WINAPI MetadataReaderInfo_GetFriendlyName(IWICMetadataReaderInfo *iface,
1518 UINT length, WCHAR *name, UINT *actual_length)
1520 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1522 TRACE("(%p,%u,%p,%p)\n", iface, length, name, actual_length);
1524 return ComponentInfo_GetStringValue(This->classkey, friendlyname_valuename,
1525 length, name, actual_length);
1528 static HRESULT WINAPI MetadataReaderInfo_GetMetadataFormat(IWICMetadataReaderInfo *iface,
1531 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1532 TRACE("(%p,%p)\n", iface, format);
1533 return ComponentInfo_GetGUIDValue(This->classkey, metadataformat_valuename, format);
1536 static HRESULT WINAPI MetadataReaderInfo_GetContainerFormats(IWICMetadataReaderInfo *iface,
1537 UINT length, GUID *formats, UINT *actual_length)
1539 if (!actual_length) return E_INVALIDARG;
1541 FIXME("(%p,%u,%p,%p): stub\n", iface, length, formats, actual_length);
1545 static HRESULT WINAPI MetadataReaderInfo_GetDeviceManufacturer(IWICMetadataReaderInfo *iface,
1546 UINT length, WCHAR *manufacturer, UINT *actual_length)
1548 FIXME("(%p,%u,%p,%p): stub\n", iface, length, manufacturer, actual_length);
1552 static HRESULT WINAPI MetadataReaderInfo_GetDeviceModels(IWICMetadataReaderInfo *iface,
1553 UINT length, WCHAR *models, UINT *actual_length)
1555 FIXME("(%p,%u,%p,%p): stub\n", iface, length, models, actual_length);
1559 static HRESULT WINAPI MetadataReaderInfo_DoesRequireFullStream(IWICMetadataReaderInfo *iface,
1562 FIXME("(%p,%p): stub\n", iface, param);
1566 static HRESULT WINAPI MetadataReaderInfo_DoesSupportPadding(IWICMetadataReaderInfo *iface,
1569 FIXME("(%p,%p): stub\n", iface, param);
1573 static HRESULT WINAPI MetadataReaderInfo_DoesRequireFixedSize(IWICMetadataReaderInfo *iface,
1576 FIXME("(%p,%p): stub\n", iface, param);
1580 static HRESULT WINAPI MetadataReaderInfo_GetPatterns(IWICMetadataReaderInfo *iface,
1581 REFGUID container, UINT length, WICMetadataPattern *pattern, UINT *count, UINT *actual_length)
1583 if (!actual_length) return E_INVALIDARG;
1585 FIXME("(%p,%s,%u,%p,%p,%p): stub\n", iface, debugstr_guid(container), length, pattern, count, actual_length);
1589 static HRESULT WINAPI MetadataReaderInfo_MatchesPattern(IWICMetadataReaderInfo *iface,
1590 REFGUID container, IStream *stream, BOOL *matches)
1592 FIXME("(%p,%s,%p,%p): stub\n", iface, debugstr_guid(container), stream, matches);
1596 static HRESULT WINAPI MetadataReaderInfo_CreateInstance(IWICMetadataReaderInfo *iface,
1597 IWICMetadataReader **reader)
1599 MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
1601 TRACE("(%p,%p)\n", iface, reader);
1603 return CoCreateInstance(&This->clsid, NULL, CLSCTX_INPROC_SERVER,
1604 &IID_IWICMetadataReader, (void **)reader);
1607 static const IWICMetadataReaderInfoVtbl MetadataReaderInfo_Vtbl = {
1608 MetadataReaderInfo_QueryInterface,
1609 MetadataReaderInfo_AddRef,
1610 MetadataReaderInfo_Release,
1611 MetadataReaderInfo_GetComponentType,
1612 MetadataReaderInfo_GetCLSID,
1613 MetadataReaderInfo_GetSigningStatus,
1614 MetadataReaderInfo_GetAuthor,
1615 MetadataReaderInfo_GetVendorGUID,
1616 MetadataReaderInfo_GetVersion,
1617 MetadataReaderInfo_GetSpecVersion,
1618 MetadataReaderInfo_GetFriendlyName,
1619 MetadataReaderInfo_GetMetadataFormat,
1620 MetadataReaderInfo_GetContainerFormats,
1621 MetadataReaderInfo_GetDeviceManufacturer,
1622 MetadataReaderInfo_GetDeviceModels,
1623 MetadataReaderInfo_DoesRequireFullStream,
1624 MetadataReaderInfo_DoesSupportPadding,
1625 MetadataReaderInfo_DoesRequireFixedSize,
1626 MetadataReaderInfo_GetPatterns,
1627 MetadataReaderInfo_MatchesPattern,
1628 MetadataReaderInfo_CreateInstance
1631 static HRESULT MetadataReaderInfo_Constructor(HKEY classkey, REFCLSID clsid, IWICComponentInfo **info)
1633 MetadataReaderInfo *This;
1635 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
1638 RegCloseKey(classkey);
1639 return E_OUTOFMEMORY;
1642 This->IWICMetadataReaderInfo_iface.lpVtbl = &MetadataReaderInfo_Vtbl;
1644 This->classkey = classkey;
1645 This->clsid = *clsid;
1647 *info = (IWICComponentInfo *)This;
1651 static const WCHAR clsid_keyname[] = {'C','L','S','I','D',0};
1652 static const WCHAR instance_keyname[] = {'I','n','s','t','a','n','c','e',0};
1655 WICComponentType type;
1657 HRESULT (*constructor)(HKEY,REFCLSID,IWICComponentInfo**);
1660 static const struct category categories[] = {
1661 {WICDecoder, &CATID_WICBitmapDecoders, BitmapDecoderInfo_Constructor},
1662 {WICEncoder, &CATID_WICBitmapEncoders, BitmapEncoderInfo_Constructor},
1663 {WICPixelFormatConverter, &CATID_WICFormatConverters, FormatConverterInfo_Constructor},
1664 {WICPixelFormat, &CATID_WICPixelFormats, PixelFormatInfo_Constructor},
1665 {WICMetadataReader, &CATID_WICMetadataReader, MetadataReaderInfo_Constructor},
1669 HRESULT CreateComponentInfo(REFCLSID clsid, IWICComponentInfo **ppIInfo)
1675 WCHAR guidstring[39];
1677 const struct category *category;
1681 res = RegOpenKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, KEY_READ, &clsidkey);
1682 if (res != ERROR_SUCCESS)
1683 return HRESULT_FROM_WIN32(res);
1685 for (category=categories; category->type; category++)
1687 StringFromGUID2(category->catid, guidstring, 39);
1688 res = RegOpenKeyExW(clsidkey, guidstring, 0, KEY_READ, &catidkey);
1689 if (res == ERROR_SUCCESS)
1691 res = RegOpenKeyExW(catidkey, instance_keyname, 0, KEY_READ, &instancekey);
1692 if (res == ERROR_SUCCESS)
1694 StringFromGUID2(clsid, guidstring, 39);
1695 res = RegOpenKeyExW(instancekey, guidstring, 0, KEY_READ, &classkey);
1696 if (res == ERROR_SUCCESS)
1698 RegCloseKey(classkey);
1701 RegCloseKey(instancekey);
1703 RegCloseKey(catidkey);
1710 res = RegOpenKeyExW(clsidkey, guidstring, 0, KEY_READ, &classkey);
1711 if (res == ERROR_SUCCESS)
1712 hr = category->constructor(classkey, clsid, ppIInfo);
1714 hr = HRESULT_FROM_WIN32(res);
1718 FIXME("%s is not supported\n", wine_dbgstr_guid(clsid));
1722 RegCloseKey(clsidkey);
1728 IEnumUnknown IEnumUnknown_iface;
1730 struct list objects;
1731 struct list *cursor;
1732 CRITICAL_SECTION lock; /* Must be held when reading or writing cursor */
1735 static inline ComponentEnum *impl_from_IEnumUnknown(IEnumUnknown *iface)
1737 return CONTAINING_RECORD(iface, ComponentEnum, IEnumUnknown_iface);
1743 } ComponentEnumItem;
1745 static const IEnumUnknownVtbl ComponentEnumVtbl;
1747 static HRESULT WINAPI ComponentEnum_QueryInterface(IEnumUnknown *iface, REFIID iid,
1750 ComponentEnum *This = impl_from_IEnumUnknown(iface);
1751 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
1753 if (!ppv) return E_INVALIDARG;
1755 if (IsEqualIID(&IID_IUnknown, iid) || IsEqualIID(&IID_IEnumUnknown, iid))
1762 return E_NOINTERFACE;
1765 IUnknown_AddRef((IUnknown*)*ppv);
1769 static ULONG WINAPI ComponentEnum_AddRef(IEnumUnknown *iface)
1771 ComponentEnum *This = impl_from_IEnumUnknown(iface);
1772 ULONG ref = InterlockedIncrement(&This->ref);
1774 TRACE("(%p) refcount=%u\n", iface, ref);
1779 static ULONG WINAPI ComponentEnum_Release(IEnumUnknown *iface)
1781 ComponentEnum *This = impl_from_IEnumUnknown(iface);
1782 ULONG ref = InterlockedDecrement(&This->ref);
1783 ComponentEnumItem *cursor, *cursor2;
1785 TRACE("(%p) refcount=%u\n", iface, ref);
1789 LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, &This->objects, ComponentEnumItem, entry)
1791 IUnknown_Release(cursor->unk);
1792 list_remove(&cursor->entry);
1793 HeapFree(GetProcessHeap(), 0, cursor);
1795 This->lock.DebugInfo->Spare[0] = 0;
1796 DeleteCriticalSection(&This->lock);
1797 HeapFree(GetProcessHeap(), 0, This);
1803 static HRESULT WINAPI ComponentEnum_Next(IEnumUnknown *iface, ULONG celt,
1804 IUnknown **rgelt, ULONG *pceltFetched)
1806 ComponentEnum *This = impl_from_IEnumUnknown(iface);
1808 ComponentEnumItem *item;
1811 TRACE("(%p,%u,%p,%p)\n", iface, celt, rgelt, pceltFetched);
1813 EnterCriticalSection(&This->lock);
1814 while (num_fetched<celt)
1821 item = LIST_ENTRY(This->cursor, ComponentEnumItem, entry);
1822 IUnknown_AddRef(item->unk);
1823 rgelt[num_fetched] = item->unk;
1825 This->cursor = list_next(&This->objects, This->cursor);
1827 LeaveCriticalSection(&This->lock);
1829 *pceltFetched = num_fetched;
1833 static HRESULT WINAPI ComponentEnum_Skip(IEnumUnknown *iface, ULONG celt)
1835 ComponentEnum *This = impl_from_IEnumUnknown(iface);
1839 TRACE("(%p,%u)\n", iface, celt);
1841 EnterCriticalSection(&This->lock);
1842 for (i=0; i<celt; i++)
1849 This->cursor = list_next(&This->objects, This->cursor);
1851 LeaveCriticalSection(&This->lock);
1855 static HRESULT WINAPI ComponentEnum_Reset(IEnumUnknown *iface)
1857 ComponentEnum *This = impl_from_IEnumUnknown(iface);
1859 TRACE("(%p)\n", iface);
1861 EnterCriticalSection(&This->lock);
1862 This->cursor = list_head(&This->objects);
1863 LeaveCriticalSection(&This->lock);
1867 static HRESULT WINAPI ComponentEnum_Clone(IEnumUnknown *iface, IEnumUnknown **ppenum)
1869 ComponentEnum *This = impl_from_IEnumUnknown(iface);
1870 ComponentEnum *new_enum;
1871 ComponentEnumItem *old_item, *new_item;
1873 struct list *old_cursor;
1875 new_enum = HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnum));
1879 return E_OUTOFMEMORY;
1882 new_enum->IEnumUnknown_iface.lpVtbl = &ComponentEnumVtbl;
1884 new_enum->cursor = NULL;
1885 list_init(&new_enum->objects);
1886 InitializeCriticalSection(&new_enum->lock);
1887 new_enum->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": ComponentEnum.lock");
1889 EnterCriticalSection(&This->lock);
1890 old_cursor = This->cursor;
1891 LeaveCriticalSection(&This->lock);
1893 LIST_FOR_EACH_ENTRY(old_item, &This->objects, ComponentEnumItem, entry)
1895 new_item = HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnumItem));
1898 ret = E_OUTOFMEMORY;
1901 new_item->unk = old_item->unk;
1902 list_add_tail(&new_enum->objects, &new_item->entry);
1903 IUnknown_AddRef(new_item->unk);
1904 if (&old_item->entry == old_cursor) new_enum->cursor = &new_item->entry;
1909 IUnknown_Release((IUnknown*)new_enum);
1913 *ppenum = (IEnumUnknown*)new_enum;
1918 static const IEnumUnknownVtbl ComponentEnumVtbl = {
1919 ComponentEnum_QueryInterface,
1920 ComponentEnum_AddRef,
1921 ComponentEnum_Release,
1924 ComponentEnum_Reset,
1928 HRESULT CreateComponentEnumerator(DWORD componentTypes, DWORD options, IEnumUnknown **ppIEnumUnknown)
1930 ComponentEnum *This;
1931 ComponentEnumItem *item;
1932 const struct category *category;
1933 HKEY clsidkey, catidkey, instancekey;
1934 WCHAR guidstring[39];
1940 if (options) FIXME("ignoring flags %x\n", options);
1942 res = RegOpenKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, KEY_READ, &clsidkey);
1943 if (res != ERROR_SUCCESS)
1944 return HRESULT_FROM_WIN32(res);
1946 This = HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnum));
1949 RegCloseKey(clsidkey);
1950 return E_OUTOFMEMORY;
1953 This->IEnumUnknown_iface.lpVtbl = &ComponentEnumVtbl;
1955 list_init(&This->objects);
1956 InitializeCriticalSection(&This->lock);
1957 This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": ComponentEnum.lock");
1959 for (category=categories; category->type && hr == S_OK; category++)
1961 if ((category->type & componentTypes) == 0) continue;
1962 StringFromGUID2(category->catid, guidstring, 39);
1963 res = RegOpenKeyExW(clsidkey, guidstring, 0, KEY_READ, &catidkey);
1964 if (res == ERROR_SUCCESS)
1966 res = RegOpenKeyExW(catidkey, instance_keyname, 0, KEY_READ, &instancekey);
1967 if (res == ERROR_SUCCESS)
1972 DWORD guidstring_size = 39;
1973 res = RegEnumKeyExW(instancekey, i, guidstring, &guidstring_size, NULL, NULL, NULL, NULL);
1974 if (res != ERROR_SUCCESS) break;
1976 item = HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnumItem));
1977 if (!item) { hr = E_OUTOFMEMORY; break; }
1979 hr = CLSIDFromString(guidstring, &clsid);
1982 hr = CreateComponentInfo(&clsid, (IWICComponentInfo**)&item->unk);
1984 list_add_tail(&This->objects, &item->entry);
1989 HeapFree(GetProcessHeap(), 0, item);
1993 RegCloseKey(instancekey);
1995 RegCloseKey(catidkey);
1997 if (res != ERROR_SUCCESS && res != ERROR_NO_MORE_ITEMS)
1998 hr = HRESULT_FROM_WIN32(res);
2000 RegCloseKey(clsidkey);
2004 IEnumUnknown_Reset((IEnumUnknown*)This);
2005 *ppIEnumUnknown = (IEnumUnknown*)This;
2009 *ppIEnumUnknown = NULL;
2010 IUnknown_Release((IUnknown*)This);
2016 HRESULT WINAPI WICConvertBitmapSource(REFWICPixelFormatGUID dstFormat, IWICBitmapSource *pISrc, IWICBitmapSource **ppIDst)
2019 IEnumUnknown *enumconverters;
2020 IUnknown *unkconverterinfo;
2021 IWICFormatConverterInfo *converterinfo=NULL;
2022 IWICFormatConverter *converter=NULL;
2024 WCHAR srcformatstr[39], dstformatstr[39];
2028 res = IWICBitmapSource_GetPixelFormat(pISrc, &srcFormat);
2029 if (FAILED(res)) return res;
2031 if (IsEqualGUID(&srcFormat, dstFormat))
2033 IWICBitmapSource_AddRef(pISrc);
2038 StringFromGUID2(&srcFormat, srcformatstr, 39);
2039 StringFromGUID2(dstFormat, dstformatstr, 39);
2041 res = CreateComponentEnumerator(WICPixelFormatConverter, 0, &enumconverters);
2042 if (FAILED(res)) return res;
2046 res = IEnumUnknown_Next(enumconverters, 1, &unkconverterinfo, &num_fetched);
2050 res = IUnknown_QueryInterface(unkconverterinfo, &IID_IWICFormatConverterInfo, (void**)&converterinfo);
2054 canconvert = ConverterSupportsFormat(converterinfo, srcformatstr);
2057 canconvert = ConverterSupportsFormat(converterinfo, dstformatstr);
2061 res = IWICFormatConverterInfo_CreateInstance(converterinfo, &converter);
2064 res = IWICFormatConverter_CanConvert(converter, &srcFormat, dstFormat, &canconvert);
2066 if (SUCCEEDED(res) && canconvert)
2067 res = IWICFormatConverter_Initialize(converter, pISrc, dstFormat, WICBitmapDitherTypeNone,
2068 NULL, 0.0, WICBitmapPaletteTypeCustom);
2070 if (FAILED(res) || !canconvert)
2074 IWICFormatConverter_Release(converter);
2081 IWICFormatConverterInfo_Release(converterinfo);
2084 IUnknown_Release(unkconverterinfo);
2090 IEnumUnknown_Release(enumconverters);
2094 *ppIDst = (IWICBitmapSource*)converter;
2099 FIXME("cannot convert %s to %s\n", debugstr_guid(&srcFormat), debugstr_guid(dstFormat));
2101 return WINCODEC_ERR_COMPONENTNOTFOUND;