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
30 #include "wincodecs_private.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs
);
59 IWICBitmapDecoder IWICBitmapDecoder_iface
;
64 CRITICAL_SECTION lock
; /* must be held when accessing stream */
68 IWICBitmapFrameDecode IWICBitmapFrameDecode_iface
;
75 static inline IcoDecoder
*impl_from_IWICBitmapDecoder(IWICBitmapDecoder
*iface
)
77 return CONTAINING_RECORD(iface
, IcoDecoder
, IWICBitmapDecoder_iface
);
80 static inline IcoFrameDecode
*impl_from_IWICBitmapFrameDecode(IWICBitmapFrameDecode
*iface
)
82 return CONTAINING_RECORD(iface
, IcoFrameDecode
, IWICBitmapFrameDecode_iface
);
85 static HRESULT WINAPI
IcoFrameDecode_QueryInterface(IWICBitmapFrameDecode
*iface
, REFIID iid
,
88 IcoFrameDecode
*This
= impl_from_IWICBitmapFrameDecode(iface
);
89 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
91 if (!ppv
) return E_INVALIDARG
;
93 if (IsEqualIID(&IID_IUnknown
, iid
) ||
94 IsEqualIID(&IID_IWICBitmapSource
, iid
) ||
95 IsEqualIID(&IID_IWICBitmapFrameDecode
, iid
))
97 *ppv
= &This
->IWICBitmapFrameDecode_iface
;
102 return E_NOINTERFACE
;
105 IUnknown_AddRef((IUnknown
*)*ppv
);
109 static ULONG WINAPI
IcoFrameDecode_AddRef(IWICBitmapFrameDecode
*iface
)
111 IcoFrameDecode
*This
= impl_from_IWICBitmapFrameDecode(iface
);
112 ULONG ref
= InterlockedIncrement(&This
->ref
);
114 TRACE("(%p) refcount=%u\n", iface
, ref
);
119 static ULONG WINAPI
IcoFrameDecode_Release(IWICBitmapFrameDecode
*iface
)
121 IcoFrameDecode
*This
= impl_from_IWICBitmapFrameDecode(iface
);
122 ULONG ref
= InterlockedDecrement(&This
->ref
);
124 TRACE("(%p) refcount=%u\n", iface
, ref
);
128 HeapFree(GetProcessHeap(), 0, This
->bits
);
129 HeapFree(GetProcessHeap(), 0, This
);
135 static HRESULT WINAPI
IcoFrameDecode_GetSize(IWICBitmapFrameDecode
*iface
,
136 UINT
*puiWidth
, UINT
*puiHeight
)
138 IcoFrameDecode
*This
= impl_from_IWICBitmapFrameDecode(iface
);
140 *puiWidth
= This
->width
;
141 *puiHeight
= This
->height
;
143 TRACE("(%p) -> (%i,%i)\n", iface
, *puiWidth
, *puiHeight
);
148 static HRESULT WINAPI
IcoFrameDecode_GetPixelFormat(IWICBitmapFrameDecode
*iface
,
149 WICPixelFormatGUID
*pPixelFormat
)
151 memcpy(pPixelFormat
, &GUID_WICPixelFormat32bppBGRA
, sizeof(GUID
));
155 static HRESULT WINAPI
IcoFrameDecode_GetResolution(IWICBitmapFrameDecode
*iface
,
156 double *pDpiX
, double *pDpiY
)
158 IcoFrameDecode
*This
= impl_from_IWICBitmapFrameDecode(iface
);
163 TRACE("(%p) -> (%f,%f)\n", iface
, *pDpiX
, *pDpiY
);
168 static HRESULT WINAPI
IcoFrameDecode_CopyPalette(IWICBitmapFrameDecode
*iface
,
169 IWICPalette
*pIPalette
)
171 TRACE("(%p,%p)\n", iface
, pIPalette
);
172 return WINCODEC_ERR_PALETTEUNAVAILABLE
;
175 static HRESULT WINAPI
IcoFrameDecode_CopyPixels(IWICBitmapFrameDecode
*iface
,
176 const WICRect
*prc
, UINT cbStride
, UINT cbBufferSize
, BYTE
*pbBuffer
)
178 IcoFrameDecode
*This
= impl_from_IWICBitmapFrameDecode(iface
);
179 TRACE("(%p,%s,%u,%u,%p)\n", iface
, debug_wic_rect(prc
), cbStride
, cbBufferSize
, pbBuffer
);
181 return copy_pixels(32, This
->bits
, This
->width
, This
->height
, This
->width
* 4,
182 prc
, cbStride
, cbBufferSize
, pbBuffer
);
185 static HRESULT WINAPI
IcoFrameDecode_GetMetadataQueryReader(IWICBitmapFrameDecode
*iface
,
186 IWICMetadataQueryReader
**ppIMetadataQueryReader
)
188 TRACE("(%p,%p)\n", iface
, ppIMetadataQueryReader
);
189 return WINCODEC_ERR_UNSUPPORTEDOPERATION
;
192 static HRESULT WINAPI
IcoFrameDecode_GetColorContexts(IWICBitmapFrameDecode
*iface
,
193 UINT cCount
, IWICColorContext
**ppIColorContexts
, UINT
*pcActualCount
)
195 TRACE("(%p,%u,%p,%p)\n", iface
, cCount
, ppIColorContexts
, pcActualCount
);
196 return WINCODEC_ERR_UNSUPPORTEDOPERATION
;
199 static HRESULT WINAPI
IcoFrameDecode_GetThumbnail(IWICBitmapFrameDecode
*iface
,
200 IWICBitmapSource
**ppIThumbnail
)
202 TRACE("(%p,%p)\n", iface
, ppIThumbnail
);
203 return IWICBitmapFrameDecode_QueryInterface(iface
, &IID_IWICBitmapSource
, (void **)ppIThumbnail
);
206 static const IWICBitmapFrameDecodeVtbl IcoFrameDecode_Vtbl
= {
207 IcoFrameDecode_QueryInterface
,
208 IcoFrameDecode_AddRef
,
209 IcoFrameDecode_Release
,
210 IcoFrameDecode_GetSize
,
211 IcoFrameDecode_GetPixelFormat
,
212 IcoFrameDecode_GetResolution
,
213 IcoFrameDecode_CopyPalette
,
214 IcoFrameDecode_CopyPixels
,
215 IcoFrameDecode_GetMetadataQueryReader
,
216 IcoFrameDecode_GetColorContexts
,
217 IcoFrameDecode_GetThumbnail
220 static inline void pixel_set_trans(DWORD
* pixel
, BOOL transparent
)
222 if (transparent
) *pixel
= 0;
223 else *pixel
|= 0xff000000;
226 static HRESULT
ReadIcoDib(IStream
*stream
, IcoFrameDecode
*result
)
229 BmpDecoder
*bmp_decoder
;
230 IWICBitmapDecoder
*decoder
;
231 IWICBitmapFrameDecode
*framedecode
;
232 WICPixelFormatGUID pixelformat
;
233 IWICBitmapSource
*source
;
234 BOOL has_alpha
=FALSE
; /* if TRUE, alpha data might be in the image data */
237 hr
= IcoDibDecoder_CreateInstance(&bmp_decoder
);
240 BmpDecoder_GetWICDecoder(bmp_decoder
, &decoder
);
241 hr
= IWICBitmapDecoder_Initialize(decoder
, stream
, WICDecodeMetadataCacheOnLoad
);
244 hr
= IWICBitmapDecoder_GetFrame(decoder
, 0, &framedecode
);
248 hr
= IWICBitmapFrameDecode_GetSize(framedecode
, &result
->width
, &result
->height
);
252 result
->bits
= HeapAlloc(GetProcessHeap(), 0, result
->width
* result
->height
* 4);
253 if (!result
->bits
) hr
= E_OUTOFMEMORY
;
257 hr
= IWICBitmapFrameDecode_GetPixelFormat(framedecode
, &pixelformat
);
259 if (IsEqualGUID(&pixelformat
, &GUID_WICPixelFormat32bppBGR
) ||
260 IsEqualGUID(&pixelformat
, &GUID_WICPixelFormat32bppBGRA
))
262 source
= (IWICBitmapSource
*)framedecode
;
263 IWICBitmapSource_AddRef(source
);
268 hr
= WICConvertBitmapSource(&GUID_WICPixelFormat32bppBGRA
,
269 (IWICBitmapSource
*)framedecode
, &source
);
277 rc
.Width
= result
->width
;
278 rc
.Height
= result
->height
;
279 hr
= IWICBitmapSource_CopyPixels(source
, &rc
, result
->width
* 4,
280 result
->width
* result
->height
* 4, result
->bits
);
282 IWICBitmapSource_Release(source
);
286 hr
= IWICBitmapFrameDecode_GetResolution(framedecode
, &result
->dpiX
, &result
->dpiY
);
288 IWICBitmapFrameDecode_Release(framedecode
);
291 if (SUCCEEDED(hr
) && has_alpha
)
293 /* If the alpha channel is fully transparent, we should ignore it. */
294 int nonzero_alpha
= 0;
297 for (i
=0; i
<(result
->height
*result
->width
); i
++)
299 if (result
->bits
[i
*4+3] != 0)
308 for (i
=0; i
<(result
->height
*result
->width
); i
++)
309 result
->bits
[i
*4+3] = 0xff;
315 if (SUCCEEDED(hr
) && !has_alpha
)
317 /* set alpha data based on the AND mask */
318 UINT andBytesPerRow
= (result
->width
+31)/32*4;
319 UINT andBytes
= andBytesPerRow
* result
->height
;
324 UINT bitsStride
= result
->width
* 4;
331 BmpDecoder_FindIconMask(bmp_decoder
, &offset
, &topdown
);
335 seek
.QuadPart
= offset
;
337 hr
= IStream_Seek(stream
, seek
, STREAM_SEEK_SET
, 0);
341 tempdata
= HeapAlloc(GetProcessHeap(), 0, andBytes
);
342 if (!tempdata
) hr
= E_OUTOFMEMORY
;
346 hr
= IStream_Read(stream
, tempdata
, andBytes
, &bytesread
);
348 if (SUCCEEDED(hr
) && bytesread
== andBytes
)
352 andStride
= andBytesPerRow
;
357 andStride
= -andBytesPerRow
;
358 andRow
= tempdata
+ (result
->height
-1)*andBytesPerRow
;
361 bitsRow
= result
->bits
;
362 for (y
=0; y
<result
->height
; y
++) {
363 BYTE
*andByte
=andRow
;
364 DWORD
*bitsPixel
=(DWORD
*)bitsRow
;
365 for (x
=0; x
<result
->width
; x
+=8) {
366 BYTE andVal
=*andByte
++;
367 pixel_set_trans(bitsPixel
++, andVal
>>7&1);
368 if (x
+1 < result
->width
) pixel_set_trans(bitsPixel
++, andVal
>>6&1);
369 if (x
+2 < result
->width
) pixel_set_trans(bitsPixel
++, andVal
>>5&1);
370 if (x
+3 < result
->width
) pixel_set_trans(bitsPixel
++, andVal
>>4&1);
371 if (x
+4 < result
->width
) pixel_set_trans(bitsPixel
++, andVal
>>3&1);
372 if (x
+5 < result
->width
) pixel_set_trans(bitsPixel
++, andVal
>>2&1);
373 if (x
+6 < result
->width
) pixel_set_trans(bitsPixel
++, andVal
>>1&1);
374 if (x
+7 < result
->width
) pixel_set_trans(bitsPixel
++, andVal
&1);
377 bitsRow
+= bitsStride
;
381 HeapFree(GetProcessHeap(), 0, tempdata
);
385 IWICBitmapDecoder_Release(decoder
);
391 static HRESULT
ReadIcoPng(IStream
*stream
, IcoFrameDecode
*result
)
393 IWICBitmapDecoder
*decoder
= NULL
;
394 IWICBitmapFrameDecode
*sourceFrame
= NULL
;
395 IWICBitmapSource
*sourceBitmap
= NULL
;
399 hr
= PngDecoder_CreateInstance(&IID_IWICBitmapDecoder
, (void**)&decoder
);
402 hr
= IWICBitmapDecoder_Initialize(decoder
, stream
, WICDecodeMetadataCacheOnLoad
);
405 hr
= IWICBitmapDecoder_GetFrame(decoder
, 0, &sourceFrame
);
408 hr
= WICConvertBitmapSource(&GUID_WICPixelFormat32bppBGRA
, (IWICBitmapSource
*)sourceFrame
, &sourceBitmap
);
411 hr
= IWICBitmapFrameDecode_GetSize(sourceFrame
, &result
->width
, &result
->height
);
414 hr
= IWICBitmapFrameDecode_GetResolution(sourceFrame
, &result
->dpiX
, &result
->dpiY
);
417 result
->bits
= HeapAlloc(GetProcessHeap(), 0, 4 * result
->width
* result
->height
);
418 if (result
->bits
== NULL
)
425 rect
.Width
= result
->width
;
426 rect
.Height
= result
->height
;
427 hr
= IWICBitmapSource_CopyPixels(sourceBitmap
, &rect
, 4*result
->width
,
428 4*result
->width
*result
->height
, result
->bits
);
432 IWICBitmapDecoder_Release(decoder
);
433 if (sourceFrame
!= NULL
)
434 IWICBitmapFrameDecode_Release(sourceFrame
);
435 if (sourceBitmap
!= NULL
)
436 IWICBitmapSource_Release(sourceBitmap
);
440 static HRESULT WINAPI
IcoDecoder_QueryInterface(IWICBitmapDecoder
*iface
, REFIID iid
,
443 IcoDecoder
*This
= impl_from_IWICBitmapDecoder(iface
);
444 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
446 if (!ppv
) return E_INVALIDARG
;
448 if (IsEqualIID(&IID_IUnknown
, iid
) ||
449 IsEqualIID(&IID_IWICBitmapDecoder
, iid
))
451 *ppv
= &This
->IWICBitmapDecoder_iface
;
456 return E_NOINTERFACE
;
459 IUnknown_AddRef((IUnknown
*)*ppv
);
463 static ULONG WINAPI
IcoDecoder_AddRef(IWICBitmapDecoder
*iface
)
465 IcoDecoder
*This
= impl_from_IWICBitmapDecoder(iface
);
466 ULONG ref
= InterlockedIncrement(&This
->ref
);
468 TRACE("(%p) refcount=%u\n", iface
, ref
);
473 static ULONG WINAPI
IcoDecoder_Release(IWICBitmapDecoder
*iface
)
475 IcoDecoder
*This
= impl_from_IWICBitmapDecoder(iface
);
476 ULONG ref
= InterlockedDecrement(&This
->ref
);
478 TRACE("(%p) refcount=%u\n", iface
, ref
);
482 This
->lock
.DebugInfo
->Spare
[0] = 0;
483 DeleteCriticalSection(&This
->lock
);
484 if (This
->stream
) IStream_Release(This
->stream
);
485 HeapFree(GetProcessHeap(), 0, This
);
491 static HRESULT WINAPI
IcoDecoder_QueryCapability(IWICBitmapDecoder
*iface
, IStream
*stream
,
496 TRACE("(%p,%p,%p)\n", iface
, stream
, capability
);
498 if (!stream
|| !capability
) return E_INVALIDARG
;
500 hr
= IWICBitmapDecoder_Initialize(iface
, stream
, WICDecodeMetadataCacheOnDemand
);
501 if (hr
!= S_OK
) return hr
;
503 *capability
= WICBitmapDecoderCapabilityCanDecodeAllImages
;
507 static HRESULT WINAPI
IcoDecoder_Initialize(IWICBitmapDecoder
*iface
, IStream
*pIStream
,
508 WICDecodeOptions cacheOptions
)
510 IcoDecoder
*This
= impl_from_IWICBitmapDecoder(iface
);
517 TRACE("(%p,%p,%x)\n", iface
, pIStream
, cacheOptions
);
519 EnterCriticalSection(&This
->lock
);
521 if (This
->initialized
)
523 hr
= WINCODEC_ERR_WRONGSTATE
;
528 hr
= IStream_Seek(pIStream
, seek
, STREAM_SEEK_SET
, NULL
);
529 if (FAILED(hr
)) goto end
;
531 hr
= IStream_Read(pIStream
, &This
->header
, sizeof(ICONHEADER
), &bytesread
);
532 if (FAILED(hr
)) goto end
;
534 if (bytesread
!= sizeof(ICONHEADER
))
536 hr
= WINCODEC_ERR_STREAMREAD
;
540 if (This
->header
.idReserved
!= 0 ||
541 This
->header
.idType
!= 1)
547 hr
= IStream_Stat(pIStream
, &statstg
, STATFLAG_NONAME
);
550 WARN("Stat() failed, hr %#x.\n", hr
);
554 for (i
= 0; i
< This
->header
.idCount
; i
++)
556 ICONDIRENTRY direntry
;
558 hr
= IStream_Read(pIStream
, &direntry
, sizeof(direntry
), &bytesread
);
559 if (FAILED(hr
)) goto end
;
561 if (bytesread
!= sizeof(direntry
) || (direntry
.dwDIBSize
+ direntry
.dwDIBOffset
> statstg
.cbSize
.QuadPart
))
563 hr
= WINCODEC_ERR_BADIMAGE
;
568 This
->initialized
= TRUE
;
569 This
->stream
= pIStream
;
570 IStream_AddRef(pIStream
);
574 LeaveCriticalSection(&This
->lock
);
579 static HRESULT WINAPI
IcoDecoder_GetContainerFormat(IWICBitmapDecoder
*iface
,
580 GUID
*pguidContainerFormat
)
582 memcpy(pguidContainerFormat
, &GUID_ContainerFormatIco
, sizeof(GUID
));
586 static HRESULT WINAPI
IcoDecoder_GetDecoderInfo(IWICBitmapDecoder
*iface
,
587 IWICBitmapDecoderInfo
**ppIDecoderInfo
)
589 TRACE("(%p,%p)\n", iface
, ppIDecoderInfo
);
591 return get_decoder_info(&CLSID_WICIcoDecoder
, ppIDecoderInfo
);
594 static HRESULT WINAPI
IcoDecoder_CopyPalette(IWICBitmapDecoder
*iface
,
595 IWICPalette
*pIPalette
)
597 TRACE("(%p,%p)\n", iface
, pIPalette
);
598 return WINCODEC_ERR_PALETTEUNAVAILABLE
;
601 static HRESULT WINAPI
IcoDecoder_GetMetadataQueryReader(IWICBitmapDecoder
*iface
,
602 IWICMetadataQueryReader
**ppIMetadataQueryReader
)
604 TRACE("(%p,%p)\n", iface
, ppIMetadataQueryReader
);
605 return WINCODEC_ERR_UNSUPPORTEDOPERATION
;
608 static HRESULT WINAPI
IcoDecoder_GetPreview(IWICBitmapDecoder
*iface
,
609 IWICBitmapSource
**ppIBitmapSource
)
611 TRACE("(%p,%p)\n", iface
, ppIBitmapSource
);
612 return WINCODEC_ERR_UNSUPPORTEDOPERATION
;
615 static HRESULT WINAPI
IcoDecoder_GetColorContexts(IWICBitmapDecoder
*iface
,
616 UINT cCount
, IWICColorContext
**ppIColorContexts
, UINT
*pcActualCount
)
618 TRACE("(%p,%u,%p,%p)\n", iface
, cCount
, ppIColorContexts
, pcActualCount
);
619 return WINCODEC_ERR_UNSUPPORTEDOPERATION
;
622 static HRESULT WINAPI
IcoDecoder_GetThumbnail(IWICBitmapDecoder
*iface
,
623 IWICBitmapSource
**ppIThumbnail
)
625 TRACE("(%p,%p)\n", iface
, ppIThumbnail
);
626 return WINCODEC_ERR_CODECNOTHUMBNAIL
;
629 static HRESULT WINAPI
IcoDecoder_GetFrameCount(IWICBitmapDecoder
*iface
,
632 IcoDecoder
*This
= impl_from_IWICBitmapDecoder(iface
);
634 if (!pCount
) return E_INVALIDARG
;
636 EnterCriticalSection(&This
->lock
);
637 *pCount
= This
->initialized
? This
->header
.idCount
: 0;
638 LeaveCriticalSection(&This
->lock
);
640 TRACE("(%p) <-- %d\n", iface
, *pCount
);
645 static HRESULT WINAPI
IcoDecoder_GetFrame(IWICBitmapDecoder
*iface
,
646 UINT index
, IWICBitmapFrameDecode
**ppIBitmapFrame
)
648 IcoDecoder
*This
= impl_from_IWICBitmapDecoder(iface
);
649 IcoFrameDecode
*result
=NULL
;
651 ULARGE_INTEGER offset
, length
;
655 IWICStream
*substream
=NULL
;
657 TRACE("(%p,%u,%p)\n", iface
, index
, ppIBitmapFrame
);
659 EnterCriticalSection(&This
->lock
);
661 if (!This
->initialized
)
663 hr
= WINCODEC_ERR_FRAMEMISSING
;
667 if (This
->header
.idCount
< index
)
673 result
= HeapAlloc(GetProcessHeap(), 0, sizeof(IcoFrameDecode
));
680 result
->IWICBitmapFrameDecode_iface
.lpVtbl
= &IcoFrameDecode_Vtbl
;
684 /* read the icon entry */
685 seek
.QuadPart
= sizeof(ICONHEADER
) + sizeof(ICONDIRENTRY
) * index
;
686 hr
= IStream_Seek(This
->stream
, seek
, STREAM_SEEK_SET
, 0);
687 if (FAILED(hr
)) goto fail
;
689 hr
= IStream_Read(This
->stream
, &entry
, sizeof(ICONDIRENTRY
), &bytesread
);
690 if (FAILED(hr
) || bytesread
!= sizeof(ICONDIRENTRY
)) goto fail
;
692 /* create a stream object for this icon */
693 hr
= StreamImpl_Create(&substream
);
694 if (FAILED(hr
)) goto fail
;
696 offset
.QuadPart
= entry
.dwDIBOffset
;
697 length
.QuadPart
= entry
.dwDIBSize
;
698 hr
= IWICStream_InitializeFromIStreamRegion(substream
, This
->stream
, offset
, length
);
699 if (FAILED(hr
)) goto fail
;
701 /* read the bitmapinfo size or magic number */
702 hr
= IWICStream_Read(substream
, &magic
, sizeof(magic
), &bytesread
);
703 if (FAILED(hr
) || bytesread
!= sizeof(magic
)) goto fail
;
705 /* forward to the appropriate decoding function based on the magic number */
708 case sizeof(BITMAPCOREHEADER
):
709 case 64: /* sizeof(BITMAPCOREHEADER2) */
710 case sizeof(BITMAPINFOHEADER
):
711 case sizeof(BITMAPV4HEADER
):
712 case sizeof(BITMAPV5HEADER
):
713 hr
= ReadIcoDib((IStream
*)substream
, result
);
716 hr
= ReadIcoPng((IStream
*)substream
, result
);
719 FIXME("Unrecognized ICO frame magic: %x\n", magic
);
723 if (FAILED(hr
)) goto fail
;
725 *ppIBitmapFrame
= &result
->IWICBitmapFrameDecode_iface
;
727 LeaveCriticalSection(&This
->lock
);
729 IWICStream_Release(substream
);
734 LeaveCriticalSection(&This
->lock
);
735 HeapFree(GetProcessHeap(), 0, result
);
736 if (substream
) IWICStream_Release(substream
);
737 if (SUCCEEDED(hr
)) hr
= E_FAIL
;
738 TRACE("<-- %x\n", hr
);
742 static const IWICBitmapDecoderVtbl IcoDecoder_Vtbl
= {
743 IcoDecoder_QueryInterface
,
746 IcoDecoder_QueryCapability
,
747 IcoDecoder_Initialize
,
748 IcoDecoder_GetContainerFormat
,
749 IcoDecoder_GetDecoderInfo
,
750 IcoDecoder_CopyPalette
,
751 IcoDecoder_GetMetadataQueryReader
,
752 IcoDecoder_GetPreview
,
753 IcoDecoder_GetColorContexts
,
754 IcoDecoder_GetThumbnail
,
755 IcoDecoder_GetFrameCount
,
759 HRESULT
IcoDecoder_CreateInstance(REFIID iid
, void** ppv
)
764 TRACE("(%s,%p)\n", debugstr_guid(iid
), ppv
);
768 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(IcoDecoder
));
769 if (!This
) return E_OUTOFMEMORY
;
771 This
->IWICBitmapDecoder_iface
.lpVtbl
= &IcoDecoder_Vtbl
;
774 This
->initialized
= FALSE
;
775 InitializeCriticalSection(&This
->lock
);
776 This
->lock
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": IcoDecoder.lock");
778 ret
= IWICBitmapDecoder_QueryInterface(&This
->IWICBitmapDecoder_iface
, iid
, ppv
);
779 IWICBitmapDecoder_Release(&This
->IWICBitmapDecoder_iface
);