2 * Copyright 2009 Vincent Povirk for CodeWeavers
3 * Copyright 2012 Dmitry Timoshkov
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include "wincodecsdk.h"
33 #include "wincodecs_private.h"
35 #include "wine/debug.h"
36 #include "wine/unicode.h"
37 #include "wine/list.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs
);
41 static const WCHAR mimetypes_valuename
[] = {'M','i','m','e','T','y','p','e','s',0};
42 static const WCHAR author_valuename
[] = {'A','u','t','h','o','r',0};
43 static const WCHAR friendlyname_valuename
[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
44 static const WCHAR pixelformats_keyname
[] = {'P','i','x','e','l','F','o','r','m','a','t','s',0};
45 static const WCHAR containerformat_valuename
[] = {'C','o','n','t','a','i','n','e','r','F','o','r','m','a','t',0};
46 static const WCHAR metadataformat_valuename
[] = {'M','e','t','a','d','a','t','a','F','o','r','m','a','t',0};
47 static const WCHAR vendor_valuename
[] = {'V','e','n','d','o','r',0};
48 static const WCHAR version_valuename
[] = {'V','e','r','s','i','o','n',0};
50 static HRESULT
ComponentInfo_GetStringValue(HKEY classkey
, LPCWSTR value
,
51 UINT buffer_size
, WCHAR
*buffer
, UINT
*actual_size
)
54 DWORD cbdata
=buffer_size
* sizeof(WCHAR
);
59 ret
= RegGetValueW(classkey
, NULL
, value
, RRF_RT_REG_SZ
|RRF_NOEXPAND
, NULL
,
62 if (ret
== ERROR_FILE_NOT_FOUND
)
68 if (ret
== 0 || ret
== ERROR_MORE_DATA
)
69 *actual_size
= cbdata
/sizeof(WCHAR
);
71 if (!buffer
&& buffer_size
!= 0)
72 /* Yes, native returns the correct size in this case. */
75 if (ret
== ERROR_MORE_DATA
)
76 return WINCODEC_ERR_INSUFFICIENTBUFFER
;
78 return HRESULT_FROM_WIN32(ret
);
81 static HRESULT
ComponentInfo_GetGUIDValue(HKEY classkey
, LPCWSTR value
,
85 WCHAR guid_string
[39];
86 DWORD cbdata
= sizeof(guid_string
);
92 ret
= RegGetValueW(classkey
, NULL
, value
, RRF_RT_REG_SZ
|RRF_NOEXPAND
, NULL
,
93 guid_string
, &cbdata
);
95 if (ret
!= ERROR_SUCCESS
)
96 return HRESULT_FROM_WIN32(ret
);
98 if (cbdata
< sizeof(guid_string
))
100 ERR("incomplete GUID value\n");
104 hr
= CLSIDFromString(guid_string
, result
);
110 IWICBitmapDecoderInfo IWICBitmapDecoderInfo_iface
;
116 static inline BitmapDecoderInfo
*impl_from_IWICBitmapDecoderInfo(IWICBitmapDecoderInfo
*iface
)
118 return CONTAINING_RECORD(iface
, BitmapDecoderInfo
, IWICBitmapDecoderInfo_iface
);
121 static HRESULT WINAPI
BitmapDecoderInfo_QueryInterface(IWICBitmapDecoderInfo
*iface
, REFIID iid
,
124 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
125 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
127 if (!ppv
) return E_INVALIDARG
;
129 if (IsEqualIID(&IID_IUnknown
, iid
) ||
130 IsEqualIID(&IID_IWICComponentInfo
, iid
) ||
131 IsEqualIID(&IID_IWICBitmapCodecInfo
, iid
) ||
132 IsEqualIID(&IID_IWICBitmapDecoderInfo
,iid
))
139 return E_NOINTERFACE
;
142 IUnknown_AddRef((IUnknown
*)*ppv
);
146 static ULONG WINAPI
BitmapDecoderInfo_AddRef(IWICBitmapDecoderInfo
*iface
)
148 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
149 ULONG ref
= InterlockedIncrement(&This
->ref
);
151 TRACE("(%p) refcount=%u\n", iface
, ref
);
156 static ULONG WINAPI
BitmapDecoderInfo_Release(IWICBitmapDecoderInfo
*iface
)
158 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
159 ULONG ref
= InterlockedDecrement(&This
->ref
);
161 TRACE("(%p) refcount=%u\n", iface
, ref
);
165 RegCloseKey(This
->classkey
);
166 HeapFree(GetProcessHeap(), 0, This
);
172 static HRESULT WINAPI
BitmapDecoderInfo_GetComponentType(IWICBitmapDecoderInfo
*iface
,
173 WICComponentType
*pType
)
175 TRACE("(%p,%p)\n", iface
, pType
);
176 if (!pType
) return E_INVALIDARG
;
181 static HRESULT WINAPI
BitmapDecoderInfo_GetCLSID(IWICBitmapDecoderInfo
*iface
, CLSID
*pclsid
)
183 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
184 TRACE("(%p,%p)\n", iface
, pclsid
);
189 memcpy(pclsid
, &This
->clsid
, sizeof(CLSID
));
194 static HRESULT WINAPI
BitmapDecoderInfo_GetSigningStatus(IWICBitmapDecoderInfo
*iface
, DWORD
*pStatus
)
196 FIXME("(%p,%p): stub\n", iface
, pStatus
);
200 static HRESULT WINAPI
BitmapDecoderInfo_GetAuthor(IWICBitmapDecoderInfo
*iface
, UINT cchAuthor
,
201 WCHAR
*wzAuthor
, UINT
*pcchActual
)
203 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
205 TRACE("(%p,%u,%p,%p)\n", iface
, cchAuthor
, wzAuthor
, pcchActual
);
207 return ComponentInfo_GetStringValue(This
->classkey
, author_valuename
,
208 cchAuthor
, wzAuthor
, pcchActual
);
211 static HRESULT WINAPI
BitmapDecoderInfo_GetVendorGUID(IWICBitmapDecoderInfo
*iface
, GUID
*pguidVendor
)
213 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
215 TRACE("(%p,%p)\n", iface
, pguidVendor
);
217 return ComponentInfo_GetGUIDValue(This
->classkey
, vendor_valuename
, pguidVendor
);
220 static HRESULT WINAPI
BitmapDecoderInfo_GetVersion(IWICBitmapDecoderInfo
*iface
, UINT cchVersion
,
221 WCHAR
*wzVersion
, UINT
*pcchActual
)
223 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
225 TRACE("(%p,%u,%p,%p)\n", iface
, cchVersion
, wzVersion
, pcchActual
);
227 return ComponentInfo_GetStringValue(This
->classkey
, version_valuename
,
228 cchVersion
, wzVersion
, pcchActual
);
231 static HRESULT WINAPI
BitmapDecoderInfo_GetSpecVersion(IWICBitmapDecoderInfo
*iface
, UINT cchSpecVersion
,
232 WCHAR
*wzSpecVersion
, UINT
*pcchActual
)
234 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchSpecVersion
, wzSpecVersion
, pcchActual
);
238 static HRESULT WINAPI
BitmapDecoderInfo_GetFriendlyName(IWICBitmapDecoderInfo
*iface
, UINT cchFriendlyName
,
239 WCHAR
*wzFriendlyName
, UINT
*pcchActual
)
241 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
243 TRACE("(%p,%u,%p,%p)\n", iface
, cchFriendlyName
, wzFriendlyName
, pcchActual
);
245 return ComponentInfo_GetStringValue(This
->classkey
, friendlyname_valuename
,
246 cchFriendlyName
, wzFriendlyName
, pcchActual
);
249 static HRESULT WINAPI
BitmapDecoderInfo_GetContainerFormat(IWICBitmapDecoderInfo
*iface
,
250 GUID
*pguidContainerFormat
)
252 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
253 TRACE("(%p,%p)\n", iface
, pguidContainerFormat
);
254 return ComponentInfo_GetGUIDValue(This
->classkey
, containerformat_valuename
, pguidContainerFormat
);
257 static HRESULT WINAPI
BitmapDecoderInfo_GetPixelFormats(IWICBitmapDecoderInfo
*iface
,
258 UINT cFormats
, GUID
*pguidPixelFormats
, UINT
*pcActual
)
260 FIXME("(%p,%u,%p,%p): stub\n", iface
, cFormats
, pguidPixelFormats
, pcActual
);
264 static HRESULT WINAPI
BitmapDecoderInfo_GetColorManagementVersion(IWICBitmapDecoderInfo
*iface
,
265 UINT cchColorManagementVersion
, WCHAR
*wzColorManagementVersion
, UINT
*pcchActual
)
267 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchColorManagementVersion
, wzColorManagementVersion
, pcchActual
);
271 static HRESULT WINAPI
BitmapDecoderInfo_GetDeviceManufacturer(IWICBitmapDecoderInfo
*iface
,
272 UINT cchDeviceManufacturer
, WCHAR
*wzDeviceManufacturer
, UINT
*pcchActual
)
274 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchDeviceManufacturer
, wzDeviceManufacturer
, pcchActual
);
278 static HRESULT WINAPI
BitmapDecoderInfo_GetDeviceModels(IWICBitmapDecoderInfo
*iface
,
279 UINT cchDeviceModels
, WCHAR
*wzDeviceModels
, UINT
*pcchActual
)
281 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchDeviceModels
, wzDeviceModels
, pcchActual
);
285 static HRESULT WINAPI
BitmapDecoderInfo_GetMimeTypes(IWICBitmapDecoderInfo
*iface
,
286 UINT cchMimeTypes
, WCHAR
*wzMimeTypes
, UINT
*pcchActual
)
288 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
290 TRACE("(%p,%u,%p,%p)\n", iface
, cchMimeTypes
, wzMimeTypes
, pcchActual
);
292 return ComponentInfo_GetStringValue(This
->classkey
, mimetypes_valuename
,
293 cchMimeTypes
, wzMimeTypes
, pcchActual
);
296 static HRESULT WINAPI
BitmapDecoderInfo_GetFileExtensions(IWICBitmapDecoderInfo
*iface
,
297 UINT cchFileExtensions
, WCHAR
*wzFileExtensions
, UINT
*pcchActual
)
299 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchFileExtensions
, wzFileExtensions
, pcchActual
);
303 static HRESULT WINAPI
BitmapDecoderInfo_DoesSupportAnimation(IWICBitmapDecoderInfo
*iface
,
304 BOOL
*pfSupportAnimation
)
306 FIXME("(%p,%p): stub\n", iface
, pfSupportAnimation
);
310 static HRESULT WINAPI
BitmapDecoderInfo_DoesSupportChromaKey(IWICBitmapDecoderInfo
*iface
,
311 BOOL
*pfSupportChromaKey
)
313 FIXME("(%p,%p): stub\n", iface
, pfSupportChromaKey
);
317 static HRESULT WINAPI
BitmapDecoderInfo_DoesSupportLossless(IWICBitmapDecoderInfo
*iface
,
318 BOOL
*pfSupportLossless
)
320 FIXME("(%p,%p): stub\n", iface
, pfSupportLossless
);
324 static HRESULT WINAPI
BitmapDecoderInfo_DoesSupportMultiframe(IWICBitmapDecoderInfo
*iface
,
325 BOOL
*pfSupportMultiframe
)
327 FIXME("(%p,%p): stub\n", iface
, pfSupportMultiframe
);
331 static HRESULT WINAPI
BitmapDecoderInfo_MatchesMimeType(IWICBitmapDecoderInfo
*iface
,
332 LPCWSTR wzMimeType
, BOOL
*pfMatches
)
334 FIXME("(%p,%s,%p): stub\n", iface
, debugstr_w(wzMimeType
), pfMatches
);
338 static HRESULT WINAPI
BitmapDecoderInfo_GetPatterns(IWICBitmapDecoderInfo
*iface
,
339 UINT cbSizePatterns
, WICBitmapPattern
*pPatterns
, UINT
*pcPatterns
, UINT
*pcbPatternsActual
)
341 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
342 UINT pattern_count
=0, patterns_size
=0;
343 WCHAR subkeyname
[11];
345 HKEY patternskey
, patternkey
;
346 static const WCHAR uintformatW
[] = {'%','u',0};
347 static const WCHAR patternsW
[] = {'P','a','t','t','e','r','n','s',0};
348 static const WCHAR positionW
[] = {'P','o','s','i','t','i','o','n',0};
349 static const WCHAR lengthW
[] = {'L','e','n','g','t','h',0};
350 static const WCHAR patternW
[] = {'P','a','t','t','e','r','n',0};
351 static const WCHAR maskW
[] = {'M','a','s','k',0};
352 static const WCHAR endofstreamW
[] = {'E','n','d','O','f','S','t','r','e','a','m',0};
355 BYTE
*bPatterns
=(BYTE
*)pPatterns
;
356 DWORD length
, valuesize
;
358 TRACE("(%p,%i,%p,%p,%p)\n", iface
, cbSizePatterns
, pPatterns
, pcPatterns
, pcbPatternsActual
);
360 res
= RegOpenKeyExW(This
->classkey
, patternsW
, 0, KEY_READ
, &patternskey
);
361 if (res
!= ERROR_SUCCESS
) return HRESULT_FROM_WIN32(res
);
363 res
= RegQueryInfoKeyW(patternskey
, NULL
, NULL
, NULL
, &pattern_count
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
364 if (res
== ERROR_SUCCESS
)
366 patterns_size
= pattern_count
* sizeof(WICBitmapPattern
);
368 for (i
=0; i
<pattern_count
; i
++)
370 snprintfW(subkeyname
, 11, uintformatW
, i
);
371 res
= RegOpenKeyExW(patternskey
, subkeyname
, 0, KEY_READ
, &patternkey
);
372 if (res
== ERROR_SUCCESS
)
374 valuesize
= sizeof(ULONG
);
375 res
= RegGetValueW(patternkey
, NULL
, lengthW
, RRF_RT_DWORD
, NULL
,
376 &length
, &valuesize
);
377 patterns_size
+= length
*2;
379 if ((cbSizePatterns
>= patterns_size
) && (res
== ERROR_SUCCESS
))
381 pPatterns
[i
].Length
= length
;
383 pPatterns
[i
].EndOfStream
= 0;
384 valuesize
= sizeof(BOOL
);
385 RegGetValueW(patternkey
, NULL
, endofstreamW
, RRF_RT_DWORD
, NULL
,
386 &pPatterns
[i
].EndOfStream
, &valuesize
);
388 pPatterns
[i
].Position
.QuadPart
= 0;
389 valuesize
= sizeof(ULARGE_INTEGER
);
390 res
= RegGetValueW(patternkey
, NULL
, positionW
, RRF_RT_DWORD
|RRF_RT_QWORD
, NULL
,
391 &pPatterns
[i
].Position
, &valuesize
);
393 if (res
== ERROR_SUCCESS
)
395 pPatterns
[i
].Pattern
= bPatterns
+patterns_size
-length
*2;
397 res
= RegGetValueW(patternkey
, NULL
, patternW
, RRF_RT_REG_BINARY
, NULL
,
398 pPatterns
[i
].Pattern
, &valuesize
);
401 if (res
== ERROR_SUCCESS
)
403 pPatterns
[i
].Mask
= bPatterns
+patterns_size
-length
;
405 res
= RegGetValueW(patternkey
, NULL
, maskW
, RRF_RT_REG_BINARY
, NULL
,
406 pPatterns
[i
].Mask
, &valuesize
);
410 RegCloseKey(patternkey
);
412 if (res
!= ERROR_SUCCESS
)
414 hr
= HRESULT_FROM_WIN32(res
);
419 else hr
= HRESULT_FROM_WIN32(res
);
421 RegCloseKey(patternskey
);
425 *pcPatterns
= pattern_count
;
426 *pcbPatternsActual
= patterns_size
;
427 if (pPatterns
&& cbSizePatterns
< patterns_size
)
428 hr
= WINCODEC_ERR_INSUFFICIENTBUFFER
;
434 static HRESULT WINAPI
BitmapDecoderInfo_MatchesPattern(IWICBitmapDecoderInfo
*iface
,
435 IStream
*pIStream
, BOOL
*pfMatches
)
437 WICBitmapPattern
*patterns
;
438 UINT pattern_count
=0, patterns_size
=0;
444 LARGE_INTEGER seekpos
;
446 TRACE("(%p,%p,%p)\n", iface
, pIStream
, pfMatches
);
448 hr
= BitmapDecoderInfo_GetPatterns(iface
, 0, NULL
, &pattern_count
, &patterns_size
);
449 if (FAILED(hr
)) return hr
;
451 patterns
= HeapAlloc(GetProcessHeap(), 0, patterns_size
);
452 if (!patterns
) return E_OUTOFMEMORY
;
454 hr
= BitmapDecoderInfo_GetPatterns(iface
, patterns_size
, patterns
, &pattern_count
, &patterns_size
);
455 if (FAILED(hr
)) goto end
;
457 for (i
=0; i
<pattern_count
; i
++)
459 if (datasize
< patterns
[i
].Length
)
461 HeapFree(GetProcessHeap(), 0, data
);
462 datasize
= patterns
[i
].Length
;
463 data
= HeapAlloc(GetProcessHeap(), 0, patterns
[i
].Length
);
471 if (patterns
[i
].EndOfStream
)
472 seekpos
.QuadPart
= -patterns
[i
].Position
.QuadPart
;
474 seekpos
.QuadPart
= patterns
[i
].Position
.QuadPart
;
475 hr
= IStream_Seek(pIStream
, seekpos
, patterns
[i
].EndOfStream
? STREAM_SEEK_END
: STREAM_SEEK_SET
, NULL
);
476 if (hr
== STG_E_INVALIDFUNCTION
) continue; /* before start of stream */
477 if (FAILED(hr
)) break;
479 hr
= IStream_Read(pIStream
, data
, patterns
[i
].Length
, &bytesread
);
480 if (hr
== S_FALSE
|| (hr
== S_OK
&& bytesread
!= patterns
[i
].Length
)) /* past end of stream */
482 if (FAILED(hr
)) break;
484 for (pos
=0; pos
<patterns
[i
].Length
; pos
++)
486 if ((data
[pos
] & patterns
[i
].Mask
[pos
]) != patterns
[i
].Pattern
[pos
])
489 if (pos
== patterns
[i
].Length
) /* matches pattern */
497 if (i
== pattern_count
) /* does not match any pattern */
504 HeapFree(GetProcessHeap(), 0, patterns
);
505 HeapFree(GetProcessHeap(), 0, data
);
510 static HRESULT WINAPI
BitmapDecoderInfo_CreateInstance(IWICBitmapDecoderInfo
*iface
,
511 IWICBitmapDecoder
**ppIBitmapDecoder
)
513 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
515 TRACE("(%p,%p)\n", iface
, ppIBitmapDecoder
);
517 return CoCreateInstance(&This
->clsid
, NULL
, CLSCTX_INPROC_SERVER
,
518 &IID_IWICBitmapDecoder
, (void**)ppIBitmapDecoder
);
521 static const IWICBitmapDecoderInfoVtbl BitmapDecoderInfo_Vtbl
= {
522 BitmapDecoderInfo_QueryInterface
,
523 BitmapDecoderInfo_AddRef
,
524 BitmapDecoderInfo_Release
,
525 BitmapDecoderInfo_GetComponentType
,
526 BitmapDecoderInfo_GetCLSID
,
527 BitmapDecoderInfo_GetSigningStatus
,
528 BitmapDecoderInfo_GetAuthor
,
529 BitmapDecoderInfo_GetVendorGUID
,
530 BitmapDecoderInfo_GetVersion
,
531 BitmapDecoderInfo_GetSpecVersion
,
532 BitmapDecoderInfo_GetFriendlyName
,
533 BitmapDecoderInfo_GetContainerFormat
,
534 BitmapDecoderInfo_GetPixelFormats
,
535 BitmapDecoderInfo_GetColorManagementVersion
,
536 BitmapDecoderInfo_GetDeviceManufacturer
,
537 BitmapDecoderInfo_GetDeviceModels
,
538 BitmapDecoderInfo_GetMimeTypes
,
539 BitmapDecoderInfo_GetFileExtensions
,
540 BitmapDecoderInfo_DoesSupportAnimation
,
541 BitmapDecoderInfo_DoesSupportChromaKey
,
542 BitmapDecoderInfo_DoesSupportLossless
,
543 BitmapDecoderInfo_DoesSupportMultiframe
,
544 BitmapDecoderInfo_MatchesMimeType
,
545 BitmapDecoderInfo_GetPatterns
,
546 BitmapDecoderInfo_MatchesPattern
,
547 BitmapDecoderInfo_CreateInstance
550 static HRESULT
BitmapDecoderInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
552 BitmapDecoderInfo
*This
;
554 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapDecoderInfo
));
557 RegCloseKey(classkey
);
558 return E_OUTOFMEMORY
;
561 This
->IWICBitmapDecoderInfo_iface
.lpVtbl
= &BitmapDecoderInfo_Vtbl
;
563 This
->classkey
= classkey
;
564 memcpy(&This
->clsid
, clsid
, sizeof(CLSID
));
566 *ppIInfo
= (IWICComponentInfo
*)This
;
571 IWICBitmapEncoderInfo IWICBitmapEncoderInfo_iface
;
577 static inline BitmapEncoderInfo
*impl_from_IWICBitmapEncoderInfo(IWICBitmapEncoderInfo
*iface
)
579 return CONTAINING_RECORD(iface
, BitmapEncoderInfo
, IWICBitmapEncoderInfo_iface
);
582 static HRESULT WINAPI
BitmapEncoderInfo_QueryInterface(IWICBitmapEncoderInfo
*iface
, REFIID iid
,
585 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
586 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
588 if (!ppv
) return E_INVALIDARG
;
590 if (IsEqualIID(&IID_IUnknown
, iid
) ||
591 IsEqualIID(&IID_IWICComponentInfo
, iid
) ||
592 IsEqualIID(&IID_IWICBitmapCodecInfo
, iid
) ||
593 IsEqualIID(&IID_IWICBitmapEncoderInfo
,iid
))
600 return E_NOINTERFACE
;
603 IUnknown_AddRef((IUnknown
*)*ppv
);
607 static ULONG WINAPI
BitmapEncoderInfo_AddRef(IWICBitmapEncoderInfo
*iface
)
609 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
610 ULONG ref
= InterlockedIncrement(&This
->ref
);
612 TRACE("(%p) refcount=%u\n", iface
, ref
);
617 static ULONG WINAPI
BitmapEncoderInfo_Release(IWICBitmapEncoderInfo
*iface
)
619 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
620 ULONG ref
= InterlockedDecrement(&This
->ref
);
622 TRACE("(%p) refcount=%u\n", iface
, ref
);
626 RegCloseKey(This
->classkey
);
627 HeapFree(GetProcessHeap(), 0, This
);
633 static HRESULT WINAPI
BitmapEncoderInfo_GetComponentType(IWICBitmapEncoderInfo
*iface
,
634 WICComponentType
*pType
)
636 TRACE("(%p,%p)\n", iface
, pType
);
637 if (!pType
) return E_INVALIDARG
;
642 static HRESULT WINAPI
BitmapEncoderInfo_GetCLSID(IWICBitmapEncoderInfo
*iface
, CLSID
*pclsid
)
644 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
645 TRACE("(%p,%p)\n", iface
, pclsid
);
650 memcpy(pclsid
, &This
->clsid
, sizeof(CLSID
));
655 static HRESULT WINAPI
BitmapEncoderInfo_GetSigningStatus(IWICBitmapEncoderInfo
*iface
, DWORD
*pStatus
)
657 FIXME("(%p,%p): stub\n", iface
, pStatus
);
661 static HRESULT WINAPI
BitmapEncoderInfo_GetAuthor(IWICBitmapEncoderInfo
*iface
, UINT cchAuthor
,
662 WCHAR
*wzAuthor
, UINT
*pcchActual
)
664 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
666 TRACE("(%p,%u,%p,%p)\n", iface
, cchAuthor
, wzAuthor
, pcchActual
);
668 return ComponentInfo_GetStringValue(This
->classkey
, author_valuename
,
669 cchAuthor
, wzAuthor
, pcchActual
);
672 static HRESULT WINAPI
BitmapEncoderInfo_GetVendorGUID(IWICBitmapEncoderInfo
*iface
, GUID
*pguidVendor
)
674 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
676 TRACE("(%p,%p)\n", iface
, pguidVendor
);
678 return ComponentInfo_GetGUIDValue(This
->classkey
, vendor_valuename
, pguidVendor
);
681 static HRESULT WINAPI
BitmapEncoderInfo_GetVersion(IWICBitmapEncoderInfo
*iface
, UINT cchVersion
,
682 WCHAR
*wzVersion
, UINT
*pcchActual
)
684 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
686 TRACE("(%p,%u,%p,%p)\n", iface
, cchVersion
, wzVersion
, pcchActual
);
688 return ComponentInfo_GetStringValue(This
->classkey
, version_valuename
,
689 cchVersion
, wzVersion
, pcchActual
);
692 static HRESULT WINAPI
BitmapEncoderInfo_GetSpecVersion(IWICBitmapEncoderInfo
*iface
, UINT cchSpecVersion
,
693 WCHAR
*wzSpecVersion
, UINT
*pcchActual
)
695 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchSpecVersion
, wzSpecVersion
, pcchActual
);
699 static HRESULT WINAPI
BitmapEncoderInfo_GetFriendlyName(IWICBitmapEncoderInfo
*iface
, UINT cchFriendlyName
,
700 WCHAR
*wzFriendlyName
, UINT
*pcchActual
)
702 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
704 TRACE("(%p,%u,%p,%p)\n", iface
, cchFriendlyName
, wzFriendlyName
, pcchActual
);
706 return ComponentInfo_GetStringValue(This
->classkey
, friendlyname_valuename
,
707 cchFriendlyName
, wzFriendlyName
, pcchActual
);
710 static HRESULT WINAPI
BitmapEncoderInfo_GetContainerFormat(IWICBitmapEncoderInfo
*iface
,
711 GUID
*pguidContainerFormat
)
713 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
714 TRACE("(%p,%p)\n", iface
, pguidContainerFormat
);
715 return ComponentInfo_GetGUIDValue(This
->classkey
, containerformat_valuename
, pguidContainerFormat
);
718 static HRESULT WINAPI
BitmapEncoderInfo_GetPixelFormats(IWICBitmapEncoderInfo
*iface
,
719 UINT cFormats
, GUID
*pguidPixelFormats
, UINT
*pcActual
)
721 FIXME("(%p,%u,%p,%p): stub\n", iface
, cFormats
, pguidPixelFormats
, pcActual
);
725 static HRESULT WINAPI
BitmapEncoderInfo_GetColorManagementVersion(IWICBitmapEncoderInfo
*iface
,
726 UINT cchColorManagementVersion
, WCHAR
*wzColorManagementVersion
, UINT
*pcchActual
)
728 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchColorManagementVersion
, wzColorManagementVersion
, pcchActual
);
732 static HRESULT WINAPI
BitmapEncoderInfo_GetDeviceManufacturer(IWICBitmapEncoderInfo
*iface
,
733 UINT cchDeviceManufacturer
, WCHAR
*wzDeviceManufacturer
, UINT
*pcchActual
)
735 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchDeviceManufacturer
, wzDeviceManufacturer
, pcchActual
);
739 static HRESULT WINAPI
BitmapEncoderInfo_GetDeviceModels(IWICBitmapEncoderInfo
*iface
,
740 UINT cchDeviceModels
, WCHAR
*wzDeviceModels
, UINT
*pcchActual
)
742 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchDeviceModels
, wzDeviceModels
, pcchActual
);
746 static HRESULT WINAPI
BitmapEncoderInfo_GetMimeTypes(IWICBitmapEncoderInfo
*iface
,
747 UINT cchMimeTypes
, WCHAR
*wzMimeTypes
, UINT
*pcchActual
)
749 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
751 TRACE("(%p,%u,%p,%p)\n", iface
, cchMimeTypes
, wzMimeTypes
, pcchActual
);
753 return ComponentInfo_GetStringValue(This
->classkey
, mimetypes_valuename
,
754 cchMimeTypes
, wzMimeTypes
, pcchActual
);
757 static HRESULT WINAPI
BitmapEncoderInfo_GetFileExtensions(IWICBitmapEncoderInfo
*iface
,
758 UINT cchFileExtensions
, WCHAR
*wzFileExtensions
, UINT
*pcchActual
)
760 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchFileExtensions
, wzFileExtensions
, pcchActual
);
764 static HRESULT WINAPI
BitmapEncoderInfo_DoesSupportAnimation(IWICBitmapEncoderInfo
*iface
,
765 BOOL
*pfSupportAnimation
)
767 FIXME("(%p,%p): stub\n", iface
, pfSupportAnimation
);
771 static HRESULT WINAPI
BitmapEncoderInfo_DoesSupportChromaKey(IWICBitmapEncoderInfo
*iface
,
772 BOOL
*pfSupportChromaKey
)
774 FIXME("(%p,%p): stub\n", iface
, pfSupportChromaKey
);
778 static HRESULT WINAPI
BitmapEncoderInfo_DoesSupportLossless(IWICBitmapEncoderInfo
*iface
,
779 BOOL
*pfSupportLossless
)
781 FIXME("(%p,%p): stub\n", iface
, pfSupportLossless
);
785 static HRESULT WINAPI
BitmapEncoderInfo_DoesSupportMultiframe(IWICBitmapEncoderInfo
*iface
,
786 BOOL
*pfSupportMultiframe
)
788 FIXME("(%p,%p): stub\n", iface
, pfSupportMultiframe
);
792 static HRESULT WINAPI
BitmapEncoderInfo_MatchesMimeType(IWICBitmapEncoderInfo
*iface
,
793 LPCWSTR wzMimeType
, BOOL
*pfMatches
)
795 FIXME("(%p,%s,%p): stub\n", iface
, debugstr_w(wzMimeType
), pfMatches
);
799 static HRESULT WINAPI
BitmapEncoderInfo_CreateInstance(IWICBitmapEncoderInfo
*iface
,
800 IWICBitmapEncoder
**ppIBitmapEncoder
)
802 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
804 TRACE("(%p,%p)\n", iface
, ppIBitmapEncoder
);
806 return CoCreateInstance(&This
->clsid
, NULL
, CLSCTX_INPROC_SERVER
,
807 &IID_IWICBitmapEncoder
, (void**)ppIBitmapEncoder
);
810 static const IWICBitmapEncoderInfoVtbl BitmapEncoderInfo_Vtbl
= {
811 BitmapEncoderInfo_QueryInterface
,
812 BitmapEncoderInfo_AddRef
,
813 BitmapEncoderInfo_Release
,
814 BitmapEncoderInfo_GetComponentType
,
815 BitmapEncoderInfo_GetCLSID
,
816 BitmapEncoderInfo_GetSigningStatus
,
817 BitmapEncoderInfo_GetAuthor
,
818 BitmapEncoderInfo_GetVendorGUID
,
819 BitmapEncoderInfo_GetVersion
,
820 BitmapEncoderInfo_GetSpecVersion
,
821 BitmapEncoderInfo_GetFriendlyName
,
822 BitmapEncoderInfo_GetContainerFormat
,
823 BitmapEncoderInfo_GetPixelFormats
,
824 BitmapEncoderInfo_GetColorManagementVersion
,
825 BitmapEncoderInfo_GetDeviceManufacturer
,
826 BitmapEncoderInfo_GetDeviceModels
,
827 BitmapEncoderInfo_GetMimeTypes
,
828 BitmapEncoderInfo_GetFileExtensions
,
829 BitmapEncoderInfo_DoesSupportAnimation
,
830 BitmapEncoderInfo_DoesSupportChromaKey
,
831 BitmapEncoderInfo_DoesSupportLossless
,
832 BitmapEncoderInfo_DoesSupportMultiframe
,
833 BitmapEncoderInfo_MatchesMimeType
,
834 BitmapEncoderInfo_CreateInstance
837 static HRESULT
BitmapEncoderInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
839 BitmapEncoderInfo
*This
;
841 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapEncoderInfo
));
844 RegCloseKey(classkey
);
845 return E_OUTOFMEMORY
;
848 This
->IWICBitmapEncoderInfo_iface
.lpVtbl
= &BitmapEncoderInfo_Vtbl
;
850 This
->classkey
= classkey
;
851 memcpy(&This
->clsid
, clsid
, sizeof(CLSID
));
853 *ppIInfo
= (IWICComponentInfo
*)This
;
858 IWICFormatConverterInfo IWICFormatConverterInfo_iface
;
862 } FormatConverterInfo
;
864 static inline FormatConverterInfo
*impl_from_IWICFormatConverterInfo(IWICFormatConverterInfo
*iface
)
866 return CONTAINING_RECORD(iface
, FormatConverterInfo
, IWICFormatConverterInfo_iface
);
869 static HRESULT WINAPI
FormatConverterInfo_QueryInterface(IWICFormatConverterInfo
*iface
, REFIID iid
,
872 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
873 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
875 if (!ppv
) return E_INVALIDARG
;
877 if (IsEqualIID(&IID_IUnknown
, iid
) ||
878 IsEqualIID(&IID_IWICComponentInfo
, iid
) ||
879 IsEqualIID(&IID_IWICFormatConverterInfo
,iid
))
886 return E_NOINTERFACE
;
889 IUnknown_AddRef((IUnknown
*)*ppv
);
893 static ULONG WINAPI
FormatConverterInfo_AddRef(IWICFormatConverterInfo
*iface
)
895 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
896 ULONG ref
= InterlockedIncrement(&This
->ref
);
898 TRACE("(%p) refcount=%u\n", iface
, ref
);
903 static ULONG WINAPI
FormatConverterInfo_Release(IWICFormatConverterInfo
*iface
)
905 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
906 ULONG ref
= InterlockedDecrement(&This
->ref
);
908 TRACE("(%p) refcount=%u\n", iface
, ref
);
912 RegCloseKey(This
->classkey
);
913 HeapFree(GetProcessHeap(), 0, This
);
919 static HRESULT WINAPI
FormatConverterInfo_GetComponentType(IWICFormatConverterInfo
*iface
,
920 WICComponentType
*pType
)
922 TRACE("(%p,%p)\n", iface
, pType
);
923 if (!pType
) return E_INVALIDARG
;
924 *pType
= WICPixelFormatConverter
;
928 static HRESULT WINAPI
FormatConverterInfo_GetCLSID(IWICFormatConverterInfo
*iface
, CLSID
*pclsid
)
930 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
931 TRACE("(%p,%p)\n", iface
, pclsid
);
936 memcpy(pclsid
, &This
->clsid
, sizeof(CLSID
));
941 static HRESULT WINAPI
FormatConverterInfo_GetSigningStatus(IWICFormatConverterInfo
*iface
, DWORD
*pStatus
)
943 FIXME("(%p,%p): stub\n", iface
, pStatus
);
947 static HRESULT WINAPI
FormatConverterInfo_GetAuthor(IWICFormatConverterInfo
*iface
, UINT cchAuthor
,
948 WCHAR
*wzAuthor
, UINT
*pcchActual
)
950 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
952 TRACE("(%p,%u,%p,%p)\n", iface
, cchAuthor
, wzAuthor
, pcchActual
);
954 return ComponentInfo_GetStringValue(This
->classkey
, author_valuename
,
955 cchAuthor
, wzAuthor
, pcchActual
);
958 static HRESULT WINAPI
FormatConverterInfo_GetVendorGUID(IWICFormatConverterInfo
*iface
, GUID
*pguidVendor
)
960 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
962 TRACE("(%p,%p)\n", iface
, pguidVendor
);
964 return ComponentInfo_GetGUIDValue(This
->classkey
, vendor_valuename
, pguidVendor
);
967 static HRESULT WINAPI
FormatConverterInfo_GetVersion(IWICFormatConverterInfo
*iface
, UINT cchVersion
,
968 WCHAR
*wzVersion
, UINT
*pcchActual
)
970 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
972 TRACE("(%p,%u,%p,%p)\n", iface
, cchVersion
, wzVersion
, pcchActual
);
974 return ComponentInfo_GetStringValue(This
->classkey
, version_valuename
,
975 cchVersion
, wzVersion
, pcchActual
);
978 static HRESULT WINAPI
FormatConverterInfo_GetSpecVersion(IWICFormatConverterInfo
*iface
, UINT cchSpecVersion
,
979 WCHAR
*wzSpecVersion
, UINT
*pcchActual
)
981 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchSpecVersion
, wzSpecVersion
, pcchActual
);
985 static HRESULT WINAPI
FormatConverterInfo_GetFriendlyName(IWICFormatConverterInfo
*iface
, UINT cchFriendlyName
,
986 WCHAR
*wzFriendlyName
, UINT
*pcchActual
)
988 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
990 TRACE("(%p,%u,%p,%p)\n", iface
, cchFriendlyName
, wzFriendlyName
, pcchActual
);
992 return ComponentInfo_GetStringValue(This
->classkey
, friendlyname_valuename
,
993 cchFriendlyName
, wzFriendlyName
, pcchActual
);
996 static HRESULT WINAPI
FormatConverterInfo_GetPixelFormats(IWICFormatConverterInfo
*iface
,
997 UINT cFormats
, GUID
*pguidPixelFormats
, UINT
*pcActual
)
999 FIXME("(%p,%u,%p,%p): stub\n", iface
, cFormats
, pguidPixelFormats
, pcActual
);
1003 static HRESULT WINAPI
FormatConverterInfo_CreateInstance(IWICFormatConverterInfo
*iface
,
1004 IWICFormatConverter
**ppIFormatConverter
)
1006 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1008 TRACE("(%p,%p)\n", iface
, ppIFormatConverter
);
1010 return CoCreateInstance(&This
->clsid
, NULL
, CLSCTX_INPROC_SERVER
,
1011 &IID_IWICFormatConverter
, (void**)ppIFormatConverter
);
1014 static BOOL
ConverterSupportsFormat(IWICFormatConverterInfo
*iface
, const WCHAR
*formatguid
)
1017 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1018 HKEY formats_key
, guid_key
;
1020 /* Avoid testing using IWICFormatConverter_GetPixelFormats because that
1021 would be O(n). A registry test should do better. */
1023 res
= RegOpenKeyExW(This
->classkey
, pixelformats_keyname
, 0, KEY_READ
, &formats_key
);
1024 if (res
!= ERROR_SUCCESS
) return FALSE
;
1026 res
= RegOpenKeyExW(formats_key
, formatguid
, 0, KEY_READ
, &guid_key
);
1027 if (res
== ERROR_SUCCESS
) RegCloseKey(guid_key
);
1029 RegCloseKey(formats_key
);
1031 return (res
== ERROR_SUCCESS
);
1034 static const IWICFormatConverterInfoVtbl FormatConverterInfo_Vtbl
= {
1035 FormatConverterInfo_QueryInterface
,
1036 FormatConverterInfo_AddRef
,
1037 FormatConverterInfo_Release
,
1038 FormatConverterInfo_GetComponentType
,
1039 FormatConverterInfo_GetCLSID
,
1040 FormatConverterInfo_GetSigningStatus
,
1041 FormatConverterInfo_GetAuthor
,
1042 FormatConverterInfo_GetVendorGUID
,
1043 FormatConverterInfo_GetVersion
,
1044 FormatConverterInfo_GetSpecVersion
,
1045 FormatConverterInfo_GetFriendlyName
,
1046 FormatConverterInfo_GetPixelFormats
,
1047 FormatConverterInfo_CreateInstance
1050 static HRESULT
FormatConverterInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
1052 FormatConverterInfo
*This
;
1054 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(FormatConverterInfo
));
1057 RegCloseKey(classkey
);
1058 return E_OUTOFMEMORY
;
1061 This
->IWICFormatConverterInfo_iface
.lpVtbl
= &FormatConverterInfo_Vtbl
;
1063 This
->classkey
= classkey
;
1064 memcpy(&This
->clsid
, clsid
, sizeof(CLSID
));
1066 *ppIInfo
= (IWICComponentInfo
*)This
;
1071 IWICPixelFormatInfo2 IWICPixelFormatInfo2_iface
;
1077 static inline PixelFormatInfo
*impl_from_IWICPixelFormatInfo2(IWICPixelFormatInfo2
*iface
)
1079 return CONTAINING_RECORD(iface
, PixelFormatInfo
, IWICPixelFormatInfo2_iface
);
1082 static HRESULT WINAPI
PixelFormatInfo_QueryInterface(IWICPixelFormatInfo2
*iface
, REFIID iid
,
1085 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1086 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
1088 if (!ppv
) return E_INVALIDARG
;
1090 if (IsEqualIID(&IID_IUnknown
, iid
) ||
1091 IsEqualIID(&IID_IWICComponentInfo
, iid
) ||
1092 IsEqualIID(&IID_IWICPixelFormatInfo
, iid
) ||
1093 IsEqualIID(&IID_IWICPixelFormatInfo2
,iid
))
1100 return E_NOINTERFACE
;
1103 IUnknown_AddRef((IUnknown
*)*ppv
);
1107 static ULONG WINAPI
PixelFormatInfo_AddRef(IWICPixelFormatInfo2
*iface
)
1109 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1110 ULONG ref
= InterlockedIncrement(&This
->ref
);
1112 TRACE("(%p) refcount=%u\n", iface
, ref
);
1117 static ULONG WINAPI
PixelFormatInfo_Release(IWICPixelFormatInfo2
*iface
)
1119 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1120 ULONG ref
= InterlockedDecrement(&This
->ref
);
1122 TRACE("(%p) refcount=%u\n", iface
, ref
);
1126 RegCloseKey(This
->classkey
);
1127 HeapFree(GetProcessHeap(), 0, This
);
1133 static HRESULT WINAPI
PixelFormatInfo_GetComponentType(IWICPixelFormatInfo2
*iface
,
1134 WICComponentType
*pType
)
1136 TRACE("(%p,%p)\n", iface
, pType
);
1137 if (!pType
) return E_INVALIDARG
;
1138 *pType
= WICPixelFormat
;
1142 static HRESULT WINAPI
PixelFormatInfo_GetCLSID(IWICPixelFormatInfo2
*iface
, CLSID
*pclsid
)
1144 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1145 TRACE("(%p,%p)\n", iface
, pclsid
);
1148 return E_INVALIDARG
;
1150 memcpy(pclsid
, &This
->clsid
, sizeof(CLSID
));
1155 static HRESULT WINAPI
PixelFormatInfo_GetSigningStatus(IWICPixelFormatInfo2
*iface
, DWORD
*pStatus
)
1157 TRACE("(%p,%p)\n", iface
, pStatus
);
1160 return E_INVALIDARG
;
1162 /* Pixel formats don't require code, so they are considered signed. */
1163 *pStatus
= WICComponentSigned
;
1168 static HRESULT WINAPI
PixelFormatInfo_GetAuthor(IWICPixelFormatInfo2
*iface
, UINT cchAuthor
,
1169 WCHAR
*wzAuthor
, UINT
*pcchActual
)
1171 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1173 TRACE("(%p,%u,%p,%p)\n", iface
, cchAuthor
, wzAuthor
, pcchActual
);
1175 return ComponentInfo_GetStringValue(This
->classkey
, author_valuename
,
1176 cchAuthor
, wzAuthor
, pcchActual
);
1179 static HRESULT WINAPI
PixelFormatInfo_GetVendorGUID(IWICPixelFormatInfo2
*iface
, GUID
*pguidVendor
)
1181 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1183 TRACE("(%p,%p)\n", iface
, pguidVendor
);
1185 return ComponentInfo_GetGUIDValue(This
->classkey
, vendor_valuename
, pguidVendor
);
1188 static HRESULT WINAPI
PixelFormatInfo_GetVersion(IWICPixelFormatInfo2
*iface
, UINT cchVersion
,
1189 WCHAR
*wzVersion
, UINT
*pcchActual
)
1191 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1193 TRACE("(%p,%u,%p,%p)\n", iface
, cchVersion
, wzVersion
, pcchActual
);
1195 return ComponentInfo_GetStringValue(This
->classkey
, version_valuename
,
1196 cchVersion
, wzVersion
, pcchActual
);
1199 static HRESULT WINAPI
PixelFormatInfo_GetSpecVersion(IWICPixelFormatInfo2
*iface
, UINT cchSpecVersion
,
1200 WCHAR
*wzSpecVersion
, UINT
*pcchActual
)
1202 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchSpecVersion
, wzSpecVersion
, pcchActual
);
1206 static HRESULT WINAPI
PixelFormatInfo_GetFriendlyName(IWICPixelFormatInfo2
*iface
, UINT cchFriendlyName
,
1207 WCHAR
*wzFriendlyName
, UINT
*pcchActual
)
1209 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1211 TRACE("(%p,%u,%p,%p)\n", iface
, cchFriendlyName
, wzFriendlyName
, pcchActual
);
1213 return ComponentInfo_GetStringValue(This
->classkey
, friendlyname_valuename
,
1214 cchFriendlyName
, wzFriendlyName
, pcchActual
);
1217 static HRESULT WINAPI
PixelFormatInfo_GetFormatGUID(IWICPixelFormatInfo2
*iface
,
1220 FIXME("(%p,%p): stub\n", iface
, pFormat
);
1224 static HRESULT WINAPI
PixelFormatInfo_GetColorContext(IWICPixelFormatInfo2
*iface
,
1225 IWICColorContext
**ppIColorContext
)
1227 FIXME("(%p,%p): stub\n", iface
, ppIColorContext
);
1231 static HRESULT WINAPI
PixelFormatInfo_GetBitsPerPixel(IWICPixelFormatInfo2
*iface
,
1232 UINT
*puiBitsPerPixel
)
1234 FIXME("(%p,%p): stub\n", iface
, puiBitsPerPixel
);
1238 static HRESULT WINAPI
PixelFormatInfo_GetChannelCount(IWICPixelFormatInfo2
*iface
,
1239 UINT
*puiChannelCount
)
1241 FIXME("(%p,%p): stub\n", iface
, puiChannelCount
);
1245 static HRESULT WINAPI
PixelFormatInfo_GetChannelMask(IWICPixelFormatInfo2
*iface
,
1246 UINT uiChannelIndex
, UINT cbMaskBuffer
, BYTE
*pbMaskBuffer
, UINT
*pcbActual
)
1248 FIXME("(%p,%u,%u,%p,%p): stub\n", iface
, uiChannelIndex
, cbMaskBuffer
, pbMaskBuffer
, pcbActual
);
1252 static HRESULT WINAPI
PixelFormatInfo_SupportsTransparency(IWICPixelFormatInfo2
*iface
,
1253 BOOL
*pfSupportsTransparency
)
1255 FIXME("(%p,%p): stub\n", iface
, pfSupportsTransparency
);
1259 static HRESULT WINAPI
PixelFormatInfo_GetNumericRepresentation(IWICPixelFormatInfo2
*iface
,
1260 WICPixelFormatNumericRepresentation
*pNumericRepresentation
)
1262 FIXME("(%p,%p): stub\n", iface
, pNumericRepresentation
);
1266 static const IWICPixelFormatInfo2Vtbl PixelFormatInfo_Vtbl
= {
1267 PixelFormatInfo_QueryInterface
,
1268 PixelFormatInfo_AddRef
,
1269 PixelFormatInfo_Release
,
1270 PixelFormatInfo_GetComponentType
,
1271 PixelFormatInfo_GetCLSID
,
1272 PixelFormatInfo_GetSigningStatus
,
1273 PixelFormatInfo_GetAuthor
,
1274 PixelFormatInfo_GetVendorGUID
,
1275 PixelFormatInfo_GetVersion
,
1276 PixelFormatInfo_GetSpecVersion
,
1277 PixelFormatInfo_GetFriendlyName
,
1278 PixelFormatInfo_GetFormatGUID
,
1279 PixelFormatInfo_GetColorContext
,
1280 PixelFormatInfo_GetBitsPerPixel
,
1281 PixelFormatInfo_GetChannelCount
,
1282 PixelFormatInfo_GetChannelMask
,
1283 PixelFormatInfo_SupportsTransparency
,
1284 PixelFormatInfo_GetNumericRepresentation
1287 static HRESULT
PixelFormatInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
1289 PixelFormatInfo
*This
;
1291 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(PixelFormatInfo
));
1294 RegCloseKey(classkey
);
1295 return E_OUTOFMEMORY
;
1298 This
->IWICPixelFormatInfo2_iface
.lpVtbl
= &PixelFormatInfo_Vtbl
;
1300 This
->classkey
= classkey
;
1301 memcpy(&This
->clsid
, clsid
, sizeof(CLSID
));
1303 *ppIInfo
= (IWICComponentInfo
*)This
;
1309 IWICMetadataReaderInfo IWICMetadataReaderInfo_iface
;
1313 } MetadataReaderInfo
;
1315 static inline MetadataReaderInfo
*impl_from_IWICMetadataReaderInfo(IWICMetadataReaderInfo
*iface
)
1317 return CONTAINING_RECORD(iface
, MetadataReaderInfo
, IWICMetadataReaderInfo_iface
);
1320 static HRESULT WINAPI
MetadataReaderInfo_QueryInterface(IWICMetadataReaderInfo
*iface
,
1321 REFIID riid
, void **ppv
)
1323 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1325 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(riid
), ppv
);
1327 if (!ppv
) return E_INVALIDARG
;
1329 if (IsEqualIID(&IID_IUnknown
, riid
) ||
1330 IsEqualIID(&IID_IWICComponentInfo
, riid
) ||
1331 IsEqualIID(&IID_IWICMetadataHandlerInfo
, riid
) ||
1332 IsEqualIID(&IID_IWICMetadataReaderInfo
, riid
))
1339 return E_NOINTERFACE
;
1342 IUnknown_AddRef((IUnknown
*)*ppv
);
1346 static ULONG WINAPI
MetadataReaderInfo_AddRef(IWICMetadataReaderInfo
*iface
)
1348 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1349 ULONG ref
= InterlockedIncrement(&This
->ref
);
1351 TRACE("(%p) refcount=%u\n", iface
, ref
);
1355 static ULONG WINAPI
MetadataReaderInfo_Release(IWICMetadataReaderInfo
*iface
)
1357 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1358 ULONG ref
= InterlockedDecrement(&This
->ref
);
1360 TRACE("(%p) refcount=%u\n", iface
, ref
);
1364 RegCloseKey(This
->classkey
);
1365 HeapFree(GetProcessHeap(), 0, This
);
1370 static HRESULT WINAPI
MetadataReaderInfo_GetComponentType(IWICMetadataReaderInfo
*iface
,
1371 WICComponentType
*type
)
1373 TRACE("(%p,%p)\n", iface
, type
);
1375 if (!type
) return E_INVALIDARG
;
1376 *type
= WICMetadataReader
;
1380 static HRESULT WINAPI
MetadataReaderInfo_GetCLSID(IWICMetadataReaderInfo
*iface
,
1383 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1385 TRACE("(%p,%p)\n", iface
, clsid
);
1387 if (!clsid
) return E_INVALIDARG
;
1388 *clsid
= This
->clsid
;
1392 static HRESULT WINAPI
MetadataReaderInfo_GetSigningStatus(IWICMetadataReaderInfo
*iface
,
1395 FIXME("(%p,%p): stub\n", iface
, status
);
1399 static HRESULT WINAPI
MetadataReaderInfo_GetAuthor(IWICMetadataReaderInfo
*iface
,
1400 UINT length
, WCHAR
*author
, UINT
*actual_length
)
1402 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1404 TRACE("(%p,%u,%p,%p)\n", iface
, length
, author
, actual_length
);
1406 return ComponentInfo_GetStringValue(This
->classkey
, author_valuename
,
1407 length
, author
, actual_length
);
1410 static HRESULT WINAPI
MetadataReaderInfo_GetVendorGUID(IWICMetadataReaderInfo
*iface
,
1413 FIXME("(%p,%p): stub\n", iface
, vendor
);
1417 static HRESULT WINAPI
MetadataReaderInfo_GetVersion(IWICMetadataReaderInfo
*iface
,
1418 UINT length
, WCHAR
*version
, UINT
*actual_length
)
1420 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1422 TRACE("(%p,%u,%p,%p)\n", iface
, length
, version
, actual_length
);
1424 return ComponentInfo_GetStringValue(This
->classkey
, version_valuename
,
1425 length
, version
, actual_length
);
1428 static HRESULT WINAPI
MetadataReaderInfo_GetSpecVersion(IWICMetadataReaderInfo
*iface
,
1429 UINT length
, WCHAR
*version
, UINT
*actual_length
)
1431 FIXME("(%p,%u,%p,%p): stub\n", iface
, length
, version
, actual_length
);
1435 static HRESULT WINAPI
MetadataReaderInfo_GetFriendlyName(IWICMetadataReaderInfo
*iface
,
1436 UINT length
, WCHAR
*name
, UINT
*actual_length
)
1438 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1440 TRACE("(%p,%u,%p,%p)\n", iface
, length
, name
, actual_length
);
1442 return ComponentInfo_GetStringValue(This
->classkey
, friendlyname_valuename
,
1443 length
, name
, actual_length
);
1446 static HRESULT WINAPI
MetadataReaderInfo_GetMetadataFormat(IWICMetadataReaderInfo
*iface
,
1449 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1450 TRACE("(%p,%p)\n", iface
, format
);
1451 return ComponentInfo_GetGUIDValue(This
->classkey
, metadataformat_valuename
, format
);
1454 static HRESULT WINAPI
MetadataReaderInfo_GetContainerFormats(IWICMetadataReaderInfo
*iface
,
1455 UINT length
, GUID
*formats
, UINT
*actual_length
)
1457 if (!actual_length
) return E_INVALIDARG
;
1459 FIXME("(%p,%u,%p,%p): stub\n", iface
, length
, formats
, actual_length
);
1463 static HRESULT WINAPI
MetadataReaderInfo_GetDeviceManufacturer(IWICMetadataReaderInfo
*iface
,
1464 UINT length
, WCHAR
*manufacturer
, UINT
*actual_length
)
1466 FIXME("(%p,%u,%p,%p): stub\n", iface
, length
, manufacturer
, actual_length
);
1470 static HRESULT WINAPI
MetadataReaderInfo_GetDeviceModels(IWICMetadataReaderInfo
*iface
,
1471 UINT length
, WCHAR
*models
, UINT
*actual_length
)
1473 FIXME("(%p,%u,%p,%p): stub\n", iface
, length
, models
, actual_length
);
1477 static HRESULT WINAPI
MetadataReaderInfo_DoesRequireFullStream(IWICMetadataReaderInfo
*iface
,
1480 FIXME("(%p,%p): stub\n", iface
, param
);
1484 static HRESULT WINAPI
MetadataReaderInfo_DoesSupportPadding(IWICMetadataReaderInfo
*iface
,
1487 FIXME("(%p,%p): stub\n", iface
, param
);
1491 static HRESULT WINAPI
MetadataReaderInfo_DoesRequireFixedSize(IWICMetadataReaderInfo
*iface
,
1494 FIXME("(%p,%p): stub\n", iface
, param
);
1498 static HRESULT WINAPI
MetadataReaderInfo_GetPatterns(IWICMetadataReaderInfo
*iface
,
1499 REFGUID container
, UINT length
, WICMetadataPattern
*pattern
, UINT
*count
, UINT
*actual_length
)
1501 if (!actual_length
) return E_INVALIDARG
;
1503 FIXME("(%p,%s,%u,%p,%p,%p): stub\n", iface
, debugstr_guid(container
), length
, pattern
, count
, actual_length
);
1507 static HRESULT WINAPI
MetadataReaderInfo_MatchesPattern(IWICMetadataReaderInfo
*iface
,
1508 REFGUID container
, IStream
*stream
, BOOL
*matches
)
1510 FIXME("(%p,%s,%p,%p): stub\n", iface
, debugstr_guid(container
), stream
, matches
);
1514 static HRESULT WINAPI
MetadataReaderInfo_CreateInstance(IWICMetadataReaderInfo
*iface
,
1515 IWICMetadataReader
**reader
)
1517 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1519 TRACE("(%p,%p)\n", iface
, reader
);
1521 return CoCreateInstance(&This
->clsid
, NULL
, CLSCTX_INPROC_SERVER
,
1522 &IID_IWICMetadataReader
, (void **)reader
);
1525 static const IWICMetadataReaderInfoVtbl MetadataReaderInfo_Vtbl
= {
1526 MetadataReaderInfo_QueryInterface
,
1527 MetadataReaderInfo_AddRef
,
1528 MetadataReaderInfo_Release
,
1529 MetadataReaderInfo_GetComponentType
,
1530 MetadataReaderInfo_GetCLSID
,
1531 MetadataReaderInfo_GetSigningStatus
,
1532 MetadataReaderInfo_GetAuthor
,
1533 MetadataReaderInfo_GetVendorGUID
,
1534 MetadataReaderInfo_GetVersion
,
1535 MetadataReaderInfo_GetSpecVersion
,
1536 MetadataReaderInfo_GetFriendlyName
,
1537 MetadataReaderInfo_GetMetadataFormat
,
1538 MetadataReaderInfo_GetContainerFormats
,
1539 MetadataReaderInfo_GetDeviceManufacturer
,
1540 MetadataReaderInfo_GetDeviceModels
,
1541 MetadataReaderInfo_DoesRequireFullStream
,
1542 MetadataReaderInfo_DoesSupportPadding
,
1543 MetadataReaderInfo_DoesRequireFixedSize
,
1544 MetadataReaderInfo_GetPatterns
,
1545 MetadataReaderInfo_MatchesPattern
,
1546 MetadataReaderInfo_CreateInstance
1549 static HRESULT
MetadataReaderInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**info
)
1551 MetadataReaderInfo
*This
;
1553 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
1556 RegCloseKey(classkey
);
1557 return E_OUTOFMEMORY
;
1560 This
->IWICMetadataReaderInfo_iface
.lpVtbl
= &MetadataReaderInfo_Vtbl
;
1562 This
->classkey
= classkey
;
1563 This
->clsid
= *clsid
;
1565 *info
= (IWICComponentInfo
*)This
;
1569 static const WCHAR clsid_keyname
[] = {'C','L','S','I','D',0};
1570 static const WCHAR instance_keyname
[] = {'I','n','s','t','a','n','c','e',0};
1573 WICComponentType type
;
1575 HRESULT (*constructor
)(HKEY
,REFCLSID
,IWICComponentInfo
**);
1578 static const struct category categories
[] = {
1579 {WICDecoder
, &CATID_WICBitmapDecoders
, BitmapDecoderInfo_Constructor
},
1580 {WICEncoder
, &CATID_WICBitmapEncoders
, BitmapEncoderInfo_Constructor
},
1581 {WICPixelFormatConverter
, &CATID_WICFormatConverters
, FormatConverterInfo_Constructor
},
1582 {WICPixelFormat
, &CATID_WICPixelFormats
, PixelFormatInfo_Constructor
},
1583 {WICMetadataReader
, &CATID_WICMetadataReader
, MetadataReaderInfo_Constructor
},
1587 HRESULT
CreateComponentInfo(REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
1593 WCHAR guidstring
[39];
1595 const struct category
*category
;
1599 res
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, clsid_keyname
, 0, KEY_READ
, &clsidkey
);
1600 if (res
!= ERROR_SUCCESS
)
1601 return HRESULT_FROM_WIN32(res
);
1603 for (category
=categories
; category
->type
; category
++)
1605 StringFromGUID2(category
->catid
, guidstring
, 39);
1606 res
= RegOpenKeyExW(clsidkey
, guidstring
, 0, KEY_READ
, &catidkey
);
1607 if (res
== ERROR_SUCCESS
)
1609 res
= RegOpenKeyExW(catidkey
, instance_keyname
, 0, KEY_READ
, &instancekey
);
1610 if (res
== ERROR_SUCCESS
)
1612 StringFromGUID2(clsid
, guidstring
, 39);
1613 res
= RegOpenKeyExW(instancekey
, guidstring
, 0, KEY_READ
, &classkey
);
1614 if (res
== ERROR_SUCCESS
)
1616 RegCloseKey(classkey
);
1619 RegCloseKey(instancekey
);
1621 RegCloseKey(catidkey
);
1628 res
= RegOpenKeyExW(clsidkey
, guidstring
, 0, KEY_READ
, &classkey
);
1629 if (res
== ERROR_SUCCESS
)
1630 hr
= category
->constructor(classkey
, clsid
, ppIInfo
);
1632 hr
= HRESULT_FROM_WIN32(res
);
1636 FIXME("%s is not supported\n", wine_dbgstr_guid(clsid
));
1640 RegCloseKey(clsidkey
);
1646 IEnumUnknown IEnumUnknown_iface
;
1648 struct list objects
;
1649 struct list
*cursor
;
1650 CRITICAL_SECTION lock
; /* Must be held when reading or writing cursor */
1653 static inline ComponentEnum
*impl_from_IEnumUnknown(IEnumUnknown
*iface
)
1655 return CONTAINING_RECORD(iface
, ComponentEnum
, IEnumUnknown_iface
);
1661 } ComponentEnumItem
;
1663 static const IEnumUnknownVtbl ComponentEnumVtbl
;
1665 static HRESULT WINAPI
ComponentEnum_QueryInterface(IEnumUnknown
*iface
, REFIID iid
,
1668 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1669 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
1671 if (!ppv
) return E_INVALIDARG
;
1673 if (IsEqualIID(&IID_IUnknown
, iid
) || IsEqualIID(&IID_IEnumUnknown
, iid
))
1680 return E_NOINTERFACE
;
1683 IUnknown_AddRef((IUnknown
*)*ppv
);
1687 static ULONG WINAPI
ComponentEnum_AddRef(IEnumUnknown
*iface
)
1689 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1690 ULONG ref
= InterlockedIncrement(&This
->ref
);
1692 TRACE("(%p) refcount=%u\n", iface
, ref
);
1697 static ULONG WINAPI
ComponentEnum_Release(IEnumUnknown
*iface
)
1699 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1700 ULONG ref
= InterlockedDecrement(&This
->ref
);
1701 ComponentEnumItem
*cursor
, *cursor2
;
1703 TRACE("(%p) refcount=%u\n", iface
, ref
);
1707 LIST_FOR_EACH_ENTRY_SAFE(cursor
, cursor2
, &This
->objects
, ComponentEnumItem
, entry
)
1709 IUnknown_Release(cursor
->unk
);
1710 list_remove(&cursor
->entry
);
1711 HeapFree(GetProcessHeap(), 0, cursor
);
1713 This
->lock
.DebugInfo
->Spare
[0] = 0;
1714 DeleteCriticalSection(&This
->lock
);
1715 HeapFree(GetProcessHeap(), 0, This
);
1721 static HRESULT WINAPI
ComponentEnum_Next(IEnumUnknown
*iface
, ULONG celt
,
1722 IUnknown
**rgelt
, ULONG
*pceltFetched
)
1724 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1726 ComponentEnumItem
*item
;
1729 TRACE("(%p,%u,%p,%p)\n", iface
, celt
, rgelt
, pceltFetched
);
1731 EnterCriticalSection(&This
->lock
);
1732 while (num_fetched
<celt
)
1739 item
= LIST_ENTRY(This
->cursor
, ComponentEnumItem
, entry
);
1740 IUnknown_AddRef(item
->unk
);
1741 rgelt
[num_fetched
] = item
->unk
;
1743 This
->cursor
= list_next(&This
->objects
, This
->cursor
);
1745 LeaveCriticalSection(&This
->lock
);
1747 *pceltFetched
= num_fetched
;
1751 static HRESULT WINAPI
ComponentEnum_Skip(IEnumUnknown
*iface
, ULONG celt
)
1753 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1757 TRACE("(%p,%u)\n", iface
, celt
);
1759 EnterCriticalSection(&This
->lock
);
1760 for (i
=0; i
<celt
; i
++)
1767 This
->cursor
= list_next(&This
->objects
, This
->cursor
);
1769 LeaveCriticalSection(&This
->lock
);
1773 static HRESULT WINAPI
ComponentEnum_Reset(IEnumUnknown
*iface
)
1775 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1777 TRACE("(%p)\n", iface
);
1779 EnterCriticalSection(&This
->lock
);
1780 This
->cursor
= list_head(&This
->objects
);
1781 LeaveCriticalSection(&This
->lock
);
1785 static HRESULT WINAPI
ComponentEnum_Clone(IEnumUnknown
*iface
, IEnumUnknown
**ppenum
)
1787 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1788 ComponentEnum
*new_enum
;
1789 ComponentEnumItem
*old_item
, *new_item
;
1791 struct list
*old_cursor
;
1793 new_enum
= HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnum
));
1797 return E_OUTOFMEMORY
;
1800 new_enum
->IEnumUnknown_iface
.lpVtbl
= &ComponentEnumVtbl
;
1802 new_enum
->cursor
= NULL
;
1803 list_init(&new_enum
->objects
);
1804 InitializeCriticalSection(&new_enum
->lock
);
1805 new_enum
->lock
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": ComponentEnum.lock");
1807 EnterCriticalSection(&This
->lock
);
1808 old_cursor
= This
->cursor
;
1809 LeaveCriticalSection(&This
->lock
);
1811 LIST_FOR_EACH_ENTRY(old_item
, &This
->objects
, ComponentEnumItem
, entry
)
1813 new_item
= HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnumItem
));
1816 ret
= E_OUTOFMEMORY
;
1819 new_item
->unk
= old_item
->unk
;
1820 list_add_tail(&new_enum
->objects
, &new_item
->entry
);
1821 IUnknown_AddRef(new_item
->unk
);
1822 if (&old_item
->entry
== old_cursor
) new_enum
->cursor
= &new_item
->entry
;
1827 IUnknown_Release((IUnknown
*)new_enum
);
1831 *ppenum
= (IEnumUnknown
*)new_enum
;
1836 static const IEnumUnknownVtbl ComponentEnumVtbl
= {
1837 ComponentEnum_QueryInterface
,
1838 ComponentEnum_AddRef
,
1839 ComponentEnum_Release
,
1842 ComponentEnum_Reset
,
1846 HRESULT
CreateComponentEnumerator(DWORD componentTypes
, DWORD options
, IEnumUnknown
**ppIEnumUnknown
)
1848 ComponentEnum
*This
;
1849 ComponentEnumItem
*item
;
1850 const struct category
*category
;
1851 HKEY clsidkey
, catidkey
, instancekey
;
1852 WCHAR guidstring
[39];
1858 if (options
) FIXME("ignoring flags %x\n", options
);
1860 res
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, clsid_keyname
, 0, KEY_READ
, &clsidkey
);
1861 if (res
!= ERROR_SUCCESS
)
1862 return HRESULT_FROM_WIN32(res
);
1864 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnum
));
1867 RegCloseKey(clsidkey
);
1868 return E_OUTOFMEMORY
;
1871 This
->IEnumUnknown_iface
.lpVtbl
= &ComponentEnumVtbl
;
1873 list_init(&This
->objects
);
1874 InitializeCriticalSection(&This
->lock
);
1875 This
->lock
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": ComponentEnum.lock");
1877 for (category
=categories
; category
->type
&& hr
== S_OK
; category
++)
1879 if ((category
->type
& componentTypes
) == 0) continue;
1880 StringFromGUID2(category
->catid
, guidstring
, 39);
1881 res
= RegOpenKeyExW(clsidkey
, guidstring
, 0, KEY_READ
, &catidkey
);
1882 if (res
== ERROR_SUCCESS
)
1884 res
= RegOpenKeyExW(catidkey
, instance_keyname
, 0, KEY_READ
, &instancekey
);
1885 if (res
== ERROR_SUCCESS
)
1890 DWORD guidstring_size
= 39;
1891 res
= RegEnumKeyExW(instancekey
, i
, guidstring
, &guidstring_size
, NULL
, NULL
, NULL
, NULL
);
1892 if (res
!= ERROR_SUCCESS
) break;
1894 item
= HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnumItem
));
1895 if (!item
) { hr
= E_OUTOFMEMORY
; break; }
1897 hr
= CLSIDFromString(guidstring
, &clsid
);
1900 hr
= CreateComponentInfo(&clsid
, (IWICComponentInfo
**)&item
->unk
);
1902 list_add_tail(&This
->objects
, &item
->entry
);
1907 HeapFree(GetProcessHeap(), 0, item
);
1911 RegCloseKey(instancekey
);
1913 RegCloseKey(catidkey
);
1915 if (res
!= ERROR_SUCCESS
&& res
!= ERROR_NO_MORE_ITEMS
)
1916 hr
= HRESULT_FROM_WIN32(res
);
1918 RegCloseKey(clsidkey
);
1922 IEnumUnknown_Reset((IEnumUnknown
*)This
);
1923 *ppIEnumUnknown
= (IEnumUnknown
*)This
;
1927 *ppIEnumUnknown
= NULL
;
1928 IUnknown_Release((IUnknown
*)This
);
1934 HRESULT WINAPI
WICConvertBitmapSource(REFWICPixelFormatGUID dstFormat
, IWICBitmapSource
*pISrc
, IWICBitmapSource
**ppIDst
)
1937 IEnumUnknown
*enumconverters
;
1938 IUnknown
*unkconverterinfo
;
1939 IWICFormatConverterInfo
*converterinfo
=NULL
;
1940 IWICFormatConverter
*converter
=NULL
;
1942 WCHAR srcformatstr
[39], dstformatstr
[39];
1946 res
= IWICBitmapSource_GetPixelFormat(pISrc
, &srcFormat
);
1947 if (FAILED(res
)) return res
;
1949 if (IsEqualGUID(&srcFormat
, dstFormat
))
1951 IWICBitmapSource_AddRef(pISrc
);
1956 StringFromGUID2(&srcFormat
, srcformatstr
, 39);
1957 StringFromGUID2(dstFormat
, dstformatstr
, 39);
1959 res
= CreateComponentEnumerator(WICPixelFormatConverter
, 0, &enumconverters
);
1960 if (FAILED(res
)) return res
;
1964 res
= IEnumUnknown_Next(enumconverters
, 1, &unkconverterinfo
, &num_fetched
);
1968 res
= IUnknown_QueryInterface(unkconverterinfo
, &IID_IWICFormatConverterInfo
, (void**)&converterinfo
);
1972 canconvert
= ConverterSupportsFormat(converterinfo
, srcformatstr
);
1975 canconvert
= ConverterSupportsFormat(converterinfo
, dstformatstr
);
1979 res
= IWICFormatConverterInfo_CreateInstance(converterinfo
, &converter
);
1982 res
= IWICFormatConverter_CanConvert(converter
, &srcFormat
, dstFormat
, &canconvert
);
1984 if (SUCCEEDED(res
) && canconvert
)
1985 res
= IWICFormatConverter_Initialize(converter
, pISrc
, dstFormat
, WICBitmapDitherTypeNone
,
1986 NULL
, 0.0, WICBitmapPaletteTypeCustom
);
1988 if (FAILED(res
) || !canconvert
)
1992 IWICFormatConverter_Release(converter
);
1999 IWICFormatConverterInfo_Release(converterinfo
);
2002 IUnknown_Release(unkconverterinfo
);
2008 IEnumUnknown_Release(enumconverters
);
2012 *ppIDst
= (IWICBitmapSource
*)converter
;
2017 FIXME("cannot convert %s to %s\n", debugstr_guid(&srcFormat
), debugstr_guid(dstFormat
));
2019 return WINCODEC_ERR_COMPONENTNOTFOUND
;