2 * Copyright 2009 Vincent Povirk for CodeWeavers
3 * Copyright 2012 Dmitry Timoshkov
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "wincodecs_private.h"
22 #include <wine/list.h>
24 static const WCHAR mimetypes_valuename
[] = {'M','i','m','e','T','y','p','e','s',0};
25 static const WCHAR author_valuename
[] = {'A','u','t','h','o','r',0};
26 static const WCHAR friendlyname_valuename
[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
27 static const WCHAR pixelformats_keyname
[] = {'P','i','x','e','l','F','o','r','m','a','t','s',0};
28 static const WCHAR formats_keyname
[] = {'F','o','r','m','a','t','s',0};
29 static const WCHAR containerformat_valuename
[] = {'C','o','n','t','a','i','n','e','r','F','o','r','m','a','t',0};
30 static const WCHAR metadataformat_valuename
[] = {'M','e','t','a','d','a','t','a','F','o','r','m','a','t',0};
31 static const WCHAR vendor_valuename
[] = {'V','e','n','d','o','r',0};
32 static const WCHAR version_valuename
[] = {'V','e','r','s','i','o','n',0};
33 static const WCHAR specversion_valuename
[] = {'S','p','e','c','V','e','r','s','i','o','n',0};
34 static const WCHAR bitsperpixel_valuename
[] = {'B','i','t','L','e','n','g','t','h',0};
35 static const WCHAR channelcount_valuename
[] = {'C','h','a','n','n','e','l','C','o','u','n','t',0};
36 static const WCHAR channelmasks_keyname
[] = {'C','h','a','n','n','e','l','M','a','s','k','s',0};
37 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};
38 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};
39 static const WCHAR requiresfullstream_valuename
[] = {'R','e','q','u','i','r','e','s','F','u','l','l','S','t','r','e','a','m',0};
40 static const WCHAR supportspadding_valuename
[] = {'S','u','p','p','o','r','t','s','P','a','d','d','i','n','g',0};
41 static const WCHAR fileextensions_valuename
[] = {'F','i','l','e','E','x','t','e','n','s','i','o','n','s',0};
43 static HRESULT
ComponentInfo_GetStringValue(HKEY classkey
, LPCWSTR value
,
44 UINT buffer_size
, WCHAR
*buffer
, UINT
*actual_size
)
47 DWORD cbdata
=buffer_size
* sizeof(WCHAR
);
52 ret
= RegGetValueW(classkey
, NULL
, value
, RRF_RT_REG_SZ
|RRF_NOEXPAND
, NULL
,
55 if (ret
== ERROR_FILE_NOT_FOUND
)
61 if (ret
== 0 || ret
== ERROR_MORE_DATA
)
62 *actual_size
= cbdata
/sizeof(WCHAR
);
64 if (!buffer
&& buffer_size
!= 0)
65 /* Yes, native returns the correct size in this case. */
68 if (ret
== ERROR_MORE_DATA
)
69 return WINCODEC_ERR_INSUFFICIENTBUFFER
;
71 return HRESULT_FROM_WIN32(ret
);
74 static HRESULT
ComponentInfo_GetGUIDValue(HKEY classkey
, LPCWSTR value
,
78 WCHAR guid_string
[39];
79 DWORD cbdata
= sizeof(guid_string
);
85 ret
= RegGetValueW(classkey
, NULL
, value
, RRF_RT_REG_SZ
|RRF_NOEXPAND
, NULL
,
86 guid_string
, &cbdata
);
88 if (ret
!= ERROR_SUCCESS
)
89 return HRESULT_FROM_WIN32(ret
);
91 if (cbdata
< sizeof(guid_string
))
93 ERR("incomplete GUID value\n");
97 hr
= CLSIDFromString(guid_string
, result
);
102 static HRESULT
ComponentInfo_GetDWORDValue(HKEY classkey
, LPCWSTR value
,
106 DWORD cbdata
= sizeof(DWORD
);
111 ret
= RegGetValueW(classkey
, NULL
, value
, RRF_RT_DWORD
, NULL
,
114 if (ret
== ERROR_FILE_NOT_FOUND
)
120 return HRESULT_FROM_WIN32(ret
);
123 static HRESULT
ComponentInfo_GetGuidList(HKEY classkey
, LPCWSTR subkeyname
,
124 UINT buffersize
, GUID
*buffer
, UINT
*actual_size
)
129 WCHAR guid_string
[39];
130 DWORD guid_string_size
;
136 ret
= RegOpenKeyExW(classkey
, subkeyname
, 0, KEY_READ
, &subkey
);
137 if (ret
!= ERROR_SUCCESS
) return HRESULT_FROM_WIN32(ret
);
142 guid_string_size
= 39;
143 while (items_returned
< buffersize
)
145 ret
= RegEnumKeyExW(subkey
, items_returned
, guid_string
,
146 &guid_string_size
, NULL
, NULL
, NULL
, NULL
);
148 if (ret
!= ERROR_SUCCESS
)
150 hr
= HRESULT_FROM_WIN32(ret
);
154 if (guid_string_size
!= 38)
160 hr
= CLSIDFromString(guid_string
, &buffer
[items_returned
]);
165 guid_string_size
= 39;
168 if (ret
== ERROR_NO_MORE_ITEMS
)
171 *actual_size
= items_returned
;
175 ret
= RegQueryInfoKeyW(subkey
, NULL
, NULL
, NULL
, actual_size
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
176 if (ret
!= ERROR_SUCCESS
)
177 hr
= HRESULT_FROM_WIN32(ret
);
186 IWICBitmapDecoderInfo IWICBitmapDecoderInfo_iface
;
192 static inline BitmapDecoderInfo
*impl_from_IWICBitmapDecoderInfo(IWICBitmapDecoderInfo
*iface
)
194 return CONTAINING_RECORD(iface
, BitmapDecoderInfo
, IWICBitmapDecoderInfo_iface
);
197 static HRESULT WINAPI
BitmapDecoderInfo_QueryInterface(IWICBitmapDecoderInfo
*iface
, REFIID iid
,
200 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
201 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
203 if (!ppv
) return E_INVALIDARG
;
205 if (IsEqualIID(&IID_IUnknown
, iid
) ||
206 IsEqualIID(&IID_IWICComponentInfo
, iid
) ||
207 IsEqualIID(&IID_IWICBitmapCodecInfo
, iid
) ||
208 IsEqualIID(&IID_IWICBitmapDecoderInfo
,iid
))
215 return E_NOINTERFACE
;
218 IUnknown_AddRef((IUnknown
*)*ppv
);
222 static ULONG WINAPI
BitmapDecoderInfo_AddRef(IWICBitmapDecoderInfo
*iface
)
224 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
225 ULONG ref
= InterlockedIncrement(&This
->ref
);
227 TRACE("(%p) refcount=%u\n", iface
, ref
);
232 static ULONG WINAPI
BitmapDecoderInfo_Release(IWICBitmapDecoderInfo
*iface
)
234 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
235 ULONG ref
= InterlockedDecrement(&This
->ref
);
237 TRACE("(%p) refcount=%u\n", iface
, ref
);
241 RegCloseKey(This
->classkey
);
242 HeapFree(GetProcessHeap(), 0, This
);
248 static HRESULT WINAPI
BitmapDecoderInfo_GetComponentType(IWICBitmapDecoderInfo
*iface
,
249 WICComponentType
*pType
)
251 TRACE("(%p,%p)\n", iface
, pType
);
252 if (!pType
) return E_INVALIDARG
;
257 static HRESULT WINAPI
BitmapDecoderInfo_GetCLSID(IWICBitmapDecoderInfo
*iface
, CLSID
*pclsid
)
259 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
260 TRACE("(%p,%p)\n", iface
, pclsid
);
265 memcpy(pclsid
, &This
->clsid
, sizeof(CLSID
));
270 static HRESULT WINAPI
BitmapDecoderInfo_GetSigningStatus(IWICBitmapDecoderInfo
*iface
, DWORD
*pStatus
)
272 FIXME("(%p,%p): stub\n", iface
, pStatus
);
276 static HRESULT WINAPI
BitmapDecoderInfo_GetAuthor(IWICBitmapDecoderInfo
*iface
, UINT cchAuthor
,
277 WCHAR
*wzAuthor
, UINT
*pcchActual
)
279 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
281 TRACE("(%p,%u,%p,%p)\n", iface
, cchAuthor
, wzAuthor
, pcchActual
);
283 return ComponentInfo_GetStringValue(This
->classkey
, author_valuename
,
284 cchAuthor
, wzAuthor
, pcchActual
);
287 static HRESULT WINAPI
BitmapDecoderInfo_GetVendorGUID(IWICBitmapDecoderInfo
*iface
, GUID
*pguidVendor
)
289 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
291 TRACE("(%p,%p)\n", iface
, pguidVendor
);
293 return ComponentInfo_GetGUIDValue(This
->classkey
, vendor_valuename
, pguidVendor
);
296 static HRESULT WINAPI
BitmapDecoderInfo_GetVersion(IWICBitmapDecoderInfo
*iface
, UINT cchVersion
,
297 WCHAR
*wzVersion
, UINT
*pcchActual
)
299 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
301 TRACE("(%p,%u,%p,%p)\n", iface
, cchVersion
, wzVersion
, pcchActual
);
303 return ComponentInfo_GetStringValue(This
->classkey
, version_valuename
,
304 cchVersion
, wzVersion
, pcchActual
);
307 static HRESULT WINAPI
BitmapDecoderInfo_GetSpecVersion(IWICBitmapDecoderInfo
*iface
, UINT cchSpecVersion
,
308 WCHAR
*wzSpecVersion
, UINT
*pcchActual
)
310 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
312 TRACE("(%p,%u,%p,%p)\n", iface
, cchSpecVersion
, wzSpecVersion
, pcchActual
);
314 return ComponentInfo_GetStringValue(This
->classkey
, specversion_valuename
,
315 cchSpecVersion
, wzSpecVersion
, pcchActual
);
318 static HRESULT WINAPI
BitmapDecoderInfo_GetFriendlyName(IWICBitmapDecoderInfo
*iface
, UINT cchFriendlyName
,
319 WCHAR
*wzFriendlyName
, UINT
*pcchActual
)
321 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
323 TRACE("(%p,%u,%p,%p)\n", iface
, cchFriendlyName
, wzFriendlyName
, pcchActual
);
325 return ComponentInfo_GetStringValue(This
->classkey
, friendlyname_valuename
,
326 cchFriendlyName
, wzFriendlyName
, pcchActual
);
329 static HRESULT WINAPI
BitmapDecoderInfo_GetContainerFormat(IWICBitmapDecoderInfo
*iface
,
330 GUID
*pguidContainerFormat
)
332 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
333 TRACE("(%p,%p)\n", iface
, pguidContainerFormat
);
334 return ComponentInfo_GetGUIDValue(This
->classkey
, containerformat_valuename
, pguidContainerFormat
);
337 static HRESULT WINAPI
BitmapDecoderInfo_GetPixelFormats(IWICBitmapDecoderInfo
*iface
,
338 UINT cFormats
, GUID
*pguidPixelFormats
, UINT
*pcActual
)
340 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
341 TRACE("(%p,%u,%p,%p)\n", iface
, cFormats
, pguidPixelFormats
, pcActual
);
342 return ComponentInfo_GetGuidList(This
->classkey
, formats_keyname
, cFormats
, pguidPixelFormats
, pcActual
);
345 static HRESULT WINAPI
BitmapDecoderInfo_GetColorManagementVersion(IWICBitmapDecoderInfo
*iface
,
346 UINT cchColorManagementVersion
, WCHAR
*wzColorManagementVersion
, UINT
*pcchActual
)
348 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchColorManagementVersion
, wzColorManagementVersion
, pcchActual
);
352 static HRESULT WINAPI
BitmapDecoderInfo_GetDeviceManufacturer(IWICBitmapDecoderInfo
*iface
,
353 UINT cchDeviceManufacturer
, WCHAR
*wzDeviceManufacturer
, UINT
*pcchActual
)
355 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchDeviceManufacturer
, wzDeviceManufacturer
, pcchActual
);
359 static HRESULT WINAPI
BitmapDecoderInfo_GetDeviceModels(IWICBitmapDecoderInfo
*iface
,
360 UINT cchDeviceModels
, WCHAR
*wzDeviceModels
, UINT
*pcchActual
)
362 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchDeviceModels
, wzDeviceModels
, pcchActual
);
366 static HRESULT WINAPI
BitmapDecoderInfo_GetMimeTypes(IWICBitmapDecoderInfo
*iface
,
367 UINT cchMimeTypes
, WCHAR
*wzMimeTypes
, UINT
*pcchActual
)
369 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
371 TRACE("(%p,%u,%p,%p)\n", iface
, cchMimeTypes
, wzMimeTypes
, pcchActual
);
373 return ComponentInfo_GetStringValue(This
->classkey
, mimetypes_valuename
,
374 cchMimeTypes
, wzMimeTypes
, pcchActual
);
377 static HRESULT WINAPI
BitmapDecoderInfo_GetFileExtensions(IWICBitmapDecoderInfo
*iface
,
378 UINT cchFileExtensions
, WCHAR
*wzFileExtensions
, UINT
*pcchActual
)
380 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
382 TRACE("(%p,%u,%p,%p)\n", iface
, cchFileExtensions
, wzFileExtensions
, pcchActual
);
384 return ComponentInfo_GetStringValue(This
->classkey
, fileextensions_valuename
,
385 cchFileExtensions
, wzFileExtensions
, pcchActual
);
388 static HRESULT WINAPI
BitmapDecoderInfo_DoesSupportAnimation(IWICBitmapDecoderInfo
*iface
,
389 BOOL
*pfSupportAnimation
)
391 FIXME("(%p,%p): stub\n", iface
, pfSupportAnimation
);
395 static HRESULT WINAPI
BitmapDecoderInfo_DoesSupportChromaKey(IWICBitmapDecoderInfo
*iface
,
396 BOOL
*pfSupportChromaKey
)
398 FIXME("(%p,%p): stub\n", iface
, pfSupportChromaKey
);
402 static HRESULT WINAPI
BitmapDecoderInfo_DoesSupportLossless(IWICBitmapDecoderInfo
*iface
,
403 BOOL
*pfSupportLossless
)
405 FIXME("(%p,%p): stub\n", iface
, pfSupportLossless
);
409 static HRESULT WINAPI
BitmapDecoderInfo_DoesSupportMultiframe(IWICBitmapDecoderInfo
*iface
,
410 BOOL
*pfSupportMultiframe
)
412 FIXME("(%p,%p): stub\n", iface
, pfSupportMultiframe
);
416 static HRESULT WINAPI
BitmapDecoderInfo_MatchesMimeType(IWICBitmapDecoderInfo
*iface
,
417 LPCWSTR wzMimeType
, BOOL
*pfMatches
)
419 FIXME("(%p,%s,%p): stub\n", iface
, debugstr_w(wzMimeType
), pfMatches
);
423 static HRESULT WINAPI
BitmapDecoderInfo_GetPatterns(IWICBitmapDecoderInfo
*iface
,
424 UINT cbSizePatterns
, WICBitmapPattern
*pPatterns
, UINT
*pcPatterns
, UINT
*pcbPatternsActual
)
426 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
427 UINT pattern_count
=0, patterns_size
=0;
428 WCHAR subkeyname
[11];
430 HKEY patternskey
, patternkey
;
431 static const WCHAR uintformatW
[] = {'%','u',0};
432 static const WCHAR patternsW
[] = {'P','a','t','t','e','r','n','s',0};
433 static const WCHAR positionW
[] = {'P','o','s','i','t','i','o','n',0};
434 static const WCHAR lengthW
[] = {'L','e','n','g','t','h',0};
435 static const WCHAR patternW
[] = {'P','a','t','t','e','r','n',0};
436 static const WCHAR maskW
[] = {'M','a','s','k',0};
437 static const WCHAR endofstreamW
[] = {'E','n','d','O','f','S','t','r','e','a','m',0};
440 BYTE
*bPatterns
=(BYTE
*)pPatterns
;
441 DWORD length
, valuesize
;
443 TRACE("(%p,%i,%p,%p,%p)\n", iface
, cbSizePatterns
, pPatterns
, pcPatterns
, pcbPatternsActual
);
445 res
= RegOpenKeyExW(This
->classkey
, patternsW
, 0, KEY_READ
, &patternskey
);
446 if (res
!= ERROR_SUCCESS
) return HRESULT_FROM_WIN32(res
);
448 res
= RegQueryInfoKeyW(patternskey
, NULL
, NULL
, NULL
, &pattern_count
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
449 if (res
== ERROR_SUCCESS
)
451 patterns_size
= pattern_count
* sizeof(WICBitmapPattern
);
453 for (i
=0; i
<pattern_count
; i
++)
455 snprintfW(subkeyname
, 11, uintformatW
, i
);
456 res
= RegOpenKeyExW(patternskey
, subkeyname
, 0, KEY_READ
, &patternkey
);
457 if (res
== ERROR_SUCCESS
)
459 valuesize
= sizeof(ULONG
);
460 res
= RegGetValueW(patternkey
, NULL
, lengthW
, RRF_RT_DWORD
, NULL
,
461 &length
, &valuesize
);
462 patterns_size
+= length
*2;
464 if ((cbSizePatterns
>= patterns_size
) && (res
== ERROR_SUCCESS
))
466 pPatterns
[i
].Length
= length
;
468 pPatterns
[i
].EndOfStream
= 0;
469 valuesize
= sizeof(BOOL
);
470 RegGetValueW(patternkey
, NULL
, endofstreamW
, RRF_RT_DWORD
, NULL
,
471 &pPatterns
[i
].EndOfStream
, &valuesize
);
473 pPatterns
[i
].Position
.QuadPart
= 0;
474 valuesize
= sizeof(ULARGE_INTEGER
);
475 res
= RegGetValueW(patternkey
, NULL
, positionW
, RRF_RT_DWORD
|RRF_RT_QWORD
, NULL
,
476 &pPatterns
[i
].Position
, &valuesize
);
478 if (res
== ERROR_SUCCESS
)
480 pPatterns
[i
].Pattern
= bPatterns
+patterns_size
-length
*2;
482 res
= RegGetValueW(patternkey
, NULL
, patternW
, RRF_RT_REG_BINARY
, NULL
,
483 pPatterns
[i
].Pattern
, &valuesize
);
486 if (res
== ERROR_SUCCESS
)
488 pPatterns
[i
].Mask
= bPatterns
+patterns_size
-length
;
490 res
= RegGetValueW(patternkey
, NULL
, maskW
, RRF_RT_REG_BINARY
, NULL
,
491 pPatterns
[i
].Mask
, &valuesize
);
495 RegCloseKey(patternkey
);
497 if (res
!= ERROR_SUCCESS
)
499 hr
= HRESULT_FROM_WIN32(res
);
504 else hr
= HRESULT_FROM_WIN32(res
);
506 RegCloseKey(patternskey
);
510 *pcPatterns
= pattern_count
;
511 *pcbPatternsActual
= patterns_size
;
512 if (pPatterns
&& cbSizePatterns
< patterns_size
)
513 hr
= WINCODEC_ERR_INSUFFICIENTBUFFER
;
519 static HRESULT WINAPI
BitmapDecoderInfo_MatchesPattern(IWICBitmapDecoderInfo
*iface
,
520 IStream
*pIStream
, BOOL
*pfMatches
)
522 WICBitmapPattern
*patterns
;
523 UINT pattern_count
=0, patterns_size
=0;
530 LARGE_INTEGER seekpos
;
532 TRACE("(%p,%p,%p)\n", iface
, pIStream
, pfMatches
);
534 hr
= BitmapDecoderInfo_GetPatterns(iface
, 0, NULL
, &pattern_count
, &patterns_size
);
535 if (FAILED(hr
)) return hr
;
537 patterns
= HeapAlloc(GetProcessHeap(), 0, patterns_size
);
538 if (!patterns
) return E_OUTOFMEMORY
;
540 hr
= BitmapDecoderInfo_GetPatterns(iface
, patterns_size
, patterns
, &pattern_count
, &patterns_size
);
541 if (FAILED(hr
)) goto end
;
543 for (i
=0; i
<pattern_count
; i
++)
545 if (datasize
< patterns
[i
].Length
)
547 HeapFree(GetProcessHeap(), 0, data
);
548 datasize
= patterns
[i
].Length
;
549 data
= HeapAlloc(GetProcessHeap(), 0, patterns
[i
].Length
);
557 if (patterns
[i
].EndOfStream
)
558 seekpos
.QuadPart
= -patterns
[i
].Position
.QuadPart
;
560 seekpos
.QuadPart
= patterns
[i
].Position
.QuadPart
;
561 hr
= IStream_Seek(pIStream
, seekpos
, patterns
[i
].EndOfStream
? STREAM_SEEK_END
: STREAM_SEEK_SET
, NULL
);
562 if (hr
== STG_E_INVALIDFUNCTION
) continue; /* before start of stream */
563 if (FAILED(hr
)) break;
565 hr
= IStream_Read(pIStream
, data
, patterns
[i
].Length
, &bytesread
);
566 if (hr
== S_FALSE
|| (hr
== S_OK
&& bytesread
!= patterns
[i
].Length
)) /* past end of stream */
568 if (FAILED(hr
)) break;
570 for (pos
=0; pos
<patterns
[i
].Length
; pos
++)
572 if ((data
[pos
] & patterns
[i
].Mask
[pos
]) != patterns
[i
].Pattern
[pos
])
575 if (pos
== patterns
[i
].Length
) /* matches pattern */
583 if (i
== pattern_count
) /* does not match any pattern */
590 HeapFree(GetProcessHeap(), 0, patterns
);
591 HeapFree(GetProcessHeap(), 0, data
);
596 static HRESULT WINAPI
BitmapDecoderInfo_CreateInstance(IWICBitmapDecoderInfo
*iface
,
597 IWICBitmapDecoder
**ppIBitmapDecoder
)
599 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
601 TRACE("(%p,%p)\n", iface
, ppIBitmapDecoder
);
603 return CoCreateInstance(&This
->clsid
, NULL
, CLSCTX_INPROC_SERVER
,
604 &IID_IWICBitmapDecoder
, (void**)ppIBitmapDecoder
);
607 static const IWICBitmapDecoderInfoVtbl BitmapDecoderInfo_Vtbl
= {
608 BitmapDecoderInfo_QueryInterface
,
609 BitmapDecoderInfo_AddRef
,
610 BitmapDecoderInfo_Release
,
611 BitmapDecoderInfo_GetComponentType
,
612 BitmapDecoderInfo_GetCLSID
,
613 BitmapDecoderInfo_GetSigningStatus
,
614 BitmapDecoderInfo_GetAuthor
,
615 BitmapDecoderInfo_GetVendorGUID
,
616 BitmapDecoderInfo_GetVersion
,
617 BitmapDecoderInfo_GetSpecVersion
,
618 BitmapDecoderInfo_GetFriendlyName
,
619 BitmapDecoderInfo_GetContainerFormat
,
620 BitmapDecoderInfo_GetPixelFormats
,
621 BitmapDecoderInfo_GetColorManagementVersion
,
622 BitmapDecoderInfo_GetDeviceManufacturer
,
623 BitmapDecoderInfo_GetDeviceModels
,
624 BitmapDecoderInfo_GetMimeTypes
,
625 BitmapDecoderInfo_GetFileExtensions
,
626 BitmapDecoderInfo_DoesSupportAnimation
,
627 BitmapDecoderInfo_DoesSupportChromaKey
,
628 BitmapDecoderInfo_DoesSupportLossless
,
629 BitmapDecoderInfo_DoesSupportMultiframe
,
630 BitmapDecoderInfo_MatchesMimeType
,
631 BitmapDecoderInfo_GetPatterns
,
632 BitmapDecoderInfo_MatchesPattern
,
633 BitmapDecoderInfo_CreateInstance
636 static HRESULT
BitmapDecoderInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
638 BitmapDecoderInfo
*This
;
640 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapDecoderInfo
));
643 RegCloseKey(classkey
);
644 return E_OUTOFMEMORY
;
647 This
->IWICBitmapDecoderInfo_iface
.lpVtbl
= &BitmapDecoderInfo_Vtbl
;
649 This
->classkey
= classkey
;
650 memcpy(&This
->clsid
, clsid
, sizeof(CLSID
));
652 *ppIInfo
= (IWICComponentInfo
*)This
;
657 IWICBitmapEncoderInfo IWICBitmapEncoderInfo_iface
;
663 static inline BitmapEncoderInfo
*impl_from_IWICBitmapEncoderInfo(IWICBitmapEncoderInfo
*iface
)
665 return CONTAINING_RECORD(iface
, BitmapEncoderInfo
, IWICBitmapEncoderInfo_iface
);
668 static HRESULT WINAPI
BitmapEncoderInfo_QueryInterface(IWICBitmapEncoderInfo
*iface
, REFIID iid
,
671 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
672 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
674 if (!ppv
) return E_INVALIDARG
;
676 if (IsEqualIID(&IID_IUnknown
, iid
) ||
677 IsEqualIID(&IID_IWICComponentInfo
, iid
) ||
678 IsEqualIID(&IID_IWICBitmapCodecInfo
, iid
) ||
679 IsEqualIID(&IID_IWICBitmapEncoderInfo
,iid
))
686 return E_NOINTERFACE
;
689 IUnknown_AddRef((IUnknown
*)*ppv
);
693 static ULONG WINAPI
BitmapEncoderInfo_AddRef(IWICBitmapEncoderInfo
*iface
)
695 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
696 ULONG ref
= InterlockedIncrement(&This
->ref
);
698 TRACE("(%p) refcount=%u\n", iface
, ref
);
703 static ULONG WINAPI
BitmapEncoderInfo_Release(IWICBitmapEncoderInfo
*iface
)
705 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
706 ULONG ref
= InterlockedDecrement(&This
->ref
);
708 TRACE("(%p) refcount=%u\n", iface
, ref
);
712 RegCloseKey(This
->classkey
);
713 HeapFree(GetProcessHeap(), 0, This
);
719 static HRESULT WINAPI
BitmapEncoderInfo_GetComponentType(IWICBitmapEncoderInfo
*iface
,
720 WICComponentType
*pType
)
722 TRACE("(%p,%p)\n", iface
, pType
);
723 if (!pType
) return E_INVALIDARG
;
728 static HRESULT WINAPI
BitmapEncoderInfo_GetCLSID(IWICBitmapEncoderInfo
*iface
, CLSID
*pclsid
)
730 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
731 TRACE("(%p,%p)\n", iface
, pclsid
);
736 memcpy(pclsid
, &This
->clsid
, sizeof(CLSID
));
741 static HRESULT WINAPI
BitmapEncoderInfo_GetSigningStatus(IWICBitmapEncoderInfo
*iface
, DWORD
*pStatus
)
743 FIXME("(%p,%p): stub\n", iface
, pStatus
);
747 static HRESULT WINAPI
BitmapEncoderInfo_GetAuthor(IWICBitmapEncoderInfo
*iface
, UINT cchAuthor
,
748 WCHAR
*wzAuthor
, UINT
*pcchActual
)
750 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
752 TRACE("(%p,%u,%p,%p)\n", iface
, cchAuthor
, wzAuthor
, pcchActual
);
754 return ComponentInfo_GetStringValue(This
->classkey
, author_valuename
,
755 cchAuthor
, wzAuthor
, pcchActual
);
758 static HRESULT WINAPI
BitmapEncoderInfo_GetVendorGUID(IWICBitmapEncoderInfo
*iface
, GUID
*pguidVendor
)
760 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
762 TRACE("(%p,%p)\n", iface
, pguidVendor
);
764 return ComponentInfo_GetGUIDValue(This
->classkey
, vendor_valuename
, pguidVendor
);
767 static HRESULT WINAPI
BitmapEncoderInfo_GetVersion(IWICBitmapEncoderInfo
*iface
, UINT cchVersion
,
768 WCHAR
*wzVersion
, UINT
*pcchActual
)
770 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
772 TRACE("(%p,%u,%p,%p)\n", iface
, cchVersion
, wzVersion
, pcchActual
);
774 return ComponentInfo_GetStringValue(This
->classkey
, version_valuename
,
775 cchVersion
, wzVersion
, pcchActual
);
778 static HRESULT WINAPI
BitmapEncoderInfo_GetSpecVersion(IWICBitmapEncoderInfo
*iface
, UINT cchSpecVersion
,
779 WCHAR
*wzSpecVersion
, UINT
*pcchActual
)
781 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
783 TRACE("(%p,%u,%p,%p)\n", iface
, cchSpecVersion
, wzSpecVersion
, pcchActual
);
785 return ComponentInfo_GetStringValue(This
->classkey
, specversion_valuename
,
786 cchSpecVersion
, wzSpecVersion
, pcchActual
);
789 static HRESULT WINAPI
BitmapEncoderInfo_GetFriendlyName(IWICBitmapEncoderInfo
*iface
, UINT cchFriendlyName
,
790 WCHAR
*wzFriendlyName
, UINT
*pcchActual
)
792 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
794 TRACE("(%p,%u,%p,%p)\n", iface
, cchFriendlyName
, wzFriendlyName
, pcchActual
);
796 return ComponentInfo_GetStringValue(This
->classkey
, friendlyname_valuename
,
797 cchFriendlyName
, wzFriendlyName
, pcchActual
);
800 static HRESULT WINAPI
BitmapEncoderInfo_GetContainerFormat(IWICBitmapEncoderInfo
*iface
,
801 GUID
*pguidContainerFormat
)
803 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
804 TRACE("(%p,%p)\n", iface
, pguidContainerFormat
);
805 return ComponentInfo_GetGUIDValue(This
->classkey
, containerformat_valuename
, pguidContainerFormat
);
808 static HRESULT WINAPI
BitmapEncoderInfo_GetPixelFormats(IWICBitmapEncoderInfo
*iface
,
809 UINT cFormats
, GUID
*pguidPixelFormats
, UINT
*pcActual
)
811 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
812 TRACE("(%p,%u,%p,%p)\n", iface
, cFormats
, pguidPixelFormats
, pcActual
);
813 return ComponentInfo_GetGuidList(This
->classkey
, formats_keyname
, cFormats
, pguidPixelFormats
, pcActual
);
816 static HRESULT WINAPI
BitmapEncoderInfo_GetColorManagementVersion(IWICBitmapEncoderInfo
*iface
,
817 UINT cchColorManagementVersion
, WCHAR
*wzColorManagementVersion
, UINT
*pcchActual
)
819 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchColorManagementVersion
, wzColorManagementVersion
, pcchActual
);
823 static HRESULT WINAPI
BitmapEncoderInfo_GetDeviceManufacturer(IWICBitmapEncoderInfo
*iface
,
824 UINT cchDeviceManufacturer
, WCHAR
*wzDeviceManufacturer
, UINT
*pcchActual
)
826 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchDeviceManufacturer
, wzDeviceManufacturer
, pcchActual
);
830 static HRESULT WINAPI
BitmapEncoderInfo_GetDeviceModels(IWICBitmapEncoderInfo
*iface
,
831 UINT cchDeviceModels
, WCHAR
*wzDeviceModels
, UINT
*pcchActual
)
833 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchDeviceModels
, wzDeviceModels
, pcchActual
);
837 static HRESULT WINAPI
BitmapEncoderInfo_GetMimeTypes(IWICBitmapEncoderInfo
*iface
,
838 UINT cchMimeTypes
, WCHAR
*wzMimeTypes
, UINT
*pcchActual
)
840 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
842 TRACE("(%p,%u,%p,%p)\n", iface
, cchMimeTypes
, wzMimeTypes
, pcchActual
);
844 return ComponentInfo_GetStringValue(This
->classkey
, mimetypes_valuename
,
845 cchMimeTypes
, wzMimeTypes
, pcchActual
);
848 static HRESULT WINAPI
BitmapEncoderInfo_GetFileExtensions(IWICBitmapEncoderInfo
*iface
,
849 UINT cchFileExtensions
, WCHAR
*wzFileExtensions
, UINT
*pcchActual
)
851 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchFileExtensions
, wzFileExtensions
, pcchActual
);
855 static HRESULT WINAPI
BitmapEncoderInfo_DoesSupportAnimation(IWICBitmapEncoderInfo
*iface
,
856 BOOL
*pfSupportAnimation
)
858 FIXME("(%p,%p): stub\n", iface
, pfSupportAnimation
);
862 static HRESULT WINAPI
BitmapEncoderInfo_DoesSupportChromaKey(IWICBitmapEncoderInfo
*iface
,
863 BOOL
*pfSupportChromaKey
)
865 FIXME("(%p,%p): stub\n", iface
, pfSupportChromaKey
);
869 static HRESULT WINAPI
BitmapEncoderInfo_DoesSupportLossless(IWICBitmapEncoderInfo
*iface
,
870 BOOL
*pfSupportLossless
)
872 FIXME("(%p,%p): stub\n", iface
, pfSupportLossless
);
876 static HRESULT WINAPI
BitmapEncoderInfo_DoesSupportMultiframe(IWICBitmapEncoderInfo
*iface
,
877 BOOL
*pfSupportMultiframe
)
879 FIXME("(%p,%p): stub\n", iface
, pfSupportMultiframe
);
883 static HRESULT WINAPI
BitmapEncoderInfo_MatchesMimeType(IWICBitmapEncoderInfo
*iface
,
884 LPCWSTR wzMimeType
, BOOL
*pfMatches
)
886 FIXME("(%p,%s,%p): stub\n", iface
, debugstr_w(wzMimeType
), pfMatches
);
890 static HRESULT WINAPI
BitmapEncoderInfo_CreateInstance(IWICBitmapEncoderInfo
*iface
,
891 IWICBitmapEncoder
**ppIBitmapEncoder
)
893 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
895 TRACE("(%p,%p)\n", iface
, ppIBitmapEncoder
);
897 return CoCreateInstance(&This
->clsid
, NULL
, CLSCTX_INPROC_SERVER
,
898 &IID_IWICBitmapEncoder
, (void**)ppIBitmapEncoder
);
901 static const IWICBitmapEncoderInfoVtbl BitmapEncoderInfo_Vtbl
= {
902 BitmapEncoderInfo_QueryInterface
,
903 BitmapEncoderInfo_AddRef
,
904 BitmapEncoderInfo_Release
,
905 BitmapEncoderInfo_GetComponentType
,
906 BitmapEncoderInfo_GetCLSID
,
907 BitmapEncoderInfo_GetSigningStatus
,
908 BitmapEncoderInfo_GetAuthor
,
909 BitmapEncoderInfo_GetVendorGUID
,
910 BitmapEncoderInfo_GetVersion
,
911 BitmapEncoderInfo_GetSpecVersion
,
912 BitmapEncoderInfo_GetFriendlyName
,
913 BitmapEncoderInfo_GetContainerFormat
,
914 BitmapEncoderInfo_GetPixelFormats
,
915 BitmapEncoderInfo_GetColorManagementVersion
,
916 BitmapEncoderInfo_GetDeviceManufacturer
,
917 BitmapEncoderInfo_GetDeviceModels
,
918 BitmapEncoderInfo_GetMimeTypes
,
919 BitmapEncoderInfo_GetFileExtensions
,
920 BitmapEncoderInfo_DoesSupportAnimation
,
921 BitmapEncoderInfo_DoesSupportChromaKey
,
922 BitmapEncoderInfo_DoesSupportLossless
,
923 BitmapEncoderInfo_DoesSupportMultiframe
,
924 BitmapEncoderInfo_MatchesMimeType
,
925 BitmapEncoderInfo_CreateInstance
928 static HRESULT
BitmapEncoderInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
930 BitmapEncoderInfo
*This
;
932 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapEncoderInfo
));
935 RegCloseKey(classkey
);
936 return E_OUTOFMEMORY
;
939 This
->IWICBitmapEncoderInfo_iface
.lpVtbl
= &BitmapEncoderInfo_Vtbl
;
941 This
->classkey
= classkey
;
942 memcpy(&This
->clsid
, clsid
, sizeof(CLSID
));
944 *ppIInfo
= (IWICComponentInfo
*)This
;
949 IWICFormatConverterInfo IWICFormatConverterInfo_iface
;
953 } FormatConverterInfo
;
955 static inline FormatConverterInfo
*impl_from_IWICFormatConverterInfo(IWICFormatConverterInfo
*iface
)
957 return CONTAINING_RECORD(iface
, FormatConverterInfo
, IWICFormatConverterInfo_iface
);
960 static HRESULT WINAPI
FormatConverterInfo_QueryInterface(IWICFormatConverterInfo
*iface
, REFIID iid
,
963 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
964 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
966 if (!ppv
) return E_INVALIDARG
;
968 if (IsEqualIID(&IID_IUnknown
, iid
) ||
969 IsEqualIID(&IID_IWICComponentInfo
, iid
) ||
970 IsEqualIID(&IID_IWICFormatConverterInfo
,iid
))
977 return E_NOINTERFACE
;
980 IUnknown_AddRef((IUnknown
*)*ppv
);
984 static ULONG WINAPI
FormatConverterInfo_AddRef(IWICFormatConverterInfo
*iface
)
986 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
987 ULONG ref
= InterlockedIncrement(&This
->ref
);
989 TRACE("(%p) refcount=%u\n", iface
, ref
);
994 static ULONG WINAPI
FormatConverterInfo_Release(IWICFormatConverterInfo
*iface
)
996 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
997 ULONG ref
= InterlockedDecrement(&This
->ref
);
999 TRACE("(%p) refcount=%u\n", iface
, ref
);
1003 RegCloseKey(This
->classkey
);
1004 HeapFree(GetProcessHeap(), 0, This
);
1010 static HRESULT WINAPI
FormatConverterInfo_GetComponentType(IWICFormatConverterInfo
*iface
,
1011 WICComponentType
*pType
)
1013 TRACE("(%p,%p)\n", iface
, pType
);
1014 if (!pType
) return E_INVALIDARG
;
1015 *pType
= WICPixelFormatConverter
;
1019 static HRESULT WINAPI
FormatConverterInfo_GetCLSID(IWICFormatConverterInfo
*iface
, CLSID
*pclsid
)
1021 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1022 TRACE("(%p,%p)\n", iface
, pclsid
);
1025 return E_INVALIDARG
;
1027 memcpy(pclsid
, &This
->clsid
, sizeof(CLSID
));
1032 static HRESULT WINAPI
FormatConverterInfo_GetSigningStatus(IWICFormatConverterInfo
*iface
, DWORD
*pStatus
)
1034 FIXME("(%p,%p): stub\n", iface
, pStatus
);
1038 static HRESULT WINAPI
FormatConverterInfo_GetAuthor(IWICFormatConverterInfo
*iface
, UINT cchAuthor
,
1039 WCHAR
*wzAuthor
, UINT
*pcchActual
)
1041 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1043 TRACE("(%p,%u,%p,%p)\n", iface
, cchAuthor
, wzAuthor
, pcchActual
);
1045 return ComponentInfo_GetStringValue(This
->classkey
, author_valuename
,
1046 cchAuthor
, wzAuthor
, pcchActual
);
1049 static HRESULT WINAPI
FormatConverterInfo_GetVendorGUID(IWICFormatConverterInfo
*iface
, GUID
*pguidVendor
)
1051 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1053 TRACE("(%p,%p)\n", iface
, pguidVendor
);
1055 return ComponentInfo_GetGUIDValue(This
->classkey
, vendor_valuename
, pguidVendor
);
1058 static HRESULT WINAPI
FormatConverterInfo_GetVersion(IWICFormatConverterInfo
*iface
, UINT cchVersion
,
1059 WCHAR
*wzVersion
, UINT
*pcchActual
)
1061 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1063 TRACE("(%p,%u,%p,%p)\n", iface
, cchVersion
, wzVersion
, pcchActual
);
1065 return ComponentInfo_GetStringValue(This
->classkey
, version_valuename
,
1066 cchVersion
, wzVersion
, pcchActual
);
1069 static HRESULT WINAPI
FormatConverterInfo_GetSpecVersion(IWICFormatConverterInfo
*iface
, UINT cchSpecVersion
,
1070 WCHAR
*wzSpecVersion
, UINT
*pcchActual
)
1072 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1074 TRACE("(%p,%u,%p,%p)\n", iface
, cchSpecVersion
, wzSpecVersion
, pcchActual
);
1076 return ComponentInfo_GetStringValue(This
->classkey
, specversion_valuename
,
1077 cchSpecVersion
, wzSpecVersion
, pcchActual
);
1080 static HRESULT WINAPI
FormatConverterInfo_GetFriendlyName(IWICFormatConverterInfo
*iface
, UINT cchFriendlyName
,
1081 WCHAR
*wzFriendlyName
, UINT
*pcchActual
)
1083 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1085 TRACE("(%p,%u,%p,%p)\n", iface
, cchFriendlyName
, wzFriendlyName
, pcchActual
);
1087 return ComponentInfo_GetStringValue(This
->classkey
, friendlyname_valuename
,
1088 cchFriendlyName
, wzFriendlyName
, pcchActual
);
1091 static HRESULT WINAPI
FormatConverterInfo_GetPixelFormats(IWICFormatConverterInfo
*iface
,
1092 UINT cFormats
, GUID
*pguidPixelFormats
, UINT
*pcActual
)
1094 FIXME("(%p,%u,%p,%p): stub\n", iface
, cFormats
, pguidPixelFormats
, pcActual
);
1098 static HRESULT WINAPI
FormatConverterInfo_CreateInstance(IWICFormatConverterInfo
*iface
,
1099 IWICFormatConverter
**ppIFormatConverter
)
1101 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1103 TRACE("(%p,%p)\n", iface
, ppIFormatConverter
);
1105 return CoCreateInstance(&This
->clsid
, NULL
, CLSCTX_INPROC_SERVER
,
1106 &IID_IWICFormatConverter
, (void**)ppIFormatConverter
);
1109 static BOOL
ConverterSupportsFormat(IWICFormatConverterInfo
*iface
, const WCHAR
*formatguid
)
1112 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1113 HKEY formats_key
, guid_key
;
1115 /* Avoid testing using IWICFormatConverter_GetPixelFormats because that
1116 would be O(n). A registry test should do better. */
1118 res
= RegOpenKeyExW(This
->classkey
, pixelformats_keyname
, 0, KEY_READ
, &formats_key
);
1119 if (res
!= ERROR_SUCCESS
) return FALSE
;
1121 res
= RegOpenKeyExW(formats_key
, formatguid
, 0, KEY_READ
, &guid_key
);
1122 if (res
== ERROR_SUCCESS
) RegCloseKey(guid_key
);
1124 RegCloseKey(formats_key
);
1126 return (res
== ERROR_SUCCESS
);
1129 static const IWICFormatConverterInfoVtbl FormatConverterInfo_Vtbl
= {
1130 FormatConverterInfo_QueryInterface
,
1131 FormatConverterInfo_AddRef
,
1132 FormatConverterInfo_Release
,
1133 FormatConverterInfo_GetComponentType
,
1134 FormatConverterInfo_GetCLSID
,
1135 FormatConverterInfo_GetSigningStatus
,
1136 FormatConverterInfo_GetAuthor
,
1137 FormatConverterInfo_GetVendorGUID
,
1138 FormatConverterInfo_GetVersion
,
1139 FormatConverterInfo_GetSpecVersion
,
1140 FormatConverterInfo_GetFriendlyName
,
1141 FormatConverterInfo_GetPixelFormats
,
1142 FormatConverterInfo_CreateInstance
1145 static HRESULT
FormatConverterInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
1147 FormatConverterInfo
*This
;
1149 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(FormatConverterInfo
));
1152 RegCloseKey(classkey
);
1153 return E_OUTOFMEMORY
;
1156 This
->IWICFormatConverterInfo_iface
.lpVtbl
= &FormatConverterInfo_Vtbl
;
1158 This
->classkey
= classkey
;
1159 memcpy(&This
->clsid
, clsid
, sizeof(CLSID
));
1161 *ppIInfo
= (IWICComponentInfo
*)This
;
1166 IWICPixelFormatInfo2 IWICPixelFormatInfo2_iface
;
1172 static inline PixelFormatInfo
*impl_from_IWICPixelFormatInfo2(IWICPixelFormatInfo2
*iface
)
1174 return CONTAINING_RECORD(iface
, PixelFormatInfo
, IWICPixelFormatInfo2_iface
);
1177 static HRESULT WINAPI
PixelFormatInfo_QueryInterface(IWICPixelFormatInfo2
*iface
, REFIID iid
,
1180 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1181 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
1183 if (!ppv
) return E_INVALIDARG
;
1185 if (IsEqualIID(&IID_IUnknown
, iid
) ||
1186 IsEqualIID(&IID_IWICComponentInfo
, iid
) ||
1187 IsEqualIID(&IID_IWICPixelFormatInfo
, iid
) ||
1188 IsEqualIID(&IID_IWICPixelFormatInfo2
,iid
))
1195 return E_NOINTERFACE
;
1198 IUnknown_AddRef((IUnknown
*)*ppv
);
1202 static ULONG WINAPI
PixelFormatInfo_AddRef(IWICPixelFormatInfo2
*iface
)
1204 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1205 ULONG ref
= InterlockedIncrement(&This
->ref
);
1207 TRACE("(%p) refcount=%u\n", iface
, ref
);
1212 static ULONG WINAPI
PixelFormatInfo_Release(IWICPixelFormatInfo2
*iface
)
1214 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1215 ULONG ref
= InterlockedDecrement(&This
->ref
);
1217 TRACE("(%p) refcount=%u\n", iface
, ref
);
1221 RegCloseKey(This
->classkey
);
1222 HeapFree(GetProcessHeap(), 0, This
);
1228 static HRESULT WINAPI
PixelFormatInfo_GetComponentType(IWICPixelFormatInfo2
*iface
,
1229 WICComponentType
*pType
)
1231 TRACE("(%p,%p)\n", iface
, pType
);
1232 if (!pType
) return E_INVALIDARG
;
1233 *pType
= WICPixelFormat
;
1237 static HRESULT WINAPI
PixelFormatInfo_GetCLSID(IWICPixelFormatInfo2
*iface
, CLSID
*pclsid
)
1239 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1240 TRACE("(%p,%p)\n", iface
, pclsid
);
1243 return E_INVALIDARG
;
1245 memcpy(pclsid
, &This
->clsid
, sizeof(CLSID
));
1250 static HRESULT WINAPI
PixelFormatInfo_GetSigningStatus(IWICPixelFormatInfo2
*iface
, DWORD
*pStatus
)
1252 TRACE("(%p,%p)\n", iface
, pStatus
);
1255 return E_INVALIDARG
;
1257 /* Pixel formats don't require code, so they are considered signed. */
1258 *pStatus
= WICComponentSigned
;
1263 static HRESULT WINAPI
PixelFormatInfo_GetAuthor(IWICPixelFormatInfo2
*iface
, UINT cchAuthor
,
1264 WCHAR
*wzAuthor
, UINT
*pcchActual
)
1266 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1268 TRACE("(%p,%u,%p,%p)\n", iface
, cchAuthor
, wzAuthor
, pcchActual
);
1270 return ComponentInfo_GetStringValue(This
->classkey
, author_valuename
,
1271 cchAuthor
, wzAuthor
, pcchActual
);
1274 static HRESULT WINAPI
PixelFormatInfo_GetVendorGUID(IWICPixelFormatInfo2
*iface
, GUID
*pguidVendor
)
1276 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1278 TRACE("(%p,%p)\n", iface
, pguidVendor
);
1280 return ComponentInfo_GetGUIDValue(This
->classkey
, vendor_valuename
, pguidVendor
);
1283 static HRESULT WINAPI
PixelFormatInfo_GetVersion(IWICPixelFormatInfo2
*iface
, UINT cchVersion
,
1284 WCHAR
*wzVersion
, UINT
*pcchActual
)
1286 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1288 TRACE("(%p,%u,%p,%p)\n", iface
, cchVersion
, wzVersion
, pcchActual
);
1290 return ComponentInfo_GetStringValue(This
->classkey
, version_valuename
,
1291 cchVersion
, wzVersion
, pcchActual
);
1294 static HRESULT WINAPI
PixelFormatInfo_GetSpecVersion(IWICPixelFormatInfo2
*iface
, UINT cchSpecVersion
,
1295 WCHAR
*wzSpecVersion
, UINT
*pcchActual
)
1297 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1299 TRACE("(%p,%u,%p,%p)\n", iface
, cchSpecVersion
, wzSpecVersion
, pcchActual
);
1301 return ComponentInfo_GetStringValue(This
->classkey
, specversion_valuename
,
1302 cchSpecVersion
, wzSpecVersion
, pcchActual
);
1305 static HRESULT WINAPI
PixelFormatInfo_GetFriendlyName(IWICPixelFormatInfo2
*iface
, UINT cchFriendlyName
,
1306 WCHAR
*wzFriendlyName
, UINT
*pcchActual
)
1308 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1310 TRACE("(%p,%u,%p,%p)\n", iface
, cchFriendlyName
, wzFriendlyName
, pcchActual
);
1312 return ComponentInfo_GetStringValue(This
->classkey
, friendlyname_valuename
,
1313 cchFriendlyName
, wzFriendlyName
, pcchActual
);
1316 static HRESULT WINAPI
PixelFormatInfo_GetFormatGUID(IWICPixelFormatInfo2
*iface
,
1319 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1320 TRACE("(%p,%p)\n", iface
, pFormat
);
1323 return E_INVALIDARG
;
1325 *pFormat
= This
->clsid
;
1330 static HRESULT WINAPI
PixelFormatInfo_GetColorContext(IWICPixelFormatInfo2
*iface
,
1331 IWICColorContext
**ppIColorContext
)
1333 FIXME("(%p,%p): stub\n", iface
, ppIColorContext
);
1337 static HRESULT WINAPI
PixelFormatInfo_GetBitsPerPixel(IWICPixelFormatInfo2
*iface
,
1338 UINT
*puiBitsPerPixel
)
1340 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1342 TRACE("(%p,%p)\n", iface
, puiBitsPerPixel
);
1344 return ComponentInfo_GetDWORDValue(This
->classkey
, bitsperpixel_valuename
, puiBitsPerPixel
);
1347 static HRESULT WINAPI
PixelFormatInfo_GetChannelCount(IWICPixelFormatInfo2
*iface
,
1348 UINT
*puiChannelCount
)
1350 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1352 TRACE("(%p,%p)\n", iface
, puiChannelCount
);
1354 return ComponentInfo_GetDWORDValue(This
->classkey
, channelcount_valuename
, puiChannelCount
);
1357 static HRESULT WINAPI
PixelFormatInfo_GetChannelMask(IWICPixelFormatInfo2
*iface
,
1358 UINT uiChannelIndex
, UINT cbMaskBuffer
, BYTE
*pbMaskBuffer
, UINT
*pcbActual
)
1360 static const WCHAR uintformatW
[] = {'%','u',0};
1361 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1365 WCHAR valuename
[11];
1368 TRACE("(%p,%u,%u,%p,%p)\n", iface
, uiChannelIndex
, cbMaskBuffer
, pbMaskBuffer
, pcbActual
);
1371 return E_INVALIDARG
;
1373 hr
= PixelFormatInfo_GetChannelCount(iface
, &channel_count
);
1375 if (SUCCEEDED(hr
) && uiChannelIndex
>= channel_count
)
1380 snprintfW(valuename
, 11, uintformatW
, uiChannelIndex
);
1382 cbData
= cbMaskBuffer
;
1384 ret
= RegGetValueW(This
->classkey
, channelmasks_keyname
, valuename
, RRF_RT_REG_BINARY
, NULL
, pbMaskBuffer
, &cbData
);
1386 if (ret
== ERROR_SUCCESS
|| ret
== ERROR_MORE_DATA
)
1387 *pcbActual
= cbData
;
1389 if (ret
== ERROR_MORE_DATA
)
1392 hr
= HRESULT_FROM_WIN32(ret
);
1398 static HRESULT WINAPI
PixelFormatInfo_SupportsTransparency(IWICPixelFormatInfo2
*iface
,
1399 BOOL
*pfSupportsTransparency
)
1401 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1403 TRACE("(%p,%p)\n", iface
, pfSupportsTransparency
);
1405 return ComponentInfo_GetDWORDValue(This
->classkey
, supportstransparency_valuename
, (DWORD
*)pfSupportsTransparency
);
1408 static HRESULT WINAPI
PixelFormatInfo_GetNumericRepresentation(IWICPixelFormatInfo2
*iface
,
1409 WICPixelFormatNumericRepresentation
*pNumericRepresentation
)
1411 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1413 TRACE("(%p,%p)\n", iface
, pNumericRepresentation
);
1415 return ComponentInfo_GetDWORDValue(This
->classkey
, numericrepresentation_valuename
, pNumericRepresentation
);
1418 static const IWICPixelFormatInfo2Vtbl PixelFormatInfo_Vtbl
= {
1419 PixelFormatInfo_QueryInterface
,
1420 PixelFormatInfo_AddRef
,
1421 PixelFormatInfo_Release
,
1422 PixelFormatInfo_GetComponentType
,
1423 PixelFormatInfo_GetCLSID
,
1424 PixelFormatInfo_GetSigningStatus
,
1425 PixelFormatInfo_GetAuthor
,
1426 PixelFormatInfo_GetVendorGUID
,
1427 PixelFormatInfo_GetVersion
,
1428 PixelFormatInfo_GetSpecVersion
,
1429 PixelFormatInfo_GetFriendlyName
,
1430 PixelFormatInfo_GetFormatGUID
,
1431 PixelFormatInfo_GetColorContext
,
1432 PixelFormatInfo_GetBitsPerPixel
,
1433 PixelFormatInfo_GetChannelCount
,
1434 PixelFormatInfo_GetChannelMask
,
1435 PixelFormatInfo_SupportsTransparency
,
1436 PixelFormatInfo_GetNumericRepresentation
1439 static HRESULT
PixelFormatInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
1441 PixelFormatInfo
*This
;
1443 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(PixelFormatInfo
));
1446 RegCloseKey(classkey
);
1447 return E_OUTOFMEMORY
;
1450 This
->IWICPixelFormatInfo2_iface
.lpVtbl
= &PixelFormatInfo_Vtbl
;
1452 This
->classkey
= classkey
;
1453 memcpy(&This
->clsid
, clsid
, sizeof(CLSID
));
1455 *ppIInfo
= (IWICComponentInfo
*)This
;
1461 IWICMetadataReaderInfo IWICMetadataReaderInfo_iface
;
1465 } MetadataReaderInfo
;
1467 static inline MetadataReaderInfo
*impl_from_IWICMetadataReaderInfo(IWICMetadataReaderInfo
*iface
)
1469 return CONTAINING_RECORD(iface
, MetadataReaderInfo
, IWICMetadataReaderInfo_iface
);
1472 static HRESULT WINAPI
MetadataReaderInfo_QueryInterface(IWICMetadataReaderInfo
*iface
,
1473 REFIID riid
, void **ppv
)
1475 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1477 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(riid
), ppv
);
1479 if (!ppv
) return E_INVALIDARG
;
1481 if (IsEqualIID(&IID_IUnknown
, riid
) ||
1482 IsEqualIID(&IID_IWICComponentInfo
, riid
) ||
1483 IsEqualIID(&IID_IWICMetadataHandlerInfo
, riid
) ||
1484 IsEqualIID(&IID_IWICMetadataReaderInfo
, riid
))
1491 return E_NOINTERFACE
;
1494 IUnknown_AddRef((IUnknown
*)*ppv
);
1498 static ULONG WINAPI
MetadataReaderInfo_AddRef(IWICMetadataReaderInfo
*iface
)
1500 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1501 ULONG ref
= InterlockedIncrement(&This
->ref
);
1503 TRACE("(%p) refcount=%u\n", iface
, ref
);
1507 static ULONG WINAPI
MetadataReaderInfo_Release(IWICMetadataReaderInfo
*iface
)
1509 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1510 ULONG ref
= InterlockedDecrement(&This
->ref
);
1512 TRACE("(%p) refcount=%u\n", iface
, ref
);
1516 RegCloseKey(This
->classkey
);
1517 HeapFree(GetProcessHeap(), 0, This
);
1522 static HRESULT WINAPI
MetadataReaderInfo_GetComponentType(IWICMetadataReaderInfo
*iface
,
1523 WICComponentType
*type
)
1525 TRACE("(%p,%p)\n", iface
, type
);
1527 if (!type
) return E_INVALIDARG
;
1528 *type
= WICMetadataReader
;
1532 static HRESULT WINAPI
MetadataReaderInfo_GetCLSID(IWICMetadataReaderInfo
*iface
,
1535 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1537 TRACE("(%p,%p)\n", iface
, clsid
);
1539 if (!clsid
) return E_INVALIDARG
;
1540 *clsid
= This
->clsid
;
1544 static HRESULT WINAPI
MetadataReaderInfo_GetSigningStatus(IWICMetadataReaderInfo
*iface
,
1547 FIXME("(%p,%p): stub\n", iface
, status
);
1551 static HRESULT WINAPI
MetadataReaderInfo_GetAuthor(IWICMetadataReaderInfo
*iface
,
1552 UINT length
, WCHAR
*author
, UINT
*actual_length
)
1554 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1556 TRACE("(%p,%u,%p,%p)\n", iface
, length
, author
, actual_length
);
1558 return ComponentInfo_GetStringValue(This
->classkey
, author_valuename
,
1559 length
, author
, actual_length
);
1562 static HRESULT WINAPI
MetadataReaderInfo_GetVendorGUID(IWICMetadataReaderInfo
*iface
,
1565 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1567 TRACE("(%p,%p)\n", iface
, vendor
);
1569 return ComponentInfo_GetGUIDValue(This
->classkey
, vendor_valuename
, vendor
);
1572 static HRESULT WINAPI
MetadataReaderInfo_GetVersion(IWICMetadataReaderInfo
*iface
,
1573 UINT length
, WCHAR
*version
, UINT
*actual_length
)
1575 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1577 TRACE("(%p,%u,%p,%p)\n", iface
, length
, version
, actual_length
);
1579 return ComponentInfo_GetStringValue(This
->classkey
, version_valuename
,
1580 length
, version
, actual_length
);
1583 static HRESULT WINAPI
MetadataReaderInfo_GetSpecVersion(IWICMetadataReaderInfo
*iface
,
1584 UINT length
, WCHAR
*version
, UINT
*actual_length
)
1586 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1588 TRACE("(%p,%u,%p,%p)\n", iface
, length
, version
, actual_length
);
1590 return ComponentInfo_GetStringValue(This
->classkey
, specversion_valuename
,
1591 length
, version
, actual_length
);
1594 static HRESULT WINAPI
MetadataReaderInfo_GetFriendlyName(IWICMetadataReaderInfo
*iface
,
1595 UINT length
, WCHAR
*name
, UINT
*actual_length
)
1597 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1599 TRACE("(%p,%u,%p,%p)\n", iface
, length
, name
, actual_length
);
1601 return ComponentInfo_GetStringValue(This
->classkey
, friendlyname_valuename
,
1602 length
, name
, actual_length
);
1605 static HRESULT WINAPI
MetadataReaderInfo_GetMetadataFormat(IWICMetadataReaderInfo
*iface
,
1608 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1609 TRACE("(%p,%p)\n", iface
, format
);
1610 return ComponentInfo_GetGUIDValue(This
->classkey
, metadataformat_valuename
, format
);
1613 static HRESULT WINAPI
MetadataReaderInfo_GetContainerFormats(IWICMetadataReaderInfo
*iface
,
1614 UINT length
, GUID
*formats
, UINT
*actual_length
)
1616 if (!actual_length
) return E_INVALIDARG
;
1618 FIXME("(%p,%u,%p,%p): stub\n", iface
, length
, formats
, actual_length
);
1622 static HRESULT WINAPI
MetadataReaderInfo_GetDeviceManufacturer(IWICMetadataReaderInfo
*iface
,
1623 UINT length
, WCHAR
*manufacturer
, UINT
*actual_length
)
1625 FIXME("(%p,%u,%p,%p): stub\n", iface
, length
, manufacturer
, actual_length
);
1629 static HRESULT WINAPI
MetadataReaderInfo_GetDeviceModels(IWICMetadataReaderInfo
*iface
,
1630 UINT length
, WCHAR
*models
, UINT
*actual_length
)
1632 FIXME("(%p,%u,%p,%p): stub\n", iface
, length
, models
, actual_length
);
1636 static HRESULT WINAPI
MetadataReaderInfo_DoesRequireFullStream(IWICMetadataReaderInfo
*iface
,
1639 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1640 TRACE("(%p,%p)\n", iface
, param
);
1641 return ComponentInfo_GetDWORDValue(This
->classkey
, requiresfullstream_valuename
, (DWORD
*)param
);
1644 static HRESULT WINAPI
MetadataReaderInfo_DoesSupportPadding(IWICMetadataReaderInfo
*iface
,
1647 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1648 TRACE("(%p,%p)\n", iface
, param
);
1649 return ComponentInfo_GetDWORDValue(This
->classkey
, supportspadding_valuename
, (DWORD
*)param
);
1652 static HRESULT WINAPI
MetadataReaderInfo_DoesRequireFixedSize(IWICMetadataReaderInfo
*iface
,
1655 FIXME("(%p,%p): stub\n", iface
, param
);
1659 static HRESULT WINAPI
MetadataReaderInfo_GetPatterns(IWICMetadataReaderInfo
*iface
,
1660 REFGUID container
, UINT length
, WICMetadataPattern
*pattern
, UINT
*count
, UINT
*actual_length
)
1662 if (!actual_length
) return E_INVALIDARG
;
1664 FIXME("(%p,%s,%u,%p,%p,%p): stub\n", iface
, debugstr_guid(container
), length
, pattern
, count
, actual_length
);
1668 static HRESULT WINAPI
MetadataReaderInfo_MatchesPattern(IWICMetadataReaderInfo
*iface
,
1669 REFGUID container
, IStream
*stream
, BOOL
*matches
)
1671 FIXME("(%p,%s,%p,%p): stub\n", iface
, debugstr_guid(container
), stream
, matches
);
1675 static HRESULT WINAPI
MetadataReaderInfo_CreateInstance(IWICMetadataReaderInfo
*iface
,
1676 IWICMetadataReader
**reader
)
1678 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1680 TRACE("(%p,%p)\n", iface
, reader
);
1682 return CoCreateInstance(&This
->clsid
, NULL
, CLSCTX_INPROC_SERVER
,
1683 &IID_IWICMetadataReader
, (void **)reader
);
1686 static const IWICMetadataReaderInfoVtbl MetadataReaderInfo_Vtbl
= {
1687 MetadataReaderInfo_QueryInterface
,
1688 MetadataReaderInfo_AddRef
,
1689 MetadataReaderInfo_Release
,
1690 MetadataReaderInfo_GetComponentType
,
1691 MetadataReaderInfo_GetCLSID
,
1692 MetadataReaderInfo_GetSigningStatus
,
1693 MetadataReaderInfo_GetAuthor
,
1694 MetadataReaderInfo_GetVendorGUID
,
1695 MetadataReaderInfo_GetVersion
,
1696 MetadataReaderInfo_GetSpecVersion
,
1697 MetadataReaderInfo_GetFriendlyName
,
1698 MetadataReaderInfo_GetMetadataFormat
,
1699 MetadataReaderInfo_GetContainerFormats
,
1700 MetadataReaderInfo_GetDeviceManufacturer
,
1701 MetadataReaderInfo_GetDeviceModels
,
1702 MetadataReaderInfo_DoesRequireFullStream
,
1703 MetadataReaderInfo_DoesSupportPadding
,
1704 MetadataReaderInfo_DoesRequireFixedSize
,
1705 MetadataReaderInfo_GetPatterns
,
1706 MetadataReaderInfo_MatchesPattern
,
1707 MetadataReaderInfo_CreateInstance
1710 static HRESULT
MetadataReaderInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**info
)
1712 MetadataReaderInfo
*This
;
1714 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
1717 RegCloseKey(classkey
);
1718 return E_OUTOFMEMORY
;
1721 This
->IWICMetadataReaderInfo_iface
.lpVtbl
= &MetadataReaderInfo_Vtbl
;
1723 This
->classkey
= classkey
;
1724 This
->clsid
= *clsid
;
1726 *info
= (IWICComponentInfo
*)This
;
1730 static const WCHAR clsid_keyname
[] = {'C','L','S','I','D',0};
1731 static const WCHAR instance_keyname
[] = {'I','n','s','t','a','n','c','e',0};
1734 WICComponentType type
;
1736 HRESULT (*constructor
)(HKEY
,REFCLSID
,IWICComponentInfo
**);
1739 static const struct category categories
[] = {
1740 {WICDecoder
, &CATID_WICBitmapDecoders
, BitmapDecoderInfo_Constructor
},
1741 {WICEncoder
, &CATID_WICBitmapEncoders
, BitmapEncoderInfo_Constructor
},
1742 {WICPixelFormatConverter
, &CATID_WICFormatConverters
, FormatConverterInfo_Constructor
},
1743 {WICPixelFormat
, &CATID_WICPixelFormats
, PixelFormatInfo_Constructor
},
1744 {WICMetadataReader
, &CATID_WICMetadataReader
, MetadataReaderInfo_Constructor
},
1748 HRESULT
CreateComponentInfo(REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
1754 WCHAR guidstring
[39];
1756 const struct category
*category
;
1760 res
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, clsid_keyname
, 0, KEY_READ
, &clsidkey
);
1761 if (res
!= ERROR_SUCCESS
)
1762 return HRESULT_FROM_WIN32(res
);
1764 for (category
=categories
; category
->type
; category
++)
1766 StringFromGUID2(category
->catid
, guidstring
, 39);
1767 res
= RegOpenKeyExW(clsidkey
, guidstring
, 0, KEY_READ
, &catidkey
);
1768 if (res
== ERROR_SUCCESS
)
1770 res
= RegOpenKeyExW(catidkey
, instance_keyname
, 0, KEY_READ
, &instancekey
);
1771 if (res
== ERROR_SUCCESS
)
1773 StringFromGUID2(clsid
, guidstring
, 39);
1774 res
= RegOpenKeyExW(instancekey
, guidstring
, 0, KEY_READ
, &classkey
);
1775 if (res
== ERROR_SUCCESS
)
1777 RegCloseKey(classkey
);
1780 RegCloseKey(instancekey
);
1782 RegCloseKey(catidkey
);
1789 res
= RegOpenKeyExW(clsidkey
, guidstring
, 0, KEY_READ
, &classkey
);
1790 if (res
== ERROR_SUCCESS
)
1791 hr
= category
->constructor(classkey
, clsid
, ppIInfo
);
1793 hr
= HRESULT_FROM_WIN32(res
);
1797 FIXME("%s is not supported\n", wine_dbgstr_guid(clsid
));
1801 RegCloseKey(clsidkey
);
1807 IEnumUnknown IEnumUnknown_iface
;
1809 struct list objects
;
1810 struct list
*cursor
;
1811 CRITICAL_SECTION lock
; /* Must be held when reading or writing cursor */
1814 static inline ComponentEnum
*impl_from_IEnumUnknown(IEnumUnknown
*iface
)
1816 return CONTAINING_RECORD(iface
, ComponentEnum
, IEnumUnknown_iface
);
1822 } ComponentEnumItem
;
1824 static const IEnumUnknownVtbl ComponentEnumVtbl
;
1826 static HRESULT WINAPI
ComponentEnum_QueryInterface(IEnumUnknown
*iface
, REFIID iid
,
1829 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1830 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
1832 if (!ppv
) return E_INVALIDARG
;
1834 if (IsEqualIID(&IID_IUnknown
, iid
) ||
1835 IsEqualIID(&IID_IEnumUnknown
, iid
))
1837 *ppv
= &This
->IEnumUnknown_iface
;
1842 return E_NOINTERFACE
;
1845 IUnknown_AddRef((IUnknown
*)*ppv
);
1849 static ULONG WINAPI
ComponentEnum_AddRef(IEnumUnknown
*iface
)
1851 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1852 ULONG ref
= InterlockedIncrement(&This
->ref
);
1854 TRACE("(%p) refcount=%u\n", iface
, ref
);
1859 static ULONG WINAPI
ComponentEnum_Release(IEnumUnknown
*iface
)
1861 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1862 ULONG ref
= InterlockedDecrement(&This
->ref
);
1863 ComponentEnumItem
*cursor
, *cursor2
;
1865 TRACE("(%p) refcount=%u\n", iface
, ref
);
1869 LIST_FOR_EACH_ENTRY_SAFE(cursor
, cursor2
, &This
->objects
, ComponentEnumItem
, entry
)
1871 IUnknown_Release(cursor
->unk
);
1872 list_remove(&cursor
->entry
);
1873 HeapFree(GetProcessHeap(), 0, cursor
);
1875 This
->lock
.DebugInfo
->Spare
[0] = 0;
1876 DeleteCriticalSection(&This
->lock
);
1877 HeapFree(GetProcessHeap(), 0, This
);
1883 static HRESULT WINAPI
ComponentEnum_Next(IEnumUnknown
*iface
, ULONG celt
,
1884 IUnknown
**rgelt
, ULONG
*pceltFetched
)
1886 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1887 ULONG num_fetched
=0;
1888 ComponentEnumItem
*item
;
1891 TRACE("(%p,%u,%p,%p)\n", iface
, celt
, rgelt
, pceltFetched
);
1893 EnterCriticalSection(&This
->lock
);
1894 while (num_fetched
<celt
)
1901 item
= LIST_ENTRY(This
->cursor
, ComponentEnumItem
, entry
);
1902 IUnknown_AddRef(item
->unk
);
1903 rgelt
[num_fetched
] = item
->unk
;
1905 This
->cursor
= list_next(&This
->objects
, This
->cursor
);
1907 LeaveCriticalSection(&This
->lock
);
1909 *pceltFetched
= num_fetched
;
1913 static HRESULT WINAPI
ComponentEnum_Skip(IEnumUnknown
*iface
, ULONG celt
)
1915 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1919 TRACE("(%p,%u)\n", iface
, celt
);
1921 EnterCriticalSection(&This
->lock
);
1922 for (i
=0; i
<celt
; i
++)
1929 This
->cursor
= list_next(&This
->objects
, This
->cursor
);
1931 LeaveCriticalSection(&This
->lock
);
1935 static HRESULT WINAPI
ComponentEnum_Reset(IEnumUnknown
*iface
)
1937 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1939 TRACE("(%p)\n", iface
);
1941 EnterCriticalSection(&This
->lock
);
1942 This
->cursor
= list_head(&This
->objects
);
1943 LeaveCriticalSection(&This
->lock
);
1947 static HRESULT WINAPI
ComponentEnum_Clone(IEnumUnknown
*iface
, IEnumUnknown
**ppenum
)
1949 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1950 ComponentEnum
*new_enum
;
1951 ComponentEnumItem
*old_item
, *new_item
;
1953 struct list
*old_cursor
;
1955 new_enum
= HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnum
));
1959 return E_OUTOFMEMORY
;
1962 new_enum
->IEnumUnknown_iface
.lpVtbl
= &ComponentEnumVtbl
;
1964 new_enum
->cursor
= NULL
;
1965 list_init(&new_enum
->objects
);
1966 InitializeCriticalSection(&new_enum
->lock
);
1967 new_enum
->lock
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": ComponentEnum.lock");
1969 EnterCriticalSection(&This
->lock
);
1970 old_cursor
= This
->cursor
;
1971 LeaveCriticalSection(&This
->lock
);
1973 LIST_FOR_EACH_ENTRY(old_item
, &This
->objects
, ComponentEnumItem
, entry
)
1975 new_item
= HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnumItem
));
1978 ret
= E_OUTOFMEMORY
;
1981 new_item
->unk
= old_item
->unk
;
1982 list_add_tail(&new_enum
->objects
, &new_item
->entry
);
1983 IUnknown_AddRef(new_item
->unk
);
1984 if (&old_item
->entry
== old_cursor
) new_enum
->cursor
= &new_item
->entry
;
1989 IEnumUnknown_Release(&new_enum
->IEnumUnknown_iface
);
1993 *ppenum
= &new_enum
->IEnumUnknown_iface
;
1998 static const IEnumUnknownVtbl ComponentEnumVtbl
= {
1999 ComponentEnum_QueryInterface
,
2000 ComponentEnum_AddRef
,
2001 ComponentEnum_Release
,
2004 ComponentEnum_Reset
,
2008 HRESULT
CreateComponentEnumerator(DWORD componentTypes
, DWORD options
, IEnumUnknown
**ppIEnumUnknown
)
2010 ComponentEnum
*This
;
2011 ComponentEnumItem
*item
;
2012 const struct category
*category
;
2013 HKEY clsidkey
, catidkey
, instancekey
;
2014 WCHAR guidstring
[39];
2020 if (options
) FIXME("ignoring flags %x\n", options
);
2022 res
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, clsid_keyname
, 0, KEY_READ
, &clsidkey
);
2023 if (res
!= ERROR_SUCCESS
)
2024 return HRESULT_FROM_WIN32(res
);
2026 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnum
));
2029 RegCloseKey(clsidkey
);
2030 return E_OUTOFMEMORY
;
2033 This
->IEnumUnknown_iface
.lpVtbl
= &ComponentEnumVtbl
;
2035 list_init(&This
->objects
);
2036 InitializeCriticalSection(&This
->lock
);
2037 This
->lock
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": ComponentEnum.lock");
2039 for (category
=categories
; category
->type
&& hr
== S_OK
; category
++)
2041 if ((category
->type
& componentTypes
) == 0) continue;
2042 StringFromGUID2(category
->catid
, guidstring
, 39);
2043 res
= RegOpenKeyExW(clsidkey
, guidstring
, 0, KEY_READ
, &catidkey
);
2044 if (res
== ERROR_SUCCESS
)
2046 res
= RegOpenKeyExW(catidkey
, instance_keyname
, 0, KEY_READ
, &instancekey
);
2047 if (res
== ERROR_SUCCESS
)
2052 DWORD guidstring_size
= 39;
2053 res
= RegEnumKeyExW(instancekey
, i
, guidstring
, &guidstring_size
, NULL
, NULL
, NULL
, NULL
);
2054 if (res
!= ERROR_SUCCESS
) break;
2056 item
= HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnumItem
));
2057 if (!item
) { hr
= E_OUTOFMEMORY
; break; }
2059 hr
= CLSIDFromString(guidstring
, &clsid
);
2062 hr
= CreateComponentInfo(&clsid
, (IWICComponentInfo
**)&item
->unk
);
2064 list_add_tail(&This
->objects
, &item
->entry
);
2069 HeapFree(GetProcessHeap(), 0, item
);
2073 RegCloseKey(instancekey
);
2075 RegCloseKey(catidkey
);
2077 if (res
!= ERROR_SUCCESS
&& res
!= ERROR_NO_MORE_ITEMS
)
2078 hr
= HRESULT_FROM_WIN32(res
);
2080 RegCloseKey(clsidkey
);
2084 IEnumUnknown_Reset(&This
->IEnumUnknown_iface
);
2085 *ppIEnumUnknown
= &This
->IEnumUnknown_iface
;
2089 *ppIEnumUnknown
= NULL
;
2090 IEnumUnknown_Release(&This
->IEnumUnknown_iface
);
2096 HRESULT WINAPI
WICConvertBitmapSource(REFWICPixelFormatGUID dstFormat
, IWICBitmapSource
*pISrc
, IWICBitmapSource
**ppIDst
)
2099 IEnumUnknown
*enumconverters
;
2100 IUnknown
*unkconverterinfo
;
2101 IWICFormatConverterInfo
*converterinfo
=NULL
;
2102 IWICFormatConverter
*converter
=NULL
;
2104 WCHAR srcformatstr
[39], dstformatstr
[39];
2108 res
= IWICBitmapSource_GetPixelFormat(pISrc
, &srcFormat
);
2109 if (FAILED(res
)) return res
;
2111 if (IsEqualGUID(&srcFormat
, dstFormat
))
2113 IWICBitmapSource_AddRef(pISrc
);
2118 StringFromGUID2(&srcFormat
, srcformatstr
, 39);
2119 StringFromGUID2(dstFormat
, dstformatstr
, 39);
2121 res
= CreateComponentEnumerator(WICPixelFormatConverter
, 0, &enumconverters
);
2122 if (FAILED(res
)) return res
;
2126 res
= IEnumUnknown_Next(enumconverters
, 1, &unkconverterinfo
, &num_fetched
);
2130 res
= IUnknown_QueryInterface(unkconverterinfo
, &IID_IWICFormatConverterInfo
, (void**)&converterinfo
);
2134 canconvert
= ConverterSupportsFormat(converterinfo
, srcformatstr
);
2137 canconvert
= ConverterSupportsFormat(converterinfo
, dstformatstr
);
2141 res
= IWICFormatConverterInfo_CreateInstance(converterinfo
, &converter
);
2144 res
= IWICFormatConverter_CanConvert(converter
, &srcFormat
, dstFormat
, &canconvert
);
2146 if (SUCCEEDED(res
) && canconvert
)
2147 res
= IWICFormatConverter_Initialize(converter
, pISrc
, dstFormat
, WICBitmapDitherTypeNone
,
2148 NULL
, 0.0, WICBitmapPaletteTypeCustom
);
2150 if (FAILED(res
) || !canconvert
)
2154 IWICFormatConverter_Release(converter
);
2161 IWICFormatConverterInfo_Release(converterinfo
);
2164 IUnknown_Release(unkconverterinfo
);
2170 IEnumUnknown_Release(enumconverters
);
2174 res
= IWICFormatConverter_QueryInterface(converter
, &IID_IWICBitmapSource
, (void **)ppIDst
);
2175 IWICFormatConverter_Release(converter
);
2180 FIXME("cannot convert %s to %s\n", debugstr_guid(&srcFormat
), debugstr_guid(dstFormat
));
2182 return WINCODEC_ERR_COMPONENTNOTFOUND
;