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 "wincodecs_private.h"
33 #include "wine/debug.h"
34 #include "wine/unicode.h"
35 #include "wine/list.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs
);
39 static const WCHAR mimetypes_valuename
[] = {'M','i','m','e','T','y','p','e','s',0};
40 static const WCHAR author_valuename
[] = {'A','u','t','h','o','r',0};
41 static const WCHAR friendlyname_valuename
[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
42 static const WCHAR pixelformats_keyname
[] = {'P','i','x','e','l','F','o','r','m','a','t','s',0};
43 static const WCHAR formats_keyname
[] = {'F','o','r','m','a','t','s',0};
44 static const WCHAR containerformat_valuename
[] = {'C','o','n','t','a','i','n','e','r','F','o','r','m','a','t',0};
45 static const WCHAR metadataformat_valuename
[] = {'M','e','t','a','d','a','t','a','F','o','r','m','a','t',0};
46 static const WCHAR vendor_valuename
[] = {'V','e','n','d','o','r',0};
47 static const WCHAR version_valuename
[] = {'V','e','r','s','i','o','n',0};
48 static const WCHAR specversion_valuename
[] = {'S','p','e','c','V','e','r','s','i','o','n',0};
49 static const WCHAR bitsperpixel_valuename
[] = {'B','i','t','L','e','n','g','t','h',0};
50 static const WCHAR channelcount_valuename
[] = {'C','h','a','n','n','e','l','C','o','u','n','t',0};
51 static const WCHAR channelmasks_keyname
[] = {'C','h','a','n','n','e','l','M','a','s','k','s',0};
52 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};
53 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};
54 static const WCHAR requiresfullstream_valuename
[] = {'R','e','q','u','i','r','e','s','F','u','l','l','S','t','r','e','a','m',0};
55 static const WCHAR supportspadding_valuename
[] = {'S','u','p','p','o','r','t','s','P','a','d','d','i','n','g',0};
56 static const WCHAR fileextensions_valuename
[] = {'F','i','l','e','E','x','t','e','n','s','i','o','n','s',0};
57 static const WCHAR containers_keyname
[] = {'C','o','n','t','a','i','n','e','r','s',0};
59 static HRESULT
ComponentInfo_GetStringValue(HKEY classkey
, LPCWSTR value
,
60 UINT buffer_size
, WCHAR
*buffer
, UINT
*actual_size
)
63 DWORD cbdata
=buffer_size
* sizeof(WCHAR
);
68 ret
= RegGetValueW(classkey
, NULL
, value
, RRF_RT_REG_SZ
|RRF_NOEXPAND
, NULL
,
71 if (ret
== ERROR_FILE_NOT_FOUND
)
77 if (ret
== 0 || ret
== ERROR_MORE_DATA
)
78 *actual_size
= cbdata
/sizeof(WCHAR
);
80 if (!buffer
&& buffer_size
!= 0)
81 /* Yes, native returns the correct size in this case. */
84 if (ret
== ERROR_MORE_DATA
)
85 return WINCODEC_ERR_INSUFFICIENTBUFFER
;
87 return HRESULT_FROM_WIN32(ret
);
90 static HRESULT
ComponentInfo_GetGUIDValue(HKEY classkey
, LPCWSTR value
,
94 WCHAR guid_string
[39];
95 DWORD cbdata
= sizeof(guid_string
);
101 ret
= RegGetValueW(classkey
, NULL
, value
, RRF_RT_REG_SZ
|RRF_NOEXPAND
, NULL
,
102 guid_string
, &cbdata
);
104 if (ret
!= ERROR_SUCCESS
)
105 return HRESULT_FROM_WIN32(ret
);
107 if (cbdata
< sizeof(guid_string
))
109 ERR("incomplete GUID value\n");
113 hr
= CLSIDFromString(guid_string
, result
);
118 static HRESULT
ComponentInfo_GetDWORDValue(HKEY classkey
, LPCWSTR value
,
122 DWORD cbdata
= sizeof(DWORD
);
127 ret
= RegGetValueW(classkey
, NULL
, value
, RRF_RT_DWORD
, NULL
,
130 if (ret
== ERROR_FILE_NOT_FOUND
)
136 return HRESULT_FROM_WIN32(ret
);
139 static HRESULT
ComponentInfo_GetGuidList(HKEY classkey
, LPCWSTR subkeyname
,
140 UINT buffersize
, GUID
*buffer
, UINT
*actual_size
)
145 WCHAR guid_string
[39];
146 DWORD guid_string_size
;
152 ret
= RegOpenKeyExW(classkey
, subkeyname
, 0, KEY_READ
, &subkey
);
153 if (ret
== ERROR_FILE_NOT_FOUND
)
158 else if (ret
!= ERROR_SUCCESS
) return HRESULT_FROM_WIN32(ret
);
163 guid_string_size
= 39;
164 while (items_returned
< buffersize
)
166 ret
= RegEnumKeyExW(subkey
, items_returned
, guid_string
,
167 &guid_string_size
, NULL
, NULL
, NULL
, NULL
);
169 if (ret
!= ERROR_SUCCESS
)
171 hr
= HRESULT_FROM_WIN32(ret
);
175 if (guid_string_size
!= 38)
181 hr
= CLSIDFromString(guid_string
, &buffer
[items_returned
]);
186 guid_string_size
= 39;
189 if (ret
== ERROR_NO_MORE_ITEMS
)
192 *actual_size
= items_returned
;
196 ret
= RegQueryInfoKeyW(subkey
, NULL
, NULL
, NULL
, actual_size
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
197 if (ret
!= ERROR_SUCCESS
)
198 hr
= HRESULT_FROM_WIN32(ret
);
207 IWICBitmapDecoderInfo IWICBitmapDecoderInfo_iface
;
213 static inline BitmapDecoderInfo
*impl_from_IWICBitmapDecoderInfo(IWICBitmapDecoderInfo
*iface
)
215 return CONTAINING_RECORD(iface
, BitmapDecoderInfo
, IWICBitmapDecoderInfo_iface
);
218 static HRESULT WINAPI
BitmapDecoderInfo_QueryInterface(IWICBitmapDecoderInfo
*iface
, REFIID iid
,
221 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
222 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
224 if (!ppv
) return E_INVALIDARG
;
226 if (IsEqualIID(&IID_IUnknown
, iid
) ||
227 IsEqualIID(&IID_IWICComponentInfo
, iid
) ||
228 IsEqualIID(&IID_IWICBitmapCodecInfo
, iid
) ||
229 IsEqualIID(&IID_IWICBitmapDecoderInfo
,iid
))
231 *ppv
= &This
->IWICBitmapDecoderInfo_iface
;
236 return E_NOINTERFACE
;
239 IUnknown_AddRef((IUnknown
*)*ppv
);
243 static ULONG WINAPI
BitmapDecoderInfo_AddRef(IWICBitmapDecoderInfo
*iface
)
245 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
246 ULONG ref
= InterlockedIncrement(&This
->ref
);
248 TRACE("(%p) refcount=%u\n", iface
, ref
);
253 static ULONG WINAPI
BitmapDecoderInfo_Release(IWICBitmapDecoderInfo
*iface
)
255 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
256 ULONG ref
= InterlockedDecrement(&This
->ref
);
258 TRACE("(%p) refcount=%u\n", iface
, ref
);
262 RegCloseKey(This
->classkey
);
263 HeapFree(GetProcessHeap(), 0, This
);
269 static HRESULT WINAPI
BitmapDecoderInfo_GetComponentType(IWICBitmapDecoderInfo
*iface
,
270 WICComponentType
*pType
)
272 TRACE("(%p,%p)\n", iface
, pType
);
273 if (!pType
) return E_INVALIDARG
;
278 static HRESULT WINAPI
BitmapDecoderInfo_GetCLSID(IWICBitmapDecoderInfo
*iface
, CLSID
*pclsid
)
280 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
281 TRACE("(%p,%p)\n", iface
, pclsid
);
286 memcpy(pclsid
, &This
->clsid
, sizeof(CLSID
));
291 static HRESULT WINAPI
BitmapDecoderInfo_GetSigningStatus(IWICBitmapDecoderInfo
*iface
, DWORD
*pStatus
)
293 FIXME("(%p,%p): stub\n", iface
, pStatus
);
297 static HRESULT WINAPI
BitmapDecoderInfo_GetAuthor(IWICBitmapDecoderInfo
*iface
, UINT cchAuthor
,
298 WCHAR
*wzAuthor
, UINT
*pcchActual
)
300 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
302 TRACE("(%p,%u,%p,%p)\n", iface
, cchAuthor
, wzAuthor
, pcchActual
);
304 return ComponentInfo_GetStringValue(This
->classkey
, author_valuename
,
305 cchAuthor
, wzAuthor
, pcchActual
);
308 static HRESULT WINAPI
BitmapDecoderInfo_GetVendorGUID(IWICBitmapDecoderInfo
*iface
, GUID
*pguidVendor
)
310 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
312 TRACE("(%p,%p)\n", iface
, pguidVendor
);
314 return ComponentInfo_GetGUIDValue(This
->classkey
, vendor_valuename
, pguidVendor
);
317 static HRESULT WINAPI
BitmapDecoderInfo_GetVersion(IWICBitmapDecoderInfo
*iface
, UINT cchVersion
,
318 WCHAR
*wzVersion
, UINT
*pcchActual
)
320 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
322 TRACE("(%p,%u,%p,%p)\n", iface
, cchVersion
, wzVersion
, pcchActual
);
324 return ComponentInfo_GetStringValue(This
->classkey
, version_valuename
,
325 cchVersion
, wzVersion
, pcchActual
);
328 static HRESULT WINAPI
BitmapDecoderInfo_GetSpecVersion(IWICBitmapDecoderInfo
*iface
, UINT cchSpecVersion
,
329 WCHAR
*wzSpecVersion
, UINT
*pcchActual
)
331 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
333 TRACE("(%p,%u,%p,%p)\n", iface
, cchSpecVersion
, wzSpecVersion
, pcchActual
);
335 return ComponentInfo_GetStringValue(This
->classkey
, specversion_valuename
,
336 cchSpecVersion
, wzSpecVersion
, pcchActual
);
339 static HRESULT WINAPI
BitmapDecoderInfo_GetFriendlyName(IWICBitmapDecoderInfo
*iface
, UINT cchFriendlyName
,
340 WCHAR
*wzFriendlyName
, UINT
*pcchActual
)
342 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
344 TRACE("(%p,%u,%p,%p)\n", iface
, cchFriendlyName
, wzFriendlyName
, pcchActual
);
346 return ComponentInfo_GetStringValue(This
->classkey
, friendlyname_valuename
,
347 cchFriendlyName
, wzFriendlyName
, pcchActual
);
350 static HRESULT WINAPI
BitmapDecoderInfo_GetContainerFormat(IWICBitmapDecoderInfo
*iface
,
351 GUID
*pguidContainerFormat
)
353 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
354 TRACE("(%p,%p)\n", iface
, pguidContainerFormat
);
355 return ComponentInfo_GetGUIDValue(This
->classkey
, containerformat_valuename
, pguidContainerFormat
);
358 static HRESULT WINAPI
BitmapDecoderInfo_GetPixelFormats(IWICBitmapDecoderInfo
*iface
,
359 UINT cFormats
, GUID
*pguidPixelFormats
, UINT
*pcActual
)
361 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
362 TRACE("(%p,%u,%p,%p)\n", iface
, cFormats
, pguidPixelFormats
, pcActual
);
363 return ComponentInfo_GetGuidList(This
->classkey
, formats_keyname
, cFormats
, pguidPixelFormats
, pcActual
);
366 static HRESULT WINAPI
BitmapDecoderInfo_GetColorManagementVersion(IWICBitmapDecoderInfo
*iface
,
367 UINT cchColorManagementVersion
, WCHAR
*wzColorManagementVersion
, UINT
*pcchActual
)
369 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchColorManagementVersion
, wzColorManagementVersion
, pcchActual
);
373 static HRESULT WINAPI
BitmapDecoderInfo_GetDeviceManufacturer(IWICBitmapDecoderInfo
*iface
,
374 UINT cchDeviceManufacturer
, WCHAR
*wzDeviceManufacturer
, UINT
*pcchActual
)
376 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchDeviceManufacturer
, wzDeviceManufacturer
, pcchActual
);
380 static HRESULT WINAPI
BitmapDecoderInfo_GetDeviceModels(IWICBitmapDecoderInfo
*iface
,
381 UINT cchDeviceModels
, WCHAR
*wzDeviceModels
, UINT
*pcchActual
)
383 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchDeviceModels
, wzDeviceModels
, pcchActual
);
387 static HRESULT WINAPI
BitmapDecoderInfo_GetMimeTypes(IWICBitmapDecoderInfo
*iface
,
388 UINT cchMimeTypes
, WCHAR
*wzMimeTypes
, UINT
*pcchActual
)
390 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
392 TRACE("(%p,%u,%p,%p)\n", iface
, cchMimeTypes
, wzMimeTypes
, pcchActual
);
394 return ComponentInfo_GetStringValue(This
->classkey
, mimetypes_valuename
,
395 cchMimeTypes
, wzMimeTypes
, pcchActual
);
398 static HRESULT WINAPI
BitmapDecoderInfo_GetFileExtensions(IWICBitmapDecoderInfo
*iface
,
399 UINT cchFileExtensions
, WCHAR
*wzFileExtensions
, UINT
*pcchActual
)
401 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
403 TRACE("(%p,%u,%p,%p)\n", iface
, cchFileExtensions
, wzFileExtensions
, pcchActual
);
405 return ComponentInfo_GetStringValue(This
->classkey
, fileextensions_valuename
,
406 cchFileExtensions
, wzFileExtensions
, pcchActual
);
409 static HRESULT WINAPI
BitmapDecoderInfo_DoesSupportAnimation(IWICBitmapDecoderInfo
*iface
,
410 BOOL
*pfSupportAnimation
)
412 FIXME("(%p,%p): stub\n", iface
, pfSupportAnimation
);
416 static HRESULT WINAPI
BitmapDecoderInfo_DoesSupportChromaKey(IWICBitmapDecoderInfo
*iface
,
417 BOOL
*pfSupportChromaKey
)
419 FIXME("(%p,%p): stub\n", iface
, pfSupportChromaKey
);
423 static HRESULT WINAPI
BitmapDecoderInfo_DoesSupportLossless(IWICBitmapDecoderInfo
*iface
,
424 BOOL
*pfSupportLossless
)
426 FIXME("(%p,%p): stub\n", iface
, pfSupportLossless
);
430 static HRESULT WINAPI
BitmapDecoderInfo_DoesSupportMultiframe(IWICBitmapDecoderInfo
*iface
,
431 BOOL
*pfSupportMultiframe
)
433 FIXME("(%p,%p): stub\n", iface
, pfSupportMultiframe
);
437 static HRESULT WINAPI
BitmapDecoderInfo_MatchesMimeType(IWICBitmapDecoderInfo
*iface
,
438 LPCWSTR wzMimeType
, BOOL
*pfMatches
)
440 FIXME("(%p,%s,%p): stub\n", iface
, debugstr_w(wzMimeType
), pfMatches
);
444 static HRESULT WINAPI
BitmapDecoderInfo_GetPatterns(IWICBitmapDecoderInfo
*iface
,
445 UINT cbSizePatterns
, WICBitmapPattern
*pPatterns
, UINT
*pcPatterns
, UINT
*pcbPatternsActual
)
447 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
448 UINT pattern_count
=0, patterns_size
=0;
449 WCHAR subkeyname
[11];
451 HKEY patternskey
, patternkey
;
452 static const WCHAR uintformatW
[] = {'%','u',0};
453 static const WCHAR patternsW
[] = {'P','a','t','t','e','r','n','s',0};
454 static const WCHAR positionW
[] = {'P','o','s','i','t','i','o','n',0};
455 static const WCHAR lengthW
[] = {'L','e','n','g','t','h',0};
456 static const WCHAR patternW
[] = {'P','a','t','t','e','r','n',0};
457 static const WCHAR maskW
[] = {'M','a','s','k',0};
458 static const WCHAR endofstreamW
[] = {'E','n','d','O','f','S','t','r','e','a','m',0};
461 BYTE
*bPatterns
=(BYTE
*)pPatterns
;
462 DWORD length
, valuesize
;
464 TRACE("(%p,%i,%p,%p,%p)\n", iface
, cbSizePatterns
, pPatterns
, pcPatterns
, pcbPatternsActual
);
466 res
= RegOpenKeyExW(This
->classkey
, patternsW
, 0, KEY_READ
, &patternskey
);
467 if (res
!= ERROR_SUCCESS
) return HRESULT_FROM_WIN32(res
);
469 res
= RegQueryInfoKeyW(patternskey
, NULL
, NULL
, NULL
, &pattern_count
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
470 if (res
== ERROR_SUCCESS
)
472 patterns_size
= pattern_count
* sizeof(WICBitmapPattern
);
474 for (i
=0; i
<pattern_count
; i
++)
476 snprintfW(subkeyname
, 11, uintformatW
, i
);
477 res
= RegOpenKeyExW(patternskey
, subkeyname
, 0, KEY_READ
, &patternkey
);
478 if (res
== ERROR_SUCCESS
)
480 valuesize
= sizeof(ULONG
);
481 res
= RegGetValueW(patternkey
, NULL
, lengthW
, RRF_RT_DWORD
, NULL
,
482 &length
, &valuesize
);
483 patterns_size
+= length
*2;
485 if ((cbSizePatterns
>= patterns_size
) && (res
== ERROR_SUCCESS
))
487 pPatterns
[i
].Length
= length
;
489 pPatterns
[i
].EndOfStream
= 0;
490 valuesize
= sizeof(BOOL
);
491 RegGetValueW(patternkey
, NULL
, endofstreamW
, RRF_RT_DWORD
, NULL
,
492 &pPatterns
[i
].EndOfStream
, &valuesize
);
494 pPatterns
[i
].Position
.QuadPart
= 0;
495 valuesize
= sizeof(ULARGE_INTEGER
);
496 res
= RegGetValueW(patternkey
, NULL
, positionW
, RRF_RT_DWORD
|RRF_RT_QWORD
, NULL
,
497 &pPatterns
[i
].Position
, &valuesize
);
499 if (res
== ERROR_SUCCESS
)
501 pPatterns
[i
].Pattern
= bPatterns
+patterns_size
-length
*2;
503 res
= RegGetValueW(patternkey
, NULL
, patternW
, RRF_RT_REG_BINARY
, NULL
,
504 pPatterns
[i
].Pattern
, &valuesize
);
507 if (res
== ERROR_SUCCESS
)
509 pPatterns
[i
].Mask
= bPatterns
+patterns_size
-length
;
511 res
= RegGetValueW(patternkey
, NULL
, maskW
, RRF_RT_REG_BINARY
, NULL
,
512 pPatterns
[i
].Mask
, &valuesize
);
516 RegCloseKey(patternkey
);
518 if (res
!= ERROR_SUCCESS
)
520 hr
= HRESULT_FROM_WIN32(res
);
525 else hr
= HRESULT_FROM_WIN32(res
);
527 RegCloseKey(patternskey
);
531 *pcPatterns
= pattern_count
;
532 *pcbPatternsActual
= patterns_size
;
533 if (pPatterns
&& cbSizePatterns
< patterns_size
)
534 hr
= WINCODEC_ERR_INSUFFICIENTBUFFER
;
540 static HRESULT WINAPI
BitmapDecoderInfo_MatchesPattern(IWICBitmapDecoderInfo
*iface
,
541 IStream
*pIStream
, BOOL
*pfMatches
)
543 WICBitmapPattern
*patterns
;
544 UINT pattern_count
=0, patterns_size
=0;
551 LARGE_INTEGER seekpos
;
553 TRACE("(%p,%p,%p)\n", iface
, pIStream
, pfMatches
);
555 hr
= BitmapDecoderInfo_GetPatterns(iface
, 0, NULL
, &pattern_count
, &patterns_size
);
556 if (FAILED(hr
)) return hr
;
558 patterns
= HeapAlloc(GetProcessHeap(), 0, patterns_size
);
559 if (!patterns
) return E_OUTOFMEMORY
;
561 hr
= BitmapDecoderInfo_GetPatterns(iface
, patterns_size
, patterns
, &pattern_count
, &patterns_size
);
562 if (FAILED(hr
)) goto end
;
564 for (i
=0; i
<pattern_count
; i
++)
566 if (datasize
< patterns
[i
].Length
)
568 HeapFree(GetProcessHeap(), 0, data
);
569 datasize
= patterns
[i
].Length
;
570 data
= HeapAlloc(GetProcessHeap(), 0, patterns
[i
].Length
);
578 if (patterns
[i
].EndOfStream
)
579 seekpos
.QuadPart
= -patterns
[i
].Position
.QuadPart
;
581 seekpos
.QuadPart
= patterns
[i
].Position
.QuadPart
;
582 hr
= IStream_Seek(pIStream
, seekpos
, patterns
[i
].EndOfStream
? STREAM_SEEK_END
: STREAM_SEEK_SET
, NULL
);
583 if (hr
== STG_E_INVALIDFUNCTION
) continue; /* before start of stream */
584 if (FAILED(hr
)) break;
586 hr
= IStream_Read(pIStream
, data
, patterns
[i
].Length
, &bytesread
);
587 if (hr
== S_FALSE
|| (hr
== S_OK
&& bytesread
!= patterns
[i
].Length
)) /* past end of stream */
589 if (FAILED(hr
)) break;
591 for (pos
=0; pos
<patterns
[i
].Length
; pos
++)
593 if ((data
[pos
] & patterns
[i
].Mask
[pos
]) != patterns
[i
].Pattern
[pos
])
596 if (pos
== patterns
[i
].Length
) /* matches pattern */
604 if (i
== pattern_count
) /* does not match any pattern */
611 HeapFree(GetProcessHeap(), 0, patterns
);
612 HeapFree(GetProcessHeap(), 0, data
);
617 static HRESULT WINAPI
BitmapDecoderInfo_CreateInstance(IWICBitmapDecoderInfo
*iface
,
618 IWICBitmapDecoder
**ppIBitmapDecoder
)
620 BitmapDecoderInfo
*This
= impl_from_IWICBitmapDecoderInfo(iface
);
622 TRACE("(%p,%p)\n", iface
, ppIBitmapDecoder
);
624 return create_instance(&This
->clsid
, &IID_IWICBitmapDecoder
, (void**)ppIBitmapDecoder
);
627 static const IWICBitmapDecoderInfoVtbl BitmapDecoderInfo_Vtbl
= {
628 BitmapDecoderInfo_QueryInterface
,
629 BitmapDecoderInfo_AddRef
,
630 BitmapDecoderInfo_Release
,
631 BitmapDecoderInfo_GetComponentType
,
632 BitmapDecoderInfo_GetCLSID
,
633 BitmapDecoderInfo_GetSigningStatus
,
634 BitmapDecoderInfo_GetAuthor
,
635 BitmapDecoderInfo_GetVendorGUID
,
636 BitmapDecoderInfo_GetVersion
,
637 BitmapDecoderInfo_GetSpecVersion
,
638 BitmapDecoderInfo_GetFriendlyName
,
639 BitmapDecoderInfo_GetContainerFormat
,
640 BitmapDecoderInfo_GetPixelFormats
,
641 BitmapDecoderInfo_GetColorManagementVersion
,
642 BitmapDecoderInfo_GetDeviceManufacturer
,
643 BitmapDecoderInfo_GetDeviceModels
,
644 BitmapDecoderInfo_GetMimeTypes
,
645 BitmapDecoderInfo_GetFileExtensions
,
646 BitmapDecoderInfo_DoesSupportAnimation
,
647 BitmapDecoderInfo_DoesSupportChromaKey
,
648 BitmapDecoderInfo_DoesSupportLossless
,
649 BitmapDecoderInfo_DoesSupportMultiframe
,
650 BitmapDecoderInfo_MatchesMimeType
,
651 BitmapDecoderInfo_GetPatterns
,
652 BitmapDecoderInfo_MatchesPattern
,
653 BitmapDecoderInfo_CreateInstance
656 static HRESULT
BitmapDecoderInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
658 BitmapDecoderInfo
*This
;
660 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapDecoderInfo
));
663 RegCloseKey(classkey
);
664 return E_OUTOFMEMORY
;
667 This
->IWICBitmapDecoderInfo_iface
.lpVtbl
= &BitmapDecoderInfo_Vtbl
;
669 This
->classkey
= classkey
;
670 memcpy(&This
->clsid
, clsid
, sizeof(CLSID
));
672 *ppIInfo
= (IWICComponentInfo
*)&This
->IWICBitmapDecoderInfo_iface
;
677 IWICBitmapEncoderInfo IWICBitmapEncoderInfo_iface
;
683 static inline BitmapEncoderInfo
*impl_from_IWICBitmapEncoderInfo(IWICBitmapEncoderInfo
*iface
)
685 return CONTAINING_RECORD(iface
, BitmapEncoderInfo
, IWICBitmapEncoderInfo_iface
);
688 static HRESULT WINAPI
BitmapEncoderInfo_QueryInterface(IWICBitmapEncoderInfo
*iface
, REFIID iid
,
691 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
692 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
694 if (!ppv
) return E_INVALIDARG
;
696 if (IsEqualIID(&IID_IUnknown
, iid
) ||
697 IsEqualIID(&IID_IWICComponentInfo
, iid
) ||
698 IsEqualIID(&IID_IWICBitmapCodecInfo
, iid
) ||
699 IsEqualIID(&IID_IWICBitmapEncoderInfo
,iid
))
701 *ppv
= &This
->IWICBitmapEncoderInfo_iface
;
706 return E_NOINTERFACE
;
709 IUnknown_AddRef((IUnknown
*)*ppv
);
713 static ULONG WINAPI
BitmapEncoderInfo_AddRef(IWICBitmapEncoderInfo
*iface
)
715 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
716 ULONG ref
= InterlockedIncrement(&This
->ref
);
718 TRACE("(%p) refcount=%u\n", iface
, ref
);
723 static ULONG WINAPI
BitmapEncoderInfo_Release(IWICBitmapEncoderInfo
*iface
)
725 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
726 ULONG ref
= InterlockedDecrement(&This
->ref
);
728 TRACE("(%p) refcount=%u\n", iface
, ref
);
732 RegCloseKey(This
->classkey
);
733 HeapFree(GetProcessHeap(), 0, This
);
739 static HRESULT WINAPI
BitmapEncoderInfo_GetComponentType(IWICBitmapEncoderInfo
*iface
,
740 WICComponentType
*pType
)
742 TRACE("(%p,%p)\n", iface
, pType
);
743 if (!pType
) return E_INVALIDARG
;
748 static HRESULT WINAPI
BitmapEncoderInfo_GetCLSID(IWICBitmapEncoderInfo
*iface
, CLSID
*pclsid
)
750 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
751 TRACE("(%p,%p)\n", iface
, pclsid
);
756 memcpy(pclsid
, &This
->clsid
, sizeof(CLSID
));
761 static HRESULT WINAPI
BitmapEncoderInfo_GetSigningStatus(IWICBitmapEncoderInfo
*iface
, DWORD
*pStatus
)
763 FIXME("(%p,%p): stub\n", iface
, pStatus
);
767 static HRESULT WINAPI
BitmapEncoderInfo_GetAuthor(IWICBitmapEncoderInfo
*iface
, UINT cchAuthor
,
768 WCHAR
*wzAuthor
, UINT
*pcchActual
)
770 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
772 TRACE("(%p,%u,%p,%p)\n", iface
, cchAuthor
, wzAuthor
, pcchActual
);
774 return ComponentInfo_GetStringValue(This
->classkey
, author_valuename
,
775 cchAuthor
, wzAuthor
, pcchActual
);
778 static HRESULT WINAPI
BitmapEncoderInfo_GetVendorGUID(IWICBitmapEncoderInfo
*iface
, GUID
*pguidVendor
)
780 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
782 TRACE("(%p,%p)\n", iface
, pguidVendor
);
784 return ComponentInfo_GetGUIDValue(This
->classkey
, vendor_valuename
, pguidVendor
);
787 static HRESULT WINAPI
BitmapEncoderInfo_GetVersion(IWICBitmapEncoderInfo
*iface
, UINT cchVersion
,
788 WCHAR
*wzVersion
, UINT
*pcchActual
)
790 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
792 TRACE("(%p,%u,%p,%p)\n", iface
, cchVersion
, wzVersion
, pcchActual
);
794 return ComponentInfo_GetStringValue(This
->classkey
, version_valuename
,
795 cchVersion
, wzVersion
, pcchActual
);
798 static HRESULT WINAPI
BitmapEncoderInfo_GetSpecVersion(IWICBitmapEncoderInfo
*iface
, UINT cchSpecVersion
,
799 WCHAR
*wzSpecVersion
, UINT
*pcchActual
)
801 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
803 TRACE("(%p,%u,%p,%p)\n", iface
, cchSpecVersion
, wzSpecVersion
, pcchActual
);
805 return ComponentInfo_GetStringValue(This
->classkey
, specversion_valuename
,
806 cchSpecVersion
, wzSpecVersion
, pcchActual
);
809 static HRESULT WINAPI
BitmapEncoderInfo_GetFriendlyName(IWICBitmapEncoderInfo
*iface
, UINT cchFriendlyName
,
810 WCHAR
*wzFriendlyName
, UINT
*pcchActual
)
812 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
814 TRACE("(%p,%u,%p,%p)\n", iface
, cchFriendlyName
, wzFriendlyName
, pcchActual
);
816 return ComponentInfo_GetStringValue(This
->classkey
, friendlyname_valuename
,
817 cchFriendlyName
, wzFriendlyName
, pcchActual
);
820 static HRESULT WINAPI
BitmapEncoderInfo_GetContainerFormat(IWICBitmapEncoderInfo
*iface
,
821 GUID
*pguidContainerFormat
)
823 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
824 TRACE("(%p,%p)\n", iface
, pguidContainerFormat
);
825 return ComponentInfo_GetGUIDValue(This
->classkey
, containerformat_valuename
, pguidContainerFormat
);
828 static HRESULT WINAPI
BitmapEncoderInfo_GetPixelFormats(IWICBitmapEncoderInfo
*iface
,
829 UINT cFormats
, GUID
*pguidPixelFormats
, UINT
*pcActual
)
831 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
832 TRACE("(%p,%u,%p,%p)\n", iface
, cFormats
, pguidPixelFormats
, pcActual
);
833 return ComponentInfo_GetGuidList(This
->classkey
, formats_keyname
, cFormats
, pguidPixelFormats
, pcActual
);
836 static HRESULT WINAPI
BitmapEncoderInfo_GetColorManagementVersion(IWICBitmapEncoderInfo
*iface
,
837 UINT cchColorManagementVersion
, WCHAR
*wzColorManagementVersion
, UINT
*pcchActual
)
839 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchColorManagementVersion
, wzColorManagementVersion
, pcchActual
);
843 static HRESULT WINAPI
BitmapEncoderInfo_GetDeviceManufacturer(IWICBitmapEncoderInfo
*iface
,
844 UINT cchDeviceManufacturer
, WCHAR
*wzDeviceManufacturer
, UINT
*pcchActual
)
846 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchDeviceManufacturer
, wzDeviceManufacturer
, pcchActual
);
850 static HRESULT WINAPI
BitmapEncoderInfo_GetDeviceModels(IWICBitmapEncoderInfo
*iface
,
851 UINT cchDeviceModels
, WCHAR
*wzDeviceModels
, UINT
*pcchActual
)
853 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchDeviceModels
, wzDeviceModels
, pcchActual
);
857 static HRESULT WINAPI
BitmapEncoderInfo_GetMimeTypes(IWICBitmapEncoderInfo
*iface
,
858 UINT cchMimeTypes
, WCHAR
*wzMimeTypes
, UINT
*pcchActual
)
860 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
862 TRACE("(%p,%u,%p,%p)\n", iface
, cchMimeTypes
, wzMimeTypes
, pcchActual
);
864 return ComponentInfo_GetStringValue(This
->classkey
, mimetypes_valuename
,
865 cchMimeTypes
, wzMimeTypes
, pcchActual
);
868 static HRESULT WINAPI
BitmapEncoderInfo_GetFileExtensions(IWICBitmapEncoderInfo
*iface
,
869 UINT cchFileExtensions
, WCHAR
*wzFileExtensions
, UINT
*pcchActual
)
871 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
873 TRACE("(%p,%u,%p,%p)\n", iface
, cchFileExtensions
, wzFileExtensions
, pcchActual
);
875 return ComponentInfo_GetStringValue(This
->classkey
, fileextensions_valuename
,
876 cchFileExtensions
, wzFileExtensions
, pcchActual
);
879 static HRESULT WINAPI
BitmapEncoderInfo_DoesSupportAnimation(IWICBitmapEncoderInfo
*iface
,
880 BOOL
*pfSupportAnimation
)
882 FIXME("(%p,%p): stub\n", iface
, pfSupportAnimation
);
886 static HRESULT WINAPI
BitmapEncoderInfo_DoesSupportChromaKey(IWICBitmapEncoderInfo
*iface
,
887 BOOL
*pfSupportChromaKey
)
889 FIXME("(%p,%p): stub\n", iface
, pfSupportChromaKey
);
893 static HRESULT WINAPI
BitmapEncoderInfo_DoesSupportLossless(IWICBitmapEncoderInfo
*iface
,
894 BOOL
*pfSupportLossless
)
896 FIXME("(%p,%p): stub\n", iface
, pfSupportLossless
);
900 static HRESULT WINAPI
BitmapEncoderInfo_DoesSupportMultiframe(IWICBitmapEncoderInfo
*iface
,
901 BOOL
*pfSupportMultiframe
)
903 FIXME("(%p,%p): stub\n", iface
, pfSupportMultiframe
);
907 static HRESULT WINAPI
BitmapEncoderInfo_MatchesMimeType(IWICBitmapEncoderInfo
*iface
,
908 LPCWSTR wzMimeType
, BOOL
*pfMatches
)
910 FIXME("(%p,%s,%p): stub\n", iface
, debugstr_w(wzMimeType
), pfMatches
);
914 static HRESULT WINAPI
BitmapEncoderInfo_CreateInstance(IWICBitmapEncoderInfo
*iface
,
915 IWICBitmapEncoder
**ppIBitmapEncoder
)
917 BitmapEncoderInfo
*This
= impl_from_IWICBitmapEncoderInfo(iface
);
919 TRACE("(%p,%p)\n", iface
, ppIBitmapEncoder
);
921 return create_instance(&This
->clsid
, &IID_IWICBitmapEncoder
, (void**)ppIBitmapEncoder
);
924 static const IWICBitmapEncoderInfoVtbl BitmapEncoderInfo_Vtbl
= {
925 BitmapEncoderInfo_QueryInterface
,
926 BitmapEncoderInfo_AddRef
,
927 BitmapEncoderInfo_Release
,
928 BitmapEncoderInfo_GetComponentType
,
929 BitmapEncoderInfo_GetCLSID
,
930 BitmapEncoderInfo_GetSigningStatus
,
931 BitmapEncoderInfo_GetAuthor
,
932 BitmapEncoderInfo_GetVendorGUID
,
933 BitmapEncoderInfo_GetVersion
,
934 BitmapEncoderInfo_GetSpecVersion
,
935 BitmapEncoderInfo_GetFriendlyName
,
936 BitmapEncoderInfo_GetContainerFormat
,
937 BitmapEncoderInfo_GetPixelFormats
,
938 BitmapEncoderInfo_GetColorManagementVersion
,
939 BitmapEncoderInfo_GetDeviceManufacturer
,
940 BitmapEncoderInfo_GetDeviceModels
,
941 BitmapEncoderInfo_GetMimeTypes
,
942 BitmapEncoderInfo_GetFileExtensions
,
943 BitmapEncoderInfo_DoesSupportAnimation
,
944 BitmapEncoderInfo_DoesSupportChromaKey
,
945 BitmapEncoderInfo_DoesSupportLossless
,
946 BitmapEncoderInfo_DoesSupportMultiframe
,
947 BitmapEncoderInfo_MatchesMimeType
,
948 BitmapEncoderInfo_CreateInstance
951 static HRESULT
BitmapEncoderInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
953 BitmapEncoderInfo
*This
;
955 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapEncoderInfo
));
958 RegCloseKey(classkey
);
959 return E_OUTOFMEMORY
;
962 This
->IWICBitmapEncoderInfo_iface
.lpVtbl
= &BitmapEncoderInfo_Vtbl
;
964 This
->classkey
= classkey
;
965 memcpy(&This
->clsid
, clsid
, sizeof(CLSID
));
967 *ppIInfo
= (IWICComponentInfo
*)&This
->IWICBitmapEncoderInfo_iface
;
972 IWICFormatConverterInfo IWICFormatConverterInfo_iface
;
976 } FormatConverterInfo
;
978 static inline FormatConverterInfo
*impl_from_IWICFormatConverterInfo(IWICFormatConverterInfo
*iface
)
980 return CONTAINING_RECORD(iface
, FormatConverterInfo
, IWICFormatConverterInfo_iface
);
983 static HRESULT WINAPI
FormatConverterInfo_QueryInterface(IWICFormatConverterInfo
*iface
, REFIID iid
,
986 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
987 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
989 if (!ppv
) return E_INVALIDARG
;
991 if (IsEqualIID(&IID_IUnknown
, iid
) ||
992 IsEqualIID(&IID_IWICComponentInfo
, iid
) ||
993 IsEqualIID(&IID_IWICFormatConverterInfo
,iid
))
995 *ppv
= &This
->IWICFormatConverterInfo_iface
;
1000 return E_NOINTERFACE
;
1003 IUnknown_AddRef((IUnknown
*)*ppv
);
1007 static ULONG WINAPI
FormatConverterInfo_AddRef(IWICFormatConverterInfo
*iface
)
1009 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1010 ULONG ref
= InterlockedIncrement(&This
->ref
);
1012 TRACE("(%p) refcount=%u\n", iface
, ref
);
1017 static ULONG WINAPI
FormatConverterInfo_Release(IWICFormatConverterInfo
*iface
)
1019 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1020 ULONG ref
= InterlockedDecrement(&This
->ref
);
1022 TRACE("(%p) refcount=%u\n", iface
, ref
);
1026 RegCloseKey(This
->classkey
);
1027 HeapFree(GetProcessHeap(), 0, This
);
1033 static HRESULT WINAPI
FormatConverterInfo_GetComponentType(IWICFormatConverterInfo
*iface
,
1034 WICComponentType
*pType
)
1036 TRACE("(%p,%p)\n", iface
, pType
);
1037 if (!pType
) return E_INVALIDARG
;
1038 *pType
= WICPixelFormatConverter
;
1042 static HRESULT WINAPI
FormatConverterInfo_GetCLSID(IWICFormatConverterInfo
*iface
, CLSID
*pclsid
)
1044 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1045 TRACE("(%p,%p)\n", iface
, pclsid
);
1048 return E_INVALIDARG
;
1050 memcpy(pclsid
, &This
->clsid
, sizeof(CLSID
));
1055 static HRESULT WINAPI
FormatConverterInfo_GetSigningStatus(IWICFormatConverterInfo
*iface
, DWORD
*pStatus
)
1057 FIXME("(%p,%p): stub\n", iface
, pStatus
);
1061 static HRESULT WINAPI
FormatConverterInfo_GetAuthor(IWICFormatConverterInfo
*iface
, UINT cchAuthor
,
1062 WCHAR
*wzAuthor
, UINT
*pcchActual
)
1064 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1066 TRACE("(%p,%u,%p,%p)\n", iface
, cchAuthor
, wzAuthor
, pcchActual
);
1068 return ComponentInfo_GetStringValue(This
->classkey
, author_valuename
,
1069 cchAuthor
, wzAuthor
, pcchActual
);
1072 static HRESULT WINAPI
FormatConverterInfo_GetVendorGUID(IWICFormatConverterInfo
*iface
, GUID
*pguidVendor
)
1074 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1076 TRACE("(%p,%p)\n", iface
, pguidVendor
);
1078 return ComponentInfo_GetGUIDValue(This
->classkey
, vendor_valuename
, pguidVendor
);
1081 static HRESULT WINAPI
FormatConverterInfo_GetVersion(IWICFormatConverterInfo
*iface
, UINT cchVersion
,
1082 WCHAR
*wzVersion
, UINT
*pcchActual
)
1084 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1086 TRACE("(%p,%u,%p,%p)\n", iface
, cchVersion
, wzVersion
, pcchActual
);
1088 return ComponentInfo_GetStringValue(This
->classkey
, version_valuename
,
1089 cchVersion
, wzVersion
, pcchActual
);
1092 static HRESULT WINAPI
FormatConverterInfo_GetSpecVersion(IWICFormatConverterInfo
*iface
, UINT cchSpecVersion
,
1093 WCHAR
*wzSpecVersion
, UINT
*pcchActual
)
1095 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1097 TRACE("(%p,%u,%p,%p)\n", iface
, cchSpecVersion
, wzSpecVersion
, pcchActual
);
1099 return ComponentInfo_GetStringValue(This
->classkey
, specversion_valuename
,
1100 cchSpecVersion
, wzSpecVersion
, pcchActual
);
1103 static HRESULT WINAPI
FormatConverterInfo_GetFriendlyName(IWICFormatConverterInfo
*iface
, UINT cchFriendlyName
,
1104 WCHAR
*wzFriendlyName
, UINT
*pcchActual
)
1106 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1108 TRACE("(%p,%u,%p,%p)\n", iface
, cchFriendlyName
, wzFriendlyName
, pcchActual
);
1110 return ComponentInfo_GetStringValue(This
->classkey
, friendlyname_valuename
,
1111 cchFriendlyName
, wzFriendlyName
, pcchActual
);
1114 static HRESULT WINAPI
FormatConverterInfo_GetPixelFormats(IWICFormatConverterInfo
*iface
,
1115 UINT cFormats
, GUID
*pguidPixelFormats
, UINT
*pcActual
)
1117 FIXME("(%p,%u,%p,%p): stub\n", iface
, cFormats
, pguidPixelFormats
, pcActual
);
1121 static HRESULT WINAPI
FormatConverterInfo_CreateInstance(IWICFormatConverterInfo
*iface
,
1122 IWICFormatConverter
**ppIFormatConverter
)
1124 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1126 TRACE("(%p,%p)\n", iface
, ppIFormatConverter
);
1128 return create_instance(&This
->clsid
, &IID_IWICFormatConverter
,
1129 (void**)ppIFormatConverter
);
1132 static BOOL
ConverterSupportsFormat(IWICFormatConverterInfo
*iface
, const WCHAR
*formatguid
)
1135 FormatConverterInfo
*This
= impl_from_IWICFormatConverterInfo(iface
);
1136 HKEY formats_key
, guid_key
;
1138 /* Avoid testing using IWICFormatConverter_GetPixelFormats because that
1139 would be O(n). A registry test should do better. */
1141 res
= RegOpenKeyExW(This
->classkey
, pixelformats_keyname
, 0, KEY_READ
, &formats_key
);
1142 if (res
!= ERROR_SUCCESS
) return FALSE
;
1144 res
= RegOpenKeyExW(formats_key
, formatguid
, 0, KEY_READ
, &guid_key
);
1145 if (res
== ERROR_SUCCESS
) RegCloseKey(guid_key
);
1147 RegCloseKey(formats_key
);
1149 return (res
== ERROR_SUCCESS
);
1152 static const IWICFormatConverterInfoVtbl FormatConverterInfo_Vtbl
= {
1153 FormatConverterInfo_QueryInterface
,
1154 FormatConverterInfo_AddRef
,
1155 FormatConverterInfo_Release
,
1156 FormatConverterInfo_GetComponentType
,
1157 FormatConverterInfo_GetCLSID
,
1158 FormatConverterInfo_GetSigningStatus
,
1159 FormatConverterInfo_GetAuthor
,
1160 FormatConverterInfo_GetVendorGUID
,
1161 FormatConverterInfo_GetVersion
,
1162 FormatConverterInfo_GetSpecVersion
,
1163 FormatConverterInfo_GetFriendlyName
,
1164 FormatConverterInfo_GetPixelFormats
,
1165 FormatConverterInfo_CreateInstance
1168 static HRESULT
FormatConverterInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
1170 FormatConverterInfo
*This
;
1172 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(FormatConverterInfo
));
1175 RegCloseKey(classkey
);
1176 return E_OUTOFMEMORY
;
1179 This
->IWICFormatConverterInfo_iface
.lpVtbl
= &FormatConverterInfo_Vtbl
;
1181 This
->classkey
= classkey
;
1182 memcpy(&This
->clsid
, clsid
, sizeof(CLSID
));
1184 *ppIInfo
= (IWICComponentInfo
*)&This
->IWICFormatConverterInfo_iface
;
1189 IWICPixelFormatInfo2 IWICPixelFormatInfo2_iface
;
1195 static inline PixelFormatInfo
*impl_from_IWICPixelFormatInfo2(IWICPixelFormatInfo2
*iface
)
1197 return CONTAINING_RECORD(iface
, PixelFormatInfo
, IWICPixelFormatInfo2_iface
);
1200 static HRESULT WINAPI
PixelFormatInfo_QueryInterface(IWICPixelFormatInfo2
*iface
, REFIID iid
,
1203 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1204 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
1206 if (!ppv
) return E_INVALIDARG
;
1208 if (IsEqualIID(&IID_IUnknown
, iid
) ||
1209 IsEqualIID(&IID_IWICComponentInfo
, iid
) ||
1210 IsEqualIID(&IID_IWICPixelFormatInfo
, iid
) ||
1211 IsEqualIID(&IID_IWICPixelFormatInfo2
,iid
))
1213 *ppv
= &This
->IWICPixelFormatInfo2_iface
;
1218 return E_NOINTERFACE
;
1221 IUnknown_AddRef((IUnknown
*)*ppv
);
1225 static ULONG WINAPI
PixelFormatInfo_AddRef(IWICPixelFormatInfo2
*iface
)
1227 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1228 ULONG ref
= InterlockedIncrement(&This
->ref
);
1230 TRACE("(%p) refcount=%u\n", iface
, ref
);
1235 static ULONG WINAPI
PixelFormatInfo_Release(IWICPixelFormatInfo2
*iface
)
1237 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1238 ULONG ref
= InterlockedDecrement(&This
->ref
);
1240 TRACE("(%p) refcount=%u\n", iface
, ref
);
1244 RegCloseKey(This
->classkey
);
1245 HeapFree(GetProcessHeap(), 0, This
);
1251 static HRESULT WINAPI
PixelFormatInfo_GetComponentType(IWICPixelFormatInfo2
*iface
,
1252 WICComponentType
*pType
)
1254 TRACE("(%p,%p)\n", iface
, pType
);
1255 if (!pType
) return E_INVALIDARG
;
1256 *pType
= WICPixelFormat
;
1260 static HRESULT WINAPI
PixelFormatInfo_GetCLSID(IWICPixelFormatInfo2
*iface
, CLSID
*pclsid
)
1262 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1263 TRACE("(%p,%p)\n", iface
, pclsid
);
1266 return E_INVALIDARG
;
1268 memcpy(pclsid
, &This
->clsid
, sizeof(CLSID
));
1273 static HRESULT WINAPI
PixelFormatInfo_GetSigningStatus(IWICPixelFormatInfo2
*iface
, DWORD
*pStatus
)
1275 TRACE("(%p,%p)\n", iface
, pStatus
);
1278 return E_INVALIDARG
;
1280 /* Pixel formats don't require code, so they are considered signed. */
1281 *pStatus
= WICComponentSigned
;
1286 static HRESULT WINAPI
PixelFormatInfo_GetAuthor(IWICPixelFormatInfo2
*iface
, UINT cchAuthor
,
1287 WCHAR
*wzAuthor
, UINT
*pcchActual
)
1289 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1291 TRACE("(%p,%u,%p,%p)\n", iface
, cchAuthor
, wzAuthor
, pcchActual
);
1293 return ComponentInfo_GetStringValue(This
->classkey
, author_valuename
,
1294 cchAuthor
, wzAuthor
, pcchActual
);
1297 static HRESULT WINAPI
PixelFormatInfo_GetVendorGUID(IWICPixelFormatInfo2
*iface
, GUID
*pguidVendor
)
1299 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1301 TRACE("(%p,%p)\n", iface
, pguidVendor
);
1303 return ComponentInfo_GetGUIDValue(This
->classkey
, vendor_valuename
, pguidVendor
);
1306 static HRESULT WINAPI
PixelFormatInfo_GetVersion(IWICPixelFormatInfo2
*iface
, UINT cchVersion
,
1307 WCHAR
*wzVersion
, UINT
*pcchActual
)
1309 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1311 TRACE("(%p,%u,%p,%p)\n", iface
, cchVersion
, wzVersion
, pcchActual
);
1313 return ComponentInfo_GetStringValue(This
->classkey
, version_valuename
,
1314 cchVersion
, wzVersion
, pcchActual
);
1317 static HRESULT WINAPI
PixelFormatInfo_GetSpecVersion(IWICPixelFormatInfo2
*iface
, UINT cchSpecVersion
,
1318 WCHAR
*wzSpecVersion
, UINT
*pcchActual
)
1320 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1322 TRACE("(%p,%u,%p,%p)\n", iface
, cchSpecVersion
, wzSpecVersion
, pcchActual
);
1324 return ComponentInfo_GetStringValue(This
->classkey
, specversion_valuename
,
1325 cchSpecVersion
, wzSpecVersion
, pcchActual
);
1328 static HRESULT WINAPI
PixelFormatInfo_GetFriendlyName(IWICPixelFormatInfo2
*iface
, UINT cchFriendlyName
,
1329 WCHAR
*wzFriendlyName
, UINT
*pcchActual
)
1331 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1333 TRACE("(%p,%u,%p,%p)\n", iface
, cchFriendlyName
, wzFriendlyName
, pcchActual
);
1335 return ComponentInfo_GetStringValue(This
->classkey
, friendlyname_valuename
,
1336 cchFriendlyName
, wzFriendlyName
, pcchActual
);
1339 static HRESULT WINAPI
PixelFormatInfo_GetFormatGUID(IWICPixelFormatInfo2
*iface
,
1342 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1343 TRACE("(%p,%p)\n", iface
, pFormat
);
1346 return E_INVALIDARG
;
1348 *pFormat
= This
->clsid
;
1353 static HRESULT WINAPI
PixelFormatInfo_GetColorContext(IWICPixelFormatInfo2
*iface
,
1354 IWICColorContext
**ppIColorContext
)
1356 FIXME("(%p,%p): stub\n", iface
, ppIColorContext
);
1360 static HRESULT WINAPI
PixelFormatInfo_GetBitsPerPixel(IWICPixelFormatInfo2
*iface
,
1361 UINT
*puiBitsPerPixel
)
1363 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1365 TRACE("(%p,%p)\n", iface
, puiBitsPerPixel
);
1367 return ComponentInfo_GetDWORDValue(This
->classkey
, bitsperpixel_valuename
, puiBitsPerPixel
);
1370 static HRESULT WINAPI
PixelFormatInfo_GetChannelCount(IWICPixelFormatInfo2
*iface
,
1371 UINT
*puiChannelCount
)
1373 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1375 TRACE("(%p,%p)\n", iface
, puiChannelCount
);
1377 return ComponentInfo_GetDWORDValue(This
->classkey
, channelcount_valuename
, puiChannelCount
);
1380 static HRESULT WINAPI
PixelFormatInfo_GetChannelMask(IWICPixelFormatInfo2
*iface
,
1381 UINT uiChannelIndex
, UINT cbMaskBuffer
, BYTE
*pbMaskBuffer
, UINT
*pcbActual
)
1383 static const WCHAR uintformatW
[] = {'%','u',0};
1384 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1388 WCHAR valuename
[11];
1391 TRACE("(%p,%u,%u,%p,%p)\n", iface
, uiChannelIndex
, cbMaskBuffer
, pbMaskBuffer
, pcbActual
);
1394 return E_INVALIDARG
;
1396 hr
= PixelFormatInfo_GetChannelCount(iface
, &channel_count
);
1398 if (SUCCEEDED(hr
) && uiChannelIndex
>= channel_count
)
1403 snprintfW(valuename
, 11, uintformatW
, uiChannelIndex
);
1405 cbData
= cbMaskBuffer
;
1407 ret
= RegGetValueW(This
->classkey
, channelmasks_keyname
, valuename
, RRF_RT_REG_BINARY
, NULL
, pbMaskBuffer
, &cbData
);
1409 if (ret
== ERROR_SUCCESS
|| ret
== ERROR_MORE_DATA
)
1410 *pcbActual
= cbData
;
1412 if (ret
== ERROR_MORE_DATA
)
1415 hr
= HRESULT_FROM_WIN32(ret
);
1421 static HRESULT WINAPI
PixelFormatInfo_SupportsTransparency(IWICPixelFormatInfo2
*iface
,
1422 BOOL
*pfSupportsTransparency
)
1424 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1426 TRACE("(%p,%p)\n", iface
, pfSupportsTransparency
);
1428 return ComponentInfo_GetDWORDValue(This
->classkey
, supportstransparency_valuename
, (DWORD
*)pfSupportsTransparency
);
1431 static HRESULT WINAPI
PixelFormatInfo_GetNumericRepresentation(IWICPixelFormatInfo2
*iface
,
1432 WICPixelFormatNumericRepresentation
*pNumericRepresentation
)
1434 PixelFormatInfo
*This
= impl_from_IWICPixelFormatInfo2(iface
);
1436 TRACE("(%p,%p)\n", iface
, pNumericRepresentation
);
1438 return ComponentInfo_GetDWORDValue(This
->classkey
, numericrepresentation_valuename
, pNumericRepresentation
);
1441 static const IWICPixelFormatInfo2Vtbl PixelFormatInfo_Vtbl
= {
1442 PixelFormatInfo_QueryInterface
,
1443 PixelFormatInfo_AddRef
,
1444 PixelFormatInfo_Release
,
1445 PixelFormatInfo_GetComponentType
,
1446 PixelFormatInfo_GetCLSID
,
1447 PixelFormatInfo_GetSigningStatus
,
1448 PixelFormatInfo_GetAuthor
,
1449 PixelFormatInfo_GetVendorGUID
,
1450 PixelFormatInfo_GetVersion
,
1451 PixelFormatInfo_GetSpecVersion
,
1452 PixelFormatInfo_GetFriendlyName
,
1453 PixelFormatInfo_GetFormatGUID
,
1454 PixelFormatInfo_GetColorContext
,
1455 PixelFormatInfo_GetBitsPerPixel
,
1456 PixelFormatInfo_GetChannelCount
,
1457 PixelFormatInfo_GetChannelMask
,
1458 PixelFormatInfo_SupportsTransparency
,
1459 PixelFormatInfo_GetNumericRepresentation
1462 static HRESULT
PixelFormatInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
1464 PixelFormatInfo
*This
;
1466 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(PixelFormatInfo
));
1469 RegCloseKey(classkey
);
1470 return E_OUTOFMEMORY
;
1473 This
->IWICPixelFormatInfo2_iface
.lpVtbl
= &PixelFormatInfo_Vtbl
;
1475 This
->classkey
= classkey
;
1476 memcpy(&This
->clsid
, clsid
, sizeof(CLSID
));
1478 *ppIInfo
= (IWICComponentInfo
*)&This
->IWICPixelFormatInfo2_iface
;
1484 IWICMetadataReaderInfo IWICMetadataReaderInfo_iface
;
1488 } MetadataReaderInfo
;
1490 static inline MetadataReaderInfo
*impl_from_IWICMetadataReaderInfo(IWICMetadataReaderInfo
*iface
)
1492 return CONTAINING_RECORD(iface
, MetadataReaderInfo
, IWICMetadataReaderInfo_iface
);
1495 static HRESULT WINAPI
MetadataReaderInfo_QueryInterface(IWICMetadataReaderInfo
*iface
,
1496 REFIID riid
, void **ppv
)
1498 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1500 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(riid
), ppv
);
1502 if (!ppv
) return E_INVALIDARG
;
1504 if (IsEqualIID(&IID_IUnknown
, riid
) ||
1505 IsEqualIID(&IID_IWICComponentInfo
, riid
) ||
1506 IsEqualIID(&IID_IWICMetadataHandlerInfo
, riid
) ||
1507 IsEqualIID(&IID_IWICMetadataReaderInfo
, riid
))
1509 *ppv
= &This
->IWICMetadataReaderInfo_iface
;
1514 return E_NOINTERFACE
;
1517 IUnknown_AddRef((IUnknown
*)*ppv
);
1521 static ULONG WINAPI
MetadataReaderInfo_AddRef(IWICMetadataReaderInfo
*iface
)
1523 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1524 ULONG ref
= InterlockedIncrement(&This
->ref
);
1526 TRACE("(%p) refcount=%u\n", iface
, ref
);
1530 static ULONG WINAPI
MetadataReaderInfo_Release(IWICMetadataReaderInfo
*iface
)
1532 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1533 ULONG ref
= InterlockedDecrement(&This
->ref
);
1535 TRACE("(%p) refcount=%u\n", iface
, ref
);
1539 RegCloseKey(This
->classkey
);
1540 HeapFree(GetProcessHeap(), 0, This
);
1545 static HRESULT WINAPI
MetadataReaderInfo_GetComponentType(IWICMetadataReaderInfo
*iface
,
1546 WICComponentType
*type
)
1548 TRACE("(%p,%p)\n", iface
, type
);
1550 if (!type
) return E_INVALIDARG
;
1551 *type
= WICMetadataReader
;
1555 static HRESULT WINAPI
MetadataReaderInfo_GetCLSID(IWICMetadataReaderInfo
*iface
,
1558 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1560 TRACE("(%p,%p)\n", iface
, clsid
);
1562 if (!clsid
) return E_INVALIDARG
;
1563 *clsid
= This
->clsid
;
1567 static HRESULT WINAPI
MetadataReaderInfo_GetSigningStatus(IWICMetadataReaderInfo
*iface
,
1570 FIXME("(%p,%p): stub\n", iface
, status
);
1574 static HRESULT WINAPI
MetadataReaderInfo_GetAuthor(IWICMetadataReaderInfo
*iface
,
1575 UINT length
, WCHAR
*author
, UINT
*actual_length
)
1577 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1579 TRACE("(%p,%u,%p,%p)\n", iface
, length
, author
, actual_length
);
1581 return ComponentInfo_GetStringValue(This
->classkey
, author_valuename
,
1582 length
, author
, actual_length
);
1585 static HRESULT WINAPI
MetadataReaderInfo_GetVendorGUID(IWICMetadataReaderInfo
*iface
,
1588 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1590 TRACE("(%p,%p)\n", iface
, vendor
);
1592 return ComponentInfo_GetGUIDValue(This
->classkey
, vendor_valuename
, vendor
);
1595 static HRESULT WINAPI
MetadataReaderInfo_GetVersion(IWICMetadataReaderInfo
*iface
,
1596 UINT length
, WCHAR
*version
, UINT
*actual_length
)
1598 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1600 TRACE("(%p,%u,%p,%p)\n", iface
, length
, version
, actual_length
);
1602 return ComponentInfo_GetStringValue(This
->classkey
, version_valuename
,
1603 length
, version
, actual_length
);
1606 static HRESULT WINAPI
MetadataReaderInfo_GetSpecVersion(IWICMetadataReaderInfo
*iface
,
1607 UINT length
, WCHAR
*version
, UINT
*actual_length
)
1609 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1611 TRACE("(%p,%u,%p,%p)\n", iface
, length
, version
, actual_length
);
1613 return ComponentInfo_GetStringValue(This
->classkey
, specversion_valuename
,
1614 length
, version
, actual_length
);
1617 static HRESULT WINAPI
MetadataReaderInfo_GetFriendlyName(IWICMetadataReaderInfo
*iface
,
1618 UINT length
, WCHAR
*name
, UINT
*actual_length
)
1620 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1622 TRACE("(%p,%u,%p,%p)\n", iface
, length
, name
, actual_length
);
1624 return ComponentInfo_GetStringValue(This
->classkey
, friendlyname_valuename
,
1625 length
, name
, actual_length
);
1628 static HRESULT WINAPI
MetadataReaderInfo_GetMetadataFormat(IWICMetadataReaderInfo
*iface
,
1631 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1632 TRACE("(%p,%p)\n", iface
, format
);
1633 return ComponentInfo_GetGUIDValue(This
->classkey
, metadataformat_valuename
, format
);
1636 static HRESULT WINAPI
MetadataReaderInfo_GetContainerFormats(IWICMetadataReaderInfo
*iface
,
1637 UINT length
, GUID
*formats
, UINT
*actual_length
)
1639 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1640 TRACE("(%p,%u,%p,%p)\n", iface
, length
, formats
, actual_length
);
1642 return ComponentInfo_GetGuidList(This
->classkey
, containers_keyname
, length
,
1643 formats
, actual_length
);
1646 static HRESULT WINAPI
MetadataReaderInfo_GetDeviceManufacturer(IWICMetadataReaderInfo
*iface
,
1647 UINT length
, WCHAR
*manufacturer
, UINT
*actual_length
)
1649 FIXME("(%p,%u,%p,%p): stub\n", iface
, length
, manufacturer
, actual_length
);
1653 static HRESULT WINAPI
MetadataReaderInfo_GetDeviceModels(IWICMetadataReaderInfo
*iface
,
1654 UINT length
, WCHAR
*models
, UINT
*actual_length
)
1656 FIXME("(%p,%u,%p,%p): stub\n", iface
, length
, models
, actual_length
);
1660 static HRESULT WINAPI
MetadataReaderInfo_DoesRequireFullStream(IWICMetadataReaderInfo
*iface
,
1663 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1664 TRACE("(%p,%p)\n", iface
, param
);
1665 return ComponentInfo_GetDWORDValue(This
->classkey
, requiresfullstream_valuename
, (DWORD
*)param
);
1668 static HRESULT WINAPI
MetadataReaderInfo_DoesSupportPadding(IWICMetadataReaderInfo
*iface
,
1671 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1672 TRACE("(%p,%p)\n", iface
, param
);
1673 return ComponentInfo_GetDWORDValue(This
->classkey
, supportspadding_valuename
, (DWORD
*)param
);
1676 static HRESULT WINAPI
MetadataReaderInfo_DoesRequireFixedSize(IWICMetadataReaderInfo
*iface
,
1679 FIXME("(%p,%p): stub\n", iface
, param
);
1683 static HRESULT WINAPI
MetadataReaderInfo_GetPatterns(IWICMetadataReaderInfo
*iface
,
1684 REFGUID container
, UINT length
, WICMetadataPattern
*patterns
, UINT
*count
, UINT
*actual_length
)
1686 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1689 UINT pattern_count
=0, patterns_size
=0;
1690 DWORD valuesize
, patternsize
;
1691 BYTE
*bPatterns
=(BYTE
*)patterns
;
1692 HKEY containers_key
, guid_key
, pattern_key
;
1693 WCHAR subkeyname
[11];
1694 WCHAR guidkeyname
[39];
1696 static const WCHAR uintformatW
[] = {'%','u',0};
1697 static const WCHAR patternW
[] = {'P','a','t','t','e','r','n',0};
1698 static const WCHAR positionW
[] = {'P','o','s','i','t','i','o','n',0};
1699 static const WCHAR maskW
[] = {'M','a','s','k',0};
1700 static const WCHAR dataoffsetW
[] = {'D','a','t','a','O','f','f','s','e','t',0};
1702 TRACE("(%p,%s,%u,%p,%p,%p)\n", iface
, debugstr_guid(container
), length
, patterns
, count
, actual_length
);
1704 if (!actual_length
|| !container
) return E_INVALIDARG
;
1706 res
= RegOpenKeyExW(This
->classkey
, containers_keyname
, 0, KEY_READ
, &containers_key
);
1707 if (res
== ERROR_SUCCESS
)
1709 StringFromGUID2(container
, guidkeyname
, 39);
1711 res
= RegOpenKeyExW(containers_key
, guidkeyname
, 0, KEY_READ
, &guid_key
);
1712 if (res
== ERROR_FILE_NOT_FOUND
) hr
= WINCODEC_ERR_COMPONENTNOTFOUND
;
1713 else if (res
!= ERROR_SUCCESS
) hr
= HRESULT_FROM_WIN32(res
);
1715 RegCloseKey(containers_key
);
1717 else if (res
== ERROR_FILE_NOT_FOUND
) hr
= WINCODEC_ERR_COMPONENTNOTFOUND
;
1718 else hr
= HRESULT_FROM_WIN32(res
);
1722 res
= RegQueryInfoKeyW(guid_key
, NULL
, NULL
, NULL
, &pattern_count
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
1723 if (res
!= ERROR_SUCCESS
) hr
= HRESULT_FROM_WIN32(res
);
1727 patterns_size
= pattern_count
* sizeof(WICMetadataPattern
);
1729 for (i
=0; i
<pattern_count
; i
++)
1731 snprintfW(subkeyname
, 11, uintformatW
, i
);
1732 res
= RegOpenKeyExW(guid_key
, subkeyname
, 0, KEY_READ
, &pattern_key
);
1733 if (res
== ERROR_SUCCESS
)
1735 res
= RegGetValueW(pattern_key
, NULL
, patternW
, RRF_RT_REG_BINARY
, NULL
,
1736 NULL
, &patternsize
);
1737 patterns_size
+= patternsize
*2;
1739 if ((length
>= patterns_size
) && (res
== ERROR_SUCCESS
))
1741 patterns
[i
].Length
= patternsize
;
1743 patterns
[i
].DataOffset
.QuadPart
= 0;
1744 valuesize
= sizeof(ULARGE_INTEGER
);
1745 RegGetValueW(pattern_key
, NULL
, dataoffsetW
, RRF_RT_DWORD
|RRF_RT_QWORD
, NULL
,
1746 &patterns
[i
].DataOffset
, &valuesize
);
1748 patterns
[i
].Position
.QuadPart
= 0;
1749 valuesize
= sizeof(ULARGE_INTEGER
);
1750 res
= RegGetValueW(pattern_key
, NULL
, positionW
, RRF_RT_DWORD
|RRF_RT_QWORD
, NULL
,
1751 &patterns
[i
].Position
, &valuesize
);
1753 if (res
== ERROR_SUCCESS
)
1755 patterns
[i
].Pattern
= bPatterns
+patterns_size
-patternsize
*2;
1756 valuesize
= patternsize
;
1757 res
= RegGetValueW(pattern_key
, NULL
, patternW
, RRF_RT_REG_BINARY
, NULL
,
1758 patterns
[i
].Pattern
, &valuesize
);
1761 if (res
== ERROR_SUCCESS
)
1763 patterns
[i
].Mask
= bPatterns
+patterns_size
-patternsize
;
1764 valuesize
= patternsize
;
1765 res
= RegGetValueW(pattern_key
, NULL
, maskW
, RRF_RT_REG_BINARY
, NULL
,
1766 patterns
[i
].Mask
, &valuesize
);
1770 RegCloseKey(pattern_key
);
1772 if (res
!= ERROR_SUCCESS
)
1774 hr
= HRESULT_FROM_WIN32(res
);
1780 RegCloseKey(guid_key
);
1785 *count
= pattern_count
;
1786 *actual_length
= patterns_size
;
1787 if (patterns
&& length
< patterns_size
)
1788 hr
= WINCODEC_ERR_INSUFFICIENTBUFFER
;
1794 static HRESULT WINAPI
MetadataReaderInfo_MatchesPattern(IWICMetadataReaderInfo
*iface
,
1795 REFGUID container
, IStream
*stream
, BOOL
*matches
)
1798 WICMetadataPattern
*patterns
;
1799 UINT pattern_count
=0, patterns_size
=0;
1804 LARGE_INTEGER seekpos
;
1807 TRACE("(%p,%s,%p,%p)\n", iface
, debugstr_guid(container
), stream
, matches
);
1809 hr
= MetadataReaderInfo_GetPatterns(iface
, container
, 0, NULL
, &pattern_count
, &patterns_size
);
1810 if (FAILED(hr
)) return hr
;
1812 patterns
= HeapAlloc(GetProcessHeap(), 0, patterns_size
);
1813 if (!patterns
) return E_OUTOFMEMORY
;
1815 hr
= MetadataReaderInfo_GetPatterns(iface
, container
, patterns_size
, patterns
, &pattern_count
, &patterns_size
);
1816 if (FAILED(hr
)) goto end
;
1818 for (i
=0; i
<pattern_count
; i
++)
1820 if (datasize
< patterns
[i
].Length
)
1822 HeapFree(GetProcessHeap(), 0, data
);
1823 datasize
= patterns
[i
].Length
;
1824 data
= HeapAlloc(GetProcessHeap(), 0, patterns
[i
].Length
);
1832 seekpos
.QuadPart
= patterns
[i
].Position
.QuadPart
;
1833 hr
= IStream_Seek(stream
, seekpos
, STREAM_SEEK_SET
, NULL
);
1834 if (FAILED(hr
)) break;
1836 hr
= IStream_Read(stream
, data
, patterns
[i
].Length
, &bytesread
);
1837 if (hr
== S_FALSE
|| (hr
== S_OK
&& bytesread
!= patterns
[i
].Length
)) /* past end of stream */
1839 if (FAILED(hr
)) break;
1841 for (pos
=0; pos
<patterns
[i
].Length
; pos
++)
1843 if ((data
[pos
] & patterns
[i
].Mask
[pos
]) != patterns
[i
].Pattern
[pos
])
1846 if (pos
== patterns
[i
].Length
) /* matches pattern */
1854 if (i
== pattern_count
) /* does not match any pattern */
1861 HeapFree(GetProcessHeap(), 0, patterns
);
1862 HeapFree(GetProcessHeap(), 0, data
);
1867 static HRESULT WINAPI
MetadataReaderInfo_CreateInstance(IWICMetadataReaderInfo
*iface
,
1868 IWICMetadataReader
**reader
)
1870 MetadataReaderInfo
*This
= impl_from_IWICMetadataReaderInfo(iface
);
1872 TRACE("(%p,%p)\n", iface
, reader
);
1874 return create_instance(&This
->clsid
, &IID_IWICMetadataReader
, (void **)reader
);
1877 static const IWICMetadataReaderInfoVtbl MetadataReaderInfo_Vtbl
= {
1878 MetadataReaderInfo_QueryInterface
,
1879 MetadataReaderInfo_AddRef
,
1880 MetadataReaderInfo_Release
,
1881 MetadataReaderInfo_GetComponentType
,
1882 MetadataReaderInfo_GetCLSID
,
1883 MetadataReaderInfo_GetSigningStatus
,
1884 MetadataReaderInfo_GetAuthor
,
1885 MetadataReaderInfo_GetVendorGUID
,
1886 MetadataReaderInfo_GetVersion
,
1887 MetadataReaderInfo_GetSpecVersion
,
1888 MetadataReaderInfo_GetFriendlyName
,
1889 MetadataReaderInfo_GetMetadataFormat
,
1890 MetadataReaderInfo_GetContainerFormats
,
1891 MetadataReaderInfo_GetDeviceManufacturer
,
1892 MetadataReaderInfo_GetDeviceModels
,
1893 MetadataReaderInfo_DoesRequireFullStream
,
1894 MetadataReaderInfo_DoesSupportPadding
,
1895 MetadataReaderInfo_DoesRequireFixedSize
,
1896 MetadataReaderInfo_GetPatterns
,
1897 MetadataReaderInfo_MatchesPattern
,
1898 MetadataReaderInfo_CreateInstance
1901 static HRESULT
MetadataReaderInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**info
)
1903 MetadataReaderInfo
*This
;
1905 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
1908 RegCloseKey(classkey
);
1909 return E_OUTOFMEMORY
;
1912 This
->IWICMetadataReaderInfo_iface
.lpVtbl
= &MetadataReaderInfo_Vtbl
;
1914 This
->classkey
= classkey
;
1915 This
->clsid
= *clsid
;
1917 *info
= (IWICComponentInfo
*)&This
->IWICMetadataReaderInfo_iface
;
1921 static const WCHAR clsid_keyname
[] = {'C','L','S','I','D',0};
1922 static const WCHAR instance_keyname
[] = {'I','n','s','t','a','n','c','e',0};
1925 WICComponentType type
;
1927 HRESULT (*constructor
)(HKEY
,REFCLSID
,IWICComponentInfo
**);
1930 static const struct category categories
[] = {
1931 {WICDecoder
, &CATID_WICBitmapDecoders
, BitmapDecoderInfo_Constructor
},
1932 {WICEncoder
, &CATID_WICBitmapEncoders
, BitmapEncoderInfo_Constructor
},
1933 {WICPixelFormatConverter
, &CATID_WICFormatConverters
, FormatConverterInfo_Constructor
},
1934 {WICPixelFormat
, &CATID_WICPixelFormats
, PixelFormatInfo_Constructor
},
1935 {WICMetadataReader
, &CATID_WICMetadataReader
, MetadataReaderInfo_Constructor
},
1939 HRESULT
CreateComponentInfo(REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
1945 WCHAR guidstring
[39];
1947 const struct category
*category
;
1951 res
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, clsid_keyname
, 0, KEY_READ
, &clsidkey
);
1952 if (res
!= ERROR_SUCCESS
)
1953 return HRESULT_FROM_WIN32(res
);
1955 for (category
=categories
; category
->type
; category
++)
1957 StringFromGUID2(category
->catid
, guidstring
, 39);
1958 res
= RegOpenKeyExW(clsidkey
, guidstring
, 0, KEY_READ
, &catidkey
);
1959 if (res
== ERROR_SUCCESS
)
1961 res
= RegOpenKeyExW(catidkey
, instance_keyname
, 0, KEY_READ
, &instancekey
);
1962 if (res
== ERROR_SUCCESS
)
1964 StringFromGUID2(clsid
, guidstring
, 39);
1965 res
= RegOpenKeyExW(instancekey
, guidstring
, 0, KEY_READ
, &classkey
);
1966 if (res
== ERROR_SUCCESS
)
1968 RegCloseKey(classkey
);
1971 RegCloseKey(instancekey
);
1973 RegCloseKey(catidkey
);
1980 res
= RegOpenKeyExW(clsidkey
, guidstring
, 0, KEY_READ
, &classkey
);
1981 if (res
== ERROR_SUCCESS
)
1982 hr
= category
->constructor(classkey
, clsid
, ppIInfo
);
1984 hr
= HRESULT_FROM_WIN32(res
);
1988 FIXME("%s is not supported\n", wine_dbgstr_guid(clsid
));
1992 RegCloseKey(clsidkey
);
1998 IEnumUnknown IEnumUnknown_iface
;
2000 struct list objects
;
2001 struct list
*cursor
;
2002 CRITICAL_SECTION lock
; /* Must be held when reading or writing cursor */
2005 static inline ComponentEnum
*impl_from_IEnumUnknown(IEnumUnknown
*iface
)
2007 return CONTAINING_RECORD(iface
, ComponentEnum
, IEnumUnknown_iface
);
2013 } ComponentEnumItem
;
2015 static const IEnumUnknownVtbl ComponentEnumVtbl
;
2017 static HRESULT WINAPI
ComponentEnum_QueryInterface(IEnumUnknown
*iface
, REFIID iid
,
2020 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
2021 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
2023 if (!ppv
) return E_INVALIDARG
;
2025 if (IsEqualIID(&IID_IUnknown
, iid
) ||
2026 IsEqualIID(&IID_IEnumUnknown
, iid
))
2028 *ppv
= &This
->IEnumUnknown_iface
;
2033 return E_NOINTERFACE
;
2036 IUnknown_AddRef((IUnknown
*)*ppv
);
2040 static ULONG WINAPI
ComponentEnum_AddRef(IEnumUnknown
*iface
)
2042 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
2043 ULONG ref
= InterlockedIncrement(&This
->ref
);
2045 TRACE("(%p) refcount=%u\n", iface
, ref
);
2050 static ULONG WINAPI
ComponentEnum_Release(IEnumUnknown
*iface
)
2052 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
2053 ULONG ref
= InterlockedDecrement(&This
->ref
);
2054 ComponentEnumItem
*cursor
, *cursor2
;
2056 TRACE("(%p) refcount=%u\n", iface
, ref
);
2060 LIST_FOR_EACH_ENTRY_SAFE(cursor
, cursor2
, &This
->objects
, ComponentEnumItem
, entry
)
2062 IUnknown_Release(cursor
->unk
);
2063 list_remove(&cursor
->entry
);
2064 HeapFree(GetProcessHeap(), 0, cursor
);
2066 This
->lock
.DebugInfo
->Spare
[0] = 0;
2067 DeleteCriticalSection(&This
->lock
);
2068 HeapFree(GetProcessHeap(), 0, This
);
2074 static HRESULT WINAPI
ComponentEnum_Next(IEnumUnknown
*iface
, ULONG celt
,
2075 IUnknown
**rgelt
, ULONG
*pceltFetched
)
2077 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
2078 ULONG num_fetched
=0;
2079 ComponentEnumItem
*item
;
2082 TRACE("(%p,%u,%p,%p)\n", iface
, celt
, rgelt
, pceltFetched
);
2084 EnterCriticalSection(&This
->lock
);
2085 while (num_fetched
<celt
)
2092 item
= LIST_ENTRY(This
->cursor
, ComponentEnumItem
, entry
);
2093 IUnknown_AddRef(item
->unk
);
2094 rgelt
[num_fetched
] = item
->unk
;
2096 This
->cursor
= list_next(&This
->objects
, This
->cursor
);
2098 LeaveCriticalSection(&This
->lock
);
2100 *pceltFetched
= num_fetched
;
2104 static HRESULT WINAPI
ComponentEnum_Skip(IEnumUnknown
*iface
, ULONG celt
)
2106 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
2110 TRACE("(%p,%u)\n", iface
, celt
);
2112 EnterCriticalSection(&This
->lock
);
2113 for (i
=0; i
<celt
; i
++)
2120 This
->cursor
= list_next(&This
->objects
, This
->cursor
);
2122 LeaveCriticalSection(&This
->lock
);
2126 static HRESULT WINAPI
ComponentEnum_Reset(IEnumUnknown
*iface
)
2128 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
2130 TRACE("(%p)\n", iface
);
2132 EnterCriticalSection(&This
->lock
);
2133 This
->cursor
= list_head(&This
->objects
);
2134 LeaveCriticalSection(&This
->lock
);
2138 static HRESULT WINAPI
ComponentEnum_Clone(IEnumUnknown
*iface
, IEnumUnknown
**ppenum
)
2140 ComponentEnum
*This
= impl_from_IEnumUnknown(iface
);
2141 ComponentEnum
*new_enum
;
2142 ComponentEnumItem
*old_item
, *new_item
;
2144 struct list
*old_cursor
;
2146 new_enum
= HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnum
));
2150 return E_OUTOFMEMORY
;
2153 new_enum
->IEnumUnknown_iface
.lpVtbl
= &ComponentEnumVtbl
;
2155 new_enum
->cursor
= NULL
;
2156 list_init(&new_enum
->objects
);
2157 InitializeCriticalSection(&new_enum
->lock
);
2158 new_enum
->lock
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": ComponentEnum.lock");
2160 EnterCriticalSection(&This
->lock
);
2161 old_cursor
= This
->cursor
;
2162 LeaveCriticalSection(&This
->lock
);
2164 LIST_FOR_EACH_ENTRY(old_item
, &This
->objects
, ComponentEnumItem
, entry
)
2166 new_item
= HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnumItem
));
2169 ret
= E_OUTOFMEMORY
;
2172 new_item
->unk
= old_item
->unk
;
2173 list_add_tail(&new_enum
->objects
, &new_item
->entry
);
2174 IUnknown_AddRef(new_item
->unk
);
2175 if (&old_item
->entry
== old_cursor
) new_enum
->cursor
= &new_item
->entry
;
2180 IEnumUnknown_Release(&new_enum
->IEnumUnknown_iface
);
2184 *ppenum
= &new_enum
->IEnumUnknown_iface
;
2189 static const IEnumUnknownVtbl ComponentEnumVtbl
= {
2190 ComponentEnum_QueryInterface
,
2191 ComponentEnum_AddRef
,
2192 ComponentEnum_Release
,
2195 ComponentEnum_Reset
,
2199 HRESULT
CreateComponentEnumerator(DWORD componentTypes
, DWORD options
, IEnumUnknown
**ppIEnumUnknown
)
2201 ComponentEnum
*This
;
2202 ComponentEnumItem
*item
;
2203 const struct category
*category
;
2204 HKEY clsidkey
, catidkey
, instancekey
;
2205 WCHAR guidstring
[39];
2211 if (options
) FIXME("ignoring flags %x\n", options
);
2213 res
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, clsid_keyname
, 0, KEY_READ
, &clsidkey
);
2214 if (res
!= ERROR_SUCCESS
)
2215 return HRESULT_FROM_WIN32(res
);
2217 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnum
));
2220 RegCloseKey(clsidkey
);
2221 return E_OUTOFMEMORY
;
2224 This
->IEnumUnknown_iface
.lpVtbl
= &ComponentEnumVtbl
;
2226 list_init(&This
->objects
);
2227 InitializeCriticalSection(&This
->lock
);
2228 This
->lock
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": ComponentEnum.lock");
2230 for (category
=categories
; category
->type
&& hr
== S_OK
; category
++)
2232 if ((category
->type
& componentTypes
) == 0) continue;
2233 StringFromGUID2(category
->catid
, guidstring
, 39);
2234 res
= RegOpenKeyExW(clsidkey
, guidstring
, 0, KEY_READ
, &catidkey
);
2235 if (res
== ERROR_SUCCESS
)
2237 res
= RegOpenKeyExW(catidkey
, instance_keyname
, 0, KEY_READ
, &instancekey
);
2238 if (res
== ERROR_SUCCESS
)
2243 DWORD guidstring_size
= 39;
2244 res
= RegEnumKeyExW(instancekey
, i
, guidstring
, &guidstring_size
, NULL
, NULL
, NULL
, NULL
);
2245 if (res
!= ERROR_SUCCESS
) break;
2247 item
= HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnumItem
));
2248 if (!item
) { hr
= E_OUTOFMEMORY
; break; }
2250 hr
= CLSIDFromString(guidstring
, &clsid
);
2253 hr
= CreateComponentInfo(&clsid
, (IWICComponentInfo
**)&item
->unk
);
2255 list_add_tail(&This
->objects
, &item
->entry
);
2260 HeapFree(GetProcessHeap(), 0, item
);
2264 RegCloseKey(instancekey
);
2266 RegCloseKey(catidkey
);
2268 if (res
!= ERROR_SUCCESS
&& res
!= ERROR_NO_MORE_ITEMS
)
2269 hr
= HRESULT_FROM_WIN32(res
);
2271 RegCloseKey(clsidkey
);
2275 IEnumUnknown_Reset(&This
->IEnumUnknown_iface
);
2276 *ppIEnumUnknown
= &This
->IEnumUnknown_iface
;
2280 *ppIEnumUnknown
= NULL
;
2281 IEnumUnknown_Release(&This
->IEnumUnknown_iface
);
2287 static BOOL
is_1bpp_format(const WICPixelFormatGUID
*format
)
2289 return IsEqualGUID(format
, &GUID_WICPixelFormatBlackWhite
) ||
2290 IsEqualGUID(format
, &GUID_WICPixelFormat1bppIndexed
);
2293 HRESULT WINAPI
WICConvertBitmapSource(REFWICPixelFormatGUID dstFormat
, IWICBitmapSource
*pISrc
, IWICBitmapSource
**ppIDst
)
2296 IEnumUnknown
*enumconverters
;
2297 IUnknown
*unkconverterinfo
;
2298 IWICFormatConverterInfo
*converterinfo
=NULL
;
2299 IWICFormatConverter
*converter
=NULL
;
2301 WCHAR srcformatstr
[39], dstformatstr
[39];
2305 TRACE("%s,%p,%p\n", debugstr_guid(dstFormat
), pISrc
, ppIDst
);
2307 res
= IWICBitmapSource_GetPixelFormat(pISrc
, &srcFormat
);
2308 if (FAILED(res
)) return res
;
2310 if (IsEqualGUID(&srcFormat
, dstFormat
) || (is_1bpp_format(&srcFormat
) && is_1bpp_format(dstFormat
)))
2312 IWICBitmapSource_AddRef(pISrc
);
2317 StringFromGUID2(&srcFormat
, srcformatstr
, 39);
2318 StringFromGUID2(dstFormat
, dstformatstr
, 39);
2320 res
= CreateComponentEnumerator(WICPixelFormatConverter
, 0, &enumconverters
);
2321 if (FAILED(res
)) return res
;
2325 res
= IEnumUnknown_Next(enumconverters
, 1, &unkconverterinfo
, &num_fetched
);
2329 res
= IUnknown_QueryInterface(unkconverterinfo
, &IID_IWICFormatConverterInfo
, (void**)&converterinfo
);
2333 canconvert
= ConverterSupportsFormat(converterinfo
, srcformatstr
);
2336 canconvert
= ConverterSupportsFormat(converterinfo
, dstformatstr
);
2340 res
= IWICFormatConverterInfo_CreateInstance(converterinfo
, &converter
);
2343 res
= IWICFormatConverter_CanConvert(converter
, &srcFormat
, dstFormat
, &canconvert
);
2345 if (SUCCEEDED(res
) && canconvert
)
2346 res
= IWICFormatConverter_Initialize(converter
, pISrc
, dstFormat
, WICBitmapDitherTypeNone
,
2347 NULL
, 0.0, WICBitmapPaletteTypeMedianCut
);
2349 if (FAILED(res
) || !canconvert
)
2353 IWICFormatConverter_Release(converter
);
2359 IWICFormatConverterInfo_Release(converterinfo
);
2362 IUnknown_Release(unkconverterinfo
);
2368 IEnumUnknown_Release(enumconverters
);
2372 res
= IWICFormatConverter_QueryInterface(converter
, &IID_IWICBitmapSource
, (void **)ppIDst
);
2373 IWICFormatConverter_Release(converter
);
2378 FIXME("cannot convert %s to %s\n", debugstr_guid(&srcFormat
), debugstr_guid(dstFormat
));
2380 return WINCODEC_ERR_COMPONENTNOTFOUND
;