2 * Copyright 2009 Vincent Povirk for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * 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 WCHAR
const mimetypes_valuename
[] = {'M','i','m','e','T','y','p','e','s',0};
40 static WCHAR
const pixelformats_keyname
[] = {'P','i','x','e','l','F','o','r','m','a','t','s',0};
42 static HRESULT
ComponentInfo_GetStringValue(HKEY classkey
, LPCWSTR value
,
43 UINT buffer_size
, WCHAR
*buffer
, UINT
*actual_size
)
46 DWORD cbdata
=buffer_size
* sizeof(WCHAR
);
51 ret
= RegGetValueW(classkey
, NULL
, value
, RRF_RT_REG_SZ
|RRF_NOEXPAND
, NULL
,
54 if (ret
== 0 || ret
== ERROR_MORE_DATA
)
55 *actual_size
= cbdata
/sizeof(WCHAR
);
57 if (!buffer
&& buffer_size
!= 0)
58 /* Yes, native returns the correct size in this case. */
61 if (ret
== ERROR_MORE_DATA
)
62 return WINCODEC_ERR_INSUFFICIENTBUFFER
;
64 return HRESULT_FROM_WIN32(ret
);
68 const IWICBitmapDecoderInfoVtbl
*lpIWICBitmapDecoderInfoVtbl
;
74 static HRESULT WINAPI
BitmapDecoderInfo_QueryInterface(IWICBitmapDecoderInfo
*iface
, REFIID iid
,
77 BitmapDecoderInfo
*This
= (BitmapDecoderInfo
*)iface
;
78 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
80 if (!ppv
) return E_INVALIDARG
;
82 if (IsEqualIID(&IID_IUnknown
, iid
) ||
83 IsEqualIID(&IID_IWICComponentInfo
, iid
) ||
84 IsEqualIID(&IID_IWICBitmapCodecInfo
, iid
) ||
85 IsEqualIID(&IID_IWICBitmapDecoderInfo
,iid
))
95 IUnknown_AddRef((IUnknown
*)*ppv
);
99 static ULONG WINAPI
BitmapDecoderInfo_AddRef(IWICBitmapDecoderInfo
*iface
)
101 BitmapDecoderInfo
*This
= (BitmapDecoderInfo
*)iface
;
102 ULONG ref
= InterlockedIncrement(&This
->ref
);
104 TRACE("(%p) refcount=%u\n", iface
, ref
);
109 static ULONG WINAPI
BitmapDecoderInfo_Release(IWICBitmapDecoderInfo
*iface
)
111 BitmapDecoderInfo
*This
= (BitmapDecoderInfo
*)iface
;
112 ULONG ref
= InterlockedDecrement(&This
->ref
);
114 TRACE("(%p) refcount=%u\n", iface
, ref
);
118 RegCloseKey(This
->classkey
);
119 HeapFree(GetProcessHeap(), 0, This
);
125 static HRESULT WINAPI
BitmapDecoderInfo_GetComponentType(IWICBitmapDecoderInfo
*iface
,
126 WICComponentType
*pType
)
128 TRACE("(%p,%p)\n", iface
, pType
);
133 static HRESULT WINAPI
BitmapDecoderInfo_GetCLSID(IWICBitmapDecoderInfo
*iface
, CLSID
*pclsid
)
135 BitmapDecoderInfo
*This
= (BitmapDecoderInfo
*)iface
;
136 TRACE("(%p,%p)\n", iface
, pclsid
);
141 memcpy(pclsid
, &This
->clsid
, sizeof(CLSID
));
146 static HRESULT WINAPI
BitmapDecoderInfo_GetSigningStatus(IWICBitmapDecoderInfo
*iface
, DWORD
*pStatus
)
148 FIXME("(%p,%p): stub\n", iface
, pStatus
);
152 static HRESULT WINAPI
BitmapDecoderInfo_GetAuthor(IWICBitmapDecoderInfo
*iface
, UINT cchAuthor
,
153 WCHAR
*wzAuthor
, UINT
*pcchActual
)
155 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchAuthor
, wzAuthor
, pcchActual
);
159 static HRESULT WINAPI
BitmapDecoderInfo_GetVendorGUID(IWICBitmapDecoderInfo
*iface
, GUID
*pguidVendor
)
161 FIXME("(%p,%p): stub\n", iface
, pguidVendor
);
165 static HRESULT WINAPI
BitmapDecoderInfo_GetVersion(IWICBitmapDecoderInfo
*iface
, UINT cchVersion
,
166 WCHAR
*wzVersion
, UINT
*pcchActual
)
168 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchVersion
, wzVersion
, pcchActual
);
172 static HRESULT WINAPI
BitmapDecoderInfo_GetSpecVersion(IWICBitmapDecoderInfo
*iface
, UINT cchSpecVersion
,
173 WCHAR
*wzSpecVersion
, UINT
*pcchActual
)
175 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchSpecVersion
, wzSpecVersion
, pcchActual
);
179 static HRESULT WINAPI
BitmapDecoderInfo_GetFriendlyName(IWICBitmapDecoderInfo
*iface
, UINT cchFriendlyName
,
180 WCHAR
*wzFriendlyName
, UINT
*pcchActual
)
182 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchFriendlyName
, wzFriendlyName
, pcchActual
);
186 static HRESULT WINAPI
BitmapDecoderInfo_GetContainerFormat(IWICBitmapDecoderInfo
*iface
,
187 GUID
*pguidContainerFormat
)
189 FIXME("(%p,%p): stub\n", iface
, pguidContainerFormat
);
193 static HRESULT WINAPI
BitmapDecoderInfo_GetPixelFormats(IWICBitmapDecoderInfo
*iface
,
194 UINT cFormats
, GUID
*pguidPixelFormats
, UINT
*pcActual
)
196 FIXME("(%p,%u,%p,%p): stub\n", iface
, cFormats
, pguidPixelFormats
, pcActual
);
200 static HRESULT WINAPI
BitmapDecoderInfo_GetColorManagementVersion(IWICBitmapDecoderInfo
*iface
,
201 UINT cchColorManagementVersion
, WCHAR
*wzColorManagementVersion
, UINT
*pcchActual
)
203 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchColorManagementVersion
, wzColorManagementVersion
, pcchActual
);
207 static HRESULT WINAPI
BitmapDecoderInfo_GetDeviceManufacturer(IWICBitmapDecoderInfo
*iface
,
208 UINT cchDeviceManufacturer
, WCHAR
*wzDeviceManufacturer
, UINT
*pcchActual
)
210 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchDeviceManufacturer
, wzDeviceManufacturer
, pcchActual
);
214 static HRESULT WINAPI
BitmapDecoderInfo_GetDeviceModels(IWICBitmapDecoderInfo
*iface
,
215 UINT cchDeviceModels
, WCHAR
*wzDeviceModels
, UINT
*pcchActual
)
217 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchDeviceModels
, wzDeviceModels
, pcchActual
);
221 static HRESULT WINAPI
BitmapDecoderInfo_GetMimeTypes(IWICBitmapDecoderInfo
*iface
,
222 UINT cchMimeTypes
, WCHAR
*wzMimeTypes
, UINT
*pcchActual
)
224 BitmapDecoderInfo
*This
= (BitmapDecoderInfo
*)iface
;
226 TRACE("(%p,%u,%p,%p)\n", iface
, cchMimeTypes
, wzMimeTypes
, pcchActual
);
228 return ComponentInfo_GetStringValue(This
->classkey
, mimetypes_valuename
,
229 cchMimeTypes
, wzMimeTypes
, pcchActual
);
232 static HRESULT WINAPI
BitmapDecoderInfo_GetFileExtensions(IWICBitmapDecoderInfo
*iface
,
233 UINT cchFileExtensions
, WCHAR
*wzFileExtensions
, UINT
*pcchActual
)
235 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchFileExtensions
, wzFileExtensions
, pcchActual
);
239 static HRESULT WINAPI
BitmapDecoderInfo_DoesSupportAnimation(IWICBitmapDecoderInfo
*iface
,
240 BOOL
*pfSupportAnimation
)
242 FIXME("(%p,%p): stub\n", iface
, pfSupportAnimation
);
246 static HRESULT WINAPI
BitmapDecoderInfo_DoesSupportChromaKey(IWICBitmapDecoderInfo
*iface
,
247 BOOL
*pfSupportChromaKey
)
249 FIXME("(%p,%p): stub\n", iface
, pfSupportChromaKey
);
253 static HRESULT WINAPI
BitmapDecoderInfo_DoesSupportLossless(IWICBitmapDecoderInfo
*iface
,
254 BOOL
*pfSupportLossless
)
256 FIXME("(%p,%p): stub\n", iface
, pfSupportLossless
);
260 static HRESULT WINAPI
BitmapDecoderInfo_DoesSupportMultiframe(IWICBitmapDecoderInfo
*iface
,
261 BOOL
*pfSupportMultiframe
)
263 FIXME("(%p,%p): stub\n", iface
, pfSupportMultiframe
);
267 static HRESULT WINAPI
BitmapDecoderInfo_MatchesMimeType(IWICBitmapDecoderInfo
*iface
,
268 LPCWSTR wzMimeType
, BOOL
*pfMatches
)
270 FIXME("(%p,%s,%p): stub\n", iface
, debugstr_w(wzMimeType
), pfMatches
);
274 static HRESULT WINAPI
BitmapDecoderInfo_GetPatterns(IWICBitmapDecoderInfo
*iface
,
275 UINT cbSizePatterns
, WICBitmapPattern
*pPatterns
, UINT
*pcPatterns
, UINT
*pcbPatternsActual
)
277 BitmapDecoderInfo
*This
= (BitmapDecoderInfo
*)iface
;
278 UINT pattern_count
=0, patterns_size
=0;
279 WCHAR subkeyname
[11];
281 HKEY patternskey
, patternkey
;
282 static const WCHAR uintformatW
[] = {'%','u',0};
283 static const WCHAR patternsW
[] = {'P','a','t','t','e','r','n','s',0};
284 static const WCHAR positionW
[] = {'P','o','s','i','t','i','o','n',0};
285 static const WCHAR lengthW
[] = {'L','e','n','g','t','h',0};
286 static const WCHAR patternW
[] = {'P','a','t','t','e','r','n',0};
287 static const WCHAR maskW
[] = {'M','a','s','k',0};
288 static const WCHAR endofstreamW
[] = {'E','n','d','O','f','S','t','r','e','a','m',0};
291 BYTE
*bPatterns
=(BYTE
*)pPatterns
;
292 DWORD length
, valuesize
;
294 TRACE("(%p,%i,%p,%p,%p)\n", iface
, cbSizePatterns
, pPatterns
, pcPatterns
, pcbPatternsActual
);
296 res
= RegOpenKeyExW(This
->classkey
, patternsW
, 0, KEY_READ
, &patternskey
);
297 if (res
!= ERROR_SUCCESS
) return HRESULT_FROM_WIN32(res
);
299 res
= RegQueryInfoKeyW(patternskey
, NULL
, NULL
, NULL
, &pattern_count
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
300 if (res
== ERROR_SUCCESS
)
302 patterns_size
= pattern_count
* sizeof(WICBitmapPattern
);
304 for (i
=0; i
<pattern_count
; i
++)
306 snprintfW(subkeyname
, 11, uintformatW
, i
);
307 res
= RegOpenKeyExW(patternskey
, subkeyname
, 0, KEY_READ
, &patternkey
);
308 if (res
== ERROR_SUCCESS
)
310 valuesize
= sizeof(ULONG
);
311 res
= RegGetValueW(patternkey
, NULL
, lengthW
, RRF_RT_DWORD
, NULL
,
312 &length
, &valuesize
);
313 patterns_size
+= length
*2;
315 if ((cbSizePatterns
>= patterns_size
) && (res
== ERROR_SUCCESS
))
317 pPatterns
[i
].Length
= length
;
319 pPatterns
[i
].EndOfStream
= 0;
320 valuesize
= sizeof(BOOL
);
321 RegGetValueW(patternkey
, NULL
, endofstreamW
, RRF_RT_DWORD
, NULL
,
322 &pPatterns
[i
].EndOfStream
, &valuesize
);
324 pPatterns
[i
].Position
.QuadPart
= 0;
325 valuesize
= sizeof(ULARGE_INTEGER
);
326 res
= RegGetValueW(patternkey
, NULL
, positionW
, RRF_RT_DWORD
|RRF_RT_QWORD
, NULL
,
327 &pPatterns
[i
].Position
, &valuesize
);
329 if (res
== ERROR_SUCCESS
)
331 pPatterns
[i
].Pattern
= bPatterns
+patterns_size
-length
*2;
333 res
= RegGetValueW(patternkey
, NULL
, patternW
, RRF_RT_REG_BINARY
, NULL
,
334 pPatterns
[i
].Pattern
, &valuesize
);
337 if (res
== ERROR_SUCCESS
)
339 pPatterns
[i
].Mask
= bPatterns
+patterns_size
-length
;
341 res
= RegGetValueW(patternkey
, NULL
, maskW
, RRF_RT_REG_BINARY
, NULL
,
342 pPatterns
[i
].Mask
, &valuesize
);
346 RegCloseKey(patternkey
);
348 if (res
!= ERROR_SUCCESS
)
350 hr
= HRESULT_FROM_WIN32(res
);
355 else hr
= HRESULT_FROM_WIN32(res
);
357 RegCloseKey(patternskey
);
361 *pcPatterns
= pattern_count
;
362 *pcbPatternsActual
= patterns_size
;
363 if (pPatterns
&& cbSizePatterns
< patterns_size
)
364 hr
= WINCODEC_ERR_INSUFFICIENTBUFFER
;
370 static HRESULT WINAPI
BitmapDecoderInfo_MatchesPattern(IWICBitmapDecoderInfo
*iface
,
371 IStream
*pIStream
, BOOL
*pfMatches
)
373 WICBitmapPattern
*patterns
;
374 UINT pattern_count
=0, patterns_size
=0;
380 LARGE_INTEGER seekpos
;
382 TRACE("(%p,%p,%p)\n", iface
, pIStream
, pfMatches
);
384 hr
= BitmapDecoderInfo_GetPatterns(iface
, 0, NULL
, &pattern_count
, &patterns_size
);
385 if (FAILED(hr
)) return hr
;
387 patterns
= HeapAlloc(GetProcessHeap(), 0, patterns_size
);
388 if (!patterns
) return E_OUTOFMEMORY
;
390 hr
= BitmapDecoderInfo_GetPatterns(iface
, patterns_size
, patterns
, &pattern_count
, &patterns_size
);
391 if (FAILED(hr
)) goto end
;
393 for (i
=0; i
<pattern_count
; i
++)
395 if (datasize
< patterns
[i
].Length
)
397 HeapFree(GetProcessHeap(), 0, data
);
398 datasize
= patterns
[i
].Length
;
399 data
= HeapAlloc(GetProcessHeap(), 0, patterns
[i
].Length
);
407 if (patterns
[i
].EndOfStream
)
408 seekpos
.QuadPart
= -patterns
[i
].Position
.QuadPart
;
410 seekpos
.QuadPart
= patterns
[i
].Position
.QuadPart
;
411 hr
= IStream_Seek(pIStream
, seekpos
, patterns
[i
].EndOfStream
? STREAM_SEEK_END
: STREAM_SEEK_SET
, NULL
);
412 if (hr
== STG_E_INVALIDFUNCTION
) continue; /* before start of stream */
413 if (FAILED(hr
)) break;
415 hr
= IStream_Read(pIStream
, data
, patterns
[i
].Length
, &bytesread
);
416 if (hr
== S_FALSE
|| (hr
== S_OK
&& bytesread
!= patterns
[i
].Length
)) /* past end of stream */
418 if (FAILED(hr
)) break;
420 for (pos
=0; pos
<patterns
[i
].Length
; pos
++)
422 if ((data
[pos
] & patterns
[i
].Mask
[pos
]) != patterns
[i
].Pattern
[pos
])
425 if (pos
== patterns
[i
].Length
) /* matches pattern */
433 if (i
== pattern_count
) /* does not match any pattern */
440 HeapFree(GetProcessHeap(), 0, patterns
);
441 HeapFree(GetProcessHeap(), 0, data
);
446 static HRESULT WINAPI
BitmapDecoderInfo_CreateInstance(IWICBitmapDecoderInfo
*iface
,
447 IWICBitmapDecoder
**ppIBitmapDecoder
)
449 BitmapDecoderInfo
*This
= (BitmapDecoderInfo
*)iface
;
451 TRACE("(%p,%p)\n", iface
, ppIBitmapDecoder
);
453 return CoCreateInstance(&This
->clsid
, NULL
, CLSCTX_INPROC_SERVER
,
454 &IID_IWICBitmapDecoder
, (void**)ppIBitmapDecoder
);
457 static const IWICBitmapDecoderInfoVtbl BitmapDecoderInfo_Vtbl
= {
458 BitmapDecoderInfo_QueryInterface
,
459 BitmapDecoderInfo_AddRef
,
460 BitmapDecoderInfo_Release
,
461 BitmapDecoderInfo_GetComponentType
,
462 BitmapDecoderInfo_GetCLSID
,
463 BitmapDecoderInfo_GetSigningStatus
,
464 BitmapDecoderInfo_GetAuthor
,
465 BitmapDecoderInfo_GetVendorGUID
,
466 BitmapDecoderInfo_GetVersion
,
467 BitmapDecoderInfo_GetSpecVersion
,
468 BitmapDecoderInfo_GetFriendlyName
,
469 BitmapDecoderInfo_GetContainerFormat
,
470 BitmapDecoderInfo_GetPixelFormats
,
471 BitmapDecoderInfo_GetColorManagementVersion
,
472 BitmapDecoderInfo_GetDeviceManufacturer
,
473 BitmapDecoderInfo_GetDeviceModels
,
474 BitmapDecoderInfo_GetMimeTypes
,
475 BitmapDecoderInfo_GetFileExtensions
,
476 BitmapDecoderInfo_DoesSupportAnimation
,
477 BitmapDecoderInfo_DoesSupportChromaKey
,
478 BitmapDecoderInfo_DoesSupportLossless
,
479 BitmapDecoderInfo_DoesSupportMultiframe
,
480 BitmapDecoderInfo_MatchesMimeType
,
481 BitmapDecoderInfo_GetPatterns
,
482 BitmapDecoderInfo_MatchesPattern
,
483 BitmapDecoderInfo_CreateInstance
486 static HRESULT
BitmapDecoderInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
488 BitmapDecoderInfo
*This
;
490 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapDecoderInfo
));
493 RegCloseKey(classkey
);
494 return E_OUTOFMEMORY
;
497 This
->lpIWICBitmapDecoderInfoVtbl
= &BitmapDecoderInfo_Vtbl
;
499 This
->classkey
= classkey
;
500 memcpy(&This
->clsid
, clsid
, sizeof(CLSID
));
502 *ppIInfo
= (IWICComponentInfo
*)This
;
507 const IWICBitmapEncoderInfoVtbl
*lpIWICBitmapEncoderInfoVtbl
;
513 static HRESULT WINAPI
BitmapEncoderInfo_QueryInterface(IWICBitmapEncoderInfo
*iface
, REFIID iid
,
516 BitmapEncoderInfo
*This
= (BitmapEncoderInfo
*)iface
;
517 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
519 if (!ppv
) return E_INVALIDARG
;
521 if (IsEqualIID(&IID_IUnknown
, iid
) ||
522 IsEqualIID(&IID_IWICComponentInfo
, iid
) ||
523 IsEqualIID(&IID_IWICBitmapCodecInfo
, iid
) ||
524 IsEqualIID(&IID_IWICBitmapEncoderInfo
,iid
))
531 return E_NOINTERFACE
;
534 IUnknown_AddRef((IUnknown
*)*ppv
);
538 static ULONG WINAPI
BitmapEncoderInfo_AddRef(IWICBitmapEncoderInfo
*iface
)
540 BitmapEncoderInfo
*This
= (BitmapEncoderInfo
*)iface
;
541 ULONG ref
= InterlockedIncrement(&This
->ref
);
543 TRACE("(%p) refcount=%u\n", iface
, ref
);
548 static ULONG WINAPI
BitmapEncoderInfo_Release(IWICBitmapEncoderInfo
*iface
)
550 BitmapEncoderInfo
*This
= (BitmapEncoderInfo
*)iface
;
551 ULONG ref
= InterlockedDecrement(&This
->ref
);
553 TRACE("(%p) refcount=%u\n", iface
, ref
);
557 RegCloseKey(This
->classkey
);
558 HeapFree(GetProcessHeap(), 0, This
);
564 static HRESULT WINAPI
BitmapEncoderInfo_GetComponentType(IWICBitmapEncoderInfo
*iface
,
565 WICComponentType
*pType
)
567 TRACE("(%p,%p)\n", iface
, pType
);
572 static HRESULT WINAPI
BitmapEncoderInfo_GetCLSID(IWICBitmapEncoderInfo
*iface
, CLSID
*pclsid
)
574 BitmapEncoderInfo
*This
= (BitmapEncoderInfo
*)iface
;
575 TRACE("(%p,%p)\n", iface
, pclsid
);
580 memcpy(pclsid
, &This
->clsid
, sizeof(CLSID
));
585 static HRESULT WINAPI
BitmapEncoderInfo_GetSigningStatus(IWICBitmapEncoderInfo
*iface
, DWORD
*pStatus
)
587 FIXME("(%p,%p): stub\n", iface
, pStatus
);
591 static HRESULT WINAPI
BitmapEncoderInfo_GetAuthor(IWICBitmapEncoderInfo
*iface
, UINT cchAuthor
,
592 WCHAR
*wzAuthor
, UINT
*pcchActual
)
594 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchAuthor
, wzAuthor
, pcchActual
);
598 static HRESULT WINAPI
BitmapEncoderInfo_GetVendorGUID(IWICBitmapEncoderInfo
*iface
, GUID
*pguidVendor
)
600 FIXME("(%p,%p): stub\n", iface
, pguidVendor
);
604 static HRESULT WINAPI
BitmapEncoderInfo_GetVersion(IWICBitmapEncoderInfo
*iface
, UINT cchVersion
,
605 WCHAR
*wzVersion
, UINT
*pcchActual
)
607 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchVersion
, wzVersion
, pcchActual
);
611 static HRESULT WINAPI
BitmapEncoderInfo_GetSpecVersion(IWICBitmapEncoderInfo
*iface
, UINT cchSpecVersion
,
612 WCHAR
*wzSpecVersion
, UINT
*pcchActual
)
614 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchSpecVersion
, wzSpecVersion
, pcchActual
);
618 static HRESULT WINAPI
BitmapEncoderInfo_GetFriendlyName(IWICBitmapEncoderInfo
*iface
, UINT cchFriendlyName
,
619 WCHAR
*wzFriendlyName
, UINT
*pcchActual
)
621 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchFriendlyName
, wzFriendlyName
, pcchActual
);
625 static HRESULT WINAPI
BitmapEncoderInfo_GetContainerFormat(IWICBitmapEncoderInfo
*iface
,
626 GUID
*pguidContainerFormat
)
628 FIXME("(%p,%p): stub\n", iface
, pguidContainerFormat
);
632 static HRESULT WINAPI
BitmapEncoderInfo_GetPixelFormats(IWICBitmapEncoderInfo
*iface
,
633 UINT cFormats
, GUID
*pguidPixelFormats
, UINT
*pcActual
)
635 FIXME("(%p,%u,%p,%p): stub\n", iface
, cFormats
, pguidPixelFormats
, pcActual
);
639 static HRESULT WINAPI
BitmapEncoderInfo_GetColorManagementVersion(IWICBitmapEncoderInfo
*iface
,
640 UINT cchColorManagementVersion
, WCHAR
*wzColorManagementVersion
, UINT
*pcchActual
)
642 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchColorManagementVersion
, wzColorManagementVersion
, pcchActual
);
646 static HRESULT WINAPI
BitmapEncoderInfo_GetDeviceManufacturer(IWICBitmapEncoderInfo
*iface
,
647 UINT cchDeviceManufacturer
, WCHAR
*wzDeviceManufacturer
, UINT
*pcchActual
)
649 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchDeviceManufacturer
, wzDeviceManufacturer
, pcchActual
);
653 static HRESULT WINAPI
BitmapEncoderInfo_GetDeviceModels(IWICBitmapEncoderInfo
*iface
,
654 UINT cchDeviceModels
, WCHAR
*wzDeviceModels
, UINT
*pcchActual
)
656 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchDeviceModels
, wzDeviceModels
, pcchActual
);
660 static HRESULT WINAPI
BitmapEncoderInfo_GetMimeTypes(IWICBitmapEncoderInfo
*iface
,
661 UINT cchMimeTypes
, WCHAR
*wzMimeTypes
, UINT
*pcchActual
)
663 BitmapEncoderInfo
*This
= (BitmapEncoderInfo
*)iface
;
665 TRACE("(%p,%u,%p,%p)\n", iface
, cchMimeTypes
, wzMimeTypes
, pcchActual
);
667 return ComponentInfo_GetStringValue(This
->classkey
, mimetypes_valuename
,
668 cchMimeTypes
, wzMimeTypes
, pcchActual
);
671 static HRESULT WINAPI
BitmapEncoderInfo_GetFileExtensions(IWICBitmapEncoderInfo
*iface
,
672 UINT cchFileExtensions
, WCHAR
*wzFileExtensions
, UINT
*pcchActual
)
674 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchFileExtensions
, wzFileExtensions
, pcchActual
);
678 static HRESULT WINAPI
BitmapEncoderInfo_DoesSupportAnimation(IWICBitmapEncoderInfo
*iface
,
679 BOOL
*pfSupportAnimation
)
681 FIXME("(%p,%p): stub\n", iface
, pfSupportAnimation
);
685 static HRESULT WINAPI
BitmapEncoderInfo_DoesSupportChromaKey(IWICBitmapEncoderInfo
*iface
,
686 BOOL
*pfSupportChromaKey
)
688 FIXME("(%p,%p): stub\n", iface
, pfSupportChromaKey
);
692 static HRESULT WINAPI
BitmapEncoderInfo_DoesSupportLossless(IWICBitmapEncoderInfo
*iface
,
693 BOOL
*pfSupportLossless
)
695 FIXME("(%p,%p): stub\n", iface
, pfSupportLossless
);
699 static HRESULT WINAPI
BitmapEncoderInfo_DoesSupportMultiframe(IWICBitmapEncoderInfo
*iface
,
700 BOOL
*pfSupportMultiframe
)
702 FIXME("(%p,%p): stub\n", iface
, pfSupportMultiframe
);
706 static HRESULT WINAPI
BitmapEncoderInfo_MatchesMimeType(IWICBitmapEncoderInfo
*iface
,
707 LPCWSTR wzMimeType
, BOOL
*pfMatches
)
709 FIXME("(%p,%s,%p): stub\n", iface
, debugstr_w(wzMimeType
), pfMatches
);
713 static HRESULT WINAPI
BitmapEncoderInfo_CreateInstance(IWICBitmapEncoderInfo
*iface
,
714 IWICBitmapEncoder
**ppIBitmapEncoder
)
716 BitmapEncoderInfo
*This
= (BitmapEncoderInfo
*)iface
;
718 TRACE("(%p,%p)\n", iface
, ppIBitmapEncoder
);
720 return CoCreateInstance(&This
->clsid
, NULL
, CLSCTX_INPROC_SERVER
,
721 &IID_IWICBitmapEncoder
, (void**)ppIBitmapEncoder
);
724 static const IWICBitmapEncoderInfoVtbl BitmapEncoderInfo_Vtbl
= {
725 BitmapEncoderInfo_QueryInterface
,
726 BitmapEncoderInfo_AddRef
,
727 BitmapEncoderInfo_Release
,
728 BitmapEncoderInfo_GetComponentType
,
729 BitmapEncoderInfo_GetCLSID
,
730 BitmapEncoderInfo_GetSigningStatus
,
731 BitmapEncoderInfo_GetAuthor
,
732 BitmapEncoderInfo_GetVendorGUID
,
733 BitmapEncoderInfo_GetVersion
,
734 BitmapEncoderInfo_GetSpecVersion
,
735 BitmapEncoderInfo_GetFriendlyName
,
736 BitmapEncoderInfo_GetContainerFormat
,
737 BitmapEncoderInfo_GetPixelFormats
,
738 BitmapEncoderInfo_GetColorManagementVersion
,
739 BitmapEncoderInfo_GetDeviceManufacturer
,
740 BitmapEncoderInfo_GetDeviceModels
,
741 BitmapEncoderInfo_GetMimeTypes
,
742 BitmapEncoderInfo_GetFileExtensions
,
743 BitmapEncoderInfo_DoesSupportAnimation
,
744 BitmapEncoderInfo_DoesSupportChromaKey
,
745 BitmapEncoderInfo_DoesSupportLossless
,
746 BitmapEncoderInfo_DoesSupportMultiframe
,
747 BitmapEncoderInfo_MatchesMimeType
,
748 BitmapEncoderInfo_CreateInstance
751 static HRESULT
BitmapEncoderInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
753 BitmapEncoderInfo
*This
;
755 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapEncoderInfo
));
758 RegCloseKey(classkey
);
759 return E_OUTOFMEMORY
;
762 This
->lpIWICBitmapEncoderInfoVtbl
= &BitmapEncoderInfo_Vtbl
;
764 This
->classkey
= classkey
;
765 memcpy(&This
->clsid
, clsid
, sizeof(CLSID
));
767 *ppIInfo
= (IWICComponentInfo
*)This
;
772 const IWICFormatConverterInfoVtbl
*lpIWICFormatConverterInfoVtbl
;
776 } FormatConverterInfo
;
778 static HRESULT WINAPI
FormatConverterInfo_QueryInterface(IWICFormatConverterInfo
*iface
, REFIID iid
,
781 FormatConverterInfo
*This
= (FormatConverterInfo
*)iface
;
782 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
784 if (!ppv
) return E_INVALIDARG
;
786 if (IsEqualIID(&IID_IUnknown
, iid
) ||
787 IsEqualIID(&IID_IWICComponentInfo
, iid
) ||
788 IsEqualIID(&IID_IWICFormatConverterInfo
,iid
))
795 return E_NOINTERFACE
;
798 IUnknown_AddRef((IUnknown
*)*ppv
);
802 static ULONG WINAPI
FormatConverterInfo_AddRef(IWICFormatConverterInfo
*iface
)
804 FormatConverterInfo
*This
= (FormatConverterInfo
*)iface
;
805 ULONG ref
= InterlockedIncrement(&This
->ref
);
807 TRACE("(%p) refcount=%u\n", iface
, ref
);
812 static ULONG WINAPI
FormatConverterInfo_Release(IWICFormatConverterInfo
*iface
)
814 FormatConverterInfo
*This
= (FormatConverterInfo
*)iface
;
815 ULONG ref
= InterlockedDecrement(&This
->ref
);
817 TRACE("(%p) refcount=%u\n", iface
, ref
);
821 RegCloseKey(This
->classkey
);
822 HeapFree(GetProcessHeap(), 0, This
);
828 static HRESULT WINAPI
FormatConverterInfo_GetComponentType(IWICFormatConverterInfo
*iface
,
829 WICComponentType
*pType
)
831 TRACE("(%p,%p)\n", iface
, pType
);
832 *pType
= WICPixelFormatConverter
;
836 static HRESULT WINAPI
FormatConverterInfo_GetCLSID(IWICFormatConverterInfo
*iface
, CLSID
*pclsid
)
838 FormatConverterInfo
*This
= (FormatConverterInfo
*)iface
;
839 TRACE("(%p,%p)\n", iface
, pclsid
);
844 memcpy(pclsid
, &This
->clsid
, sizeof(CLSID
));
849 static HRESULT WINAPI
FormatConverterInfo_GetSigningStatus(IWICFormatConverterInfo
*iface
, DWORD
*pStatus
)
851 FIXME("(%p,%p): stub\n", iface
, pStatus
);
855 static HRESULT WINAPI
FormatConverterInfo_GetAuthor(IWICFormatConverterInfo
*iface
, UINT cchAuthor
,
856 WCHAR
*wzAuthor
, UINT
*pcchActual
)
858 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchAuthor
, wzAuthor
, pcchActual
);
862 static HRESULT WINAPI
FormatConverterInfo_GetVendorGUID(IWICFormatConverterInfo
*iface
, GUID
*pguidVendor
)
864 FIXME("(%p,%p): stub\n", iface
, pguidVendor
);
868 static HRESULT WINAPI
FormatConverterInfo_GetVersion(IWICFormatConverterInfo
*iface
, UINT cchVersion
,
869 WCHAR
*wzVersion
, UINT
*pcchActual
)
871 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchVersion
, wzVersion
, pcchActual
);
875 static HRESULT WINAPI
FormatConverterInfo_GetSpecVersion(IWICFormatConverterInfo
*iface
, UINT cchSpecVersion
,
876 WCHAR
*wzSpecVersion
, UINT
*pcchActual
)
878 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchSpecVersion
, wzSpecVersion
, pcchActual
);
882 static HRESULT WINAPI
FormatConverterInfo_GetFriendlyName(IWICFormatConverterInfo
*iface
, UINT cchFriendlyName
,
883 WCHAR
*wzFriendlyName
, UINT
*pcchActual
)
885 FIXME("(%p,%u,%p,%p): stub\n", iface
, cchFriendlyName
, wzFriendlyName
, pcchActual
);
889 static HRESULT WINAPI
FormatConverterInfo_GetPixelFormats(IWICFormatConverterInfo
*iface
,
890 UINT cFormats
, GUID
*pguidPixelFormats
, UINT
*pcActual
)
892 FIXME("(%p,%u,%p,%p): stub\n", iface
, cFormats
, pguidPixelFormats
, pcActual
);
896 static HRESULT WINAPI
FormatConverterInfo_CreateInstance(IWICFormatConverterInfo
*iface
,
897 IWICFormatConverter
**ppIFormatConverter
)
899 FormatConverterInfo
*This
= (FormatConverterInfo
*)iface
;
901 TRACE("(%p,%p)\n", iface
, ppIFormatConverter
);
903 return CoCreateInstance(&This
->clsid
, NULL
, CLSCTX_INPROC_SERVER
,
904 &IID_IWICFormatConverter
, (void**)ppIFormatConverter
);
907 static BOOL
ConverterSupportsFormat(IWICFormatConverterInfo
*iface
, const WCHAR
*formatguid
)
910 FormatConverterInfo
*This
= (FormatConverterInfo
*)iface
;
911 HKEY formats_key
, guid_key
;
913 /* Avoid testing using IWICFormatConverter_GetPixelFormats because that
914 would be O(n). A registry test should do better. */
916 res
= RegOpenKeyExW(This
->classkey
, pixelformats_keyname
, 0, KEY_READ
, &formats_key
);
917 if (res
!= ERROR_SUCCESS
) return FALSE
;
919 res
= RegOpenKeyExW(formats_key
, formatguid
, 0, KEY_READ
, &guid_key
);
920 if (res
== ERROR_SUCCESS
) RegCloseKey(guid_key
);
922 RegCloseKey(formats_key
);
924 return (res
== ERROR_SUCCESS
);
927 static const IWICFormatConverterInfoVtbl FormatConverterInfo_Vtbl
= {
928 FormatConverterInfo_QueryInterface
,
929 FormatConverterInfo_AddRef
,
930 FormatConverterInfo_Release
,
931 FormatConverterInfo_GetComponentType
,
932 FormatConverterInfo_GetCLSID
,
933 FormatConverterInfo_GetSigningStatus
,
934 FormatConverterInfo_GetAuthor
,
935 FormatConverterInfo_GetVendorGUID
,
936 FormatConverterInfo_GetVersion
,
937 FormatConverterInfo_GetSpecVersion
,
938 FormatConverterInfo_GetFriendlyName
,
939 FormatConverterInfo_GetPixelFormats
,
940 FormatConverterInfo_CreateInstance
943 static HRESULT
FormatConverterInfo_Constructor(HKEY classkey
, REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
945 FormatConverterInfo
*This
;
947 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(FormatConverterInfo
));
950 RegCloseKey(classkey
);
951 return E_OUTOFMEMORY
;
954 This
->lpIWICFormatConverterInfoVtbl
= &FormatConverterInfo_Vtbl
;
956 This
->classkey
= classkey
;
957 memcpy(&This
->clsid
, clsid
, sizeof(CLSID
));
959 *ppIInfo
= (IWICComponentInfo
*)This
;
963 static WCHAR
const clsid_keyname
[] = {'C','L','S','I','D',0};
964 static WCHAR
const instance_keyname
[] = {'I','n','s','t','a','n','c','e',0};
967 WICComponentType type
;
969 HRESULT (*constructor
)(HKEY
,REFCLSID
,IWICComponentInfo
**);
972 static const struct category categories
[] = {
973 {WICDecoder
, &CATID_WICBitmapDecoders
, BitmapDecoderInfo_Constructor
},
974 {WICEncoder
, &CATID_WICBitmapEncoders
, BitmapEncoderInfo_Constructor
},
975 {WICPixelFormatConverter
, &CATID_WICFormatConverters
, FormatConverterInfo_Constructor
},
979 HRESULT
CreateComponentInfo(REFCLSID clsid
, IWICComponentInfo
**ppIInfo
)
985 WCHAR guidstring
[39];
987 const struct category
*category
;
991 res
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, clsid_keyname
, 0, KEY_READ
, &clsidkey
);
992 if (res
!= ERROR_SUCCESS
)
993 return HRESULT_FROM_WIN32(res
);
995 for (category
=categories
; category
->type
; category
++)
997 StringFromGUID2(category
->catid
, guidstring
, 39);
998 res
= RegOpenKeyExW(clsidkey
, guidstring
, 0, KEY_READ
, &catidkey
);
999 if (res
== ERROR_SUCCESS
)
1001 res
= RegOpenKeyExW(catidkey
, instance_keyname
, 0, KEY_READ
, &instancekey
);
1002 if (res
== ERROR_SUCCESS
)
1004 StringFromGUID2(clsid
, guidstring
, 39);
1005 res
= RegOpenKeyExW(instancekey
, guidstring
, 0, KEY_READ
, &classkey
);
1006 if (res
== ERROR_SUCCESS
)
1008 RegCloseKey(classkey
);
1011 RegCloseKey(instancekey
);
1013 RegCloseKey(catidkey
);
1020 res
= RegOpenKeyExW(clsidkey
, guidstring
, 0, KEY_READ
, &classkey
);
1021 if (res
== ERROR_SUCCESS
)
1022 hr
= category
->constructor(classkey
, clsid
, ppIInfo
);
1024 hr
= HRESULT_FROM_WIN32(res
);
1029 RegCloseKey(clsidkey
);
1035 const IEnumUnknownVtbl
*IEnumUnknown_Vtbl
;
1037 struct list objects
;
1038 struct list
*cursor
;
1039 CRITICAL_SECTION lock
; /* Must be held when reading or writing cursor */
1045 } ComponentEnumItem
;
1047 static const IEnumUnknownVtbl ComponentEnumVtbl
;
1049 static HRESULT WINAPI
ComponentEnum_QueryInterface(IEnumUnknown
*iface
, REFIID iid
,
1052 ComponentEnum
*This
= (ComponentEnum
*)iface
;
1053 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
1055 if (!ppv
) return E_INVALIDARG
;
1057 if (IsEqualIID(&IID_IUnknown
, iid
) || IsEqualIID(&IID_IEnumUnknown
, iid
))
1064 return E_NOINTERFACE
;
1067 IUnknown_AddRef((IUnknown
*)*ppv
);
1071 static ULONG WINAPI
ComponentEnum_AddRef(IEnumUnknown
*iface
)
1073 ComponentEnum
*This
= (ComponentEnum
*)iface
;
1074 ULONG ref
= InterlockedIncrement(&This
->ref
);
1076 TRACE("(%p) refcount=%u\n", iface
, ref
);
1081 static ULONG WINAPI
ComponentEnum_Release(IEnumUnknown
*iface
)
1083 ComponentEnum
*This
= (ComponentEnum
*)iface
;
1084 ULONG ref
= InterlockedDecrement(&This
->ref
);
1085 ComponentEnumItem
*cursor
, *cursor2
;
1087 TRACE("(%p) refcount=%u\n", iface
, ref
);
1091 LIST_FOR_EACH_ENTRY_SAFE(cursor
, cursor2
, &This
->objects
, ComponentEnumItem
, entry
)
1093 IUnknown_Release(cursor
->unk
);
1094 list_remove(&cursor
->entry
);
1095 HeapFree(GetProcessHeap(), 0, cursor
);
1097 This
->lock
.DebugInfo
->Spare
[0] = 0;
1098 DeleteCriticalSection(&This
->lock
);
1099 HeapFree(GetProcessHeap(), 0, This
);
1105 static HRESULT WINAPI
ComponentEnum_Next(IEnumUnknown
*iface
, ULONG celt
,
1106 IUnknown
**rgelt
, ULONG
*pceltFetched
)
1108 ComponentEnum
*This
= (ComponentEnum
*)iface
;
1110 ComponentEnumItem
*item
;
1113 TRACE("(%p,%u,%p,%p)\n", iface
, celt
, rgelt
, pceltFetched
);
1115 EnterCriticalSection(&This
->lock
);
1116 while (num_fetched
<celt
)
1123 item
= LIST_ENTRY(This
->cursor
, ComponentEnumItem
, entry
);
1124 IUnknown_AddRef(item
->unk
);
1125 rgelt
[num_fetched
] = item
->unk
;
1127 This
->cursor
= list_next(&This
->objects
, This
->cursor
);
1129 LeaveCriticalSection(&This
->lock
);
1131 *pceltFetched
= num_fetched
;
1135 static HRESULT WINAPI
ComponentEnum_Skip(IEnumUnknown
*iface
, ULONG celt
)
1137 ComponentEnum
*This
= (ComponentEnum
*)iface
;
1141 TRACE("(%p,%u)\n", iface
, celt
);
1143 EnterCriticalSection(&This
->lock
);
1144 for (i
=0; i
<celt
; i
++)
1151 This
->cursor
= list_next(&This
->objects
, This
->cursor
);
1153 LeaveCriticalSection(&This
->lock
);
1157 static HRESULT WINAPI
ComponentEnum_Reset(IEnumUnknown
*iface
)
1159 ComponentEnum
*This
= (ComponentEnum
*)iface
;
1161 TRACE("(%p)\n", iface
);
1163 EnterCriticalSection(&This
->lock
);
1164 This
->cursor
= list_head(&This
->objects
);
1165 LeaveCriticalSection(&This
->lock
);
1169 static HRESULT WINAPI
ComponentEnum_Clone(IEnumUnknown
*iface
, IEnumUnknown
**ppenum
)
1171 ComponentEnum
*This
= (ComponentEnum
*)iface
;
1172 ComponentEnum
*new_enum
;
1173 ComponentEnumItem
*old_item
, *new_item
;
1175 struct list
*old_cursor
;
1177 new_enum
= HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnum
));
1181 return E_OUTOFMEMORY
;
1184 new_enum
->IEnumUnknown_Vtbl
= &ComponentEnumVtbl
;
1186 new_enum
->cursor
= NULL
;
1187 list_init(&new_enum
->objects
);
1188 InitializeCriticalSection(&new_enum
->lock
);
1189 new_enum
->lock
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": ComponentEnum.lock");
1191 EnterCriticalSection(&This
->lock
);
1192 old_cursor
= This
->cursor
;
1193 LeaveCriticalSection(&This
->lock
);
1195 LIST_FOR_EACH_ENTRY(old_item
, &This
->objects
, ComponentEnumItem
, entry
)
1197 new_item
= HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnumItem
));
1200 ret
= E_OUTOFMEMORY
;
1203 new_item
->unk
= old_item
->unk
;
1204 list_add_tail(&new_enum
->objects
, &new_item
->entry
);
1205 IUnknown_AddRef(new_item
->unk
);
1206 if (&old_item
->entry
== old_cursor
) new_enum
->cursor
= &new_item
->entry
;
1211 IUnknown_Release((IUnknown
*)new_enum
);
1215 *ppenum
= (IEnumUnknown
*)new_enum
;
1220 static const IEnumUnknownVtbl ComponentEnumVtbl
= {
1221 ComponentEnum_QueryInterface
,
1222 ComponentEnum_AddRef
,
1223 ComponentEnum_Release
,
1226 ComponentEnum_Reset
,
1230 HRESULT
CreateComponentEnumerator(DWORD componentTypes
, DWORD options
, IEnumUnknown
**ppIEnumUnknown
)
1232 ComponentEnum
*This
;
1233 ComponentEnumItem
*item
;
1234 const struct category
*category
;
1235 HKEY clsidkey
, catidkey
, instancekey
;
1236 WCHAR guidstring
[39];
1242 if (options
) FIXME("ignoring flags %x\n", options
);
1244 res
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, clsid_keyname
, 0, KEY_READ
, &clsidkey
);
1245 if (res
!= ERROR_SUCCESS
)
1246 return HRESULT_FROM_WIN32(res
);
1248 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnum
));
1251 RegCloseKey(clsidkey
);
1252 return E_OUTOFMEMORY
;
1255 This
->IEnumUnknown_Vtbl
= &ComponentEnumVtbl
;
1257 list_init(&This
->objects
);
1258 InitializeCriticalSection(&This
->lock
);
1259 This
->lock
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": ComponentEnum.lock");
1261 for (category
=categories
; category
->type
&& hr
== S_OK
; category
++)
1263 if ((category
->type
& componentTypes
) == 0) continue;
1264 StringFromGUID2(category
->catid
, guidstring
, 39);
1265 res
= RegOpenKeyExW(clsidkey
, guidstring
, 0, KEY_READ
, &catidkey
);
1266 if (res
== ERROR_SUCCESS
)
1268 res
= RegOpenKeyExW(catidkey
, instance_keyname
, 0, KEY_READ
, &instancekey
);
1269 if (res
== ERROR_SUCCESS
)
1274 DWORD guidstring_size
= 39;
1275 res
= RegEnumKeyExW(instancekey
, i
, guidstring
, &guidstring_size
, NULL
, NULL
, NULL
, NULL
);
1276 if (res
!= ERROR_SUCCESS
) break;
1278 item
= HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentEnumItem
));
1279 if (!item
) { hr
= E_OUTOFMEMORY
; break; }
1281 hr
= CLSIDFromString(guidstring
, &clsid
);
1284 hr
= CreateComponentInfo(&clsid
, (IWICComponentInfo
**)&item
->unk
);
1286 list_add_tail(&This
->objects
, &item
->entry
);
1291 HeapFree(GetProcessHeap(), 0, item
);
1295 RegCloseKey(instancekey
);
1297 RegCloseKey(catidkey
);
1299 if (res
!= ERROR_SUCCESS
&& res
!= ERROR_NO_MORE_ITEMS
)
1300 hr
= HRESULT_FROM_WIN32(res
);
1302 RegCloseKey(clsidkey
);
1306 IEnumUnknown_Reset((IEnumUnknown
*)This
);
1307 *ppIEnumUnknown
= (IEnumUnknown
*)This
;
1311 *ppIEnumUnknown
= NULL
;
1312 IUnknown_Release((IUnknown
*)This
);
1318 HRESULT WINAPI
WICConvertBitmapSource(REFWICPixelFormatGUID dstFormat
, IWICBitmapSource
*pISrc
, IWICBitmapSource
**ppIDst
)
1321 IEnumUnknown
*enumconverters
;
1322 IUnknown
*unkconverterinfo
;
1323 IWICFormatConverterInfo
*converterinfo
=NULL
;
1324 IWICFormatConverter
*converter
=NULL
;
1326 WCHAR srcformatstr
[39], dstformatstr
[39];
1330 res
= IWICBitmapSource_GetPixelFormat(pISrc
, &srcFormat
);
1331 if (FAILED(res
)) return res
;
1333 if (IsEqualGUID(&srcFormat
, dstFormat
))
1335 IWICBitmapSource_AddRef(pISrc
);
1340 StringFromGUID2(&srcFormat
, srcformatstr
, 39);
1341 StringFromGUID2(dstFormat
, dstformatstr
, 39);
1343 res
= CreateComponentEnumerator(WICPixelFormatConverter
, 0, &enumconverters
);
1344 if (FAILED(res
)) return res
;
1348 res
= IEnumUnknown_Next(enumconverters
, 1, &unkconverterinfo
, &num_fetched
);
1352 res
= IUnknown_QueryInterface(unkconverterinfo
, &IID_IWICFormatConverterInfo
, (void**)&converterinfo
);
1356 canconvert
= ConverterSupportsFormat(converterinfo
, srcformatstr
);
1359 canconvert
= ConverterSupportsFormat(converterinfo
, dstformatstr
);
1363 res
= IWICFormatConverterInfo_CreateInstance(converterinfo
, &converter
);
1366 res
= IWICFormatConverter_CanConvert(converter
, &srcFormat
, dstFormat
, &canconvert
);
1368 if (SUCCEEDED(res
) && canconvert
)
1369 res
= IWICFormatConverter_Initialize(converter
, pISrc
, dstFormat
, WICBitmapDitherTypeNone
,
1370 NULL
, 0.0, WICBitmapPaletteTypeCustom
);
1372 if (FAILED(res
) || !canconvert
)
1376 IWICFormatConverter_Release(converter
);
1383 IWICFormatConverterInfo_Release(converterinfo
);
1386 IUnknown_Release(unkconverterinfo
);
1392 IEnumUnknown_Release(enumconverters
);
1396 *ppIDst
= (IWICBitmapSource
*)converter
;
1401 FIXME("cannot convert %s to %s\n", debugstr_guid(&srcFormat
), debugstr_guid(dstFormat
));
1403 return WINCODEC_ERR_COMPONENTNOTFOUND
;