2 * Copyright 2009 Vincent Povirk for CodeWeavers
3 * Copyright 2012 Dmitry Timoshkov
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include "wincodecsdk.h"
33 #include "wincodecs_private.h"
35 #include "wine/debug.h"
36 #include "wine/unicode.h"
37 #include "wine/list.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs
);
41 static const WCHAR mimetypes_valuename
[] = {'M','i','m','e','T','y','p','e','s',0};
42 static const WCHAR author_valuename
[] = {'A','u','t','h','o','r',0};
43 static const WCHAR friendlyname_valuename
[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
44 static const WCHAR pixelformats_keyname
[] = {'P','i','x','e','l','F','o','r','m','a','t','s',0};
45 static const WCHAR formats_keyname
[] = {'F','o','r','m','a','t','s',0};
46 static const WCHAR containerformat_valuename
[] = {'C','o','n','t','a','i','n','e','r','F','o','r','m','a','t',0};
47 static const WCHAR metadataformat_valuename
[] = {'M','e','t','a','d','a','t','a','F','o','r','m','a','t',0};
48 static const WCHAR vendor_valuename
[] = {'V','e','n','d','o','r',0};
49 static const WCHAR version_valuename
[] = {'V','e','r','s','i','o','n',0};
50 static const WCHAR specversion_valuename
[] = {'S','p','e','c','V','e','r','s','i','o','n',0};
51 static const WCHAR bitsperpixel_valuename
[] = {'B','i','t','L','e','n','g','t','h',0};
52 static const WCHAR channelcount_valuename
[] = {'C','h','a','n','n','e','l','C','o','u','n','t',0};
53 static const WCHAR channelmasks_keyname
[] = {'C','h','a','n','n','e','l','M','a','s','k','s',0};
54 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};
55 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};
56 static const WCHAR requiresfullstream_valuename
[] = {'R','e','q','u','i','r','e','s','F','u','l','l','S','t','r','e','a','m',0};
57 static const WCHAR supportspadding_valuename
[] = {'S','u','p','p','o','r','t','s','P','a','d','d','i','n','g',0};
59 static HRESULT
ComponentInfo_GetStringValue(HKEY classkey
, LPCWSTR value
,
60 UINT buffer_size
, WCHAR
*buffer
, UINT
*actual_size
)
63 DWORD cbdata
=buffer_size
* sizeof(WCHAR
);
68 ret
= RegGetValueW(classkey
, NULL
, value
, RRF_RT_REG_SZ
|RRF_NOEXPAND
, NULL
,
71 if (ret
== ERROR_FILE_NOT_FOUND
)
77 if (ret
== 0 || ret
== ERROR_MORE_DATA
)
78 *actual_size
= cbdata
/sizeof(WCHAR
);
80 if (!buffer
&& buffer_size
!= 0)
81 /* Yes, native returns the correct size in this case. */
84 if (ret
== ERROR_MORE_DATA
)
85 return WINCODEC_ERR_INSUFFICIENTBUFFER
;
87 return HRESULT_FROM_WIN32(ret
);
90 static HRESULT
ComponentInfo_GetGUIDValue(HKEY classkey
, LPCWSTR value
,
94 WCHAR guid_string
[39];
95 DWORD cbdata
= sizeof(guid_string
);
101 ret
= RegGetValueW(classkey
, NULL
, value
, RRF_RT_REG_SZ
|RRF_NOEXPAND
, NULL
,
102 guid_string
, &cbdata
);
104 if (ret
!= ERROR_SUCCESS
)
105 return HRESULT_FROM_WIN32(ret
);
107 if (cbdata
< sizeof(guid_string
))
109 ERR("incomplete GUID value\n");
113 hr
= CLSIDFromString(guid_string
, result
);
118 static HRESULT
ComponentInfo_GetDWORDValue(HKEY classkey
, LPCWSTR value
,
122 DWORD cbdata
= sizeof(DWORD
);
127 ret
= RegGetValueW(classkey
, NULL
, value
, RRF_RT_DWORD
, NULL
,
130 if (ret
== ERROR_FILE_NOT_FOUND
)
136 return HRESULT_FROM_WIN32(ret
);
139 static HRESULT
ComponentInfo_GetGuidList(HKEY classkey
, LPCWSTR subkeyname
,
140 UINT buffersize
, GUID
*buffer
, UINT
*actual_size
)
145 WCHAR guid_string
[39];
146 DWORD guid_string_size
;
152 ret
= RegOpenKeyExW(classkey
, subkeyname
, 0, KEY_READ
, &subkey
);
153 if (ret
!= ERROR_SUCCESS
) return HRESULT_FROM_WIN32(ret
);
158 guid_string_size
= 39;
159 while (items_returned
< buffersize
)
161 ret
= RegEnumKeyExW(subkey
, items_returned
, guid_string
,
162 &guid_string_size
, NULL
, NULL
, NULL
, NULL
);
164 if (ret
!= ERROR_SUCCESS
)
166 hr
= HRESULT_FROM_WIN32(ret
);
170 if (guid_string_size
!= 38)
176 hr
= CLSIDFromString(guid_string
, &buffer
[items_returned
]);
181 guid_string_size
= 39;
184 if (ret
== ERROR_NO_MORE_ITEMS
)
187 *actual_size
= items_returned
;
191 ret
= RegQueryInfoKeyW(subkey
, NULL
, NULL
, NULL
, actual_size
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
192 if (ret
!= ERROR_SUCCESS
)
193 hr
= HRESULT_FROM_WIN32(ret
);
202 IWICBitmapDecoderInfo IWICBitmapDecoderInfo_iface
;
208 static inline BitmapDecoderInfo
*impl_from_IWICBitmapDecoderInfo(IWICBitmapDecoderInfo
*iface
)
210 return CONTAINING_RECORD(iface
, BitmapDecoderInfo
, IWICBitmapDecoderInfo_iface
);
213 static HRESULT WINAPI
BitmapDecoderInfo_QueryInterface(IWICBitmapDecoderInfo
*iface
, REFIID iid
,
216 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
217 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
219 if (!ppv
) return E_INVALIDARG
;
221 if (IsEqualIID(&IID_IUnknown
, iid
) ||
222 IsEqualIID(&IID_IWICComponentInfo
, iid
) ||
223 IsEqualIID(&IID_IWICBitmapCodecInfo
, iid
) ||
224 IsEqualIID(&IID_IWICBitmapDecoderInfo
,iid
))
231 return E_NOINTERFACE
;
234 IUnknown_AddRef((IUnknown
*)*ppv
);
238 static ULONG WINAPI
BitmapDecoderInfo_AddRef(IWICBitmapDecoderInfo
*iface
)
240 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
241 ULONG ref
= InterlockedIncrement(&This
->ref
);
243 TRACE("(%p) refcount=%u\n", iface
, ref
);
248 static ULONG WINAPI
BitmapDecoderInfo_Release(IWICBitmapDecoderInfo
*iface
)
250 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
251 ULONG ref
= InterlockedDecrement(&This
->ref
);
253 TRACE("(%p) refcount=%u\n", iface
, ref
);
257 RegCloseKey(This
->classkey
);
258 HeapFree(GetProcessHeap(), 0, This
);
264 static HRESULT WINAPI
BitmapDecoderInfo_GetComponentType(IWICBitmapDecoderInfo
*iface
,
265 WICComponentType
*pType
)
267 TRACE("(%p,%p)\n", iface
, pType
);
268 if (!pType
) return E_INVALIDARG
;
273 static HRESULT WINAPI
BitmapDecoderInfo_GetCLSID(IWICBitmapDecoderInfo
*iface
, CLSID
*pclsid
)
275 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
276 TRACE("(%p,%p)\n", iface
, pclsid
);
281 memcpy(pclsid
, &This
->clsid
, sizeof(CLSID
));
286 static HRESULT WINAPI
BitmapDecoderInfo_GetSigningStatus(IWICBitmapDecoderInfo
*iface
, DWORD
*pStatus
)
288 FIXME("(%p,%p): stub\n", iface
, pStatus
);
292 static HRESULT WINAPI
BitmapDecoderInfo_GetAuthor(IWICBitmapDecoderInfo
*iface
, UINT cchAuthor
,
293 WCHAR
*wzAuthor
, UINT
*pcchActual
)
295 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
297 TRACE("(%p,%u,%p,%p)\n", iface
, cchAuthor
, wzAuthor
, pcchActual
);
299 return ComponentInfo_GetStringValue(This
->classkey
, author_valuename
,
300 cchAuthor
, wzAuthor
, pcchActual
);
303 static HRESULT WINAPI
BitmapDecoderInfo_GetVendorGUID(IWICBitmapDecoderInfo
*iface
, GUID
*pguidVendor
)
305 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
307 TRACE("(%p,%p)\n", iface
, pguidVendor
);
309 return ComponentInfo_GetGUIDValue(This
->classkey
, vendor_valuename
, pguidVendor
);
312 static HRESULT WINAPI
BitmapDecoderInfo_GetVersion(IWICBitmapDecoderInfo
*iface
, UINT cchVersion
,
313 WCHAR
*wzVersion
, UINT
*pcchActual
)
315 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
317 TRACE("(%p,%u,%p,%p)\n", iface
, cchVersion
, wzVersion
, pcchActual
);
319 return ComponentInfo_GetStringValue(This
->classkey
, version_valuename
,
320 cchVersion
, wzVersion
, pcchActual
);
323 static HRESULT WINAPI
BitmapDecoderInfo_GetSpecVersion(IWICBitmapDecoderInfo
*iface
, UINT cchSpecVersion
,
324 WCHAR
*wzSpecVersion
, UINT
*pcchActual
)
326 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
328 TRACE("(%p,%u,%p,%p)\n", iface
, cchSpecVersion
, wzSpecVersion
, pcchActual
);
330 return ComponentInfo_GetStringValue(This
->classkey
, specversion_valuename
,
331 cchSpecVersion
, wzSpecVersion
, pcchActual
);
334 static HRESULT WINAPI
BitmapDecoderInfo_GetFriendlyName(IWICBitmapDecoderInfo
*iface
, UINT cchFriendlyName
,
335 WCHAR
*wzFriendlyName
, UINT
*pcchActual
)
337 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
339 TRACE("(%p,%u,%p,%p)\n", iface
, cchFriendlyName
, wzFriendlyName
, pcchActual
);
341 return ComponentInfo_GetStringValue(This
->classkey
, friendlyname_valuename
,
342 cchFriendlyName
, wzFriendlyName
, pcchActual
);
345 static HRESULT WINAPI
BitmapDecoderInfo_GetContainerFormat(IWICBitmapDecoderInfo
*iface
,
346 GUID
*pguidContainerFormat
)
348 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
349 TRACE("(%p,%p)\n", iface
, pguidContainerFormat
);
350 return ComponentInfo_GetGUIDValue(This
->classkey
, containerformat_valuename
, pguidContainerFormat
);
353 static HRESULT WINAPI
BitmapDecoderInfo_GetPixelFormats(IWICBitmapDecoderInfo
*iface
,
354 UINT cFormats
, GUID
*pguidPixelFormats
, UINT
*pcActual
)
356 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
357 TRACE("(%p,%u,%p,%p)\n", iface
, cFormats
, pguidPixelFormats
, pcActual
);
358 return ComponentInfo_GetGuidList(This
->classkey
, formats_keyname
, cFormats
, pguidPixelFormats
, pcActual
);
361 static HRESULT WINAPI
BitmapDecoderInfo_GetColorManagementVersion(IWICBitmapDecoderInfo
*iface
,
362 UINT cchColorManagementVersion
, WCHAR
*wzColorManagementVersion
, UINT
*pcchActual
)
364 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchColorManagementVersion
, wzColorManagementVersion
, pcchActual
);
368 static HRESULT WINAPI
BitmapDecoderInfo_GetDeviceManufacturer(IWICBitmapDecoderInfo
*iface
,
369 UINT cchDeviceManufacturer
, WCHAR
*wzDeviceManufacturer
, UINT
*pcchActual
)
371 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchDeviceManufacturer
, wzDeviceManufacturer
, pcchActual
);
375 static HRESULT WINAPI
BitmapDecoderInfo_GetDeviceModels(IWICBitmapDecoderInfo
*iface
,
376 UINT cchDeviceModels
, WCHAR
*wzDeviceModels
, UINT
*pcchActual
)
378 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchDeviceModels
, wzDeviceModels
, pcchActual
);
382 static HRESULT WINAPI
BitmapDecoderInfo_GetMimeTypes(IWICBitmapDecoderInfo
*iface
,
383 UINT cchMimeTypes
, WCHAR
*wzMimeTypes
, UINT
*pcchActual
)
385 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
387 TRACE("(%p,%u,%p,%p)\n", iface
, cchMimeTypes
, wzMimeTypes
, pcchActual
);
389 return ComponentInfo_GetStringValue(This
->classkey
, mimetypes_valuename
,
390 cchMimeTypes
, wzMimeTypes
, pcchActual
);
393 static HRESULT WINAPI
BitmapDecoderInfo_GetFileExtensions(IWICBitmapDecoderInfo
*iface
,
394 UINT cchFileExtensions
, WCHAR
*wzFileExtensions
, UINT
*pcchActual
)
396 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchFileExtensions
, wzFileExtensions
, pcchActual
);
400 static HRESULT WINAPI
BitmapDecoderInfo_DoesSupportAnimation(IWICBitmapDecoderInfo
*iface
,
401 BOOL
*pfSupportAnimation
)
403 FIXME("(%p,%p): stub\n", iface
, pfSupportAnimation
);
407 static HRESULT WINAPI
BitmapDecoderInfo_DoesSupportChromaKey(IWICBitmapDecoderInfo
*iface
,
408 BOOL
*pfSupportChromaKey
)
410 FIXME("(%p,%p): stub\n", iface
, pfSupportChromaKey
);
414 static HRESULT WINAPI
BitmapDecoderInfo_DoesSupportLossless(IWICBitmapDecoderInfo
*iface
,
415 BOOL
*pfSupportLossless
)
417 FIXME("(%p,%p): stub\n", iface
, pfSupportLossless
);
421 static HRESULT WINAPI
BitmapDecoderInfo_DoesSupportMultiframe(IWICBitmapDecoderInfo
*iface
,
422 BOOL
*pfSupportMultiframe
)
424 FIXME("(%p,%p): stub\n", iface
, pfSupportMultiframe
);
428 static HRESULT WINAPI
BitmapDecoderInfo_MatchesMimeType(IWICBitmapDecoderInfo
*iface
,
429 LPCWSTR wzMimeType
, BOOL
*pfMatches
)
431 FIXME("(%p,%s,%p): stub\n", iface
, debugstr_w(wzMimeType
), pfMatches
);
435 static HRESULT WINAPI
BitmapDecoderInfo_GetPatterns(IWICBitmapDecoderInfo
*iface
,
436 UINT cbSizePatterns
, WICBitmapPattern
*pPatterns
, UINT
*pcPatterns
, UINT
*pcbPatternsActual
)
438 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
439 UINT pattern_count
=0, patterns_size
=0;
440 WCHAR subkeyname
[11];
442 HKEY patternskey
, patternkey
;
443 static const WCHAR uintformatW
[] = {'%','u',0};
444 static const WCHAR patternsW
[] = {'P','a','t','t','e','r','n','s',0};
445 static const WCHAR positionW
[] = {'P','o','s','i','t','i','o','n',0};
446 static const WCHAR lengthW
[] = {'L','e','n','g','t','h',0};
447 static const WCHAR patternW
[] = {'P','a','t','t','e','r','n',0};
448 static const WCHAR maskW
[] = {'M','a','s','k',0};
449 static const WCHAR endofstreamW
[] = {'E','n','d','O','f','S','t','r','e','a','m',0};
452 BYTE
*bPatterns
=(BYTE
*)pPatterns
;
453 DWORD length
, valuesize
;
455 TRACE("(%p,%i,%p,%p,%p)\n", iface
, cbSizePatterns
, pPatterns
, pcPatterns
, pcbPatternsActual
);
457 res
= RegOpenKeyExW(This
->classkey
, patternsW
, 0, KEY_READ
, &patternskey
);
458 if (res
!= ERROR_SUCCESS
) return HRESULT_FROM_WIN32(res
);
460 res
= RegQueryInfoKeyW(patternskey
, NULL
, NULL
, NULL
, &pattern_count
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
461 if (res
== ERROR_SUCCESS
)
463 patterns_size
= pattern_count
* sizeof(WICBitmapPattern
);
465 for (i
=0; i
<pattern_count
; i
++)
467 snprintfW(subkeyname
, 11, uintformatW
, i
);
468 res
= RegOpenKeyExW(patternskey
, subkeyname
, 0, KEY_READ
, &patternkey
);
469 if (res
== ERROR_SUCCESS
)
471 valuesize
= sizeof(ULONG
);
472 res
= RegGetValueW(patternkey
, NULL
, lengthW
, RRF_RT_DWORD
, NULL
,
473 &length
, &valuesize
);
474 patterns_size
+= length
*2;
476 if ((cbSizePatterns
>= patterns_size
) && (res
== ERROR_SUCCESS
))
478 pPatterns
[i
].Length
= length
;
480 pPatterns
[i
].EndOfStream
= 0;
481 valuesize
= sizeof(BOOL
);
482 RegGetValueW(patternkey
, NULL
, endofstreamW
, RRF_RT_DWORD
, NULL
,
483 &pPatterns
[i
].EndOfStream
, &valuesize
);
485 pPatterns
[i
].Position
.QuadPart
= 0;
486 valuesize
= sizeof(ULARGE_INTEGER
);
487 res
= RegGetValueW(patternkey
, NULL
, positionW
, RRF_RT_DWORD
|RRF_RT_QWORD
, NULL
,
488 &pPatterns
[i
].Position
, &valuesize
);
490 if (res
== ERROR_SUCCESS
)
492 pPatterns
[i
].Pattern
= bPatterns
+patterns_size
-length
*2;
494 res
= RegGetValueW(patternkey
, NULL
, patternW
, RRF_RT_REG_BINARY
, NULL
,
495 pPatterns
[i
].Pattern
, &valuesize
);
498 if (res
== ERROR_SUCCESS
)
500 pPatterns
[i
].Mask
= bPatterns
+patterns_size
-length
;
502 res
= RegGetValueW(patternkey
, NULL
, maskW
, RRF_RT_REG_BINARY
, NULL
,
503 pPatterns
[i
].Mask
, &valuesize
);
507 RegCloseKey(patternkey
);
509 if (res
!= ERROR_SUCCESS
)
511 hr
= HRESULT_FROM_WIN32(res
);
516 else hr
= HRESULT_FROM_WIN32(res
);
518 RegCloseKey(patternskey
);
522 *pcPatterns
= pattern_count
;
523 *pcbPatternsActual
= patterns_size
;
524 if (pPatterns
&& cbSizePatterns
< patterns_size
)
525 hr
= WINCODEC_ERR_INSUFFICIENTBUFFER
;
531 static HRESULT WINAPI
BitmapDecoderInfo_MatchesPattern(IWICBitmapDecoderInfo
*iface
,
532 IStream
*pIStream
, BOOL
*pfMatches
)
534 WICBitmapPattern
*patterns
;
535 UINT pattern_count
=0, patterns_size
=0;
541 LARGE_INTEGER seekpos
;
543 TRACE("(%p,%p,%p)\n", iface
, pIStream
, pfMatches
);
545 hr
= BitmapDecoderInfo_GetPatterns(iface
, 0, NULL
, &pattern_count
, &patterns_size
);
546 if (FAILED(hr
)) return hr
;
548 patterns
= HeapAlloc(GetProcessHeap(), 0, patterns_size
);
549 if (!patterns
) return E_OUTOFMEMORY
;
551 hr
= BitmapDecoderInfo_GetPatterns(iface
, patterns_size
, patterns
, &pattern_count
, &patterns_size
);
552 if (FAILED(hr
)) goto end
;
554 for (i
=0; i
<pattern_count
; i
++)
556 if (datasize
< patterns
[i
].Length
)
558 HeapFree(GetProcessHeap(), 0, data
);
559 datasize
= patterns
[i
].Length
;
560 data
= HeapAlloc(GetProcessHeap(), 0, patterns
[i
].Length
);
568 if (patterns
[i
].EndOfStream
)
569 seekpos
.QuadPart
= -patterns
[i
].Position
.QuadPart
;
571 seekpos
.QuadPart
= patterns
[i
].Position
.QuadPart
;
572 hr
= IStream_Seek(pIStream
, seekpos
, patterns
[i
].EndOfStream
? STREAM_SEEK_END
: STREAM_SEEK_SET
, NULL
);
573 if (hr
== STG_E_INVALIDFUNCTION
) continue; /* before start of stream */
574 if (FAILED(hr
)) break;
576 hr
= IStream_Read(pIStream
, data
, patterns
[i
].Length
, &bytesread
);
577 if (hr
== S_FALSE
|| (hr
== S_OK
&& bytesread
!= patterns
[i
].Length
)) /* past end of stream */
579 if (FAILED(hr
)) break;
581 for (pos
=0; pos
<patterns
[i
].Length
; pos
++)
583 if ((data
[pos
] & patterns
[i
].Mask
[pos
]) != patterns
[i
].Pattern
[pos
])
586 if (pos
== patterns
[i
].Length
) /* matches pattern */
594 if (i
== pattern_count
) /* does not match any pattern */
601 HeapFree(GetProcessHeap(), 0, patterns
);
602 HeapFree(GetProcessHeap(), 0, data
);
607 static HRESULT WINAPI
BitmapDecoderInfo_CreateInstance(IWICBitmapDecoderInfo
*iface
,
608 IWICBitmapDecoder
**ppIBitmapDecoder
)
610 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
612 TRACE("(%p,%p)\n", iface
, ppIBitmapDecoder
);
614 return CoCreateInstance(&This
->clsid
, NULL
, CLSCTX_INPROC_SERVER
,
615 &IID_IWICBitmapDecoder
, (void**)ppIBitmapDecoder
);
618 static const IWICBitmapDecoderInfoVtbl BitmapDecoderInfo_Vtbl
= {
619 BitmapDecoderInfo_QueryInterface
,
620 BitmapDecoderInfo_AddRef
,
621 BitmapDecoderInfo_Release
,
622 BitmapDecoderInfo_GetComponentType
,
623 BitmapDecoderInfo_GetCLSID
,
624 BitmapDecoderInfo_GetSigningStatus
,
625 BitmapDecoderInfo_GetAuthor
,
626 BitmapDecoderInfo_GetVendorGUID
,
627 BitmapDecoderInfo_GetVersion
,
628 BitmapDecoderInfo_GetSpecVersion
,
629 BitmapDecoderInfo_GetFriendlyName
,
630 BitmapDecoderInfo_GetContainerFormat
,
631 BitmapDecoderInfo_GetPixelFormats
,
632 BitmapDecoderInfo_GetColorManagementVersion
,
633 BitmapDecoderInfo_GetDeviceManufacturer
,
634 BitmapDecoderInfo_GetDeviceModels
,
635 BitmapDecoderInfo_GetMimeTypes
,
636 BitmapDecoderInfo_GetFileExtensions
,
637 BitmapDecoderInfo_DoesSupportAnimation
,
638 BitmapDecoderInfo_DoesSupportChromaKey
,
639 BitmapDecoderInfo_DoesSupportLossless
,
640 BitmapDecoderInfo_DoesSupportMultiframe
,
641 BitmapDecoderInfo_MatchesMimeType
,
642 BitmapDecoderInfo_GetPatterns
,
643 BitmapDecoderInfo_MatchesPattern
,
644 BitmapDecoderInfo_CreateInstance
647 static HRESULT
BitmapDecoderInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
649 BitmapDecoderInfo
*This
;
651 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapDecoderInfo
));
654 RegCloseKey(classkey
);
655 return E_OUTOFMEMORY
;
658 This
->IWICBitmapDecoderInfo_iface
.lpVtbl
= &BitmapDecoderInfo_Vtbl
;
660 This
->classkey
= classkey
;
661 memcpy(&This
->clsid
, clsid
, sizeof(CLSID
));
663 *ppIInfo
= (IWICComponentInfo
*)This
;
668 IWICBitmapEncoderInfo IWICBitmapEncoderInfo_iface
;
674 static inline BitmapEncoderInfo
*impl_from_IWICBitmapEncoderInfo(IWICBitmapEncoderInfo
*iface
)
676 return CONTAINING_RECORD(iface
, BitmapEncoderInfo
, IWICBitmapEncoderInfo_iface
);
679 static HRESULT WINAPI
BitmapEncoderInfo_QueryInterface(IWICBitmapEncoderInfo
*iface
, REFIID iid
,
682 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
683 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
685 if (!ppv
) return E_INVALIDARG
;
687 if (IsEqualIID(&IID_IUnknown
, iid
) ||
688 IsEqualIID(&IID_IWICComponentInfo
, iid
) ||
689 IsEqualIID(&IID_IWICBitmapCodecInfo
, iid
) ||
690 IsEqualIID(&IID_IWICBitmapEncoderInfo
,iid
))
697 return E_NOINTERFACE
;
700 IUnknown_AddRef((IUnknown
*)*ppv
);
704 static ULONG WINAPI
BitmapEncoderInfo_AddRef(IWICBitmapEncoderInfo
*iface
)
706 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
707 ULONG ref
= InterlockedIncrement(&This
->ref
);
709 TRACE("(%p) refcount=%u\n", iface
, ref
);
714 static ULONG WINAPI
BitmapEncoderInfo_Release(IWICBitmapEncoderInfo
*iface
)
716 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
717 ULONG ref
= InterlockedDecrement(&This
->ref
);
719 TRACE("(%p) refcount=%u\n", iface
, ref
);
723 RegCloseKey(This
->classkey
);
724 HeapFree(GetProcessHeap(), 0, This
);
730 static HRESULT WINAPI
BitmapEncoderInfo_GetComponentType(IWICBitmapEncoderInfo
*iface
,
731 WICComponentType
*pType
)
733 TRACE("(%p,%p)\n", iface
, pType
);
734 if (!pType
) return E_INVALIDARG
;
739 static HRESULT WINAPI
BitmapEncoderInfo_GetCLSID(IWICBitmapEncoderInfo
*iface
, CLSID
*pclsid
)
741 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
742 TRACE("(%p,%p)\n", iface
, pclsid
);
747 memcpy(pclsid
, &This
->clsid
, sizeof(CLSID
));
752 static HRESULT WINAPI
BitmapEncoderInfo_GetSigningStatus(IWICBitmapEncoderInfo
*iface
, DWORD
*pStatus
)
754 FIXME("(%p,%p): stub\n", iface
, pStatus
);
758 static HRESULT WINAPI
BitmapEncoderInfo_GetAuthor(IWICBitmapEncoderInfo
*iface
, UINT cchAuthor
,
759 WCHAR
*wzAuthor
, UINT
*pcchActual
)
761 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
763 TRACE("(%p,%u,%p,%p)\n", iface
, cchAuthor
, wzAuthor
, pcchActual
);
765 return ComponentInfo_GetStringValue(This
->classkey
, author_valuename
,
766 cchAuthor
, wzAuthor
, pcchActual
);
769 static HRESULT WINAPI
BitmapEncoderInfo_GetVendorGUID(IWICBitmapEncoderInfo
*iface
, GUID
*pguidVendor
)
771 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
773 TRACE("(%p,%p)\n", iface
, pguidVendor
);
775 return ComponentInfo_GetGUIDValue(This
->classkey
, vendor_valuename
, pguidVendor
);
778 static HRESULT WINAPI
BitmapEncoderInfo_GetVersion(IWICBitmapEncoderInfo
*iface
, UINT cchVersion
,
779 WCHAR
*wzVersion
, UINT
*pcchActual
)
781 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
783 TRACE("(%p,%u,%p,%p)\n", iface
, cchVersion
, wzVersion
, pcchActual
);
785 return ComponentInfo_GetStringValue(This
->classkey
, version_valuename
,
786 cchVersion
, wzVersion
, pcchActual
);
789 static HRESULT WINAPI
BitmapEncoderInfo_GetSpecVersion(IWICBitmapEncoderInfo
*iface
, UINT cchSpecVersion
,
790 WCHAR
*wzSpecVersion
, UINT
*pcchActual
)
792 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
794 TRACE("(%p,%u,%p,%p)\n", iface
, cchSpecVersion
, wzSpecVersion
, pcchActual
);
796 return ComponentInfo_GetStringValue(This
->classkey
, specversion_valuename
,
797 cchSpecVersion
, wzSpecVersion
, pcchActual
);
800 static HRESULT WINAPI
BitmapEncoderInfo_GetFriendlyName(IWICBitmapEncoderInfo
*iface
, UINT cchFriendlyName
,
801 WCHAR
*wzFriendlyName
, UINT
*pcchActual
)
803 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
805 TRACE("(%p,%u,%p,%p)\n", iface
, cchFriendlyName
, wzFriendlyName
, pcchActual
);
807 return ComponentInfo_GetStringValue(This
->classkey
, friendlyname_valuename
,
808 cchFriendlyName
, wzFriendlyName
, pcchActual
);
811 static HRESULT WINAPI
BitmapEncoderInfo_GetContainerFormat(IWICBitmapEncoderInfo
*iface
,
812 GUID
*pguidContainerFormat
)
814 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
815 TRACE("(%p,%p)\n", iface
, pguidContainerFormat
);
816 return ComponentInfo_GetGUIDValue(This
->classkey
, containerformat_valuename
, pguidContainerFormat
);
819 static HRESULT WINAPI
BitmapEncoderInfo_GetPixelFormats(IWICBitmapEncoderInfo
*iface
,
820 UINT cFormats
, GUID
*pguidPixelFormats
, UINT
*pcActual
)
822 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
823 TRACE("(%p,%u,%p,%p)\n", iface
, cFormats
, pguidPixelFormats
, pcActual
);
824 return ComponentInfo_GetGuidList(This
->classkey
, formats_keyname
, cFormats
, pguidPixelFormats
, pcActual
);
827 static HRESULT WINAPI
BitmapEncoderInfo_GetColorManagementVersion(IWICBitmapEncoderInfo
*iface
,
828 UINT cchColorManagementVersion
, WCHAR
*wzColorManagementVersion
, UINT
*pcchActual
)
830 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchColorManagementVersion
, wzColorManagementVersion
, pcchActual
);
834 static HRESULT WINAPI
BitmapEncoderInfo_GetDeviceManufacturer(IWICBitmapEncoderInfo
*iface
,
835 UINT cchDeviceManufacturer
, WCHAR
*wzDeviceManufacturer
, UINT
*pcchActual
)
837 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchDeviceManufacturer
, wzDeviceManufacturer
, pcchActual
);
841 static HRESULT WINAPI
BitmapEncoderInfo_GetDeviceModels(IWICBitmapEncoderInfo
*iface
,
842 UINT cchDeviceModels
, WCHAR
*wzDeviceModels
, UINT
*pcchActual
)
844 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchDeviceModels
, wzDeviceModels
, pcchActual
);
848 static HRESULT WINAPI
BitmapEncoderInfo_GetMimeTypes(IWICBitmapEncoderInfo
*iface
,
849 UINT cchMimeTypes
, WCHAR
*wzMimeTypes
, UINT
*pcchActual
)
851 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
853 TRACE("(%p,%u,%p,%p)\n", iface
, cchMimeTypes
, wzMimeTypes
, pcchActual
);
855 return ComponentInfo_GetStringValue(This
->classkey
, mimetypes_valuename
,
856 cchMimeTypes
, wzMimeTypes
, pcchActual
);
859 static HRESULT WINAPI
BitmapEncoderInfo_GetFileExtensions(IWICBitmapEncoderInfo
*iface
,
860 UINT cchFileExtensions
, WCHAR
*wzFileExtensions
, UINT
*pcchActual
)
862 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchFileExtensions
, wzFileExtensions
, pcchActual
);
866 static HRESULT WINAPI
BitmapEncoderInfo_DoesSupportAnimation(IWICBitmapEncoderInfo
*iface
,
867 BOOL
*pfSupportAnimation
)
869 FIXME("(%p,%p): stub\n", iface
, pfSupportAnimation
);
873 static HRESULT WINAPI
BitmapEncoderInfo_DoesSupportChromaKey(IWICBitmapEncoderInfo
*iface
,
874 BOOL
*pfSupportChromaKey
)
876 FIXME("(%p,%p): stub\n", iface
, pfSupportChromaKey
);
880 static HRESULT WINAPI
BitmapEncoderInfo_DoesSupportLossless(IWICBitmapEncoderInfo
*iface
,
881 BOOL
*pfSupportLossless
)
883 FIXME("(%p,%p): stub\n", iface
, pfSupportLossless
);
887 static HRESULT WINAPI
BitmapEncoderInfo_DoesSupportMultiframe(IWICBitmapEncoderInfo
*iface
,
888 BOOL
*pfSupportMultiframe
)
890 FIXME("(%p,%p): stub\n", iface
, pfSupportMultiframe
);
894 static HRESULT WINAPI
BitmapEncoderInfo_MatchesMimeType(IWICBitmapEncoderInfo
*iface
,
895 LPCWSTR wzMimeType
, BOOL
*pfMatches
)
897 FIXME("(%p,%s,%p): stub\n", iface
, debugstr_w(wzMimeType
), pfMatches
);
901 static HRESULT WINAPI
BitmapEncoderInfo_CreateInstance(IWICBitmapEncoderInfo
*iface
,
902 IWICBitmapEncoder
**ppIBitmapEncoder
)
904 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
906 TRACE("(%p,%p)\n", iface
, ppIBitmapEncoder
);
908 return CoCreateInstance(&This
->clsid
, NULL
, CLSCTX_INPROC_SERVER
,
909 &IID_IWICBitmapEncoder
, (void**)ppIBitmapEncoder
);
912 static const IWICBitmapEncoderInfoVtbl BitmapEncoderInfo_Vtbl
= {
913 BitmapEncoderInfo_QueryInterface
,
914 BitmapEncoderInfo_AddRef
,
915 BitmapEncoderInfo_Release
,
916 BitmapEncoderInfo_GetComponentType
,
917 BitmapEncoderInfo_GetCLSID
,
918 BitmapEncoderInfo_GetSigningStatus
,
919 BitmapEncoderInfo_GetAuthor
,
920 BitmapEncoderInfo_GetVendorGUID
,
921 BitmapEncoderInfo_GetVersion
,
922 BitmapEncoderInfo_GetSpecVersion
,
923 BitmapEncoderInfo_GetFriendlyName
,
924 BitmapEncoderInfo_GetContainerFormat
,
925 BitmapEncoderInfo_GetPixelFormats
,
926 BitmapEncoderInfo_GetColorManagementVersion
,
927 BitmapEncoderInfo_GetDeviceManufacturer
,
928 BitmapEncoderInfo_GetDeviceModels
,
929 BitmapEncoderInfo_GetMimeTypes
,
930 BitmapEncoderInfo_GetFileExtensions
,
931 BitmapEncoderInfo_DoesSupportAnimation
,
932 BitmapEncoderInfo_DoesSupportChromaKey
,
933 BitmapEncoderInfo_DoesSupportLossless
,
934 BitmapEncoderInfo_DoesSupportMultiframe
,
935 BitmapEncoderInfo_MatchesMimeType
,
936 BitmapEncoderInfo_CreateInstance
939 static HRESULT
BitmapEncoderInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
941 BitmapEncoderInfo
*This
;
943 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapEncoderInfo
));
946 RegCloseKey(classkey
);
947 return E_OUTOFMEMORY
;
950 This
->IWICBitmapEncoderInfo_iface
.lpVtbl
= &BitmapEncoderInfo_Vtbl
;
952 This
->classkey
= classkey
;
953 memcpy(&This
->clsid
, clsid
, sizeof(CLSID
));
955 *ppIInfo
= (IWICComponentInfo
*)This
;
960 IWICFormatConverterInfo IWICFormatConverterInfo_iface
;
964 } FormatConverterInfo
;
966 static inline FormatConverterInfo
*impl_from_IWICFormatConverterInfo(IWICFormatConverterInfo
*iface
)
968 return CONTAINING_RECORD(iface
, FormatConverterInfo
, IWICFormatConverterInfo_iface
);
971 static HRESULT WINAPI
FormatConverterInfo_QueryInterface(IWICFormatConverterInfo
*iface
, REFIID iid
,
974 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
975 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
977 if (!ppv
) return E_INVALIDARG
;
979 if (IsEqualIID(&IID_IUnknown
, iid
) ||
980 IsEqualIID(&IID_IWICComponentInfo
, iid
) ||
981 IsEqualIID(&IID_IWICFormatConverterInfo
,iid
))
988 return E_NOINTERFACE
;
991 IUnknown_AddRef((IUnknown
*)*ppv
);
995 static ULONG WINAPI
FormatConverterInfo_AddRef(IWICFormatConverterInfo
*iface
)
997 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
998 ULONG ref
= InterlockedIncrement(&This
->ref
);
1000 TRACE("(%p) refcount=%u\n", iface
, ref
);
1005 static ULONG WINAPI
FormatConverterInfo_Release(IWICFormatConverterInfo
*iface
)
1007 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1008 ULONG ref
= InterlockedDecrement(&This
->ref
);
1010 TRACE("(%p) refcount=%u\n", iface
, ref
);
1014 RegCloseKey(This
->classkey
);
1015 HeapFree(GetProcessHeap(), 0, This
);
1021 static HRESULT WINAPI
FormatConverterInfo_GetComponentType(IWICFormatConverterInfo
*iface
,
1022 WICComponentType
*pType
)
1024 TRACE("(%p,%p)\n", iface
, pType
);
1025 if (!pType
) return E_INVALIDARG
;
1026 *pType
= WICPixelFormatConverter
;
1030 static HRESULT WINAPI
FormatConverterInfo_GetCLSID(IWICFormatConverterInfo
*iface
, CLSID
*pclsid
)
1032 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1033 TRACE("(%p,%p)\n", iface
, pclsid
);
1036 return E_INVALIDARG
;
1038 memcpy(pclsid
, &This
->clsid
, sizeof(CLSID
));
1043 static HRESULT WINAPI
FormatConverterInfo_GetSigningStatus(IWICFormatConverterInfo
*iface
, DWORD
*pStatus
)
1045 FIXME("(%p,%p): stub\n", iface
, pStatus
);
1049 static HRESULT WINAPI
FormatConverterInfo_GetAuthor(IWICFormatConverterInfo
*iface
, UINT cchAuthor
,
1050 WCHAR
*wzAuthor
, UINT
*pcchActual
)
1052 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1054 TRACE("(%p,%u,%p,%p)\n", iface
, cchAuthor
, wzAuthor
, pcchActual
);
1056 return ComponentInfo_GetStringValue(This
->classkey
, author_valuename
,
1057 cchAuthor
, wzAuthor
, pcchActual
);
1060 static HRESULT WINAPI
FormatConverterInfo_GetVendorGUID(IWICFormatConverterInfo
*iface
, GUID
*pguidVendor
)
1062 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1064 TRACE("(%p,%p)\n", iface
, pguidVendor
);
1066 return ComponentInfo_GetGUIDValue(This
->classkey
, vendor_valuename
, pguidVendor
);
1069 static HRESULT WINAPI
FormatConverterInfo_GetVersion(IWICFormatConverterInfo
*iface
, UINT cchVersion
,
1070 WCHAR
*wzVersion
, UINT
*pcchActual
)
1072 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1074 TRACE("(%p,%u,%p,%p)\n", iface
, cchVersion
, wzVersion
, pcchActual
);
1076 return ComponentInfo_GetStringValue(This
->classkey
, version_valuename
,
1077 cchVersion
, wzVersion
, pcchActual
);
1080 static HRESULT WINAPI
FormatConverterInfo_GetSpecVersion(IWICFormatConverterInfo
*iface
, UINT cchSpecVersion
,
1081 WCHAR
*wzSpecVersion
, UINT
*pcchActual
)
1083 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1085 TRACE("(%p,%u,%p,%p)\n", iface
, cchSpecVersion
, wzSpecVersion
, pcchActual
);
1087 return ComponentInfo_GetStringValue(This
->classkey
, specversion_valuename
,
1088 cchSpecVersion
, wzSpecVersion
, pcchActual
);
1091 static HRESULT WINAPI
FormatConverterInfo_GetFriendlyName(IWICFormatConverterInfo
*iface
, UINT cchFriendlyName
,
1092 WCHAR
*wzFriendlyName
, UINT
*pcchActual
)
1094 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1096 TRACE("(%p,%u,%p,%p)\n", iface
, cchFriendlyName
, wzFriendlyName
, pcchActual
);
1098 return ComponentInfo_GetStringValue(This
->classkey
, friendlyname_valuename
,
1099 cchFriendlyName
, wzFriendlyName
, pcchActual
);
1102 static HRESULT WINAPI
FormatConverterInfo_GetPixelFormats(IWICFormatConverterInfo
*iface
,
1103 UINT cFormats
, GUID
*pguidPixelFormats
, UINT
*pcActual
)
1105 FIXME("(%p,%u,%p,%p): stub\n", iface
, cFormats
, pguidPixelFormats
, pcActual
);
1109 static HRESULT WINAPI
FormatConverterInfo_CreateInstance(IWICFormatConverterInfo
*iface
,
1110 IWICFormatConverter
**ppIFormatConverter
)
1112 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1114 TRACE("(%p,%p)\n", iface
, ppIFormatConverter
);
1116 return CoCreateInstance(&This
->clsid
, NULL
, CLSCTX_INPROC_SERVER
,
1117 &IID_IWICFormatConverter
, (void**)ppIFormatConverter
);
1120 static BOOL
ConverterSupportsFormat(IWICFormatConverterInfo
*iface
, const WCHAR
*formatguid
)
1123 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1124 HKEY formats_key
, guid_key
;
1126 /* Avoid testing using IWICFormatConverter_GetPixelFormats because that
1127 would be O(n). A registry test should do better. */
1129 res
= RegOpenKeyExW(This
->classkey
, pixelformats_keyname
, 0, KEY_READ
, &formats_key
);
1130 if (res
!= ERROR_SUCCESS
) return FALSE
;
1132 res
= RegOpenKeyExW(formats_key
, formatguid
, 0, KEY_READ
, &guid_key
);
1133 if (res
== ERROR_SUCCESS
) RegCloseKey(guid_key
);
1135 RegCloseKey(formats_key
);
1137 return (res
== ERROR_SUCCESS
);
1140 static const IWICFormatConverterInfoVtbl FormatConverterInfo_Vtbl
= {
1141 FormatConverterInfo_QueryInterface
,
1142 FormatConverterInfo_AddRef
,
1143 FormatConverterInfo_Release
,
1144 FormatConverterInfo_GetComponentType
,
1145 FormatConverterInfo_GetCLSID
,
1146 FormatConverterInfo_GetSigningStatus
,
1147 FormatConverterInfo_GetAuthor
,
1148 FormatConverterInfo_GetVendorGUID
,
1149 FormatConverterInfo_GetVersion
,
1150 FormatConverterInfo_GetSpecVersion
,
1151 FormatConverterInfo_GetFriendlyName
,
1152 FormatConverterInfo_GetPixelFormats
,
1153 FormatConverterInfo_CreateInstance
1156 static HRESULT
FormatConverterInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
1158 FormatConverterInfo
*This
;
1160 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(FormatConverterInfo
));
1163 RegCloseKey(classkey
);
1164 return E_OUTOFMEMORY
;
1167 This
->IWICFormatConverterInfo_iface
.lpVtbl
= &FormatConverterInfo_Vtbl
;
1169 This
->classkey
= classkey
;
1170 memcpy(&This
->clsid
, clsid
, sizeof(CLSID
));
1172 *ppIInfo
= (IWICComponentInfo
*)This
;
1177 IWICPixelFormatInfo2 IWICPixelFormatInfo2_iface
;
1183 static inline PixelFormatInfo
*impl_from_IWICPixelFormatInfo2(IWICPixelFormatInfo2
*iface
)
1185 return CONTAINING_RECORD(iface
, PixelFormatInfo
, IWICPixelFormatInfo2_iface
);
1188 static HRESULT WINAPI
PixelFormatInfo_QueryInterface(IWICPixelFormatInfo2
*iface
, REFIID iid
,
1191 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1192 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
1194 if (!ppv
) return E_INVALIDARG
;
1196 if (IsEqualIID(&IID_IUnknown
, iid
) ||
1197 IsEqualIID(&IID_IWICComponentInfo
, iid
) ||
1198 IsEqualIID(&IID_IWICPixelFormatInfo
, iid
) ||
1199 IsEqualIID(&IID_IWICPixelFormatInfo2
,iid
))
1206 return E_NOINTERFACE
;
1209 IUnknown_AddRef((IUnknown
*)*ppv
);
1213 static ULONG WINAPI
PixelFormatInfo_AddRef(IWICPixelFormatInfo2
*iface
)
1215 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1216 ULONG ref
= InterlockedIncrement(&This
->ref
);
1218 TRACE("(%p) refcount=%u\n", iface
, ref
);
1223 static ULONG WINAPI
PixelFormatInfo_Release(IWICPixelFormatInfo2
*iface
)
1225 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1226 ULONG ref
= InterlockedDecrement(&This
->ref
);
1228 TRACE("(%p) refcount=%u\n", iface
, ref
);
1232 RegCloseKey(This
->classkey
);
1233 HeapFree(GetProcessHeap(), 0, This
);
1239 static HRESULT WINAPI
PixelFormatInfo_GetComponentType(IWICPixelFormatInfo2
*iface
,
1240 WICComponentType
*pType
)
1242 TRACE("(%p,%p)\n", iface
, pType
);
1243 if (!pType
) return E_INVALIDARG
;
1244 *pType
= WICPixelFormat
;
1248 static HRESULT WINAPI
PixelFormatInfo_GetCLSID(IWICPixelFormatInfo2
*iface
, CLSID
*pclsid
)
1250 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1251 TRACE("(%p,%p)\n", iface
, pclsid
);
1254 return E_INVALIDARG
;
1256 memcpy(pclsid
, &This
->clsid
, sizeof(CLSID
));
1261 static HRESULT WINAPI
PixelFormatInfo_GetSigningStatus(IWICPixelFormatInfo2
*iface
, DWORD
*pStatus
)
1263 TRACE("(%p,%p)\n", iface
, pStatus
);
1266 return E_INVALIDARG
;
1268 /* Pixel formats don't require code, so they are considered signed. */
1269 *pStatus
= WICComponentSigned
;
1274 static HRESULT WINAPI
PixelFormatInfo_GetAuthor(IWICPixelFormatInfo2
*iface
, UINT cchAuthor
,
1275 WCHAR
*wzAuthor
, UINT
*pcchActual
)
1277 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1279 TRACE("(%p,%u,%p,%p)\n", iface
, cchAuthor
, wzAuthor
, pcchActual
);
1281 return ComponentInfo_GetStringValue(This
->classkey
, author_valuename
,
1282 cchAuthor
, wzAuthor
, pcchActual
);
1285 static HRESULT WINAPI
PixelFormatInfo_GetVendorGUID(IWICPixelFormatInfo2
*iface
, GUID
*pguidVendor
)
1287 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1289 TRACE("(%p,%p)\n", iface
, pguidVendor
);
1291 return ComponentInfo_GetGUIDValue(This
->classkey
, vendor_valuename
, pguidVendor
);
1294 static HRESULT WINAPI
PixelFormatInfo_GetVersion(IWICPixelFormatInfo2
*iface
, UINT cchVersion
,
1295 WCHAR
*wzVersion
, UINT
*pcchActual
)
1297 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1299 TRACE("(%p,%u,%p,%p)\n", iface
, cchVersion
, wzVersion
, pcchActual
);
1301 return ComponentInfo_GetStringValue(This
->classkey
, version_valuename
,
1302 cchVersion
, wzVersion
, pcchActual
);
1305 static HRESULT WINAPI
PixelFormatInfo_GetSpecVersion(IWICPixelFormatInfo2
*iface
, UINT cchSpecVersion
,
1306 WCHAR
*wzSpecVersion
, UINT
*pcchActual
)
1308 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1310 TRACE("(%p,%u,%p,%p)\n", iface
, cchSpecVersion
, wzSpecVersion
, pcchActual
);
1312 return ComponentInfo_GetStringValue(This
->classkey
, specversion_valuename
,
1313 cchSpecVersion
, wzSpecVersion
, pcchActual
);
1316 static HRESULT WINAPI
PixelFormatInfo_GetFriendlyName(IWICPixelFormatInfo2
*iface
, UINT cchFriendlyName
,
1317 WCHAR
*wzFriendlyName
, UINT
*pcchActual
)
1319 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1321 TRACE("(%p,%u,%p,%p)\n", iface
, cchFriendlyName
, wzFriendlyName
, pcchActual
);
1323 return ComponentInfo_GetStringValue(This
->classkey
, friendlyname_valuename
,
1324 cchFriendlyName
, wzFriendlyName
, pcchActual
);
1327 static HRESULT WINAPI
PixelFormatInfo_GetFormatGUID(IWICPixelFormatInfo2
*iface
,
1330 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1331 TRACE("(%p,%p)\n", iface
, pFormat
);
1334 return E_INVALIDARG
;
1336 *pFormat
= This
->clsid
;
1341 static HRESULT WINAPI
PixelFormatInfo_GetColorContext(IWICPixelFormatInfo2
*iface
,
1342 IWICColorContext
**ppIColorContext
)
1344 FIXME("(%p,%p): stub\n", iface
, ppIColorContext
);
1348 static HRESULT WINAPI
PixelFormatInfo_GetBitsPerPixel(IWICPixelFormatInfo2
*iface
,
1349 UINT
*puiBitsPerPixel
)
1351 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1353 TRACE("(%p,%p)\n", iface
, puiBitsPerPixel
);
1355 return ComponentInfo_GetDWORDValue(This
->classkey
, bitsperpixel_valuename
, puiBitsPerPixel
);
1358 static HRESULT WINAPI
PixelFormatInfo_GetChannelCount(IWICPixelFormatInfo2
*iface
,
1359 UINT
*puiChannelCount
)
1361 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1363 TRACE("(%p,%p)\n", iface
, puiChannelCount
);
1365 return ComponentInfo_GetDWORDValue(This
->classkey
, channelcount_valuename
, puiChannelCount
);
1368 static HRESULT WINAPI
PixelFormatInfo_GetChannelMask(IWICPixelFormatInfo2
*iface
,
1369 UINT uiChannelIndex
, UINT cbMaskBuffer
, BYTE
*pbMaskBuffer
, UINT
*pcbActual
)
1371 static const WCHAR uintformatW
[] = {'%','u',0};
1372 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1376 WCHAR valuename
[11];
1379 TRACE("(%p,%u,%u,%p,%p)\n", iface
, uiChannelIndex
, cbMaskBuffer
, pbMaskBuffer
, pcbActual
);
1382 return E_INVALIDARG
;
1384 hr
= PixelFormatInfo_GetChannelCount(iface
, &channel_count
);
1386 if (SUCCEEDED(hr
) && uiChannelIndex
>= channel_count
)
1391 snprintfW(valuename
, 11, uintformatW
, uiChannelIndex
);
1393 cbData
= cbMaskBuffer
;
1395 ret
= RegGetValueW(This
->classkey
, channelmasks_keyname
, valuename
, RRF_RT_REG_BINARY
, NULL
, pbMaskBuffer
, &cbData
);
1397 if (ret
== ERROR_SUCCESS
|| ret
== ERROR_MORE_DATA
)
1398 *pcbActual
= cbData
;
1400 if (ret
== ERROR_MORE_DATA
)
1403 hr
= HRESULT_FROM_WIN32(ret
);
1409 static HRESULT WINAPI
PixelFormatInfo_SupportsTransparency(IWICPixelFormatInfo2
*iface
,
1410 BOOL
*pfSupportsTransparency
)
1412 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1414 TRACE("(%p,%p)\n", iface
, pfSupportsTransparency
);
1416 return ComponentInfo_GetDWORDValue(This
->classkey
, supportstransparency_valuename
, (DWORD
*)pfSupportsTransparency
);
1419 static HRESULT WINAPI
PixelFormatInfo_GetNumericRepresentation(IWICPixelFormatInfo2
*iface
,
1420 WICPixelFormatNumericRepresentation
*pNumericRepresentation
)
1422 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1424 TRACE("(%p,%p)\n", iface
, pNumericRepresentation
);
1426 return ComponentInfo_GetDWORDValue(This
->classkey
, numericrepresentation_valuename
, pNumericRepresentation
);
1429 static const IWICPixelFormatInfo2Vtbl PixelFormatInfo_Vtbl
= {
1430 PixelFormatInfo_QueryInterface
,
1431 PixelFormatInfo_AddRef
,
1432 PixelFormatInfo_Release
,
1433 PixelFormatInfo_GetComponentType
,
1434 PixelFormatInfo_GetCLSID
,
1435 PixelFormatInfo_GetSigningStatus
,
1436 PixelFormatInfo_GetAuthor
,
1437 PixelFormatInfo_GetVendorGUID
,
1438 PixelFormatInfo_GetVersion
,
1439 PixelFormatInfo_GetSpecVersion
,
1440 PixelFormatInfo_GetFriendlyName
,
1441 PixelFormatInfo_GetFormatGUID
,
1442 PixelFormatInfo_GetColorContext
,
1443 PixelFormatInfo_GetBitsPerPixel
,
1444 PixelFormatInfo_GetChannelCount
,
1445 PixelFormatInfo_GetChannelMask
,
1446 PixelFormatInfo_SupportsTransparency
,
1447 PixelFormatInfo_GetNumericRepresentation
1450 static HRESULT
PixelFormatInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
1452 PixelFormatInfo
*This
;
1454 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(PixelFormatInfo
));
1457 RegCloseKey(classkey
);
1458 return E_OUTOFMEMORY
;
1461 This
->IWICPixelFormatInfo2_iface
.lpVtbl
= &PixelFormatInfo_Vtbl
;
1463 This
->classkey
= classkey
;
1464 memcpy(&This
->clsid
, clsid
, sizeof(CLSID
));
1466 *ppIInfo
= (IWICComponentInfo
*)This
;
1472 IWICMetadataReaderInfo IWICMetadataReaderInfo_iface
;
1476 } MetadataReaderInfo
;
1478 static inline MetadataReaderInfo
*impl_from_IWICMetadataReaderInfo(IWICMetadataReaderInfo
*iface
)
1480 return CONTAINING_RECORD(iface
, MetadataReaderInfo
, IWICMetadataReaderInfo_iface
);
1483 static HRESULT WINAPI
MetadataReaderInfo_QueryInterface(IWICMetadataReaderInfo
*iface
,
1484 REFIID riid
, void **ppv
)
1486 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1488 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(riid
), ppv
);
1490 if (!ppv
) return E_INVALIDARG
;
1492 if (IsEqualIID(&IID_IUnknown
, riid
) ||
1493 IsEqualIID(&IID_IWICComponentInfo
, riid
) ||
1494 IsEqualIID(&IID_IWICMetadataHandlerInfo
, riid
) ||
1495 IsEqualIID(&IID_IWICMetadataReaderInfo
, riid
))
1502 return E_NOINTERFACE
;
1505 IUnknown_AddRef((IUnknown
*)*ppv
);
1509 static ULONG WINAPI
MetadataReaderInfo_AddRef(IWICMetadataReaderInfo
*iface
)
1511 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1512 ULONG ref
= InterlockedIncrement(&This
->ref
);
1514 TRACE("(%p) refcount=%u\n", iface
, ref
);
1518 static ULONG WINAPI
MetadataReaderInfo_Release(IWICMetadataReaderInfo
*iface
)
1520 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1521 ULONG ref
= InterlockedDecrement(&This
->ref
);
1523 TRACE("(%p) refcount=%u\n", iface
, ref
);
1527 RegCloseKey(This
->classkey
);
1528 HeapFree(GetProcessHeap(), 0, This
);
1533 static HRESULT WINAPI
MetadataReaderInfo_GetComponentType(IWICMetadataReaderInfo
*iface
,
1534 WICComponentType
*type
)
1536 TRACE("(%p,%p)\n", iface
, type
);
1538 if (!type
) return E_INVALIDARG
;
1539 *type
= WICMetadataReader
;
1543 static HRESULT WINAPI
MetadataReaderInfo_GetCLSID(IWICMetadataReaderInfo
*iface
,
1546 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1548 TRACE("(%p,%p)\n", iface
, clsid
);
1550 if (!clsid
) return E_INVALIDARG
;
1551 *clsid
= This
->clsid
;
1555 static HRESULT WINAPI
MetadataReaderInfo_GetSigningStatus(IWICMetadataReaderInfo
*iface
,
1558 FIXME("(%p,%p): stub\n", iface
, status
);
1562 static HRESULT WINAPI
MetadataReaderInfo_GetAuthor(IWICMetadataReaderInfo
*iface
,
1563 UINT length
, WCHAR
*author
, UINT
*actual_length
)
1565 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1567 TRACE("(%p,%u,%p,%p)\n", iface
, length
, author
, actual_length
);
1569 return ComponentInfo_GetStringValue(This
->classkey
, author_valuename
,
1570 length
, author
, actual_length
);
1573 static HRESULT WINAPI
MetadataReaderInfo_GetVendorGUID(IWICMetadataReaderInfo
*iface
,
1576 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1578 TRACE("(%p,%p)\n", iface
, vendor
);
1580 return ComponentInfo_GetGUIDValue(This
->classkey
, vendor_valuename
, vendor
);
1583 static HRESULT WINAPI
MetadataReaderInfo_GetVersion(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
, version_valuename
,
1591 length
, version
, actual_length
);
1594 static HRESULT WINAPI
MetadataReaderInfo_GetSpecVersion(IWICMetadataReaderInfo
*iface
,
1595 UINT length
, WCHAR
*version
, UINT
*actual_length
)
1597 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1599 TRACE("(%p,%u,%p,%p)\n", iface
, length
, version
, actual_length
);
1601 return ComponentInfo_GetStringValue(This
->classkey
, specversion_valuename
,
1602 length
, version
, actual_length
);
1605 static HRESULT WINAPI
MetadataReaderInfo_GetFriendlyName(IWICMetadataReaderInfo
*iface
,
1606 UINT length
, WCHAR
*name
, UINT
*actual_length
)
1608 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1610 TRACE("(%p,%u,%p,%p)\n", iface
, length
, name
, actual_length
);
1612 return ComponentInfo_GetStringValue(This
->classkey
, friendlyname_valuename
,
1613 length
, name
, actual_length
);
1616 static HRESULT WINAPI
MetadataReaderInfo_GetMetadataFormat(IWICMetadataReaderInfo
*iface
,
1619 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1620 TRACE("(%p,%p)\n", iface
, format
);
1621 return ComponentInfo_GetGUIDValue(This
->classkey
, metadataformat_valuename
, format
);
1624 static HRESULT WINAPI
MetadataReaderInfo_GetContainerFormats(IWICMetadataReaderInfo
*iface
,
1625 UINT length
, GUID
*formats
, UINT
*actual_length
)
1627 if (!actual_length
) return E_INVALIDARG
;
1629 FIXME("(%p,%u,%p,%p): stub\n", iface
, length
, formats
, actual_length
);
1633 static HRESULT WINAPI
MetadataReaderInfo_GetDeviceManufacturer(IWICMetadataReaderInfo
*iface
,
1634 UINT length
, WCHAR
*manufacturer
, UINT
*actual_length
)
1636 FIXME("(%p,%u,%p,%p): stub\n", iface
, length
, manufacturer
, actual_length
);
1640 static HRESULT WINAPI
MetadataReaderInfo_GetDeviceModels(IWICMetadataReaderInfo
*iface
,
1641 UINT length
, WCHAR
*models
, UINT
*actual_length
)
1643 FIXME("(%p,%u,%p,%p): stub\n", iface
, length
, models
, actual_length
);
1647 static HRESULT WINAPI
MetadataReaderInfo_DoesRequireFullStream(IWICMetadataReaderInfo
*iface
,
1650 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1651 TRACE("(%p,%p)\n", iface
, param
);
1652 return ComponentInfo_GetDWORDValue(This
->classkey
, requiresfullstream_valuename
, (DWORD
*)param
);
1655 static HRESULT WINAPI
MetadataReaderInfo_DoesSupportPadding(IWICMetadataReaderInfo
*iface
,
1658 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1659 TRACE("(%p,%p)\n", iface
, param
);
1660 return ComponentInfo_GetDWORDValue(This
->classkey
, supportspadding_valuename
, (DWORD
*)param
);
1663 static HRESULT WINAPI
MetadataReaderInfo_DoesRequireFixedSize(IWICMetadataReaderInfo
*iface
,
1666 FIXME("(%p,%p): stub\n", iface
, param
);
1670 static HRESULT WINAPI
MetadataReaderInfo_GetPatterns(IWICMetadataReaderInfo
*iface
,
1671 REFGUID container
, UINT length
, WICMetadataPattern
*pattern
, UINT
*count
, UINT
*actual_length
)
1673 if (!actual_length
) return E_INVALIDARG
;
1675 FIXME("(%p,%s,%u,%p,%p,%p): stub\n", iface
, debugstr_guid(container
), length
, pattern
, count
, actual_length
);
1679 static HRESULT WINAPI
MetadataReaderInfo_MatchesPattern(IWICMetadataReaderInfo
*iface
,
1680 REFGUID container
, IStream
*stream
, BOOL
*matches
)
1682 FIXME("(%p,%s,%p,%p): stub\n", iface
, debugstr_guid(container
), stream
, matches
);
1686 static HRESULT WINAPI
MetadataReaderInfo_CreateInstance(IWICMetadataReaderInfo
*iface
,
1687 IWICMetadataReader
**reader
)
1689 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1691 TRACE("(%p,%p)\n", iface
, reader
);
1693 return CoCreateInstance(&This
->clsid
, NULL
, CLSCTX_INPROC_SERVER
,
1694 &IID_IWICMetadataReader
, (void **)reader
);
1697 static const IWICMetadataReaderInfoVtbl MetadataReaderInfo_Vtbl
= {
1698 MetadataReaderInfo_QueryInterface
,
1699 MetadataReaderInfo_AddRef
,
1700 MetadataReaderInfo_Release
,
1701 MetadataReaderInfo_GetComponentType
,
1702 MetadataReaderInfo_GetCLSID
,
1703 MetadataReaderInfo_GetSigningStatus
,
1704 MetadataReaderInfo_GetAuthor
,
1705 MetadataReaderInfo_GetVendorGUID
,
1706 MetadataReaderInfo_GetVersion
,
1707 MetadataReaderInfo_GetSpecVersion
,
1708 MetadataReaderInfo_GetFriendlyName
,
1709 MetadataReaderInfo_GetMetadataFormat
,
1710 MetadataReaderInfo_GetContainerFormats
,
1711 MetadataReaderInfo_GetDeviceManufacturer
,
1712 MetadataReaderInfo_GetDeviceModels
,
1713 MetadataReaderInfo_DoesRequireFullStream
,
1714 MetadataReaderInfo_DoesSupportPadding
,
1715 MetadataReaderInfo_DoesRequireFixedSize
,
1716 MetadataReaderInfo_GetPatterns
,
1717 MetadataReaderInfo_MatchesPattern
,
1718 MetadataReaderInfo_CreateInstance
1721 static HRESULT
MetadataReaderInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**info
)
1723 MetadataReaderInfo
*This
;
1725 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
1728 RegCloseKey(classkey
);
1729 return E_OUTOFMEMORY
;
1732 This
->IWICMetadataReaderInfo_iface
.lpVtbl
= &MetadataReaderInfo_Vtbl
;
1734 This
->classkey
= classkey
;
1735 This
->clsid
= *clsid
;
1737 *info
= (IWICComponentInfo
*)This
;
1741 static const WCHAR clsid_keyname
[] = {'C','L','S','I','D',0};
1742 static const WCHAR instance_keyname
[] = {'I','n','s','t','a','n','c','e',0};
1745 WICComponentType type
;
1747 HRESULT (*constructor
)(HKEY
,REFCLSID
,IWICComponentInfo
**);
1750 static const struct category categories
[] = {
1751 {WICDecoder
, &CATID_WICBitmapDecoders
, BitmapDecoderInfo_Constructor
},
1752 {WICEncoder
, &CATID_WICBitmapEncoders
, BitmapEncoderInfo_Constructor
},
1753 {WICPixelFormatConverter
, &CATID_WICFormatConverters
, FormatConverterInfo_Constructor
},
1754 {WICPixelFormat
, &CATID_WICPixelFormats
, PixelFormatInfo_Constructor
},
1755 {WICMetadataReader
, &CATID_WICMetadataReader
, MetadataReaderInfo_Constructor
},
1759 HRESULT
CreateComponentInfo(REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
1765 WCHAR guidstring
[39];
1767 const struct category
*category
;
1771 res
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, clsid_keyname
, 0, KEY_READ
, &clsidkey
);
1772 if (res
!= ERROR_SUCCESS
)
1773 return HRESULT_FROM_WIN32(res
);
1775 for (category
=categories
; category
->type
; category
++)
1777 StringFromGUID2(category
->catid
, guidstring
, 39);
1778 res
= RegOpenKeyExW(clsidkey
, guidstring
, 0, KEY_READ
, &catidkey
);
1779 if (res
== ERROR_SUCCESS
)
1781 res
= RegOpenKeyExW(catidkey
, instance_keyname
, 0, KEY_READ
, &instancekey
);
1782 if (res
== ERROR_SUCCESS
)
1784 StringFromGUID2(clsid
, guidstring
, 39);
1785 res
= RegOpenKeyExW(instancekey
, guidstring
, 0, KEY_READ
, &classkey
);
1786 if (res
== ERROR_SUCCESS
)
1788 RegCloseKey(classkey
);
1791 RegCloseKey(instancekey
);
1793 RegCloseKey(catidkey
);
1800 res
= RegOpenKeyExW(clsidkey
, guidstring
, 0, KEY_READ
, &classkey
);
1801 if (res
== ERROR_SUCCESS
)
1802 hr
= category
->constructor(classkey
, clsid
, ppIInfo
);
1804 hr
= HRESULT_FROM_WIN32(res
);
1808 FIXME("%s is not supported\n", wine_dbgstr_guid(clsid
));
1812 RegCloseKey(clsidkey
);
1818 IEnumUnknown IEnumUnknown_iface
;
1820 struct list objects
;
1821 struct list
*cursor
;
1822 CRITICAL_SECTION lock
; /* Must be held when reading or writing cursor */
1825 static inline ComponentEnum
*impl_from_IEnumUnknown(IEnumUnknown
*iface
)
1827 return CONTAINING_RECORD(iface
, ComponentEnum
, IEnumUnknown_iface
);
1833 } ComponentEnumItem
;
1835 static const IEnumUnknownVtbl ComponentEnumVtbl
;
1837 static HRESULT WINAPI
ComponentEnum_QueryInterface(IEnumUnknown
*iface
, REFIID iid
,
1840 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1841 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
1843 if (!ppv
) return E_INVALIDARG
;
1845 if (IsEqualIID(&IID_IUnknown
, iid
) ||
1846 IsEqualIID(&IID_IEnumUnknown
, iid
))
1848 *ppv
= &This
->IEnumUnknown_iface
;
1853 return E_NOINTERFACE
;
1856 IUnknown_AddRef((IUnknown
*)*ppv
);
1860 static ULONG WINAPI
ComponentEnum_AddRef(IEnumUnknown
*iface
)
1862 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1863 ULONG ref
= InterlockedIncrement(&This
->ref
);
1865 TRACE("(%p) refcount=%u\n", iface
, ref
);
1870 static ULONG WINAPI
ComponentEnum_Release(IEnumUnknown
*iface
)
1872 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1873 ULONG ref
= InterlockedDecrement(&This
->ref
);
1874 ComponentEnumItem
*cursor
, *cursor2
;
1876 TRACE("(%p) refcount=%u\n", iface
, ref
);
1880 LIST_FOR_EACH_ENTRY_SAFE(cursor
, cursor2
, &This
->objects
, ComponentEnumItem
, entry
)
1882 IUnknown_Release(cursor
->unk
);
1883 list_remove(&cursor
->entry
);
1884 HeapFree(GetProcessHeap(), 0, cursor
);
1886 This
->lock
.DebugInfo
->Spare
[0] = 0;
1887 DeleteCriticalSection(&This
->lock
);
1888 HeapFree(GetProcessHeap(), 0, This
);
1894 static HRESULT WINAPI
ComponentEnum_Next(IEnumUnknown
*iface
, ULONG celt
,
1895 IUnknown
**rgelt
, ULONG
*pceltFetched
)
1897 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1899 ComponentEnumItem
*item
;
1902 TRACE("(%p,%u,%p,%p)\n", iface
, celt
, rgelt
, pceltFetched
);
1904 EnterCriticalSection(&This
->lock
);
1905 while (num_fetched
<celt
)
1912 item
= LIST_ENTRY(This
->cursor
, ComponentEnumItem
, entry
);
1913 IUnknown_AddRef(item
->unk
);
1914 rgelt
[num_fetched
] = item
->unk
;
1916 This
->cursor
= list_next(&This
->objects
, This
->cursor
);
1918 LeaveCriticalSection(&This
->lock
);
1920 *pceltFetched
= num_fetched
;
1924 static HRESULT WINAPI
ComponentEnum_Skip(IEnumUnknown
*iface
, ULONG celt
)
1926 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1930 TRACE("(%p,%u)\n", iface
, celt
);
1932 EnterCriticalSection(&This
->lock
);
1933 for (i
=0; i
<celt
; i
++)
1940 This
->cursor
= list_next(&This
->objects
, This
->cursor
);
1942 LeaveCriticalSection(&This
->lock
);
1946 static HRESULT WINAPI
ComponentEnum_Reset(IEnumUnknown
*iface
)
1948 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1950 TRACE("(%p)\n", iface
);
1952 EnterCriticalSection(&This
->lock
);
1953 This
->cursor
= list_head(&This
->objects
);
1954 LeaveCriticalSection(&This
->lock
);
1958 static HRESULT WINAPI
ComponentEnum_Clone(IEnumUnknown
*iface
, IEnumUnknown
**ppenum
)
1960 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1961 ComponentEnum
*new_enum
;
1962 ComponentEnumItem
*old_item
, *new_item
;
1964 struct list
*old_cursor
;
1966 new_enum
= HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnum
));
1970 return E_OUTOFMEMORY
;
1973 new_enum
->IEnumUnknown_iface
.lpVtbl
= &ComponentEnumVtbl
;
1975 new_enum
->cursor
= NULL
;
1976 list_init(&new_enum
->objects
);
1977 InitializeCriticalSection(&new_enum
->lock
);
1978 new_enum
->lock
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": ComponentEnum.lock");
1980 EnterCriticalSection(&This
->lock
);
1981 old_cursor
= This
->cursor
;
1982 LeaveCriticalSection(&This
->lock
);
1984 LIST_FOR_EACH_ENTRY(old_item
, &This
->objects
, ComponentEnumItem
, entry
)
1986 new_item
= HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnumItem
));
1989 ret
= E_OUTOFMEMORY
;
1992 new_item
->unk
= old_item
->unk
;
1993 list_add_tail(&new_enum
->objects
, &new_item
->entry
);
1994 IUnknown_AddRef(new_item
->unk
);
1995 if (&old_item
->entry
== old_cursor
) new_enum
->cursor
= &new_item
->entry
;
2000 IEnumUnknown_Release(&new_enum
->IEnumUnknown_iface
);
2004 *ppenum
= &new_enum
->IEnumUnknown_iface
;
2009 static const IEnumUnknownVtbl ComponentEnumVtbl
= {
2010 ComponentEnum_QueryInterface
,
2011 ComponentEnum_AddRef
,
2012 ComponentEnum_Release
,
2015 ComponentEnum_Reset
,
2019 HRESULT
CreateComponentEnumerator(DWORD componentTypes
, DWORD options
, IEnumUnknown
**ppIEnumUnknown
)
2021 ComponentEnum
*This
;
2022 ComponentEnumItem
*item
;
2023 const struct category
*category
;
2024 HKEY clsidkey
, catidkey
, instancekey
;
2025 WCHAR guidstring
[39];
2031 if (options
) FIXME("ignoring flags %x\n", options
);
2033 res
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, clsid_keyname
, 0, KEY_READ
, &clsidkey
);
2034 if (res
!= ERROR_SUCCESS
)
2035 return HRESULT_FROM_WIN32(res
);
2037 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnum
));
2040 RegCloseKey(clsidkey
);
2041 return E_OUTOFMEMORY
;
2044 This
->IEnumUnknown_iface
.lpVtbl
= &ComponentEnumVtbl
;
2046 list_init(&This
->objects
);
2047 InitializeCriticalSection(&This
->lock
);
2048 This
->lock
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": ComponentEnum.lock");
2050 for (category
=categories
; category
->type
&& hr
== S_OK
; category
++)
2052 if ((category
->type
& componentTypes
) == 0) continue;
2053 StringFromGUID2(category
->catid
, guidstring
, 39);
2054 res
= RegOpenKeyExW(clsidkey
, guidstring
, 0, KEY_READ
, &catidkey
);
2055 if (res
== ERROR_SUCCESS
)
2057 res
= RegOpenKeyExW(catidkey
, instance_keyname
, 0, KEY_READ
, &instancekey
);
2058 if (res
== ERROR_SUCCESS
)
2063 DWORD guidstring_size
= 39;
2064 res
= RegEnumKeyExW(instancekey
, i
, guidstring
, &guidstring_size
, NULL
, NULL
, NULL
, NULL
);
2065 if (res
!= ERROR_SUCCESS
) break;
2067 item
= HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnumItem
));
2068 if (!item
) { hr
= E_OUTOFMEMORY
; break; }
2070 hr
= CLSIDFromString(guidstring
, &clsid
);
2073 hr
= CreateComponentInfo(&clsid
, (IWICComponentInfo
**)&item
->unk
);
2075 list_add_tail(&This
->objects
, &item
->entry
);
2080 HeapFree(GetProcessHeap(), 0, item
);
2084 RegCloseKey(instancekey
);
2086 RegCloseKey(catidkey
);
2088 if (res
!= ERROR_SUCCESS
&& res
!= ERROR_NO_MORE_ITEMS
)
2089 hr
= HRESULT_FROM_WIN32(res
);
2091 RegCloseKey(clsidkey
);
2095 IEnumUnknown_Reset(&This
->IEnumUnknown_iface
);
2096 *ppIEnumUnknown
= &This
->IEnumUnknown_iface
;
2100 *ppIEnumUnknown
= NULL
;
2101 IEnumUnknown_Release(&This
->IEnumUnknown_iface
);
2107 HRESULT WINAPI
WICConvertBitmapSource(REFWICPixelFormatGUID dstFormat
, IWICBitmapSource
*pISrc
, IWICBitmapSource
**ppIDst
)
2110 IEnumUnknown
*enumconverters
;
2111 IUnknown
*unkconverterinfo
;
2112 IWICFormatConverterInfo
*converterinfo
=NULL
;
2113 IWICFormatConverter
*converter
=NULL
;
2115 WCHAR srcformatstr
[39], dstformatstr
[39];
2119 res
= IWICBitmapSource_GetPixelFormat(pISrc
, &srcFormat
);
2120 if (FAILED(res
)) return res
;
2122 if (IsEqualGUID(&srcFormat
, dstFormat
))
2124 IWICBitmapSource_AddRef(pISrc
);
2129 StringFromGUID2(&srcFormat
, srcformatstr
, 39);
2130 StringFromGUID2(dstFormat
, dstformatstr
, 39);
2132 res
= CreateComponentEnumerator(WICPixelFormatConverter
, 0, &enumconverters
);
2133 if (FAILED(res
)) return res
;
2137 res
= IEnumUnknown_Next(enumconverters
, 1, &unkconverterinfo
, &num_fetched
);
2141 res
= IUnknown_QueryInterface(unkconverterinfo
, &IID_IWICFormatConverterInfo
, (void**)&converterinfo
);
2145 canconvert
= ConverterSupportsFormat(converterinfo
, srcformatstr
);
2148 canconvert
= ConverterSupportsFormat(converterinfo
, dstformatstr
);
2152 res
= IWICFormatConverterInfo_CreateInstance(converterinfo
, &converter
);
2155 res
= IWICFormatConverter_CanConvert(converter
, &srcFormat
, dstFormat
, &canconvert
);
2157 if (SUCCEEDED(res
) && canconvert
)
2158 res
= IWICFormatConverter_Initialize(converter
, pISrc
, dstFormat
, WICBitmapDitherTypeNone
,
2159 NULL
, 0.0, WICBitmapPaletteTypeCustom
);
2161 if (FAILED(res
) || !canconvert
)
2165 IWICFormatConverter_Release(converter
);
2172 IWICFormatConverterInfo_Release(converterinfo
);
2175 IUnknown_Release(unkconverterinfo
);
2181 IEnumUnknown_Release(enumconverters
);
2185 res
= IWICFormatConverter_QueryInterface(converter
, &IID_IWICBitmapSource
, (void **)ppIDst
);
2186 IWICFormatConverter_Release(converter
);
2191 FIXME("cannot convert %s to %s\n", debugstr_guid(&srcFormat
), debugstr_guid(dstFormat
));
2193 return WINCODEC_ERR_COMPONENTNOTFOUND
;