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};
58 static const WCHAR fileextensions_valuename
[] = {'F','i','l','e','E','x','t','e','n','s','i','o','n','s',0};
60 static HRESULT
ComponentInfo_GetStringValue(HKEY classkey
, LPCWSTR value
,
61 UINT buffer_size
, WCHAR
*buffer
, UINT
*actual_size
)
64 DWORD cbdata
=buffer_size
* sizeof(WCHAR
);
69 ret
= RegGetValueW(classkey
, NULL
, value
, RRF_RT_REG_SZ
|RRF_NOEXPAND
, NULL
,
72 if (ret
== ERROR_FILE_NOT_FOUND
)
78 if (ret
== 0 || ret
== ERROR_MORE_DATA
)
79 *actual_size
= cbdata
/sizeof(WCHAR
);
81 if (!buffer
&& buffer_size
!= 0)
82 /* Yes, native returns the correct size in this case. */
85 if (ret
== ERROR_MORE_DATA
)
86 return WINCODEC_ERR_INSUFFICIENTBUFFER
;
88 return HRESULT_FROM_WIN32(ret
);
91 static HRESULT
ComponentInfo_GetGUIDValue(HKEY classkey
, LPCWSTR value
,
95 WCHAR guid_string
[39];
96 DWORD cbdata
= sizeof(guid_string
);
102 ret
= RegGetValueW(classkey
, NULL
, value
, RRF_RT_REG_SZ
|RRF_NOEXPAND
, NULL
,
103 guid_string
, &cbdata
);
105 if (ret
!= ERROR_SUCCESS
)
106 return HRESULT_FROM_WIN32(ret
);
108 if (cbdata
< sizeof(guid_string
))
110 ERR("incomplete GUID value\n");
114 hr
= CLSIDFromString(guid_string
, result
);
119 static HRESULT
ComponentInfo_GetDWORDValue(HKEY classkey
, LPCWSTR value
,
123 DWORD cbdata
= sizeof(DWORD
);
128 ret
= RegGetValueW(classkey
, NULL
, value
, RRF_RT_DWORD
, NULL
,
131 if (ret
== ERROR_FILE_NOT_FOUND
)
137 return HRESULT_FROM_WIN32(ret
);
140 static HRESULT
ComponentInfo_GetGuidList(HKEY classkey
, LPCWSTR subkeyname
,
141 UINT buffersize
, GUID
*buffer
, UINT
*actual_size
)
146 WCHAR guid_string
[39];
147 DWORD guid_string_size
;
153 ret
= RegOpenKeyExW(classkey
, subkeyname
, 0, KEY_READ
, &subkey
);
154 if (ret
!= ERROR_SUCCESS
) return HRESULT_FROM_WIN32(ret
);
159 guid_string_size
= 39;
160 while (items_returned
< buffersize
)
162 ret
= RegEnumKeyExW(subkey
, items_returned
, guid_string
,
163 &guid_string_size
, NULL
, NULL
, NULL
, NULL
);
165 if (ret
!= ERROR_SUCCESS
)
167 hr
= HRESULT_FROM_WIN32(ret
);
171 if (guid_string_size
!= 38)
177 hr
= CLSIDFromString(guid_string
, &buffer
[items_returned
]);
182 guid_string_size
= 39;
185 if (ret
== ERROR_NO_MORE_ITEMS
)
188 *actual_size
= items_returned
;
192 ret
= RegQueryInfoKeyW(subkey
, NULL
, NULL
, NULL
, actual_size
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
193 if (ret
!= ERROR_SUCCESS
)
194 hr
= HRESULT_FROM_WIN32(ret
);
203 IWICBitmapDecoderInfo IWICBitmapDecoderInfo_iface
;
209 static inline BitmapDecoderInfo
*impl_from_IWICBitmapDecoderInfo(IWICBitmapDecoderInfo
*iface
)
211 return CONTAINING_RECORD(iface
, BitmapDecoderInfo
, IWICBitmapDecoderInfo_iface
);
214 static HRESULT WINAPI
BitmapDecoderInfo_QueryInterface(IWICBitmapDecoderInfo
*iface
, REFIID iid
,
217 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
218 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
220 if (!ppv
) return E_INVALIDARG
;
222 if (IsEqualIID(&IID_IUnknown
, iid
) ||
223 IsEqualIID(&IID_IWICComponentInfo
, iid
) ||
224 IsEqualIID(&IID_IWICBitmapCodecInfo
, iid
) ||
225 IsEqualIID(&IID_IWICBitmapDecoderInfo
,iid
))
232 return E_NOINTERFACE
;
235 IUnknown_AddRef((IUnknown
*)*ppv
);
239 static ULONG WINAPI
BitmapDecoderInfo_AddRef(IWICBitmapDecoderInfo
*iface
)
241 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
242 ULONG ref
= InterlockedIncrement(&This
->ref
);
244 TRACE("(%p) refcount=%u\n", iface
, ref
);
249 static ULONG WINAPI
BitmapDecoderInfo_Release(IWICBitmapDecoderInfo
*iface
)
251 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
252 ULONG ref
= InterlockedDecrement(&This
->ref
);
254 TRACE("(%p) refcount=%u\n", iface
, ref
);
258 RegCloseKey(This
->classkey
);
259 HeapFree(GetProcessHeap(), 0, This
);
265 static HRESULT WINAPI
BitmapDecoderInfo_GetComponentType(IWICBitmapDecoderInfo
*iface
,
266 WICComponentType
*pType
)
268 TRACE("(%p,%p)\n", iface
, pType
);
269 if (!pType
) return E_INVALIDARG
;
274 static HRESULT WINAPI
BitmapDecoderInfo_GetCLSID(IWICBitmapDecoderInfo
*iface
, CLSID
*pclsid
)
276 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
277 TRACE("(%p,%p)\n", iface
, pclsid
);
282 memcpy(pclsid
, &This
->clsid
, sizeof(CLSID
));
287 static HRESULT WINAPI
BitmapDecoderInfo_GetSigningStatus(IWICBitmapDecoderInfo
*iface
, DWORD
*pStatus
)
289 FIXME("(%p,%p): stub\n", iface
, pStatus
);
293 static HRESULT WINAPI
BitmapDecoderInfo_GetAuthor(IWICBitmapDecoderInfo
*iface
, UINT cchAuthor
,
294 WCHAR
*wzAuthor
, UINT
*pcchActual
)
296 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
298 TRACE("(%p,%u,%p,%p)\n", iface
, cchAuthor
, wzAuthor
, pcchActual
);
300 return ComponentInfo_GetStringValue(This
->classkey
, author_valuename
,
301 cchAuthor
, wzAuthor
, pcchActual
);
304 static HRESULT WINAPI
BitmapDecoderInfo_GetVendorGUID(IWICBitmapDecoderInfo
*iface
, GUID
*pguidVendor
)
306 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
308 TRACE("(%p,%p)\n", iface
, pguidVendor
);
310 return ComponentInfo_GetGUIDValue(This
->classkey
, vendor_valuename
, pguidVendor
);
313 static HRESULT WINAPI
BitmapDecoderInfo_GetVersion(IWICBitmapDecoderInfo
*iface
, UINT cchVersion
,
314 WCHAR
*wzVersion
, UINT
*pcchActual
)
316 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
318 TRACE("(%p,%u,%p,%p)\n", iface
, cchVersion
, wzVersion
, pcchActual
);
320 return ComponentInfo_GetStringValue(This
->classkey
, version_valuename
,
321 cchVersion
, wzVersion
, pcchActual
);
324 static HRESULT WINAPI
BitmapDecoderInfo_GetSpecVersion(IWICBitmapDecoderInfo
*iface
, UINT cchSpecVersion
,
325 WCHAR
*wzSpecVersion
, UINT
*pcchActual
)
327 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
329 TRACE("(%p,%u,%p,%p)\n", iface
, cchSpecVersion
, wzSpecVersion
, pcchActual
);
331 return ComponentInfo_GetStringValue(This
->classkey
, specversion_valuename
,
332 cchSpecVersion
, wzSpecVersion
, pcchActual
);
335 static HRESULT WINAPI
BitmapDecoderInfo_GetFriendlyName(IWICBitmapDecoderInfo
*iface
, UINT cchFriendlyName
,
336 WCHAR
*wzFriendlyName
, UINT
*pcchActual
)
338 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
340 TRACE("(%p,%u,%p,%p)\n", iface
, cchFriendlyName
, wzFriendlyName
, pcchActual
);
342 return ComponentInfo_GetStringValue(This
->classkey
, friendlyname_valuename
,
343 cchFriendlyName
, wzFriendlyName
, pcchActual
);
346 static HRESULT WINAPI
BitmapDecoderInfo_GetContainerFormat(IWICBitmapDecoderInfo
*iface
,
347 GUID
*pguidContainerFormat
)
349 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
350 TRACE("(%p,%p)\n", iface
, pguidContainerFormat
);
351 return ComponentInfo_GetGUIDValue(This
->classkey
, containerformat_valuename
, pguidContainerFormat
);
354 static HRESULT WINAPI
BitmapDecoderInfo_GetPixelFormats(IWICBitmapDecoderInfo
*iface
,
355 UINT cFormats
, GUID
*pguidPixelFormats
, UINT
*pcActual
)
357 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
358 TRACE("(%p,%u,%p,%p)\n", iface
, cFormats
, pguidPixelFormats
, pcActual
);
359 return ComponentInfo_GetGuidList(This
->classkey
, formats_keyname
, cFormats
, pguidPixelFormats
, pcActual
);
362 static HRESULT WINAPI
BitmapDecoderInfo_GetColorManagementVersion(IWICBitmapDecoderInfo
*iface
,
363 UINT cchColorManagementVersion
, WCHAR
*wzColorManagementVersion
, UINT
*pcchActual
)
365 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchColorManagementVersion
, wzColorManagementVersion
, pcchActual
);
369 static HRESULT WINAPI
BitmapDecoderInfo_GetDeviceManufacturer(IWICBitmapDecoderInfo
*iface
,
370 UINT cchDeviceManufacturer
, WCHAR
*wzDeviceManufacturer
, UINT
*pcchActual
)
372 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchDeviceManufacturer
, wzDeviceManufacturer
, pcchActual
);
376 static HRESULT WINAPI
BitmapDecoderInfo_GetDeviceModels(IWICBitmapDecoderInfo
*iface
,
377 UINT cchDeviceModels
, WCHAR
*wzDeviceModels
, UINT
*pcchActual
)
379 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchDeviceModels
, wzDeviceModels
, pcchActual
);
383 static HRESULT WINAPI
BitmapDecoderInfo_GetMimeTypes(IWICBitmapDecoderInfo
*iface
,
384 UINT cchMimeTypes
, WCHAR
*wzMimeTypes
, UINT
*pcchActual
)
386 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
388 TRACE("(%p,%u,%p,%p)\n", iface
, cchMimeTypes
, wzMimeTypes
, pcchActual
);
390 return ComponentInfo_GetStringValue(This
->classkey
, mimetypes_valuename
,
391 cchMimeTypes
, wzMimeTypes
, pcchActual
);
394 static HRESULT WINAPI
BitmapDecoderInfo_GetFileExtensions(IWICBitmapDecoderInfo
*iface
,
395 UINT cchFileExtensions
, WCHAR
*wzFileExtensions
, UINT
*pcchActual
)
397 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
399 TRACE("(%p,%u,%p,%p)\n", iface
, cchFileExtensions
, wzFileExtensions
, pcchActual
);
401 return ComponentInfo_GetStringValue(This
->classkey
, fileextensions_valuename
,
402 cchFileExtensions
, wzFileExtensions
, pcchActual
);
405 static HRESULT WINAPI
BitmapDecoderInfo_DoesSupportAnimation(IWICBitmapDecoderInfo
*iface
,
406 BOOL
*pfSupportAnimation
)
408 FIXME("(%p,%p): stub\n", iface
, pfSupportAnimation
);
412 static HRESULT WINAPI
BitmapDecoderInfo_DoesSupportChromaKey(IWICBitmapDecoderInfo
*iface
,
413 BOOL
*pfSupportChromaKey
)
415 FIXME("(%p,%p): stub\n", iface
, pfSupportChromaKey
);
419 static HRESULT WINAPI
BitmapDecoderInfo_DoesSupportLossless(IWICBitmapDecoderInfo
*iface
,
420 BOOL
*pfSupportLossless
)
422 FIXME("(%p,%p): stub\n", iface
, pfSupportLossless
);
426 static HRESULT WINAPI
BitmapDecoderInfo_DoesSupportMultiframe(IWICBitmapDecoderInfo
*iface
,
427 BOOL
*pfSupportMultiframe
)
429 FIXME("(%p,%p): stub\n", iface
, pfSupportMultiframe
);
433 static HRESULT WINAPI
BitmapDecoderInfo_MatchesMimeType(IWICBitmapDecoderInfo
*iface
,
434 LPCWSTR wzMimeType
, BOOL
*pfMatches
)
436 FIXME("(%p,%s,%p): stub\n", iface
, debugstr_w(wzMimeType
), pfMatches
);
440 static HRESULT WINAPI
BitmapDecoderInfo_GetPatterns(IWICBitmapDecoderInfo
*iface
,
441 UINT cbSizePatterns
, WICBitmapPattern
*pPatterns
, UINT
*pcPatterns
, UINT
*pcbPatternsActual
)
443 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
444 UINT pattern_count
=0, patterns_size
=0;
445 WCHAR subkeyname
[11];
447 HKEY patternskey
, patternkey
;
448 static const WCHAR uintformatW
[] = {'%','u',0};
449 static const WCHAR patternsW
[] = {'P','a','t','t','e','r','n','s',0};
450 static const WCHAR positionW
[] = {'P','o','s','i','t','i','o','n',0};
451 static const WCHAR lengthW
[] = {'L','e','n','g','t','h',0};
452 static const WCHAR patternW
[] = {'P','a','t','t','e','r','n',0};
453 static const WCHAR maskW
[] = {'M','a','s','k',0};
454 static const WCHAR endofstreamW
[] = {'E','n','d','O','f','S','t','r','e','a','m',0};
457 BYTE
*bPatterns
=(BYTE
*)pPatterns
;
458 DWORD length
, valuesize
;
460 TRACE("(%p,%i,%p,%p,%p)\n", iface
, cbSizePatterns
, pPatterns
, pcPatterns
, pcbPatternsActual
);
462 res
= RegOpenKeyExW(This
->classkey
, patternsW
, 0, KEY_READ
, &patternskey
);
463 if (res
!= ERROR_SUCCESS
) return HRESULT_FROM_WIN32(res
);
465 res
= RegQueryInfoKeyW(patternskey
, NULL
, NULL
, NULL
, &pattern_count
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
466 if (res
== ERROR_SUCCESS
)
468 patterns_size
= pattern_count
* sizeof(WICBitmapPattern
);
470 for (i
=0; i
<pattern_count
; i
++)
472 snprintfW(subkeyname
, 11, uintformatW
, i
);
473 res
= RegOpenKeyExW(patternskey
, subkeyname
, 0, KEY_READ
, &patternkey
);
474 if (res
== ERROR_SUCCESS
)
476 valuesize
= sizeof(ULONG
);
477 res
= RegGetValueW(patternkey
, NULL
, lengthW
, RRF_RT_DWORD
, NULL
,
478 &length
, &valuesize
);
479 patterns_size
+= length
*2;
481 if ((cbSizePatterns
>= patterns_size
) && (res
== ERROR_SUCCESS
))
483 pPatterns
[i
].Length
= length
;
485 pPatterns
[i
].EndOfStream
= 0;
486 valuesize
= sizeof(BOOL
);
487 RegGetValueW(patternkey
, NULL
, endofstreamW
, RRF_RT_DWORD
, NULL
,
488 &pPatterns
[i
].EndOfStream
, &valuesize
);
490 pPatterns
[i
].Position
.QuadPart
= 0;
491 valuesize
= sizeof(ULARGE_INTEGER
);
492 res
= RegGetValueW(patternkey
, NULL
, positionW
, RRF_RT_DWORD
|RRF_RT_QWORD
, NULL
,
493 &pPatterns
[i
].Position
, &valuesize
);
495 if (res
== ERROR_SUCCESS
)
497 pPatterns
[i
].Pattern
= bPatterns
+patterns_size
-length
*2;
499 res
= RegGetValueW(patternkey
, NULL
, patternW
, RRF_RT_REG_BINARY
, NULL
,
500 pPatterns
[i
].Pattern
, &valuesize
);
503 if (res
== ERROR_SUCCESS
)
505 pPatterns
[i
].Mask
= bPatterns
+patterns_size
-length
;
507 res
= RegGetValueW(patternkey
, NULL
, maskW
, RRF_RT_REG_BINARY
, NULL
,
508 pPatterns
[i
].Mask
, &valuesize
);
512 RegCloseKey(patternkey
);
514 if (res
!= ERROR_SUCCESS
)
516 hr
= HRESULT_FROM_WIN32(res
);
521 else hr
= HRESULT_FROM_WIN32(res
);
523 RegCloseKey(patternskey
);
527 *pcPatterns
= pattern_count
;
528 *pcbPatternsActual
= patterns_size
;
529 if (pPatterns
&& cbSizePatterns
< patterns_size
)
530 hr
= WINCODEC_ERR_INSUFFICIENTBUFFER
;
536 static HRESULT WINAPI
BitmapDecoderInfo_MatchesPattern(IWICBitmapDecoderInfo
*iface
,
537 IStream
*pIStream
, BOOL
*pfMatches
)
539 WICBitmapPattern
*patterns
;
540 UINT pattern_count
=0, patterns_size
=0;
547 LARGE_INTEGER seekpos
;
549 TRACE("(%p,%p,%p)\n", iface
, pIStream
, pfMatches
);
551 hr
= BitmapDecoderInfo_GetPatterns(iface
, 0, NULL
, &pattern_count
, &patterns_size
);
552 if (FAILED(hr
)) return hr
;
554 patterns
= HeapAlloc(GetProcessHeap(), 0, patterns_size
);
555 if (!patterns
) return E_OUTOFMEMORY
;
557 hr
= BitmapDecoderInfo_GetPatterns(iface
, patterns_size
, patterns
, &pattern_count
, &patterns_size
);
558 if (FAILED(hr
)) goto end
;
560 for (i
=0; i
<pattern_count
; i
++)
562 if (datasize
< patterns
[i
].Length
)
564 HeapFree(GetProcessHeap(), 0, data
);
565 datasize
= patterns
[i
].Length
;
566 data
= HeapAlloc(GetProcessHeap(), 0, patterns
[i
].Length
);
574 if (patterns
[i
].EndOfStream
)
575 seekpos
.QuadPart
= -patterns
[i
].Position
.QuadPart
;
577 seekpos
.QuadPart
= patterns
[i
].Position
.QuadPart
;
578 hr
= IStream_Seek(pIStream
, seekpos
, patterns
[i
].EndOfStream
? STREAM_SEEK_END
: STREAM_SEEK_SET
, NULL
);
579 if (hr
== STG_E_INVALIDFUNCTION
) continue; /* before start of stream */
580 if (FAILED(hr
)) break;
582 hr
= IStream_Read(pIStream
, data
, patterns
[i
].Length
, &bytesread
);
583 if (hr
== S_FALSE
|| (hr
== S_OK
&& bytesread
!= patterns
[i
].Length
)) /* past end of stream */
585 if (FAILED(hr
)) break;
587 for (pos
=0; pos
<patterns
[i
].Length
; pos
++)
589 if ((data
[pos
] & patterns
[i
].Mask
[pos
]) != patterns
[i
].Pattern
[pos
])
592 if (pos
== patterns
[i
].Length
) /* matches pattern */
600 if (i
== pattern_count
) /* does not match any pattern */
607 HeapFree(GetProcessHeap(), 0, patterns
);
608 HeapFree(GetProcessHeap(), 0, data
);
613 static HRESULT WINAPI
BitmapDecoderInfo_CreateInstance(IWICBitmapDecoderInfo
*iface
,
614 IWICBitmapDecoder
**ppIBitmapDecoder
)
616 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
618 TRACE("(%p,%p)\n", iface
, ppIBitmapDecoder
);
620 return CoCreateInstance(&This
->clsid
, NULL
, CLSCTX_INPROC_SERVER
,
621 &IID_IWICBitmapDecoder
, (void**)ppIBitmapDecoder
);
624 static const IWICBitmapDecoderInfoVtbl BitmapDecoderInfo_Vtbl
= {
625 BitmapDecoderInfo_QueryInterface
,
626 BitmapDecoderInfo_AddRef
,
627 BitmapDecoderInfo_Release
,
628 BitmapDecoderInfo_GetComponentType
,
629 BitmapDecoderInfo_GetCLSID
,
630 BitmapDecoderInfo_GetSigningStatus
,
631 BitmapDecoderInfo_GetAuthor
,
632 BitmapDecoderInfo_GetVendorGUID
,
633 BitmapDecoderInfo_GetVersion
,
634 BitmapDecoderInfo_GetSpecVersion
,
635 BitmapDecoderInfo_GetFriendlyName
,
636 BitmapDecoderInfo_GetContainerFormat
,
637 BitmapDecoderInfo_GetPixelFormats
,
638 BitmapDecoderInfo_GetColorManagementVersion
,
639 BitmapDecoderInfo_GetDeviceManufacturer
,
640 BitmapDecoderInfo_GetDeviceModels
,
641 BitmapDecoderInfo_GetMimeTypes
,
642 BitmapDecoderInfo_GetFileExtensions
,
643 BitmapDecoderInfo_DoesSupportAnimation
,
644 BitmapDecoderInfo_DoesSupportChromaKey
,
645 BitmapDecoderInfo_DoesSupportLossless
,
646 BitmapDecoderInfo_DoesSupportMultiframe
,
647 BitmapDecoderInfo_MatchesMimeType
,
648 BitmapDecoderInfo_GetPatterns
,
649 BitmapDecoderInfo_MatchesPattern
,
650 BitmapDecoderInfo_CreateInstance
653 static HRESULT
BitmapDecoderInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
655 BitmapDecoderInfo
*This
;
657 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapDecoderInfo
));
660 RegCloseKey(classkey
);
661 return E_OUTOFMEMORY
;
664 This
->IWICBitmapDecoderInfo_iface
.lpVtbl
= &BitmapDecoderInfo_Vtbl
;
666 This
->classkey
= classkey
;
667 memcpy(&This
->clsid
, clsid
, sizeof(CLSID
));
669 *ppIInfo
= (IWICComponentInfo
*)This
;
674 IWICBitmapEncoderInfo IWICBitmapEncoderInfo_iface
;
680 static inline BitmapEncoderInfo
*impl_from_IWICBitmapEncoderInfo(IWICBitmapEncoderInfo
*iface
)
682 return CONTAINING_RECORD(iface
, BitmapEncoderInfo
, IWICBitmapEncoderInfo_iface
);
685 static HRESULT WINAPI
BitmapEncoderInfo_QueryInterface(IWICBitmapEncoderInfo
*iface
, REFIID iid
,
688 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
689 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
691 if (!ppv
) return E_INVALIDARG
;
693 if (IsEqualIID(&IID_IUnknown
, iid
) ||
694 IsEqualIID(&IID_IWICComponentInfo
, iid
) ||
695 IsEqualIID(&IID_IWICBitmapCodecInfo
, iid
) ||
696 IsEqualIID(&IID_IWICBitmapEncoderInfo
,iid
))
703 return E_NOINTERFACE
;
706 IUnknown_AddRef((IUnknown
*)*ppv
);
710 static ULONG WINAPI
BitmapEncoderInfo_AddRef(IWICBitmapEncoderInfo
*iface
)
712 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
713 ULONG ref
= InterlockedIncrement(&This
->ref
);
715 TRACE("(%p) refcount=%u\n", iface
, ref
);
720 static ULONG WINAPI
BitmapEncoderInfo_Release(IWICBitmapEncoderInfo
*iface
)
722 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
723 ULONG ref
= InterlockedDecrement(&This
->ref
);
725 TRACE("(%p) refcount=%u\n", iface
, ref
);
729 RegCloseKey(This
->classkey
);
730 HeapFree(GetProcessHeap(), 0, This
);
736 static HRESULT WINAPI
BitmapEncoderInfo_GetComponentType(IWICBitmapEncoderInfo
*iface
,
737 WICComponentType
*pType
)
739 TRACE("(%p,%p)\n", iface
, pType
);
740 if (!pType
) return E_INVALIDARG
;
745 static HRESULT WINAPI
BitmapEncoderInfo_GetCLSID(IWICBitmapEncoderInfo
*iface
, CLSID
*pclsid
)
747 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
748 TRACE("(%p,%p)\n", iface
, pclsid
);
753 memcpy(pclsid
, &This
->clsid
, sizeof(CLSID
));
758 static HRESULT WINAPI
BitmapEncoderInfo_GetSigningStatus(IWICBitmapEncoderInfo
*iface
, DWORD
*pStatus
)
760 FIXME("(%p,%p): stub\n", iface
, pStatus
);
764 static HRESULT WINAPI
BitmapEncoderInfo_GetAuthor(IWICBitmapEncoderInfo
*iface
, UINT cchAuthor
,
765 WCHAR
*wzAuthor
, UINT
*pcchActual
)
767 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
769 TRACE("(%p,%u,%p,%p)\n", iface
, cchAuthor
, wzAuthor
, pcchActual
);
771 return ComponentInfo_GetStringValue(This
->classkey
, author_valuename
,
772 cchAuthor
, wzAuthor
, pcchActual
);
775 static HRESULT WINAPI
BitmapEncoderInfo_GetVendorGUID(IWICBitmapEncoderInfo
*iface
, GUID
*pguidVendor
)
777 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
779 TRACE("(%p,%p)\n", iface
, pguidVendor
);
781 return ComponentInfo_GetGUIDValue(This
->classkey
, vendor_valuename
, pguidVendor
);
784 static HRESULT WINAPI
BitmapEncoderInfo_GetVersion(IWICBitmapEncoderInfo
*iface
, UINT cchVersion
,
785 WCHAR
*wzVersion
, UINT
*pcchActual
)
787 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
789 TRACE("(%p,%u,%p,%p)\n", iface
, cchVersion
, wzVersion
, pcchActual
);
791 return ComponentInfo_GetStringValue(This
->classkey
, version_valuename
,
792 cchVersion
, wzVersion
, pcchActual
);
795 static HRESULT WINAPI
BitmapEncoderInfo_GetSpecVersion(IWICBitmapEncoderInfo
*iface
, UINT cchSpecVersion
,
796 WCHAR
*wzSpecVersion
, UINT
*pcchActual
)
798 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
800 TRACE("(%p,%u,%p,%p)\n", iface
, cchSpecVersion
, wzSpecVersion
, pcchActual
);
802 return ComponentInfo_GetStringValue(This
->classkey
, specversion_valuename
,
803 cchSpecVersion
, wzSpecVersion
, pcchActual
);
806 static HRESULT WINAPI
BitmapEncoderInfo_GetFriendlyName(IWICBitmapEncoderInfo
*iface
, UINT cchFriendlyName
,
807 WCHAR
*wzFriendlyName
, UINT
*pcchActual
)
809 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
811 TRACE("(%p,%u,%p,%p)\n", iface
, cchFriendlyName
, wzFriendlyName
, pcchActual
);
813 return ComponentInfo_GetStringValue(This
->classkey
, friendlyname_valuename
,
814 cchFriendlyName
, wzFriendlyName
, pcchActual
);
817 static HRESULT WINAPI
BitmapEncoderInfo_GetContainerFormat(IWICBitmapEncoderInfo
*iface
,
818 GUID
*pguidContainerFormat
)
820 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
821 TRACE("(%p,%p)\n", iface
, pguidContainerFormat
);
822 return ComponentInfo_GetGUIDValue(This
->classkey
, containerformat_valuename
, pguidContainerFormat
);
825 static HRESULT WINAPI
BitmapEncoderInfo_GetPixelFormats(IWICBitmapEncoderInfo
*iface
,
826 UINT cFormats
, GUID
*pguidPixelFormats
, UINT
*pcActual
)
828 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
829 TRACE("(%p,%u,%p,%p)\n", iface
, cFormats
, pguidPixelFormats
, pcActual
);
830 return ComponentInfo_GetGuidList(This
->classkey
, formats_keyname
, cFormats
, pguidPixelFormats
, pcActual
);
833 static HRESULT WINAPI
BitmapEncoderInfo_GetColorManagementVersion(IWICBitmapEncoderInfo
*iface
,
834 UINT cchColorManagementVersion
, WCHAR
*wzColorManagementVersion
, UINT
*pcchActual
)
836 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchColorManagementVersion
, wzColorManagementVersion
, pcchActual
);
840 static HRESULT WINAPI
BitmapEncoderInfo_GetDeviceManufacturer(IWICBitmapEncoderInfo
*iface
,
841 UINT cchDeviceManufacturer
, WCHAR
*wzDeviceManufacturer
, UINT
*pcchActual
)
843 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchDeviceManufacturer
, wzDeviceManufacturer
, pcchActual
);
847 static HRESULT WINAPI
BitmapEncoderInfo_GetDeviceModels(IWICBitmapEncoderInfo
*iface
,
848 UINT cchDeviceModels
, WCHAR
*wzDeviceModels
, UINT
*pcchActual
)
850 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchDeviceModels
, wzDeviceModels
, pcchActual
);
854 static HRESULT WINAPI
BitmapEncoderInfo_GetMimeTypes(IWICBitmapEncoderInfo
*iface
,
855 UINT cchMimeTypes
, WCHAR
*wzMimeTypes
, UINT
*pcchActual
)
857 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
859 TRACE("(%p,%u,%p,%p)\n", iface
, cchMimeTypes
, wzMimeTypes
, pcchActual
);
861 return ComponentInfo_GetStringValue(This
->classkey
, mimetypes_valuename
,
862 cchMimeTypes
, wzMimeTypes
, pcchActual
);
865 static HRESULT WINAPI
BitmapEncoderInfo_GetFileExtensions(IWICBitmapEncoderInfo
*iface
,
866 UINT cchFileExtensions
, WCHAR
*wzFileExtensions
, UINT
*pcchActual
)
868 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchFileExtensions
, wzFileExtensions
, pcchActual
);
872 static HRESULT WINAPI
BitmapEncoderInfo_DoesSupportAnimation(IWICBitmapEncoderInfo
*iface
,
873 BOOL
*pfSupportAnimation
)
875 FIXME("(%p,%p): stub\n", iface
, pfSupportAnimation
);
879 static HRESULT WINAPI
BitmapEncoderInfo_DoesSupportChromaKey(IWICBitmapEncoderInfo
*iface
,
880 BOOL
*pfSupportChromaKey
)
882 FIXME("(%p,%p): stub\n", iface
, pfSupportChromaKey
);
886 static HRESULT WINAPI
BitmapEncoderInfo_DoesSupportLossless(IWICBitmapEncoderInfo
*iface
,
887 BOOL
*pfSupportLossless
)
889 FIXME("(%p,%p): stub\n", iface
, pfSupportLossless
);
893 static HRESULT WINAPI
BitmapEncoderInfo_DoesSupportMultiframe(IWICBitmapEncoderInfo
*iface
,
894 BOOL
*pfSupportMultiframe
)
896 FIXME("(%p,%p): stub\n", iface
, pfSupportMultiframe
);
900 static HRESULT WINAPI
BitmapEncoderInfo_MatchesMimeType(IWICBitmapEncoderInfo
*iface
,
901 LPCWSTR wzMimeType
, BOOL
*pfMatches
)
903 FIXME("(%p,%s,%p): stub\n", iface
, debugstr_w(wzMimeType
), pfMatches
);
907 static HRESULT WINAPI
BitmapEncoderInfo_CreateInstance(IWICBitmapEncoderInfo
*iface
,
908 IWICBitmapEncoder
**ppIBitmapEncoder
)
910 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
912 TRACE("(%p,%p)\n", iface
, ppIBitmapEncoder
);
914 return CoCreateInstance(&This
->clsid
, NULL
, CLSCTX_INPROC_SERVER
,
915 &IID_IWICBitmapEncoder
, (void**)ppIBitmapEncoder
);
918 static const IWICBitmapEncoderInfoVtbl BitmapEncoderInfo_Vtbl
= {
919 BitmapEncoderInfo_QueryInterface
,
920 BitmapEncoderInfo_AddRef
,
921 BitmapEncoderInfo_Release
,
922 BitmapEncoderInfo_GetComponentType
,
923 BitmapEncoderInfo_GetCLSID
,
924 BitmapEncoderInfo_GetSigningStatus
,
925 BitmapEncoderInfo_GetAuthor
,
926 BitmapEncoderInfo_GetVendorGUID
,
927 BitmapEncoderInfo_GetVersion
,
928 BitmapEncoderInfo_GetSpecVersion
,
929 BitmapEncoderInfo_GetFriendlyName
,
930 BitmapEncoderInfo_GetContainerFormat
,
931 BitmapEncoderInfo_GetPixelFormats
,
932 BitmapEncoderInfo_GetColorManagementVersion
,
933 BitmapEncoderInfo_GetDeviceManufacturer
,
934 BitmapEncoderInfo_GetDeviceModels
,
935 BitmapEncoderInfo_GetMimeTypes
,
936 BitmapEncoderInfo_GetFileExtensions
,
937 BitmapEncoderInfo_DoesSupportAnimation
,
938 BitmapEncoderInfo_DoesSupportChromaKey
,
939 BitmapEncoderInfo_DoesSupportLossless
,
940 BitmapEncoderInfo_DoesSupportMultiframe
,
941 BitmapEncoderInfo_MatchesMimeType
,
942 BitmapEncoderInfo_CreateInstance
945 static HRESULT
BitmapEncoderInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
947 BitmapEncoderInfo
*This
;
949 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapEncoderInfo
));
952 RegCloseKey(classkey
);
953 return E_OUTOFMEMORY
;
956 This
->IWICBitmapEncoderInfo_iface
.lpVtbl
= &BitmapEncoderInfo_Vtbl
;
958 This
->classkey
= classkey
;
959 memcpy(&This
->clsid
, clsid
, sizeof(CLSID
));
961 *ppIInfo
= (IWICComponentInfo
*)This
;
966 IWICFormatConverterInfo IWICFormatConverterInfo_iface
;
970 } FormatConverterInfo
;
972 static inline FormatConverterInfo
*impl_from_IWICFormatConverterInfo(IWICFormatConverterInfo
*iface
)
974 return CONTAINING_RECORD(iface
, FormatConverterInfo
, IWICFormatConverterInfo_iface
);
977 static HRESULT WINAPI
FormatConverterInfo_QueryInterface(IWICFormatConverterInfo
*iface
, REFIID iid
,
980 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
981 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
983 if (!ppv
) return E_INVALIDARG
;
985 if (IsEqualIID(&IID_IUnknown
, iid
) ||
986 IsEqualIID(&IID_IWICComponentInfo
, iid
) ||
987 IsEqualIID(&IID_IWICFormatConverterInfo
,iid
))
994 return E_NOINTERFACE
;
997 IUnknown_AddRef((IUnknown
*)*ppv
);
1001 static ULONG WINAPI
FormatConverterInfo_AddRef(IWICFormatConverterInfo
*iface
)
1003 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1004 ULONG ref
= InterlockedIncrement(&This
->ref
);
1006 TRACE("(%p) refcount=%u\n", iface
, ref
);
1011 static ULONG WINAPI
FormatConverterInfo_Release(IWICFormatConverterInfo
*iface
)
1013 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1014 ULONG ref
= InterlockedDecrement(&This
->ref
);
1016 TRACE("(%p) refcount=%u\n", iface
, ref
);
1020 RegCloseKey(This
->classkey
);
1021 HeapFree(GetProcessHeap(), 0, This
);
1027 static HRESULT WINAPI
FormatConverterInfo_GetComponentType(IWICFormatConverterInfo
*iface
,
1028 WICComponentType
*pType
)
1030 TRACE("(%p,%p)\n", iface
, pType
);
1031 if (!pType
) return E_INVALIDARG
;
1032 *pType
= WICPixelFormatConverter
;
1036 static HRESULT WINAPI
FormatConverterInfo_GetCLSID(IWICFormatConverterInfo
*iface
, CLSID
*pclsid
)
1038 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1039 TRACE("(%p,%p)\n", iface
, pclsid
);
1042 return E_INVALIDARG
;
1044 memcpy(pclsid
, &This
->clsid
, sizeof(CLSID
));
1049 static HRESULT WINAPI
FormatConverterInfo_GetSigningStatus(IWICFormatConverterInfo
*iface
, DWORD
*pStatus
)
1051 FIXME("(%p,%p): stub\n", iface
, pStatus
);
1055 static HRESULT WINAPI
FormatConverterInfo_GetAuthor(IWICFormatConverterInfo
*iface
, UINT cchAuthor
,
1056 WCHAR
*wzAuthor
, UINT
*pcchActual
)
1058 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1060 TRACE("(%p,%u,%p,%p)\n", iface
, cchAuthor
, wzAuthor
, pcchActual
);
1062 return ComponentInfo_GetStringValue(This
->classkey
, author_valuename
,
1063 cchAuthor
, wzAuthor
, pcchActual
);
1066 static HRESULT WINAPI
FormatConverterInfo_GetVendorGUID(IWICFormatConverterInfo
*iface
, GUID
*pguidVendor
)
1068 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1070 TRACE("(%p,%p)\n", iface
, pguidVendor
);
1072 return ComponentInfo_GetGUIDValue(This
->classkey
, vendor_valuename
, pguidVendor
);
1075 static HRESULT WINAPI
FormatConverterInfo_GetVersion(IWICFormatConverterInfo
*iface
, UINT cchVersion
,
1076 WCHAR
*wzVersion
, UINT
*pcchActual
)
1078 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1080 TRACE("(%p,%u,%p,%p)\n", iface
, cchVersion
, wzVersion
, pcchActual
);
1082 return ComponentInfo_GetStringValue(This
->classkey
, version_valuename
,
1083 cchVersion
, wzVersion
, pcchActual
);
1086 static HRESULT WINAPI
FormatConverterInfo_GetSpecVersion(IWICFormatConverterInfo
*iface
, UINT cchSpecVersion
,
1087 WCHAR
*wzSpecVersion
, UINT
*pcchActual
)
1089 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1091 TRACE("(%p,%u,%p,%p)\n", iface
, cchSpecVersion
, wzSpecVersion
, pcchActual
);
1093 return ComponentInfo_GetStringValue(This
->classkey
, specversion_valuename
,
1094 cchSpecVersion
, wzSpecVersion
, pcchActual
);
1097 static HRESULT WINAPI
FormatConverterInfo_GetFriendlyName(IWICFormatConverterInfo
*iface
, UINT cchFriendlyName
,
1098 WCHAR
*wzFriendlyName
, UINT
*pcchActual
)
1100 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1102 TRACE("(%p,%u,%p,%p)\n", iface
, cchFriendlyName
, wzFriendlyName
, pcchActual
);
1104 return ComponentInfo_GetStringValue(This
->classkey
, friendlyname_valuename
,
1105 cchFriendlyName
, wzFriendlyName
, pcchActual
);
1108 static HRESULT WINAPI
FormatConverterInfo_GetPixelFormats(IWICFormatConverterInfo
*iface
,
1109 UINT cFormats
, GUID
*pguidPixelFormats
, UINT
*pcActual
)
1111 FIXME("(%p,%u,%p,%p): stub\n", iface
, cFormats
, pguidPixelFormats
, pcActual
);
1115 static HRESULT WINAPI
FormatConverterInfo_CreateInstance(IWICFormatConverterInfo
*iface
,
1116 IWICFormatConverter
**ppIFormatConverter
)
1118 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1120 TRACE("(%p,%p)\n", iface
, ppIFormatConverter
);
1122 return CoCreateInstance(&This
->clsid
, NULL
, CLSCTX_INPROC_SERVER
,
1123 &IID_IWICFormatConverter
, (void**)ppIFormatConverter
);
1126 static BOOL
ConverterSupportsFormat(IWICFormatConverterInfo
*iface
, const WCHAR
*formatguid
)
1129 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1130 HKEY formats_key
, guid_key
;
1132 /* Avoid testing using IWICFormatConverter_GetPixelFormats because that
1133 would be O(n). A registry test should do better. */
1135 res
= RegOpenKeyExW(This
->classkey
, pixelformats_keyname
, 0, KEY_READ
, &formats_key
);
1136 if (res
!= ERROR_SUCCESS
) return FALSE
;
1138 res
= RegOpenKeyExW(formats_key
, formatguid
, 0, KEY_READ
, &guid_key
);
1139 if (res
== ERROR_SUCCESS
) RegCloseKey(guid_key
);
1141 RegCloseKey(formats_key
);
1143 return (res
== ERROR_SUCCESS
);
1146 static const IWICFormatConverterInfoVtbl FormatConverterInfo_Vtbl
= {
1147 FormatConverterInfo_QueryInterface
,
1148 FormatConverterInfo_AddRef
,
1149 FormatConverterInfo_Release
,
1150 FormatConverterInfo_GetComponentType
,
1151 FormatConverterInfo_GetCLSID
,
1152 FormatConverterInfo_GetSigningStatus
,
1153 FormatConverterInfo_GetAuthor
,
1154 FormatConverterInfo_GetVendorGUID
,
1155 FormatConverterInfo_GetVersion
,
1156 FormatConverterInfo_GetSpecVersion
,
1157 FormatConverterInfo_GetFriendlyName
,
1158 FormatConverterInfo_GetPixelFormats
,
1159 FormatConverterInfo_CreateInstance
1162 static HRESULT
FormatConverterInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
1164 FormatConverterInfo
*This
;
1166 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(FormatConverterInfo
));
1169 RegCloseKey(classkey
);
1170 return E_OUTOFMEMORY
;
1173 This
->IWICFormatConverterInfo_iface
.lpVtbl
= &FormatConverterInfo_Vtbl
;
1175 This
->classkey
= classkey
;
1176 memcpy(&This
->clsid
, clsid
, sizeof(CLSID
));
1178 *ppIInfo
= (IWICComponentInfo
*)This
;
1183 IWICPixelFormatInfo2 IWICPixelFormatInfo2_iface
;
1189 static inline PixelFormatInfo
*impl_from_IWICPixelFormatInfo2(IWICPixelFormatInfo2
*iface
)
1191 return CONTAINING_RECORD(iface
, PixelFormatInfo
, IWICPixelFormatInfo2_iface
);
1194 static HRESULT WINAPI
PixelFormatInfo_QueryInterface(IWICPixelFormatInfo2
*iface
, REFIID iid
,
1197 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1198 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
1200 if (!ppv
) return E_INVALIDARG
;
1202 if (IsEqualIID(&IID_IUnknown
, iid
) ||
1203 IsEqualIID(&IID_IWICComponentInfo
, iid
) ||
1204 IsEqualIID(&IID_IWICPixelFormatInfo
, iid
) ||
1205 IsEqualIID(&IID_IWICPixelFormatInfo2
,iid
))
1212 return E_NOINTERFACE
;
1215 IUnknown_AddRef((IUnknown
*)*ppv
);
1219 static ULONG WINAPI
PixelFormatInfo_AddRef(IWICPixelFormatInfo2
*iface
)
1221 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1222 ULONG ref
= InterlockedIncrement(&This
->ref
);
1224 TRACE("(%p) refcount=%u\n", iface
, ref
);
1229 static ULONG WINAPI
PixelFormatInfo_Release(IWICPixelFormatInfo2
*iface
)
1231 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1232 ULONG ref
= InterlockedDecrement(&This
->ref
);
1234 TRACE("(%p) refcount=%u\n", iface
, ref
);
1238 RegCloseKey(This
->classkey
);
1239 HeapFree(GetProcessHeap(), 0, This
);
1245 static HRESULT WINAPI
PixelFormatInfo_GetComponentType(IWICPixelFormatInfo2
*iface
,
1246 WICComponentType
*pType
)
1248 TRACE("(%p,%p)\n", iface
, pType
);
1249 if (!pType
) return E_INVALIDARG
;
1250 *pType
= WICPixelFormat
;
1254 static HRESULT WINAPI
PixelFormatInfo_GetCLSID(IWICPixelFormatInfo2
*iface
, CLSID
*pclsid
)
1256 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1257 TRACE("(%p,%p)\n", iface
, pclsid
);
1260 return E_INVALIDARG
;
1262 memcpy(pclsid
, &This
->clsid
, sizeof(CLSID
));
1267 static HRESULT WINAPI
PixelFormatInfo_GetSigningStatus(IWICPixelFormatInfo2
*iface
, DWORD
*pStatus
)
1269 TRACE("(%p,%p)\n", iface
, pStatus
);
1272 return E_INVALIDARG
;
1274 /* Pixel formats don't require code, so they are considered signed. */
1275 *pStatus
= WICComponentSigned
;
1280 static HRESULT WINAPI
PixelFormatInfo_GetAuthor(IWICPixelFormatInfo2
*iface
, UINT cchAuthor
,
1281 WCHAR
*wzAuthor
, UINT
*pcchActual
)
1283 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1285 TRACE("(%p,%u,%p,%p)\n", iface
, cchAuthor
, wzAuthor
, pcchActual
);
1287 return ComponentInfo_GetStringValue(This
->classkey
, author_valuename
,
1288 cchAuthor
, wzAuthor
, pcchActual
);
1291 static HRESULT WINAPI
PixelFormatInfo_GetVendorGUID(IWICPixelFormatInfo2
*iface
, GUID
*pguidVendor
)
1293 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1295 TRACE("(%p,%p)\n", iface
, pguidVendor
);
1297 return ComponentInfo_GetGUIDValue(This
->classkey
, vendor_valuename
, pguidVendor
);
1300 static HRESULT WINAPI
PixelFormatInfo_GetVersion(IWICPixelFormatInfo2
*iface
, UINT cchVersion
,
1301 WCHAR
*wzVersion
, UINT
*pcchActual
)
1303 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1305 TRACE("(%p,%u,%p,%p)\n", iface
, cchVersion
, wzVersion
, pcchActual
);
1307 return ComponentInfo_GetStringValue(This
->classkey
, version_valuename
,
1308 cchVersion
, wzVersion
, pcchActual
);
1311 static HRESULT WINAPI
PixelFormatInfo_GetSpecVersion(IWICPixelFormatInfo2
*iface
, UINT cchSpecVersion
,
1312 WCHAR
*wzSpecVersion
, UINT
*pcchActual
)
1314 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1316 TRACE("(%p,%u,%p,%p)\n", iface
, cchSpecVersion
, wzSpecVersion
, pcchActual
);
1318 return ComponentInfo_GetStringValue(This
->classkey
, specversion_valuename
,
1319 cchSpecVersion
, wzSpecVersion
, pcchActual
);
1322 static HRESULT WINAPI
PixelFormatInfo_GetFriendlyName(IWICPixelFormatInfo2
*iface
, UINT cchFriendlyName
,
1323 WCHAR
*wzFriendlyName
, UINT
*pcchActual
)
1325 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1327 TRACE("(%p,%u,%p,%p)\n", iface
, cchFriendlyName
, wzFriendlyName
, pcchActual
);
1329 return ComponentInfo_GetStringValue(This
->classkey
, friendlyname_valuename
,
1330 cchFriendlyName
, wzFriendlyName
, pcchActual
);
1333 static HRESULT WINAPI
PixelFormatInfo_GetFormatGUID(IWICPixelFormatInfo2
*iface
,
1336 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1337 TRACE("(%p,%p)\n", iface
, pFormat
);
1340 return E_INVALIDARG
;
1342 *pFormat
= This
->clsid
;
1347 static HRESULT WINAPI
PixelFormatInfo_GetColorContext(IWICPixelFormatInfo2
*iface
,
1348 IWICColorContext
**ppIColorContext
)
1350 FIXME("(%p,%p): stub\n", iface
, ppIColorContext
);
1354 static HRESULT WINAPI
PixelFormatInfo_GetBitsPerPixel(IWICPixelFormatInfo2
*iface
,
1355 UINT
*puiBitsPerPixel
)
1357 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1359 TRACE("(%p,%p)\n", iface
, puiBitsPerPixel
);
1361 return ComponentInfo_GetDWORDValue(This
->classkey
, bitsperpixel_valuename
, puiBitsPerPixel
);
1364 static HRESULT WINAPI
PixelFormatInfo_GetChannelCount(IWICPixelFormatInfo2
*iface
,
1365 UINT
*puiChannelCount
)
1367 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1369 TRACE("(%p,%p)\n", iface
, puiChannelCount
);
1371 return ComponentInfo_GetDWORDValue(This
->classkey
, channelcount_valuename
, puiChannelCount
);
1374 static HRESULT WINAPI
PixelFormatInfo_GetChannelMask(IWICPixelFormatInfo2
*iface
,
1375 UINT uiChannelIndex
, UINT cbMaskBuffer
, BYTE
*pbMaskBuffer
, UINT
*pcbActual
)
1377 static const WCHAR uintformatW
[] = {'%','u',0};
1378 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1382 WCHAR valuename
[11];
1385 TRACE("(%p,%u,%u,%p,%p)\n", iface
, uiChannelIndex
, cbMaskBuffer
, pbMaskBuffer
, pcbActual
);
1388 return E_INVALIDARG
;
1390 hr
= PixelFormatInfo_GetChannelCount(iface
, &channel_count
);
1392 if (SUCCEEDED(hr
) && uiChannelIndex
>= channel_count
)
1397 snprintfW(valuename
, 11, uintformatW
, uiChannelIndex
);
1399 cbData
= cbMaskBuffer
;
1401 ret
= RegGetValueW(This
->classkey
, channelmasks_keyname
, valuename
, RRF_RT_REG_BINARY
, NULL
, pbMaskBuffer
, &cbData
);
1403 if (ret
== ERROR_SUCCESS
|| ret
== ERROR_MORE_DATA
)
1404 *pcbActual
= cbData
;
1406 if (ret
== ERROR_MORE_DATA
)
1409 hr
= HRESULT_FROM_WIN32(ret
);
1415 static HRESULT WINAPI
PixelFormatInfo_SupportsTransparency(IWICPixelFormatInfo2
*iface
,
1416 BOOL
*pfSupportsTransparency
)
1418 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1420 TRACE("(%p,%p)\n", iface
, pfSupportsTransparency
);
1422 return ComponentInfo_GetDWORDValue(This
->classkey
, supportstransparency_valuename
, (DWORD
*)pfSupportsTransparency
);
1425 static HRESULT WINAPI
PixelFormatInfo_GetNumericRepresentation(IWICPixelFormatInfo2
*iface
,
1426 WICPixelFormatNumericRepresentation
*pNumericRepresentation
)
1428 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1430 TRACE("(%p,%p)\n", iface
, pNumericRepresentation
);
1432 return ComponentInfo_GetDWORDValue(This
->classkey
, numericrepresentation_valuename
, pNumericRepresentation
);
1435 static const IWICPixelFormatInfo2Vtbl PixelFormatInfo_Vtbl
= {
1436 PixelFormatInfo_QueryInterface
,
1437 PixelFormatInfo_AddRef
,
1438 PixelFormatInfo_Release
,
1439 PixelFormatInfo_GetComponentType
,
1440 PixelFormatInfo_GetCLSID
,
1441 PixelFormatInfo_GetSigningStatus
,
1442 PixelFormatInfo_GetAuthor
,
1443 PixelFormatInfo_GetVendorGUID
,
1444 PixelFormatInfo_GetVersion
,
1445 PixelFormatInfo_GetSpecVersion
,
1446 PixelFormatInfo_GetFriendlyName
,
1447 PixelFormatInfo_GetFormatGUID
,
1448 PixelFormatInfo_GetColorContext
,
1449 PixelFormatInfo_GetBitsPerPixel
,
1450 PixelFormatInfo_GetChannelCount
,
1451 PixelFormatInfo_GetChannelMask
,
1452 PixelFormatInfo_SupportsTransparency
,
1453 PixelFormatInfo_GetNumericRepresentation
1456 static HRESULT
PixelFormatInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
1458 PixelFormatInfo
*This
;
1460 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(PixelFormatInfo
));
1463 RegCloseKey(classkey
);
1464 return E_OUTOFMEMORY
;
1467 This
->IWICPixelFormatInfo2_iface
.lpVtbl
= &PixelFormatInfo_Vtbl
;
1469 This
->classkey
= classkey
;
1470 memcpy(&This
->clsid
, clsid
, sizeof(CLSID
));
1472 *ppIInfo
= (IWICComponentInfo
*)This
;
1478 IWICMetadataReaderInfo IWICMetadataReaderInfo_iface
;
1482 } MetadataReaderInfo
;
1484 static inline MetadataReaderInfo
*impl_from_IWICMetadataReaderInfo(IWICMetadataReaderInfo
*iface
)
1486 return CONTAINING_RECORD(iface
, MetadataReaderInfo
, IWICMetadataReaderInfo_iface
);
1489 static HRESULT WINAPI
MetadataReaderInfo_QueryInterface(IWICMetadataReaderInfo
*iface
,
1490 REFIID riid
, void **ppv
)
1492 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1494 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(riid
), ppv
);
1496 if (!ppv
) return E_INVALIDARG
;
1498 if (IsEqualIID(&IID_IUnknown
, riid
) ||
1499 IsEqualIID(&IID_IWICComponentInfo
, riid
) ||
1500 IsEqualIID(&IID_IWICMetadataHandlerInfo
, riid
) ||
1501 IsEqualIID(&IID_IWICMetadataReaderInfo
, riid
))
1508 return E_NOINTERFACE
;
1511 IUnknown_AddRef((IUnknown
*)*ppv
);
1515 static ULONG WINAPI
MetadataReaderInfo_AddRef(IWICMetadataReaderInfo
*iface
)
1517 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1518 ULONG ref
= InterlockedIncrement(&This
->ref
);
1520 TRACE("(%p) refcount=%u\n", iface
, ref
);
1524 static ULONG WINAPI
MetadataReaderInfo_Release(IWICMetadataReaderInfo
*iface
)
1526 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1527 ULONG ref
= InterlockedDecrement(&This
->ref
);
1529 TRACE("(%p) refcount=%u\n", iface
, ref
);
1533 RegCloseKey(This
->classkey
);
1534 HeapFree(GetProcessHeap(), 0, This
);
1539 static HRESULT WINAPI
MetadataReaderInfo_GetComponentType(IWICMetadataReaderInfo
*iface
,
1540 WICComponentType
*type
)
1542 TRACE("(%p,%p)\n", iface
, type
);
1544 if (!type
) return E_INVALIDARG
;
1545 *type
= WICMetadataReader
;
1549 static HRESULT WINAPI
MetadataReaderInfo_GetCLSID(IWICMetadataReaderInfo
*iface
,
1552 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1554 TRACE("(%p,%p)\n", iface
, clsid
);
1556 if (!clsid
) return E_INVALIDARG
;
1557 *clsid
= This
->clsid
;
1561 static HRESULT WINAPI
MetadataReaderInfo_GetSigningStatus(IWICMetadataReaderInfo
*iface
,
1564 FIXME("(%p,%p): stub\n", iface
, status
);
1568 static HRESULT WINAPI
MetadataReaderInfo_GetAuthor(IWICMetadataReaderInfo
*iface
,
1569 UINT length
, WCHAR
*author
, UINT
*actual_length
)
1571 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1573 TRACE("(%p,%u,%p,%p)\n", iface
, length
, author
, actual_length
);
1575 return ComponentInfo_GetStringValue(This
->classkey
, author_valuename
,
1576 length
, author
, actual_length
);
1579 static HRESULT WINAPI
MetadataReaderInfo_GetVendorGUID(IWICMetadataReaderInfo
*iface
,
1582 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1584 TRACE("(%p,%p)\n", iface
, vendor
);
1586 return ComponentInfo_GetGUIDValue(This
->classkey
, vendor_valuename
, vendor
);
1589 static HRESULT WINAPI
MetadataReaderInfo_GetVersion(IWICMetadataReaderInfo
*iface
,
1590 UINT length
, WCHAR
*version
, UINT
*actual_length
)
1592 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1594 TRACE("(%p,%u,%p,%p)\n", iface
, length
, version
, actual_length
);
1596 return ComponentInfo_GetStringValue(This
->classkey
, version_valuename
,
1597 length
, version
, actual_length
);
1600 static HRESULT WINAPI
MetadataReaderInfo_GetSpecVersion(IWICMetadataReaderInfo
*iface
,
1601 UINT length
, WCHAR
*version
, UINT
*actual_length
)
1603 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1605 TRACE("(%p,%u,%p,%p)\n", iface
, length
, version
, actual_length
);
1607 return ComponentInfo_GetStringValue(This
->classkey
, specversion_valuename
,
1608 length
, version
, actual_length
);
1611 static HRESULT WINAPI
MetadataReaderInfo_GetFriendlyName(IWICMetadataReaderInfo
*iface
,
1612 UINT length
, WCHAR
*name
, UINT
*actual_length
)
1614 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1616 TRACE("(%p,%u,%p,%p)\n", iface
, length
, name
, actual_length
);
1618 return ComponentInfo_GetStringValue(This
->classkey
, friendlyname_valuename
,
1619 length
, name
, actual_length
);
1622 static HRESULT WINAPI
MetadataReaderInfo_GetMetadataFormat(IWICMetadataReaderInfo
*iface
,
1625 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1626 TRACE("(%p,%p)\n", iface
, format
);
1627 return ComponentInfo_GetGUIDValue(This
->classkey
, metadataformat_valuename
, format
);
1630 static HRESULT WINAPI
MetadataReaderInfo_GetContainerFormats(IWICMetadataReaderInfo
*iface
,
1631 UINT length
, GUID
*formats
, UINT
*actual_length
)
1633 if (!actual_length
) return E_INVALIDARG
;
1635 FIXME("(%p,%u,%p,%p): stub\n", iface
, length
, formats
, actual_length
);
1639 static HRESULT WINAPI
MetadataReaderInfo_GetDeviceManufacturer(IWICMetadataReaderInfo
*iface
,
1640 UINT length
, WCHAR
*manufacturer
, UINT
*actual_length
)
1642 FIXME("(%p,%u,%p,%p): stub\n", iface
, length
, manufacturer
, actual_length
);
1646 static HRESULT WINAPI
MetadataReaderInfo_GetDeviceModels(IWICMetadataReaderInfo
*iface
,
1647 UINT length
, WCHAR
*models
, UINT
*actual_length
)
1649 FIXME("(%p,%u,%p,%p): stub\n", iface
, length
, models
, actual_length
);
1653 static HRESULT WINAPI
MetadataReaderInfo_DoesRequireFullStream(IWICMetadataReaderInfo
*iface
,
1656 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1657 TRACE("(%p,%p)\n", iface
, param
);
1658 return ComponentInfo_GetDWORDValue(This
->classkey
, requiresfullstream_valuename
, (DWORD
*)param
);
1661 static HRESULT WINAPI
MetadataReaderInfo_DoesSupportPadding(IWICMetadataReaderInfo
*iface
,
1664 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1665 TRACE("(%p,%p)\n", iface
, param
);
1666 return ComponentInfo_GetDWORDValue(This
->classkey
, supportspadding_valuename
, (DWORD
*)param
);
1669 static HRESULT WINAPI
MetadataReaderInfo_DoesRequireFixedSize(IWICMetadataReaderInfo
*iface
,
1672 FIXME("(%p,%p): stub\n", iface
, param
);
1676 static HRESULT WINAPI
MetadataReaderInfo_GetPatterns(IWICMetadataReaderInfo
*iface
,
1677 REFGUID container
, UINT length
, WICMetadataPattern
*pattern
, UINT
*count
, UINT
*actual_length
)
1679 if (!actual_length
) return E_INVALIDARG
;
1681 FIXME("(%p,%s,%u,%p,%p,%p): stub\n", iface
, debugstr_guid(container
), length
, pattern
, count
, actual_length
);
1685 static HRESULT WINAPI
MetadataReaderInfo_MatchesPattern(IWICMetadataReaderInfo
*iface
,
1686 REFGUID container
, IStream
*stream
, BOOL
*matches
)
1688 FIXME("(%p,%s,%p,%p): stub\n", iface
, debugstr_guid(container
), stream
, matches
);
1692 static HRESULT WINAPI
MetadataReaderInfo_CreateInstance(IWICMetadataReaderInfo
*iface
,
1693 IWICMetadataReader
**reader
)
1695 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1697 TRACE("(%p,%p)\n", iface
, reader
);
1699 return CoCreateInstance(&This
->clsid
, NULL
, CLSCTX_INPROC_SERVER
,
1700 &IID_IWICMetadataReader
, (void **)reader
);
1703 static const IWICMetadataReaderInfoVtbl MetadataReaderInfo_Vtbl
= {
1704 MetadataReaderInfo_QueryInterface
,
1705 MetadataReaderInfo_AddRef
,
1706 MetadataReaderInfo_Release
,
1707 MetadataReaderInfo_GetComponentType
,
1708 MetadataReaderInfo_GetCLSID
,
1709 MetadataReaderInfo_GetSigningStatus
,
1710 MetadataReaderInfo_GetAuthor
,
1711 MetadataReaderInfo_GetVendorGUID
,
1712 MetadataReaderInfo_GetVersion
,
1713 MetadataReaderInfo_GetSpecVersion
,
1714 MetadataReaderInfo_GetFriendlyName
,
1715 MetadataReaderInfo_GetMetadataFormat
,
1716 MetadataReaderInfo_GetContainerFormats
,
1717 MetadataReaderInfo_GetDeviceManufacturer
,
1718 MetadataReaderInfo_GetDeviceModels
,
1719 MetadataReaderInfo_DoesRequireFullStream
,
1720 MetadataReaderInfo_DoesSupportPadding
,
1721 MetadataReaderInfo_DoesRequireFixedSize
,
1722 MetadataReaderInfo_GetPatterns
,
1723 MetadataReaderInfo_MatchesPattern
,
1724 MetadataReaderInfo_CreateInstance
1727 static HRESULT
MetadataReaderInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**info
)
1729 MetadataReaderInfo
*This
;
1731 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
1734 RegCloseKey(classkey
);
1735 return E_OUTOFMEMORY
;
1738 This
->IWICMetadataReaderInfo_iface
.lpVtbl
= &MetadataReaderInfo_Vtbl
;
1740 This
->classkey
= classkey
;
1741 This
->clsid
= *clsid
;
1743 *info
= (IWICComponentInfo
*)This
;
1747 static const WCHAR clsid_keyname
[] = {'C','L','S','I','D',0};
1748 static const WCHAR instance_keyname
[] = {'I','n','s','t','a','n','c','e',0};
1751 WICComponentType type
;
1753 HRESULT (*constructor
)(HKEY
,REFCLSID
,IWICComponentInfo
**);
1756 static const struct category categories
[] = {
1757 {WICDecoder
, &CATID_WICBitmapDecoders
, BitmapDecoderInfo_Constructor
},
1758 {WICEncoder
, &CATID_WICBitmapEncoders
, BitmapEncoderInfo_Constructor
},
1759 {WICPixelFormatConverter
, &CATID_WICFormatConverters
, FormatConverterInfo_Constructor
},
1760 {WICPixelFormat
, &CATID_WICPixelFormats
, PixelFormatInfo_Constructor
},
1761 {WICMetadataReader
, &CATID_WICMetadataReader
, MetadataReaderInfo_Constructor
},
1765 HRESULT
CreateComponentInfo(REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
1771 WCHAR guidstring
[39];
1773 const struct category
*category
;
1777 res
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, clsid_keyname
, 0, KEY_READ
, &clsidkey
);
1778 if (res
!= ERROR_SUCCESS
)
1779 return HRESULT_FROM_WIN32(res
);
1781 for (category
=categories
; category
->type
; category
++)
1783 StringFromGUID2(category
->catid
, guidstring
, 39);
1784 res
= RegOpenKeyExW(clsidkey
, guidstring
, 0, KEY_READ
, &catidkey
);
1785 if (res
== ERROR_SUCCESS
)
1787 res
= RegOpenKeyExW(catidkey
, instance_keyname
, 0, KEY_READ
, &instancekey
);
1788 if (res
== ERROR_SUCCESS
)
1790 StringFromGUID2(clsid
, guidstring
, 39);
1791 res
= RegOpenKeyExW(instancekey
, guidstring
, 0, KEY_READ
, &classkey
);
1792 if (res
== ERROR_SUCCESS
)
1794 RegCloseKey(classkey
);
1797 RegCloseKey(instancekey
);
1799 RegCloseKey(catidkey
);
1806 res
= RegOpenKeyExW(clsidkey
, guidstring
, 0, KEY_READ
, &classkey
);
1807 if (res
== ERROR_SUCCESS
)
1808 hr
= category
->constructor(classkey
, clsid
, ppIInfo
);
1810 hr
= HRESULT_FROM_WIN32(res
);
1814 FIXME("%s is not supported\n", wine_dbgstr_guid(clsid
));
1818 RegCloseKey(clsidkey
);
1824 IEnumUnknown IEnumUnknown_iface
;
1826 struct list objects
;
1827 struct list
*cursor
;
1828 CRITICAL_SECTION lock
; /* Must be held when reading or writing cursor */
1831 static inline ComponentEnum
*impl_from_IEnumUnknown(IEnumUnknown
*iface
)
1833 return CONTAINING_RECORD(iface
, ComponentEnum
, IEnumUnknown_iface
);
1839 } ComponentEnumItem
;
1841 static const IEnumUnknownVtbl ComponentEnumVtbl
;
1843 static HRESULT WINAPI
ComponentEnum_QueryInterface(IEnumUnknown
*iface
, REFIID iid
,
1846 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1847 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
1849 if (!ppv
) return E_INVALIDARG
;
1851 if (IsEqualIID(&IID_IUnknown
, iid
) ||
1852 IsEqualIID(&IID_IEnumUnknown
, iid
))
1854 *ppv
= &This
->IEnumUnknown_iface
;
1859 return E_NOINTERFACE
;
1862 IUnknown_AddRef((IUnknown
*)*ppv
);
1866 static ULONG WINAPI
ComponentEnum_AddRef(IEnumUnknown
*iface
)
1868 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1869 ULONG ref
= InterlockedIncrement(&This
->ref
);
1871 TRACE("(%p) refcount=%u\n", iface
, ref
);
1876 static ULONG WINAPI
ComponentEnum_Release(IEnumUnknown
*iface
)
1878 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1879 ULONG ref
= InterlockedDecrement(&This
->ref
);
1880 ComponentEnumItem
*cursor
, *cursor2
;
1882 TRACE("(%p) refcount=%u\n", iface
, ref
);
1886 LIST_FOR_EACH_ENTRY_SAFE(cursor
, cursor2
, &This
->objects
, ComponentEnumItem
, entry
)
1888 IUnknown_Release(cursor
->unk
);
1889 list_remove(&cursor
->entry
);
1890 HeapFree(GetProcessHeap(), 0, cursor
);
1892 This
->lock
.DebugInfo
->Spare
[0] = 0;
1893 DeleteCriticalSection(&This
->lock
);
1894 HeapFree(GetProcessHeap(), 0, This
);
1900 static HRESULT WINAPI
ComponentEnum_Next(IEnumUnknown
*iface
, ULONG celt
,
1901 IUnknown
**rgelt
, ULONG
*pceltFetched
)
1903 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1904 ULONG num_fetched
=0;
1905 ComponentEnumItem
*item
;
1908 TRACE("(%p,%u,%p,%p)\n", iface
, celt
, rgelt
, pceltFetched
);
1910 EnterCriticalSection(&This
->lock
);
1911 while (num_fetched
<celt
)
1918 item
= LIST_ENTRY(This
->cursor
, ComponentEnumItem
, entry
);
1919 IUnknown_AddRef(item
->unk
);
1920 rgelt
[num_fetched
] = item
->unk
;
1922 This
->cursor
= list_next(&This
->objects
, This
->cursor
);
1924 LeaveCriticalSection(&This
->lock
);
1926 *pceltFetched
= num_fetched
;
1930 static HRESULT WINAPI
ComponentEnum_Skip(IEnumUnknown
*iface
, ULONG celt
)
1932 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1936 TRACE("(%p,%u)\n", iface
, celt
);
1938 EnterCriticalSection(&This
->lock
);
1939 for (i
=0; i
<celt
; i
++)
1946 This
->cursor
= list_next(&This
->objects
, This
->cursor
);
1948 LeaveCriticalSection(&This
->lock
);
1952 static HRESULT WINAPI
ComponentEnum_Reset(IEnumUnknown
*iface
)
1954 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1956 TRACE("(%p)\n", iface
);
1958 EnterCriticalSection(&This
->lock
);
1959 This
->cursor
= list_head(&This
->objects
);
1960 LeaveCriticalSection(&This
->lock
);
1964 static HRESULT WINAPI
ComponentEnum_Clone(IEnumUnknown
*iface
, IEnumUnknown
**ppenum
)
1966 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
1967 ComponentEnum
*new_enum
;
1968 ComponentEnumItem
*old_item
, *new_item
;
1970 struct list
*old_cursor
;
1972 new_enum
= HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnum
));
1976 return E_OUTOFMEMORY
;
1979 new_enum
->IEnumUnknown_iface
.lpVtbl
= &ComponentEnumVtbl
;
1981 new_enum
->cursor
= NULL
;
1982 list_init(&new_enum
->objects
);
1983 InitializeCriticalSection(&new_enum
->lock
);
1984 new_enum
->lock
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": ComponentEnum.lock");
1986 EnterCriticalSection(&This
->lock
);
1987 old_cursor
= This
->cursor
;
1988 LeaveCriticalSection(&This
->lock
);
1990 LIST_FOR_EACH_ENTRY(old_item
, &This
->objects
, ComponentEnumItem
, entry
)
1992 new_item
= HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnumItem
));
1995 ret
= E_OUTOFMEMORY
;
1998 new_item
->unk
= old_item
->unk
;
1999 list_add_tail(&new_enum
->objects
, &new_item
->entry
);
2000 IUnknown_AddRef(new_item
->unk
);
2001 if (&old_item
->entry
== old_cursor
) new_enum
->cursor
= &new_item
->entry
;
2006 IEnumUnknown_Release(&new_enum
->IEnumUnknown_iface
);
2010 *ppenum
= &new_enum
->IEnumUnknown_iface
;
2015 static const IEnumUnknownVtbl ComponentEnumVtbl
= {
2016 ComponentEnum_QueryInterface
,
2017 ComponentEnum_AddRef
,
2018 ComponentEnum_Release
,
2021 ComponentEnum_Reset
,
2025 HRESULT
CreateComponentEnumerator(DWORD componentTypes
, DWORD options
, IEnumUnknown
**ppIEnumUnknown
)
2027 ComponentEnum
*This
;
2028 ComponentEnumItem
*item
;
2029 const struct category
*category
;
2030 HKEY clsidkey
, catidkey
, instancekey
;
2031 WCHAR guidstring
[39];
2037 if (options
) FIXME("ignoring flags %x\n", options
);
2039 res
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, clsid_keyname
, 0, KEY_READ
, &clsidkey
);
2040 if (res
!= ERROR_SUCCESS
)
2041 return HRESULT_FROM_WIN32(res
);
2043 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnum
));
2046 RegCloseKey(clsidkey
);
2047 return E_OUTOFMEMORY
;
2050 This
->IEnumUnknown_iface
.lpVtbl
= &ComponentEnumVtbl
;
2052 list_init(&This
->objects
);
2053 InitializeCriticalSection(&This
->lock
);
2054 This
->lock
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": ComponentEnum.lock");
2056 for (category
=categories
; category
->type
&& hr
== S_OK
; category
++)
2058 if ((category
->type
& componentTypes
) == 0) continue;
2059 StringFromGUID2(category
->catid
, guidstring
, 39);
2060 res
= RegOpenKeyExW(clsidkey
, guidstring
, 0, KEY_READ
, &catidkey
);
2061 if (res
== ERROR_SUCCESS
)
2063 res
= RegOpenKeyExW(catidkey
, instance_keyname
, 0, KEY_READ
, &instancekey
);
2064 if (res
== ERROR_SUCCESS
)
2069 DWORD guidstring_size
= 39;
2070 res
= RegEnumKeyExW(instancekey
, i
, guidstring
, &guidstring_size
, NULL
, NULL
, NULL
, NULL
);
2071 if (res
!= ERROR_SUCCESS
) break;
2073 item
= HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnumItem
));
2074 if (!item
) { hr
= E_OUTOFMEMORY
; break; }
2076 hr
= CLSIDFromString(guidstring
, &clsid
);
2079 hr
= CreateComponentInfo(&clsid
, (IWICComponentInfo
**)&item
->unk
);
2081 list_add_tail(&This
->objects
, &item
->entry
);
2086 HeapFree(GetProcessHeap(), 0, item
);
2090 RegCloseKey(instancekey
);
2092 RegCloseKey(catidkey
);
2094 if (res
!= ERROR_SUCCESS
&& res
!= ERROR_NO_MORE_ITEMS
)
2095 hr
= HRESULT_FROM_WIN32(res
);
2097 RegCloseKey(clsidkey
);
2101 IEnumUnknown_Reset(&This
->IEnumUnknown_iface
);
2102 *ppIEnumUnknown
= &This
->IEnumUnknown_iface
;
2106 *ppIEnumUnknown
= NULL
;
2107 IEnumUnknown_Release(&This
->IEnumUnknown_iface
);
2113 HRESULT WINAPI
WICConvertBitmapSource(REFWICPixelFormatGUID dstFormat
, IWICBitmapSource
*pISrc
, IWICBitmapSource
**ppIDst
)
2116 IEnumUnknown
*enumconverters
;
2117 IUnknown
*unkconverterinfo
;
2118 IWICFormatConverterInfo
*converterinfo
=NULL
;
2119 IWICFormatConverter
*converter
=NULL
;
2121 WCHAR srcformatstr
[39], dstformatstr
[39];
2125 res
= IWICBitmapSource_GetPixelFormat(pISrc
, &srcFormat
);
2126 if (FAILED(res
)) return res
;
2128 if (IsEqualGUID(&srcFormat
, dstFormat
))
2130 IWICBitmapSource_AddRef(pISrc
);
2135 StringFromGUID2(&srcFormat
, srcformatstr
, 39);
2136 StringFromGUID2(dstFormat
, dstformatstr
, 39);
2138 res
= CreateComponentEnumerator(WICPixelFormatConverter
, 0, &enumconverters
);
2139 if (FAILED(res
)) return res
;
2143 res
= IEnumUnknown_Next(enumconverters
, 1, &unkconverterinfo
, &num_fetched
);
2147 res
= IUnknown_QueryInterface(unkconverterinfo
, &IID_IWICFormatConverterInfo
, (void**)&converterinfo
);
2151 canconvert
= ConverterSupportsFormat(converterinfo
, srcformatstr
);
2154 canconvert
= ConverterSupportsFormat(converterinfo
, dstformatstr
);
2158 res
= IWICFormatConverterInfo_CreateInstance(converterinfo
, &converter
);
2161 res
= IWICFormatConverter_CanConvert(converter
, &srcFormat
, dstFormat
, &canconvert
);
2163 if (SUCCEEDED(res
) && canconvert
)
2164 res
= IWICFormatConverter_Initialize(converter
, pISrc
, dstFormat
, WICBitmapDitherTypeNone
,
2165 NULL
, 0.0, WICBitmapPaletteTypeCustom
);
2167 if (FAILED(res
) || !canconvert
)
2171 IWICFormatConverter_Release(converter
);
2178 IWICFormatConverterInfo_Release(converterinfo
);
2181 IUnknown_Release(unkconverterinfo
);
2187 IEnumUnknown_Release(enumconverters
);
2191 res
= IWICFormatConverter_QueryInterface(converter
, &IID_IWICBitmapSource
, (void **)ppIDst
);
2192 IWICFormatConverter_Release(converter
);
2197 FIXME("cannot convert %s to %s\n", debugstr_guid(&srcFormat
), debugstr_guid(dstFormat
));
2199 return WINCODEC_ERR_COMPONENTNOTFOUND
;