2 * Copyright 2009 Vincent Povirk for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include "wincodecs_private.h"
33 #include "wine/debug.h"
34 #include "wine/unicode.h"
35 #include "wine/list.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
39 static const WCHAR mimetypes_valuename[] = {'M','i','m','e','T','y','p','e','s',0};
40 static const WCHAR author_valuename[] = {'A','u','t','h','o','r',0};
41 static const WCHAR friendlyname_valuename[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
42 static const WCHAR pixelformats_keyname[] = {'P','i','x','e','l','F','o','r','m','a','t','s',0};
43 static const WCHAR containerformat_valuename[] = {'C','o','n','t','a','i','n','e','r','F','o','r','m','a','t',0};
44 static const WCHAR vendor_valuename[] = {'V','e','n','d','o','r',0};
46 static HRESULT ComponentInfo_GetStringValue(HKEY classkey, LPCWSTR value,
47 UINT buffer_size, WCHAR *buffer, UINT *actual_size)
50 DWORD cbdata=buffer_size * sizeof(WCHAR);
55 ret = RegGetValueW(classkey, NULL, value, RRF_RT_REG_SZ|RRF_NOEXPAND, NULL,
58 if (ret == 0 || ret == ERROR_MORE_DATA)
59 *actual_size = cbdata/sizeof(WCHAR);
61 if (!buffer && buffer_size != 0)
62 /* Yes, native returns the correct size in this case. */
65 if (ret == ERROR_MORE_DATA)
66 return WINCODEC_ERR_INSUFFICIENTBUFFER;
68 return HRESULT_FROM_WIN32(ret);
71 static HRESULT ComponentInfo_GetGUIDValue(HKEY classkey, LPCWSTR value,
75 WCHAR guid_string[39];
76 DWORD cbdata = sizeof(guid_string);
82 ret = RegGetValueW(classkey, NULL, value, RRF_RT_REG_SZ|RRF_NOEXPAND, NULL,
83 guid_string, &cbdata);
85 if (ret != ERROR_SUCCESS)
86 return HRESULT_FROM_WIN32(ret);
88 if (cbdata < sizeof(guid_string))
90 ERR("incomplete GUID value\n");
94 hr = CLSIDFromString(guid_string, result);
100 IWICBitmapDecoderInfo IWICBitmapDecoderInfo_iface;
106 static inline BitmapDecoderInfo *impl_from_IWICBitmapDecoderInfo(IWICBitmapDecoderInfo *iface)
108 return CONTAINING_RECORD(iface, BitmapDecoderInfo, IWICBitmapDecoderInfo_iface);
111 static HRESULT WINAPI BitmapDecoderInfo_QueryInterface(IWICBitmapDecoderInfo *iface, REFIID iid,
114 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
115 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
117 if (!ppv) return E_INVALIDARG;
119 if (IsEqualIID(&IID_IUnknown, iid) ||
120 IsEqualIID(&IID_IWICComponentInfo, iid) ||
121 IsEqualIID(&IID_IWICBitmapCodecInfo, iid) ||
122 IsEqualIID(&IID_IWICBitmapDecoderInfo ,iid))
129 return E_NOINTERFACE;
132 IUnknown_AddRef((IUnknown*)*ppv);
136 static ULONG WINAPI BitmapDecoderInfo_AddRef(IWICBitmapDecoderInfo *iface)
138 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
139 ULONG ref = InterlockedIncrement(&This->ref);
141 TRACE("(%p) refcount=%u\n", iface, ref);
146 static ULONG WINAPI BitmapDecoderInfo_Release(IWICBitmapDecoderInfo *iface)
148 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
149 ULONG ref = InterlockedDecrement(&This->ref);
151 TRACE("(%p) refcount=%u\n", iface, ref);
155 RegCloseKey(This->classkey);
156 HeapFree(GetProcessHeap(), 0, This);
162 static HRESULT WINAPI BitmapDecoderInfo_GetComponentType(IWICBitmapDecoderInfo *iface,
163 WICComponentType *pType)
165 TRACE("(%p,%p)\n", iface, pType);
166 if (!pType) return E_INVALIDARG;
171 static HRESULT WINAPI BitmapDecoderInfo_GetCLSID(IWICBitmapDecoderInfo *iface, CLSID *pclsid)
173 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
174 TRACE("(%p,%p)\n", iface, pclsid);
179 memcpy(pclsid, &This->clsid, sizeof(CLSID));
184 static HRESULT WINAPI BitmapDecoderInfo_GetSigningStatus(IWICBitmapDecoderInfo *iface, DWORD *pStatus)
186 FIXME("(%p,%p): stub\n", iface, pStatus);
190 static HRESULT WINAPI BitmapDecoderInfo_GetAuthor(IWICBitmapDecoderInfo *iface, UINT cchAuthor,
191 WCHAR *wzAuthor, UINT *pcchActual)
193 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
195 TRACE("(%p,%u,%p,%p)\n", iface, cchAuthor, wzAuthor, pcchActual);
197 return ComponentInfo_GetStringValue(This->classkey, author_valuename,
198 cchAuthor, wzAuthor, pcchActual);
201 static HRESULT WINAPI BitmapDecoderInfo_GetVendorGUID(IWICBitmapDecoderInfo *iface, GUID *pguidVendor)
203 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
205 TRACE("(%p,%p)\n", iface, pguidVendor);
207 return ComponentInfo_GetGUIDValue(This->classkey, vendor_valuename, pguidVendor);
210 static HRESULT WINAPI BitmapDecoderInfo_GetVersion(IWICBitmapDecoderInfo *iface, UINT cchVersion,
211 WCHAR *wzVersion, UINT *pcchActual)
213 FIXME("(%p,%u,%p,%p): stub\n", iface, cchVersion, wzVersion, pcchActual);
217 static HRESULT WINAPI BitmapDecoderInfo_GetSpecVersion(IWICBitmapDecoderInfo *iface, UINT cchSpecVersion,
218 WCHAR *wzSpecVersion, UINT *pcchActual)
220 FIXME("(%p,%u,%p,%p): stub\n", iface, cchSpecVersion, wzSpecVersion, pcchActual);
224 static HRESULT WINAPI BitmapDecoderInfo_GetFriendlyName(IWICBitmapDecoderInfo *iface, UINT cchFriendlyName,
225 WCHAR *wzFriendlyName, UINT *pcchActual)
227 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
229 TRACE("(%p,%u,%p,%p)\n", iface, cchFriendlyName, wzFriendlyName, pcchActual);
231 return ComponentInfo_GetStringValue(This->classkey, friendlyname_valuename,
232 cchFriendlyName, wzFriendlyName, pcchActual);
235 static HRESULT WINAPI BitmapDecoderInfo_GetContainerFormat(IWICBitmapDecoderInfo *iface,
236 GUID *pguidContainerFormat)
238 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
239 TRACE("(%p,%p)\n", iface, pguidContainerFormat);
240 return ComponentInfo_GetGUIDValue(This->classkey, containerformat_valuename, pguidContainerFormat);
243 static HRESULT WINAPI BitmapDecoderInfo_GetPixelFormats(IWICBitmapDecoderInfo *iface,
244 UINT cFormats, GUID *pguidPixelFormats, UINT *pcActual)
246 FIXME("(%p,%u,%p,%p): stub\n", iface, cFormats, pguidPixelFormats, pcActual);
250 static HRESULT WINAPI BitmapDecoderInfo_GetColorManagementVersion(IWICBitmapDecoderInfo *iface,
251 UINT cchColorManagementVersion, WCHAR *wzColorManagementVersion, UINT *pcchActual)
253 FIXME("(%p,%u,%p,%p): stub\n", iface, cchColorManagementVersion, wzColorManagementVersion, pcchActual);
257 static HRESULT WINAPI BitmapDecoderInfo_GetDeviceManufacturer(IWICBitmapDecoderInfo *iface,
258 UINT cchDeviceManufacturer, WCHAR *wzDeviceManufacturer, UINT *pcchActual)
260 FIXME("(%p,%u,%p,%p): stub\n", iface, cchDeviceManufacturer, wzDeviceManufacturer, pcchActual);
264 static HRESULT WINAPI BitmapDecoderInfo_GetDeviceModels(IWICBitmapDecoderInfo *iface,
265 UINT cchDeviceModels, WCHAR *wzDeviceModels, UINT *pcchActual)
267 FIXME("(%p,%u,%p,%p): stub\n", iface, cchDeviceModels, wzDeviceModels, pcchActual);
271 static HRESULT WINAPI BitmapDecoderInfo_GetMimeTypes(IWICBitmapDecoderInfo *iface,
272 UINT cchMimeTypes, WCHAR *wzMimeTypes, UINT *pcchActual)
274 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
276 TRACE("(%p,%u,%p,%p)\n", iface, cchMimeTypes, wzMimeTypes, pcchActual);
278 return ComponentInfo_GetStringValue(This->classkey, mimetypes_valuename,
279 cchMimeTypes, wzMimeTypes, pcchActual);
282 static HRESULT WINAPI BitmapDecoderInfo_GetFileExtensions(IWICBitmapDecoderInfo *iface,
283 UINT cchFileExtensions, WCHAR *wzFileExtensions, UINT *pcchActual)
285 FIXME("(%p,%u,%p,%p): stub\n", iface, cchFileExtensions, wzFileExtensions, pcchActual);
289 static HRESULT WINAPI BitmapDecoderInfo_DoesSupportAnimation(IWICBitmapDecoderInfo *iface,
290 BOOL *pfSupportAnimation)
292 FIXME("(%p,%p): stub\n", iface, pfSupportAnimation);
296 static HRESULT WINAPI BitmapDecoderInfo_DoesSupportChromaKey(IWICBitmapDecoderInfo *iface,
297 BOOL *pfSupportChromaKey)
299 FIXME("(%p,%p): stub\n", iface, pfSupportChromaKey);
303 static HRESULT WINAPI BitmapDecoderInfo_DoesSupportLossless(IWICBitmapDecoderInfo *iface,
304 BOOL *pfSupportLossless)
306 FIXME("(%p,%p): stub\n", iface, pfSupportLossless);
310 static HRESULT WINAPI BitmapDecoderInfo_DoesSupportMultiframe(IWICBitmapDecoderInfo *iface,
311 BOOL *pfSupportMultiframe)
313 FIXME("(%p,%p): stub\n", iface, pfSupportMultiframe);
317 static HRESULT WINAPI BitmapDecoderInfo_MatchesMimeType(IWICBitmapDecoderInfo *iface,
318 LPCWSTR wzMimeType, BOOL *pfMatches)
320 FIXME("(%p,%s,%p): stub\n", iface, debugstr_w(wzMimeType), pfMatches);
324 static HRESULT WINAPI BitmapDecoderInfo_GetPatterns(IWICBitmapDecoderInfo *iface,
325 UINT cbSizePatterns, WICBitmapPattern *pPatterns, UINT *pcPatterns, UINT *pcbPatternsActual)
327 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
328 UINT pattern_count=0, patterns_size=0;
329 WCHAR subkeyname[11];
331 HKEY patternskey, patternkey;
332 static const WCHAR uintformatW[] = {'%','u',0};
333 static const WCHAR patternsW[] = {'P','a','t','t','e','r','n','s',0};
334 static const WCHAR positionW[] = {'P','o','s','i','t','i','o','n',0};
335 static const WCHAR lengthW[] = {'L','e','n','g','t','h',0};
336 static const WCHAR patternW[] = {'P','a','t','t','e','r','n',0};
337 static const WCHAR maskW[] = {'M','a','s','k',0};
338 static const WCHAR endofstreamW[] = {'E','n','d','O','f','S','t','r','e','a','m',0};
341 BYTE *bPatterns=(BYTE*)pPatterns;
342 DWORD length, valuesize;
344 TRACE("(%p,%i,%p,%p,%p)\n", iface, cbSizePatterns, pPatterns, pcPatterns, pcbPatternsActual);
346 res = RegOpenKeyExW(This->classkey, patternsW, 0, KEY_READ, &patternskey);
347 if (res != ERROR_SUCCESS) return HRESULT_FROM_WIN32(res);
349 res = RegQueryInfoKeyW(patternskey, NULL, NULL, NULL, &pattern_count, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
350 if (res == ERROR_SUCCESS)
352 patterns_size = pattern_count * sizeof(WICBitmapPattern);
354 for (i=0; i<pattern_count; i++)
356 snprintfW(subkeyname, 11, uintformatW, i);
357 res = RegOpenKeyExW(patternskey, subkeyname, 0, KEY_READ, &patternkey);
358 if (res == ERROR_SUCCESS)
360 valuesize = sizeof(ULONG);
361 res = RegGetValueW(patternkey, NULL, lengthW, RRF_RT_DWORD, NULL,
362 &length, &valuesize);
363 patterns_size += length*2;
365 if ((cbSizePatterns >= patterns_size) && (res == ERROR_SUCCESS))
367 pPatterns[i].Length = length;
369 pPatterns[i].EndOfStream = 0;
370 valuesize = sizeof(BOOL);
371 RegGetValueW(patternkey, NULL, endofstreamW, RRF_RT_DWORD, NULL,
372 &pPatterns[i].EndOfStream, &valuesize);
374 pPatterns[i].Position.QuadPart = 0;
375 valuesize = sizeof(ULARGE_INTEGER);
376 res = RegGetValueW(patternkey, NULL, positionW, RRF_RT_DWORD|RRF_RT_QWORD, NULL,
377 &pPatterns[i].Position, &valuesize);
379 if (res == ERROR_SUCCESS)
381 pPatterns[i].Pattern = bPatterns+patterns_size-length*2;
383 res = RegGetValueW(patternkey, NULL, patternW, RRF_RT_REG_BINARY, NULL,
384 pPatterns[i].Pattern, &valuesize);
387 if (res == ERROR_SUCCESS)
389 pPatterns[i].Mask = bPatterns+patterns_size-length;
391 res = RegGetValueW(patternkey, NULL, maskW, RRF_RT_REG_BINARY, NULL,
392 pPatterns[i].Mask, &valuesize);
396 RegCloseKey(patternkey);
398 if (res != ERROR_SUCCESS)
400 hr = HRESULT_FROM_WIN32(res);
405 else hr = HRESULT_FROM_WIN32(res);
407 RegCloseKey(patternskey);
411 *pcPatterns = pattern_count;
412 *pcbPatternsActual = patterns_size;
413 if (pPatterns && cbSizePatterns < patterns_size)
414 hr = WINCODEC_ERR_INSUFFICIENTBUFFER;
420 static HRESULT WINAPI BitmapDecoderInfo_MatchesPattern(IWICBitmapDecoderInfo *iface,
421 IStream *pIStream, BOOL *pfMatches)
423 WICBitmapPattern *patterns;
424 UINT pattern_count=0, patterns_size=0;
430 LARGE_INTEGER seekpos;
432 TRACE("(%p,%p,%p)\n", iface, pIStream, pfMatches);
434 hr = BitmapDecoderInfo_GetPatterns(iface, 0, NULL, &pattern_count, &patterns_size);
435 if (FAILED(hr)) return hr;
437 patterns = HeapAlloc(GetProcessHeap(), 0, patterns_size);
438 if (!patterns) return E_OUTOFMEMORY;
440 hr = BitmapDecoderInfo_GetPatterns(iface, patterns_size, patterns, &pattern_count, &patterns_size);
441 if (FAILED(hr)) goto end;
443 for (i=0; i<pattern_count; i++)
445 if (datasize < patterns[i].Length)
447 HeapFree(GetProcessHeap(), 0, data);
448 datasize = patterns[i].Length;
449 data = HeapAlloc(GetProcessHeap(), 0, patterns[i].Length);
457 if (patterns[i].EndOfStream)
458 seekpos.QuadPart = -patterns[i].Position.QuadPart;
460 seekpos.QuadPart = patterns[i].Position.QuadPart;
461 hr = IStream_Seek(pIStream, seekpos, patterns[i].EndOfStream ? STREAM_SEEK_END : STREAM_SEEK_SET, NULL);
462 if (hr == STG_E_INVALIDFUNCTION) continue; /* before start of stream */
463 if (FAILED(hr)) break;
465 hr = IStream_Read(pIStream, data, patterns[i].Length, &bytesread);
466 if (hr == S_FALSE || (hr == S_OK && bytesread != patterns[i].Length)) /* past end of stream */
468 if (FAILED(hr)) break;
470 for (pos=0; pos<patterns[i].Length; pos++)
472 if ((data[pos] & patterns[i].Mask[pos]) != patterns[i].Pattern[pos])
475 if (pos == patterns[i].Length) /* matches pattern */
483 if (i == pattern_count) /* does not match any pattern */
490 HeapFree(GetProcessHeap(), 0, patterns);
491 HeapFree(GetProcessHeap(), 0, data);
496 static HRESULT WINAPI BitmapDecoderInfo_CreateInstance(IWICBitmapDecoderInfo *iface,
497 IWICBitmapDecoder **ppIBitmapDecoder)
499 BitmapDecoderInfo *This = impl_from_IWICBitmapDecoderInfo(iface);
501 TRACE("(%p,%p)\n", iface, ppIBitmapDecoder);
503 return CoCreateInstance(&This->clsid, NULL, CLSCTX_INPROC_SERVER,
504 &IID_IWICBitmapDecoder, (void**)ppIBitmapDecoder);
507 static const IWICBitmapDecoderInfoVtbl BitmapDecoderInfo_Vtbl = {
508 BitmapDecoderInfo_QueryInterface,
509 BitmapDecoderInfo_AddRef,
510 BitmapDecoderInfo_Release,
511 BitmapDecoderInfo_GetComponentType,
512 BitmapDecoderInfo_GetCLSID,
513 BitmapDecoderInfo_GetSigningStatus,
514 BitmapDecoderInfo_GetAuthor,
515 BitmapDecoderInfo_GetVendorGUID,
516 BitmapDecoderInfo_GetVersion,
517 BitmapDecoderInfo_GetSpecVersion,
518 BitmapDecoderInfo_GetFriendlyName,
519 BitmapDecoderInfo_GetContainerFormat,
520 BitmapDecoderInfo_GetPixelFormats,
521 BitmapDecoderInfo_GetColorManagementVersion,
522 BitmapDecoderInfo_GetDeviceManufacturer,
523 BitmapDecoderInfo_GetDeviceModels,
524 BitmapDecoderInfo_GetMimeTypes,
525 BitmapDecoderInfo_GetFileExtensions,
526 BitmapDecoderInfo_DoesSupportAnimation,
527 BitmapDecoderInfo_DoesSupportChromaKey,
528 BitmapDecoderInfo_DoesSupportLossless,
529 BitmapDecoderInfo_DoesSupportMultiframe,
530 BitmapDecoderInfo_MatchesMimeType,
531 BitmapDecoderInfo_GetPatterns,
532 BitmapDecoderInfo_MatchesPattern,
533 BitmapDecoderInfo_CreateInstance
536 static HRESULT BitmapDecoderInfo_Constructor(HKEY classkey, REFCLSID clsid, IWICComponentInfo **ppIInfo)
538 BitmapDecoderInfo *This;
540 This = HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapDecoderInfo));
543 RegCloseKey(classkey);
544 return E_OUTOFMEMORY;
547 This->IWICBitmapDecoderInfo_iface.lpVtbl = &BitmapDecoderInfo_Vtbl;
549 This->classkey = classkey;
550 memcpy(&This->clsid, clsid, sizeof(CLSID));
552 *ppIInfo = (IWICComponentInfo*)This;
557 IWICBitmapEncoderInfo IWICBitmapEncoderInfo_iface;
563 static inline BitmapEncoderInfo *impl_from_IWICBitmapEncoderInfo(IWICBitmapEncoderInfo *iface)
565 return CONTAINING_RECORD(iface, BitmapEncoderInfo, IWICBitmapEncoderInfo_iface);
568 static HRESULT WINAPI BitmapEncoderInfo_QueryInterface(IWICBitmapEncoderInfo *iface, REFIID iid,
571 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
572 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
574 if (!ppv) return E_INVALIDARG;
576 if (IsEqualIID(&IID_IUnknown, iid) ||
577 IsEqualIID(&IID_IWICComponentInfo, iid) ||
578 IsEqualIID(&IID_IWICBitmapCodecInfo, iid) ||
579 IsEqualIID(&IID_IWICBitmapEncoderInfo ,iid))
586 return E_NOINTERFACE;
589 IUnknown_AddRef((IUnknown*)*ppv);
593 static ULONG WINAPI BitmapEncoderInfo_AddRef(IWICBitmapEncoderInfo *iface)
595 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
596 ULONG ref = InterlockedIncrement(&This->ref);
598 TRACE("(%p) refcount=%u\n", iface, ref);
603 static ULONG WINAPI BitmapEncoderInfo_Release(IWICBitmapEncoderInfo *iface)
605 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
606 ULONG ref = InterlockedDecrement(&This->ref);
608 TRACE("(%p) refcount=%u\n", iface, ref);
612 RegCloseKey(This->classkey);
613 HeapFree(GetProcessHeap(), 0, This);
619 static HRESULT WINAPI BitmapEncoderInfo_GetComponentType(IWICBitmapEncoderInfo *iface,
620 WICComponentType *pType)
622 TRACE("(%p,%p)\n", iface, pType);
623 if (!pType) return E_INVALIDARG;
628 static HRESULT WINAPI BitmapEncoderInfo_GetCLSID(IWICBitmapEncoderInfo *iface, CLSID *pclsid)
630 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
631 TRACE("(%p,%p)\n", iface, pclsid);
636 memcpy(pclsid, &This->clsid, sizeof(CLSID));
641 static HRESULT WINAPI BitmapEncoderInfo_GetSigningStatus(IWICBitmapEncoderInfo *iface, DWORD *pStatus)
643 FIXME("(%p,%p): stub\n", iface, pStatus);
647 static HRESULT WINAPI BitmapEncoderInfo_GetAuthor(IWICBitmapEncoderInfo *iface, UINT cchAuthor,
648 WCHAR *wzAuthor, UINT *pcchActual)
650 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
652 TRACE("(%p,%u,%p,%p)\n", iface, cchAuthor, wzAuthor, pcchActual);
654 return ComponentInfo_GetStringValue(This->classkey, author_valuename,
655 cchAuthor, wzAuthor, pcchActual);
658 static HRESULT WINAPI BitmapEncoderInfo_GetVendorGUID(IWICBitmapEncoderInfo *iface, GUID *pguidVendor)
660 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
662 TRACE("(%p,%p)\n", iface, pguidVendor);
664 return ComponentInfo_GetGUIDValue(This->classkey, vendor_valuename, pguidVendor);
667 static HRESULT WINAPI BitmapEncoderInfo_GetVersion(IWICBitmapEncoderInfo *iface, UINT cchVersion,
668 WCHAR *wzVersion, UINT *pcchActual)
670 FIXME("(%p,%u,%p,%p): stub\n", iface, cchVersion, wzVersion, pcchActual);
674 static HRESULT WINAPI BitmapEncoderInfo_GetSpecVersion(IWICBitmapEncoderInfo *iface, UINT cchSpecVersion,
675 WCHAR *wzSpecVersion, UINT *pcchActual)
677 FIXME("(%p,%u,%p,%p): stub\n", iface, cchSpecVersion, wzSpecVersion, pcchActual);
681 static HRESULT WINAPI BitmapEncoderInfo_GetFriendlyName(IWICBitmapEncoderInfo *iface, UINT cchFriendlyName,
682 WCHAR *wzFriendlyName, UINT *pcchActual)
684 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
686 TRACE("(%p,%u,%p,%p)\n", iface, cchFriendlyName, wzFriendlyName, pcchActual);
688 return ComponentInfo_GetStringValue(This->classkey, friendlyname_valuename,
689 cchFriendlyName, wzFriendlyName, pcchActual);
692 static HRESULT WINAPI BitmapEncoderInfo_GetContainerFormat(IWICBitmapEncoderInfo *iface,
693 GUID *pguidContainerFormat)
695 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
696 TRACE("(%p,%p)\n", iface, pguidContainerFormat);
697 return ComponentInfo_GetGUIDValue(This->classkey, containerformat_valuename, pguidContainerFormat);
700 static HRESULT WINAPI BitmapEncoderInfo_GetPixelFormats(IWICBitmapEncoderInfo *iface,
701 UINT cFormats, GUID *pguidPixelFormats, UINT *pcActual)
703 FIXME("(%p,%u,%p,%p): stub\n", iface, cFormats, pguidPixelFormats, pcActual);
707 static HRESULT WINAPI BitmapEncoderInfo_GetColorManagementVersion(IWICBitmapEncoderInfo *iface,
708 UINT cchColorManagementVersion, WCHAR *wzColorManagementVersion, UINT *pcchActual)
710 FIXME("(%p,%u,%p,%p): stub\n", iface, cchColorManagementVersion, wzColorManagementVersion, pcchActual);
714 static HRESULT WINAPI BitmapEncoderInfo_GetDeviceManufacturer(IWICBitmapEncoderInfo *iface,
715 UINT cchDeviceManufacturer, WCHAR *wzDeviceManufacturer, UINT *pcchActual)
717 FIXME("(%p,%u,%p,%p): stub\n", iface, cchDeviceManufacturer, wzDeviceManufacturer, pcchActual);
721 static HRESULT WINAPI BitmapEncoderInfo_GetDeviceModels(IWICBitmapEncoderInfo *iface,
722 UINT cchDeviceModels, WCHAR *wzDeviceModels, UINT *pcchActual)
724 FIXME("(%p,%u,%p,%p): stub\n", iface, cchDeviceModels, wzDeviceModels, pcchActual);
728 static HRESULT WINAPI BitmapEncoderInfo_GetMimeTypes(IWICBitmapEncoderInfo *iface,
729 UINT cchMimeTypes, WCHAR *wzMimeTypes, UINT *pcchActual)
731 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
733 TRACE("(%p,%u,%p,%p)\n", iface, cchMimeTypes, wzMimeTypes, pcchActual);
735 return ComponentInfo_GetStringValue(This->classkey, mimetypes_valuename,
736 cchMimeTypes, wzMimeTypes, pcchActual);
739 static HRESULT WINAPI BitmapEncoderInfo_GetFileExtensions(IWICBitmapEncoderInfo *iface,
740 UINT cchFileExtensions, WCHAR *wzFileExtensions, UINT *pcchActual)
742 FIXME("(%p,%u,%p,%p): stub\n", iface, cchFileExtensions, wzFileExtensions, pcchActual);
746 static HRESULT WINAPI BitmapEncoderInfo_DoesSupportAnimation(IWICBitmapEncoderInfo *iface,
747 BOOL *pfSupportAnimation)
749 FIXME("(%p,%p): stub\n", iface, pfSupportAnimation);
753 static HRESULT WINAPI BitmapEncoderInfo_DoesSupportChromaKey(IWICBitmapEncoderInfo *iface,
754 BOOL *pfSupportChromaKey)
756 FIXME("(%p,%p): stub\n", iface, pfSupportChromaKey);
760 static HRESULT WINAPI BitmapEncoderInfo_DoesSupportLossless(IWICBitmapEncoderInfo *iface,
761 BOOL *pfSupportLossless)
763 FIXME("(%p,%p): stub\n", iface, pfSupportLossless);
767 static HRESULT WINAPI BitmapEncoderInfo_DoesSupportMultiframe(IWICBitmapEncoderInfo *iface,
768 BOOL *pfSupportMultiframe)
770 FIXME("(%p,%p): stub\n", iface, pfSupportMultiframe);
774 static HRESULT WINAPI BitmapEncoderInfo_MatchesMimeType(IWICBitmapEncoderInfo *iface,
775 LPCWSTR wzMimeType, BOOL *pfMatches)
777 FIXME("(%p,%s,%p): stub\n", iface, debugstr_w(wzMimeType), pfMatches);
781 static HRESULT WINAPI BitmapEncoderInfo_CreateInstance(IWICBitmapEncoderInfo *iface,
782 IWICBitmapEncoder **ppIBitmapEncoder)
784 BitmapEncoderInfo *This = impl_from_IWICBitmapEncoderInfo(iface);
786 TRACE("(%p,%p)\n", iface, ppIBitmapEncoder);
788 return CoCreateInstance(&This->clsid, NULL, CLSCTX_INPROC_SERVER,
789 &IID_IWICBitmapEncoder, (void**)ppIBitmapEncoder);
792 static const IWICBitmapEncoderInfoVtbl BitmapEncoderInfo_Vtbl = {
793 BitmapEncoderInfo_QueryInterface,
794 BitmapEncoderInfo_AddRef,
795 BitmapEncoderInfo_Release,
796 BitmapEncoderInfo_GetComponentType,
797 BitmapEncoderInfo_GetCLSID,
798 BitmapEncoderInfo_GetSigningStatus,
799 BitmapEncoderInfo_GetAuthor,
800 BitmapEncoderInfo_GetVendorGUID,
801 BitmapEncoderInfo_GetVersion,
802 BitmapEncoderInfo_GetSpecVersion,
803 BitmapEncoderInfo_GetFriendlyName,
804 BitmapEncoderInfo_GetContainerFormat,
805 BitmapEncoderInfo_GetPixelFormats,
806 BitmapEncoderInfo_GetColorManagementVersion,
807 BitmapEncoderInfo_GetDeviceManufacturer,
808 BitmapEncoderInfo_GetDeviceModels,
809 BitmapEncoderInfo_GetMimeTypes,
810 BitmapEncoderInfo_GetFileExtensions,
811 BitmapEncoderInfo_DoesSupportAnimation,
812 BitmapEncoderInfo_DoesSupportChromaKey,
813 BitmapEncoderInfo_DoesSupportLossless,
814 BitmapEncoderInfo_DoesSupportMultiframe,
815 BitmapEncoderInfo_MatchesMimeType,
816 BitmapEncoderInfo_CreateInstance
819 static HRESULT BitmapEncoderInfo_Constructor(HKEY classkey, REFCLSID clsid, IWICComponentInfo **ppIInfo)
821 BitmapEncoderInfo *This;
823 This = HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapEncoderInfo));
826 RegCloseKey(classkey);
827 return E_OUTOFMEMORY;
830 This->IWICBitmapEncoderInfo_iface.lpVtbl = &BitmapEncoderInfo_Vtbl;
832 This->classkey = classkey;
833 memcpy(&This->clsid, clsid, sizeof(CLSID));
835 *ppIInfo = (IWICComponentInfo*)This;
840 IWICFormatConverterInfo IWICFormatConverterInfo_iface;
844 } FormatConverterInfo;
846 static inline FormatConverterInfo *impl_from_IWICFormatConverterInfo(IWICFormatConverterInfo *iface)
848 return CONTAINING_RECORD(iface, FormatConverterInfo, IWICFormatConverterInfo_iface);
851 static HRESULT WINAPI FormatConverterInfo_QueryInterface(IWICFormatConverterInfo *iface, REFIID iid,
854 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
855 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
857 if (!ppv) return E_INVALIDARG;
859 if (IsEqualIID(&IID_IUnknown, iid) ||
860 IsEqualIID(&IID_IWICComponentInfo, iid) ||
861 IsEqualIID(&IID_IWICFormatConverterInfo ,iid))
868 return E_NOINTERFACE;
871 IUnknown_AddRef((IUnknown*)*ppv);
875 static ULONG WINAPI FormatConverterInfo_AddRef(IWICFormatConverterInfo *iface)
877 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
878 ULONG ref = InterlockedIncrement(&This->ref);
880 TRACE("(%p) refcount=%u\n", iface, ref);
885 static ULONG WINAPI FormatConverterInfo_Release(IWICFormatConverterInfo *iface)
887 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
888 ULONG ref = InterlockedDecrement(&This->ref);
890 TRACE("(%p) refcount=%u\n", iface, ref);
894 RegCloseKey(This->classkey);
895 HeapFree(GetProcessHeap(), 0, This);
901 static HRESULT WINAPI FormatConverterInfo_GetComponentType(IWICFormatConverterInfo *iface,
902 WICComponentType *pType)
904 TRACE("(%p,%p)\n", iface, pType);
905 if (!pType) return E_INVALIDARG;
906 *pType = WICPixelFormatConverter;
910 static HRESULT WINAPI FormatConverterInfo_GetCLSID(IWICFormatConverterInfo *iface, CLSID *pclsid)
912 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
913 TRACE("(%p,%p)\n", iface, pclsid);
918 memcpy(pclsid, &This->clsid, sizeof(CLSID));
923 static HRESULT WINAPI FormatConverterInfo_GetSigningStatus(IWICFormatConverterInfo *iface, DWORD *pStatus)
925 FIXME("(%p,%p): stub\n", iface, pStatus);
929 static HRESULT WINAPI FormatConverterInfo_GetAuthor(IWICFormatConverterInfo *iface, UINT cchAuthor,
930 WCHAR *wzAuthor, UINT *pcchActual)
932 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
934 TRACE("(%p,%u,%p,%p)\n", iface, cchAuthor, wzAuthor, pcchActual);
936 return ComponentInfo_GetStringValue(This->classkey, author_valuename,
937 cchAuthor, wzAuthor, pcchActual);
940 static HRESULT WINAPI FormatConverterInfo_GetVendorGUID(IWICFormatConverterInfo *iface, GUID *pguidVendor)
942 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
944 TRACE("(%p,%p)\n", iface, pguidVendor);
946 return ComponentInfo_GetGUIDValue(This->classkey, vendor_valuename, pguidVendor);
949 static HRESULT WINAPI FormatConverterInfo_GetVersion(IWICFormatConverterInfo *iface, UINT cchVersion,
950 WCHAR *wzVersion, UINT *pcchActual)
952 FIXME("(%p,%u,%p,%p): stub\n", iface, cchVersion, wzVersion, pcchActual);
956 static HRESULT WINAPI FormatConverterInfo_GetSpecVersion(IWICFormatConverterInfo *iface, UINT cchSpecVersion,
957 WCHAR *wzSpecVersion, UINT *pcchActual)
959 FIXME("(%p,%u,%p,%p): stub\n", iface, cchSpecVersion, wzSpecVersion, pcchActual);
963 static HRESULT WINAPI FormatConverterInfo_GetFriendlyName(IWICFormatConverterInfo *iface, UINT cchFriendlyName,
964 WCHAR *wzFriendlyName, UINT *pcchActual)
966 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
968 TRACE("(%p,%u,%p,%p)\n", iface, cchFriendlyName, wzFriendlyName, pcchActual);
970 return ComponentInfo_GetStringValue(This->classkey, friendlyname_valuename,
971 cchFriendlyName, wzFriendlyName, pcchActual);
974 static HRESULT WINAPI FormatConverterInfo_GetPixelFormats(IWICFormatConverterInfo *iface,
975 UINT cFormats, GUID *pguidPixelFormats, UINT *pcActual)
977 FIXME("(%p,%u,%p,%p): stub\n", iface, cFormats, pguidPixelFormats, pcActual);
981 static HRESULT WINAPI FormatConverterInfo_CreateInstance(IWICFormatConverterInfo *iface,
982 IWICFormatConverter **ppIFormatConverter)
984 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
986 TRACE("(%p,%p)\n", iface, ppIFormatConverter);
988 return CoCreateInstance(&This->clsid, NULL, CLSCTX_INPROC_SERVER,
989 &IID_IWICFormatConverter, (void**)ppIFormatConverter);
992 static BOOL ConverterSupportsFormat(IWICFormatConverterInfo *iface, const WCHAR *formatguid)
995 FormatConverterInfo *This = impl_from_IWICFormatConverterInfo(iface);
996 HKEY formats_key, guid_key;
998 /* Avoid testing using IWICFormatConverter_GetPixelFormats because that
999 would be O(n). A registry test should do better. */
1001 res = RegOpenKeyExW(This->classkey, pixelformats_keyname, 0, KEY_READ, &formats_key);
1002 if (res != ERROR_SUCCESS) return FALSE;
1004 res = RegOpenKeyExW(formats_key, formatguid, 0, KEY_READ, &guid_key);
1005 if (res == ERROR_SUCCESS) RegCloseKey(guid_key);
1007 RegCloseKey(formats_key);
1009 return (res == ERROR_SUCCESS);
1012 static const IWICFormatConverterInfoVtbl FormatConverterInfo_Vtbl = {
1013 FormatConverterInfo_QueryInterface,
1014 FormatConverterInfo_AddRef,
1015 FormatConverterInfo_Release,
1016 FormatConverterInfo_GetComponentType,
1017 FormatConverterInfo_GetCLSID,
1018 FormatConverterInfo_GetSigningStatus,
1019 FormatConverterInfo_GetAuthor,
1020 FormatConverterInfo_GetVendorGUID,
1021 FormatConverterInfo_GetVersion,
1022 FormatConverterInfo_GetSpecVersion,
1023 FormatConverterInfo_GetFriendlyName,
1024 FormatConverterInfo_GetPixelFormats,
1025 FormatConverterInfo_CreateInstance
1028 static HRESULT FormatConverterInfo_Constructor(HKEY classkey, REFCLSID clsid, IWICComponentInfo **ppIInfo)
1030 FormatConverterInfo *This;
1032 This = HeapAlloc(GetProcessHeap(), 0, sizeof(FormatConverterInfo));
1035 RegCloseKey(classkey);
1036 return E_OUTOFMEMORY;
1039 This->IWICFormatConverterInfo_iface.lpVtbl = &FormatConverterInfo_Vtbl;
1041 This->classkey = classkey;
1042 memcpy(&This->clsid, clsid, sizeof(CLSID));
1044 *ppIInfo = (IWICComponentInfo*)This;
1049 IWICPixelFormatInfo2 IWICPixelFormatInfo2_iface;
1055 static inline PixelFormatInfo *impl_from_IWICPixelFormatInfo2(IWICPixelFormatInfo2 *iface)
1057 return CONTAINING_RECORD(iface, PixelFormatInfo, IWICPixelFormatInfo2_iface);
1060 static HRESULT WINAPI PixelFormatInfo_QueryInterface(IWICPixelFormatInfo2 *iface, REFIID iid,
1063 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1064 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
1066 if (!ppv) return E_INVALIDARG;
1068 if (IsEqualIID(&IID_IUnknown, iid) ||
1069 IsEqualIID(&IID_IWICComponentInfo, iid) ||
1070 IsEqualIID(&IID_IWICPixelFormatInfo, iid) ||
1071 IsEqualIID(&IID_IWICPixelFormatInfo2 ,iid))
1078 return E_NOINTERFACE;
1081 IUnknown_AddRef((IUnknown*)*ppv);
1085 static ULONG WINAPI PixelFormatInfo_AddRef(IWICPixelFormatInfo2 *iface)
1087 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1088 ULONG ref = InterlockedIncrement(&This->ref);
1090 TRACE("(%p) refcount=%u\n", iface, ref);
1095 static ULONG WINAPI PixelFormatInfo_Release(IWICPixelFormatInfo2 *iface)
1097 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1098 ULONG ref = InterlockedDecrement(&This->ref);
1100 TRACE("(%p) refcount=%u\n", iface, ref);
1104 RegCloseKey(This->classkey);
1105 HeapFree(GetProcessHeap(), 0, This);
1111 static HRESULT WINAPI PixelFormatInfo_GetComponentType(IWICPixelFormatInfo2 *iface,
1112 WICComponentType *pType)
1114 TRACE("(%p,%p)\n", iface, pType);
1115 if (!pType) return E_INVALIDARG;
1116 *pType = WICPixelFormat;
1120 static HRESULT WINAPI PixelFormatInfo_GetCLSID(IWICPixelFormatInfo2 *iface, CLSID *pclsid)
1122 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1123 TRACE("(%p,%p)\n", iface, pclsid);
1126 return E_INVALIDARG;
1128 memcpy(pclsid, &This->clsid, sizeof(CLSID));
1133 static HRESULT WINAPI PixelFormatInfo_GetSigningStatus(IWICPixelFormatInfo2 *iface, DWORD *pStatus)
1135 TRACE("(%p,%p)\n", iface, pStatus);
1138 return E_INVALIDARG;
1140 /* Pixel formats don't require code, so they are considered signed. */
1141 *pStatus = WICComponentSigned;
1146 static HRESULT WINAPI PixelFormatInfo_GetAuthor(IWICPixelFormatInfo2 *iface, UINT cchAuthor,
1147 WCHAR *wzAuthor, UINT *pcchActual)
1149 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1151 TRACE("(%p,%u,%p,%p)\n", iface, cchAuthor, wzAuthor, pcchActual);
1153 return ComponentInfo_GetStringValue(This->classkey, author_valuename,
1154 cchAuthor, wzAuthor, pcchActual);
1157 static HRESULT WINAPI PixelFormatInfo_GetVendorGUID(IWICPixelFormatInfo2 *iface, GUID *pguidVendor)
1159 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1161 TRACE("(%p,%p)\n", iface, pguidVendor);
1163 return ComponentInfo_GetGUIDValue(This->classkey, vendor_valuename, pguidVendor);
1166 static HRESULT WINAPI PixelFormatInfo_GetVersion(IWICPixelFormatInfo2 *iface, UINT cchVersion,
1167 WCHAR *wzVersion, UINT *pcchActual)
1169 FIXME("(%p,%u,%p,%p): stub\n", iface, cchVersion, wzVersion, pcchActual);
1173 static HRESULT WINAPI PixelFormatInfo_GetSpecVersion(IWICPixelFormatInfo2 *iface, UINT cchSpecVersion,
1174 WCHAR *wzSpecVersion, UINT *pcchActual)
1176 FIXME("(%p,%u,%p,%p): stub\n", iface, cchSpecVersion, wzSpecVersion, pcchActual);
1180 static HRESULT WINAPI PixelFormatInfo_GetFriendlyName(IWICPixelFormatInfo2 *iface, UINT cchFriendlyName,
1181 WCHAR *wzFriendlyName, UINT *pcchActual)
1183 PixelFormatInfo *This = impl_from_IWICPixelFormatInfo2(iface);
1185 TRACE("(%p,%u,%p,%p)\n", iface, cchFriendlyName, wzFriendlyName, pcchActual);
1187 return ComponentInfo_GetStringValue(This->classkey, friendlyname_valuename,
1188 cchFriendlyName, wzFriendlyName, pcchActual);
1191 static HRESULT WINAPI PixelFormatInfo_GetFormatGUID(IWICPixelFormatInfo2 *iface,
1194 FIXME("(%p,%p): stub\n", iface, pFormat);
1198 static HRESULT WINAPI PixelFormatInfo_GetColorContext(IWICPixelFormatInfo2 *iface,
1199 IWICColorContext **ppIColorContext)
1201 FIXME("(%p,%p): stub\n", iface, ppIColorContext);
1205 static HRESULT WINAPI PixelFormatInfo_GetBitsPerPixel(IWICPixelFormatInfo2 *iface,
1206 UINT *puiBitsPerPixel)
1208 FIXME("(%p,%p): stub\n", iface, puiBitsPerPixel);
1212 static HRESULT WINAPI PixelFormatInfo_GetChannelCount(IWICPixelFormatInfo2 *iface,
1213 UINT *puiChannelCount)
1215 FIXME("(%p,%p): stub\n", iface, puiChannelCount);
1219 static HRESULT WINAPI PixelFormatInfo_GetChannelMask(IWICPixelFormatInfo2 *iface,
1220 UINT uiChannelIndex, UINT cbMaskBuffer, BYTE *pbMaskBuffer, UINT *pcbActual)
1222 FIXME("(%p,%u,%u,%p,%p): stub\n", iface, uiChannelIndex, cbMaskBuffer, pbMaskBuffer, pcbActual);
1226 static HRESULT WINAPI PixelFormatInfo_SupportsTransparency(IWICPixelFormatInfo2 *iface,
1227 BOOL *pfSupportsTransparency)
1229 FIXME("(%p,%p): stub\n", iface, pfSupportsTransparency);
1233 static HRESULT WINAPI PixelFormatInfo_GetNumericRepresentation(IWICPixelFormatInfo2 *iface,
1234 WICPixelFormatNumericRepresentation *pNumericRepresentation)
1236 FIXME("(%p,%p): stub\n", iface, pNumericRepresentation);
1240 static const IWICPixelFormatInfo2Vtbl PixelFormatInfo_Vtbl = {
1241 PixelFormatInfo_QueryInterface,
1242 PixelFormatInfo_AddRef,
1243 PixelFormatInfo_Release,
1244 PixelFormatInfo_GetComponentType,
1245 PixelFormatInfo_GetCLSID,
1246 PixelFormatInfo_GetSigningStatus,
1247 PixelFormatInfo_GetAuthor,
1248 PixelFormatInfo_GetVendorGUID,
1249 PixelFormatInfo_GetVersion,
1250 PixelFormatInfo_GetSpecVersion,
1251 PixelFormatInfo_GetFriendlyName,
1252 PixelFormatInfo_GetFormatGUID,
1253 PixelFormatInfo_GetColorContext,
1254 PixelFormatInfo_GetBitsPerPixel,
1255 PixelFormatInfo_GetChannelCount,
1256 PixelFormatInfo_GetChannelMask,
1257 PixelFormatInfo_SupportsTransparency,
1258 PixelFormatInfo_GetNumericRepresentation
1261 static HRESULT PixelFormatInfo_Constructor(HKEY classkey, REFCLSID clsid, IWICComponentInfo **ppIInfo)
1263 PixelFormatInfo *This;
1265 This = HeapAlloc(GetProcessHeap(), 0, sizeof(PixelFormatInfo));
1268 RegCloseKey(classkey);
1269 return E_OUTOFMEMORY;
1272 This->IWICPixelFormatInfo2_iface.lpVtbl = &PixelFormatInfo_Vtbl;
1274 This->classkey = classkey;
1275 memcpy(&This->clsid, clsid, sizeof(CLSID));
1277 *ppIInfo = (IWICComponentInfo*)This;
1281 static const WCHAR clsid_keyname[] = {'C','L','S','I','D',0};
1282 static const WCHAR instance_keyname[] = {'I','n','s','t','a','n','c','e',0};
1285 WICComponentType type;
1287 HRESULT (*constructor)(HKEY,REFCLSID,IWICComponentInfo**);
1290 static const struct category categories[] = {
1291 {WICDecoder, &CATID_WICBitmapDecoders, BitmapDecoderInfo_Constructor},
1292 {WICEncoder, &CATID_WICBitmapEncoders, BitmapEncoderInfo_Constructor},
1293 {WICPixelFormatConverter, &CATID_WICFormatConverters, FormatConverterInfo_Constructor},
1294 {WICPixelFormat, &CATID_WICPixelFormats, PixelFormatInfo_Constructor},
1298 HRESULT CreateComponentInfo(REFCLSID clsid, IWICComponentInfo **ppIInfo)
1304 WCHAR guidstring[39];
1306 const struct category *category;
1310 res = RegOpenKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, KEY_READ, &clsidkey);
1311 if (res != ERROR_SUCCESS)
1312 return HRESULT_FROM_WIN32(res);
1314 for (category=categories; category->type; category++)
1316 StringFromGUID2(category->catid, guidstring, 39);
1317 res = RegOpenKeyExW(clsidkey, guidstring, 0, KEY_READ, &catidkey);
1318 if (res == ERROR_SUCCESS)
1320 res = RegOpenKeyExW(catidkey, instance_keyname, 0, KEY_READ, &instancekey);
1321 if (res == ERROR_SUCCESS)
1323 StringFromGUID2(clsid, guidstring, 39);
1324 res = RegOpenKeyExW(instancekey, guidstring, 0, KEY_READ, &classkey);
1325 if (res == ERROR_SUCCESS)
1327 RegCloseKey(classkey);
1330 RegCloseKey(instancekey);
1332 RegCloseKey(catidkey);
1339 res = RegOpenKeyExW(clsidkey, guidstring, 0, KEY_READ, &classkey);
1340 if (res == ERROR_SUCCESS)
1341 hr = category->constructor(classkey, clsid, ppIInfo);
1343 hr = HRESULT_FROM_WIN32(res);
1348 RegCloseKey(clsidkey);
1354 IEnumUnknown IEnumUnknown_iface;
1356 struct list objects;
1357 struct list *cursor;
1358 CRITICAL_SECTION lock; /* Must be held when reading or writing cursor */
1361 static inline ComponentEnum *impl_from_IEnumUnknown(IEnumUnknown *iface)
1363 return CONTAINING_RECORD(iface, ComponentEnum, IEnumUnknown_iface);
1369 } ComponentEnumItem;
1371 static const IEnumUnknownVtbl ComponentEnumVtbl;
1373 static HRESULT WINAPI ComponentEnum_QueryInterface(IEnumUnknown *iface, REFIID iid,
1376 ComponentEnum *This = impl_from_IEnumUnknown(iface);
1377 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
1379 if (!ppv) return E_INVALIDARG;
1381 if (IsEqualIID(&IID_IUnknown, iid) || IsEqualIID(&IID_IEnumUnknown, iid))
1388 return E_NOINTERFACE;
1391 IUnknown_AddRef((IUnknown*)*ppv);
1395 static ULONG WINAPI ComponentEnum_AddRef(IEnumUnknown *iface)
1397 ComponentEnum *This = impl_from_IEnumUnknown(iface);
1398 ULONG ref = InterlockedIncrement(&This->ref);
1400 TRACE("(%p) refcount=%u\n", iface, ref);
1405 static ULONG WINAPI ComponentEnum_Release(IEnumUnknown *iface)
1407 ComponentEnum *This = impl_from_IEnumUnknown(iface);
1408 ULONG ref = InterlockedDecrement(&This->ref);
1409 ComponentEnumItem *cursor, *cursor2;
1411 TRACE("(%p) refcount=%u\n", iface, ref);
1415 LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, &This->objects, ComponentEnumItem, entry)
1417 IUnknown_Release(cursor->unk);
1418 list_remove(&cursor->entry);
1419 HeapFree(GetProcessHeap(), 0, cursor);
1421 This->lock.DebugInfo->Spare[0] = 0;
1422 DeleteCriticalSection(&This->lock);
1423 HeapFree(GetProcessHeap(), 0, This);
1429 static HRESULT WINAPI ComponentEnum_Next(IEnumUnknown *iface, ULONG celt,
1430 IUnknown **rgelt, ULONG *pceltFetched)
1432 ComponentEnum *This = impl_from_IEnumUnknown(iface);
1434 ComponentEnumItem *item;
1437 TRACE("(%p,%u,%p,%p)\n", iface, celt, rgelt, pceltFetched);
1439 EnterCriticalSection(&This->lock);
1440 while (num_fetched<celt)
1447 item = LIST_ENTRY(This->cursor, ComponentEnumItem, entry);
1448 IUnknown_AddRef(item->unk);
1449 rgelt[num_fetched] = item->unk;
1451 This->cursor = list_next(&This->objects, This->cursor);
1453 LeaveCriticalSection(&This->lock);
1455 *pceltFetched = num_fetched;
1459 static HRESULT WINAPI ComponentEnum_Skip(IEnumUnknown *iface, ULONG celt)
1461 ComponentEnum *This = impl_from_IEnumUnknown(iface);
1465 TRACE("(%p,%u)\n", iface, celt);
1467 EnterCriticalSection(&This->lock);
1468 for (i=0; i<celt; i++)
1475 This->cursor = list_next(&This->objects, This->cursor);
1477 LeaveCriticalSection(&This->lock);
1481 static HRESULT WINAPI ComponentEnum_Reset(IEnumUnknown *iface)
1483 ComponentEnum *This = impl_from_IEnumUnknown(iface);
1485 TRACE("(%p)\n", iface);
1487 EnterCriticalSection(&This->lock);
1488 This->cursor = list_head(&This->objects);
1489 LeaveCriticalSection(&This->lock);
1493 static HRESULT WINAPI ComponentEnum_Clone(IEnumUnknown *iface, IEnumUnknown **ppenum)
1495 ComponentEnum *This = impl_from_IEnumUnknown(iface);
1496 ComponentEnum *new_enum;
1497 ComponentEnumItem *old_item, *new_item;
1499 struct list *old_cursor;
1501 new_enum = HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnum));
1505 return E_OUTOFMEMORY;
1508 new_enum->IEnumUnknown_iface.lpVtbl = &ComponentEnumVtbl;
1510 new_enum->cursor = NULL;
1511 list_init(&new_enum->objects);
1512 InitializeCriticalSection(&new_enum->lock);
1513 new_enum->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": ComponentEnum.lock");
1515 EnterCriticalSection(&This->lock);
1516 old_cursor = This->cursor;
1517 LeaveCriticalSection(&This->lock);
1519 LIST_FOR_EACH_ENTRY(old_item, &This->objects, ComponentEnumItem, entry)
1521 new_item = HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnumItem));
1524 ret = E_OUTOFMEMORY;
1527 new_item->unk = old_item->unk;
1528 list_add_tail(&new_enum->objects, &new_item->entry);
1529 IUnknown_AddRef(new_item->unk);
1530 if (&old_item->entry == old_cursor) new_enum->cursor = &new_item->entry;
1535 IUnknown_Release((IUnknown*)new_enum);
1539 *ppenum = (IEnumUnknown*)new_enum;
1544 static const IEnumUnknownVtbl ComponentEnumVtbl = {
1545 ComponentEnum_QueryInterface,
1546 ComponentEnum_AddRef,
1547 ComponentEnum_Release,
1550 ComponentEnum_Reset,
1554 HRESULT CreateComponentEnumerator(DWORD componentTypes, DWORD options, IEnumUnknown **ppIEnumUnknown)
1556 ComponentEnum *This;
1557 ComponentEnumItem *item;
1558 const struct category *category;
1559 HKEY clsidkey, catidkey, instancekey;
1560 WCHAR guidstring[39];
1566 if (options) FIXME("ignoring flags %x\n", options);
1568 res = RegOpenKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, KEY_READ, &clsidkey);
1569 if (res != ERROR_SUCCESS)
1570 return HRESULT_FROM_WIN32(res);
1572 This = HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnum));
1575 RegCloseKey(clsidkey);
1576 return E_OUTOFMEMORY;
1579 This->IEnumUnknown_iface.lpVtbl = &ComponentEnumVtbl;
1581 list_init(&This->objects);
1582 InitializeCriticalSection(&This->lock);
1583 This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": ComponentEnum.lock");
1585 for (category=categories; category->type && hr == S_OK; category++)
1587 if ((category->type & componentTypes) == 0) continue;
1588 StringFromGUID2(category->catid, guidstring, 39);
1589 res = RegOpenKeyExW(clsidkey, guidstring, 0, KEY_READ, &catidkey);
1590 if (res == ERROR_SUCCESS)
1592 res = RegOpenKeyExW(catidkey, instance_keyname, 0, KEY_READ, &instancekey);
1593 if (res == ERROR_SUCCESS)
1598 DWORD guidstring_size = 39;
1599 res = RegEnumKeyExW(instancekey, i, guidstring, &guidstring_size, NULL, NULL, NULL, NULL);
1600 if (res != ERROR_SUCCESS) break;
1602 item = HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnumItem));
1603 if (!item) { hr = E_OUTOFMEMORY; break; }
1605 hr = CLSIDFromString(guidstring, &clsid);
1608 hr = CreateComponentInfo(&clsid, (IWICComponentInfo**)&item->unk);
1610 list_add_tail(&This->objects, &item->entry);
1615 HeapFree(GetProcessHeap(), 0, item);
1619 RegCloseKey(instancekey);
1621 RegCloseKey(catidkey);
1623 if (res != ERROR_SUCCESS && res != ERROR_NO_MORE_ITEMS)
1624 hr = HRESULT_FROM_WIN32(res);
1626 RegCloseKey(clsidkey);
1630 IEnumUnknown_Reset((IEnumUnknown*)This);
1631 *ppIEnumUnknown = (IEnumUnknown*)This;
1635 *ppIEnumUnknown = NULL;
1636 IUnknown_Release((IUnknown*)This);
1642 HRESULT WINAPI WICConvertBitmapSource(REFWICPixelFormatGUID dstFormat, IWICBitmapSource *pISrc, IWICBitmapSource **ppIDst)
1645 IEnumUnknown *enumconverters;
1646 IUnknown *unkconverterinfo;
1647 IWICFormatConverterInfo *converterinfo=NULL;
1648 IWICFormatConverter *converter=NULL;
1650 WCHAR srcformatstr[39], dstformatstr[39];
1654 res = IWICBitmapSource_GetPixelFormat(pISrc, &srcFormat);
1655 if (FAILED(res)) return res;
1657 if (IsEqualGUID(&srcFormat, dstFormat))
1659 IWICBitmapSource_AddRef(pISrc);
1664 StringFromGUID2(&srcFormat, srcformatstr, 39);
1665 StringFromGUID2(dstFormat, dstformatstr, 39);
1667 res = CreateComponentEnumerator(WICPixelFormatConverter, 0, &enumconverters);
1668 if (FAILED(res)) return res;
1672 res = IEnumUnknown_Next(enumconverters, 1, &unkconverterinfo, &num_fetched);
1676 res = IUnknown_QueryInterface(unkconverterinfo, &IID_IWICFormatConverterInfo, (void**)&converterinfo);
1680 canconvert = ConverterSupportsFormat(converterinfo, srcformatstr);
1683 canconvert = ConverterSupportsFormat(converterinfo, dstformatstr);
1687 res = IWICFormatConverterInfo_CreateInstance(converterinfo, &converter);
1690 res = IWICFormatConverter_CanConvert(converter, &srcFormat, dstFormat, &canconvert);
1692 if (SUCCEEDED(res) && canconvert)
1693 res = IWICFormatConverter_Initialize(converter, pISrc, dstFormat, WICBitmapDitherTypeNone,
1694 NULL, 0.0, WICBitmapPaletteTypeCustom);
1696 if (FAILED(res) || !canconvert)
1700 IWICFormatConverter_Release(converter);
1707 IWICFormatConverterInfo_Release(converterinfo);
1710 IUnknown_Release(unkconverterinfo);
1716 IEnumUnknown_Release(enumconverters);
1720 *ppIDst = (IWICBitmapSource*)converter;
1725 FIXME("cannot convert %s to %s\n", debugstr_guid(&srcFormat), debugstr_guid(dstFormat));
1727 return WINCODEC_ERR_COMPONENTNOTFOUND;