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"
35 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs
);
60 IWICBitmapDecoder IWICBitmapDecoder_iface
;
65 CRITICAL_SECTION lock
; /* must be held when accessing stream */
69 IWICBitmapFrameDecode IWICBitmapFrameDecode_iface
;
76 static inline IcoDecoder
*impl_from_IWICBitmapDecoder(IWICBitmapDecoder
*iface
)
78 return CONTAINING_RECORD(iface
, IcoDecoder
, IWICBitmapDecoder_iface
);
81 static inline IcoFrameDecode
*impl_from_IWICBitmapFrameDecode(IWICBitmapFrameDecode
*iface
)
83 return CONTAINING_RECORD(iface
, IcoFrameDecode
, IWICBitmapFrameDecode_iface
);
86 static HRESULT WINAPI
IcoFrameDecode_QueryInterface(IWICBitmapFrameDecode
*iface
, REFIID iid
,
89 IcoFrameDecode
*This
= impl_from_IWICBitmapFrameDecode(iface
);
90 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
92 if (!ppv
) return E_INVALIDARG
;
94 if (IsEqualIID(&IID_IUnknown
, iid
) ||
95 IsEqualIID(&IID_IWICBitmapSource
, iid
) ||
96 IsEqualIID(&IID_IWICBitmapFrameDecode
, iid
))
98 *ppv
= &This
->IWICBitmapFrameDecode_iface
;
103 return E_NOINTERFACE
;
106 IUnknown_AddRef((IUnknown
*)*ppv
);
110 static ULONG WINAPI
IcoFrameDecode_AddRef(IWICBitmapFrameDecode
*iface
)
112 IcoFrameDecode
*This
= impl_from_IWICBitmapFrameDecode(iface
);
113 ULONG ref
= InterlockedIncrement(&This
->ref
);
115 TRACE("(%p) refcount=%u\n", iface
, ref
);
120 static ULONG WINAPI
IcoFrameDecode_Release(IWICBitmapFrameDecode
*iface
)
122 IcoFrameDecode
*This
= impl_from_IWICBitmapFrameDecode(iface
);
123 ULONG ref
= InterlockedDecrement(&This
->ref
);
125 TRACE("(%p) refcount=%u\n", iface
, ref
);
129 HeapFree(GetProcessHeap(), 0, This
->bits
);
130 HeapFree(GetProcessHeap(), 0, This
);
136 static HRESULT WINAPI
IcoFrameDecode_GetSize(IWICBitmapFrameDecode
*iface
,
137 UINT
*puiWidth
, UINT
*puiHeight
)
139 IcoFrameDecode
*This
= impl_from_IWICBitmapFrameDecode(iface
);
141 *puiWidth
= This
->width
;
142 *puiHeight
= This
->height
;
144 TRACE("(%p) -> (%i,%i)\n", iface
, *puiWidth
, *puiHeight
);
149 static HRESULT WINAPI
IcoFrameDecode_GetPixelFormat(IWICBitmapFrameDecode
*iface
,
150 WICPixelFormatGUID
*pPixelFormat
)
152 memcpy(pPixelFormat
, &GUID_WICPixelFormat32bppBGRA
, sizeof(GUID
));
156 static HRESULT WINAPI
IcoFrameDecode_GetResolution(IWICBitmapFrameDecode
*iface
,
157 double *pDpiX
, double *pDpiY
)
159 IcoFrameDecode
*This
= impl_from_IWICBitmapFrameDecode(iface
);
164 TRACE("(%p) -> (%f,%f)\n", iface
, *pDpiX
, *pDpiY
);
169 static HRESULT WINAPI
IcoFrameDecode_CopyPalette(IWICBitmapFrameDecode
*iface
,
170 IWICPalette
*pIPalette
)
172 TRACE("(%p,%p)\n", iface
, pIPalette
);
173 return WINCODEC_ERR_PALETTEUNAVAILABLE
;
176 static HRESULT WINAPI
IcoFrameDecode_CopyPixels(IWICBitmapFrameDecode
*iface
,
177 const WICRect
*prc
, UINT cbStride
, UINT cbBufferSize
, BYTE
*pbBuffer
)
179 IcoFrameDecode
*This
= impl_from_IWICBitmapFrameDecode(iface
);
180 TRACE("(%p,%p,%u,%u,%p)\n", iface
, prc
, cbStride
, cbBufferSize
, pbBuffer
);
182 return copy_pixels(32, This
->bits
, This
->width
, This
->height
, This
->width
* 4,
183 prc
, cbStride
, cbBufferSize
, pbBuffer
);
186 static HRESULT WINAPI
IcoFrameDecode_GetMetadataQueryReader(IWICBitmapFrameDecode
*iface
,
187 IWICMetadataQueryReader
**ppIMetadataQueryReader
)
189 TRACE("(%p,%p)\n", iface
, ppIMetadataQueryReader
);
190 return WINCODEC_ERR_UNSUPPORTEDOPERATION
;
193 static HRESULT WINAPI
IcoFrameDecode_GetColorContexts(IWICBitmapFrameDecode
*iface
,
194 UINT cCount
, IWICColorContext
**ppIColorContexts
, UINT
*pcActualCount
)
196 TRACE("(%p,%u,%p,%p)\n", iface
, cCount
, ppIColorContexts
, pcActualCount
);
197 return WINCODEC_ERR_UNSUPPORTEDOPERATION
;
200 static HRESULT WINAPI
IcoFrameDecode_GetThumbnail(IWICBitmapFrameDecode
*iface
,
201 IWICBitmapSource
**ppIThumbnail
)
203 TRACE("(%p,%p)\n", iface
, ppIThumbnail
);
204 return IWICBitmapFrameDecode_QueryInterface(iface
, &IID_IWICBitmapSource
, (void **)ppIThumbnail
);
207 static const IWICBitmapFrameDecodeVtbl IcoFrameDecode_Vtbl
= {
208 IcoFrameDecode_QueryInterface
,
209 IcoFrameDecode_AddRef
,
210 IcoFrameDecode_Release
,
211 IcoFrameDecode_GetSize
,
212 IcoFrameDecode_GetPixelFormat
,
213 IcoFrameDecode_GetResolution
,
214 IcoFrameDecode_CopyPalette
,
215 IcoFrameDecode_CopyPixels
,
216 IcoFrameDecode_GetMetadataQueryReader
,
217 IcoFrameDecode_GetColorContexts
,
218 IcoFrameDecode_GetThumbnail
221 static inline void pixel_set_trans(DWORD
* pixel
, BOOL transparent
)
223 if (transparent
) *pixel
= 0;
224 else *pixel
|= 0xff000000;
227 static HRESULT
ReadIcoDib(IStream
*stream
, IcoFrameDecode
*result
)
230 BmpDecoder
*bmp_decoder
;
231 IWICBitmapDecoder
*decoder
;
232 IWICBitmapFrameDecode
*framedecode
;
233 WICPixelFormatGUID pixelformat
;
234 IWICBitmapSource
*source
;
235 BOOL has_alpha
=FALSE
; /* if TRUE, alpha data might be in the image data */
238 hr
= IcoDibDecoder_CreateInstance(&bmp_decoder
);
241 BmpDecoder_GetWICDecoder(bmp_decoder
, &decoder
);
242 hr
= IWICBitmapDecoder_Initialize(decoder
, stream
, WICDecodeMetadataCacheOnLoad
);
245 hr
= IWICBitmapDecoder_GetFrame(decoder
, 0, &framedecode
);
249 hr
= IWICBitmapFrameDecode_GetSize(framedecode
, &result
->width
, &result
->height
);
253 result
->bits
= HeapAlloc(GetProcessHeap(), 0, result
->width
* result
->height
* 4);
254 if (!result
->bits
) hr
= E_OUTOFMEMORY
;
258 hr
= IWICBitmapFrameDecode_GetPixelFormat(framedecode
, &pixelformat
);
260 if (IsEqualGUID(&pixelformat
, &GUID_WICPixelFormat32bppBGR
) ||
261 IsEqualGUID(&pixelformat
, &GUID_WICPixelFormat32bppBGRA
))
263 source
= (IWICBitmapSource
*)framedecode
;
264 IWICBitmapSource_AddRef(source
);
269 hr
= WICConvertBitmapSource(&GUID_WICPixelFormat32bppBGRA
,
270 (IWICBitmapSource
*)framedecode
, &source
);
278 rc
.Width
= result
->width
;
279 rc
.Height
= result
->height
;
280 hr
= IWICBitmapSource_CopyPixels(source
, &rc
, result
->width
* 4,
281 result
->width
* result
->height
* 4, result
->bits
);
283 IWICBitmapSource_Release(source
);
287 hr
= IWICBitmapFrameDecode_GetResolution(framedecode
, &result
->dpiX
, &result
->dpiY
);
289 IWICBitmapFrameDecode_Release(framedecode
);
292 if (SUCCEEDED(hr
) && has_alpha
)
294 /* If the alpha channel is fully transparent, we should ignore it. */
295 int nonzero_alpha
= 0;
298 for (i
=0; i
<(result
->height
*result
->width
); i
++)
300 if (result
->bits
[i
*4+3] != 0)
309 for (i
=0; i
<(result
->height
*result
->width
); i
++)
310 result
->bits
[i
*4+3] = 0xff;
316 if (SUCCEEDED(hr
) && !has_alpha
)
318 /* set alpha data based on the AND mask */
319 UINT andBytesPerRow
= (result
->width
+31)/32*4;
320 UINT andBytes
= andBytesPerRow
* result
->height
;
325 UINT bitsStride
= result
->width
* 4;
332 BmpDecoder_FindIconMask(bmp_decoder
, &offset
, &topdown
);
336 seek
.QuadPart
= offset
;
338 hr
= IStream_Seek(stream
, seek
, STREAM_SEEK_SET
, 0);
342 tempdata
= HeapAlloc(GetProcessHeap(), 0, andBytes
);
343 if (!tempdata
) hr
= E_OUTOFMEMORY
;
347 hr
= IStream_Read(stream
, tempdata
, andBytes
, &bytesread
);
349 if (SUCCEEDED(hr
) && bytesread
== andBytes
)
353 andStride
= andBytesPerRow
;
358 andStride
= -andBytesPerRow
;
359 andRow
= tempdata
+ (result
->height
-1)*andBytesPerRow
;
362 bitsRow
= result
->bits
;
363 for (y
=0; y
<result
->height
; y
++) {
364 BYTE
*andByte
=andRow
;
365 DWORD
*bitsPixel
=(DWORD
*)bitsRow
;
366 for (x
=0; x
<result
->width
; x
+=8) {
367 BYTE andVal
=*andByte
++;
368 pixel_set_trans(bitsPixel
++, andVal
>>7&1);
369 if (x
+1 < result
->width
) pixel_set_trans(bitsPixel
++, andVal
>>6&1);
370 if (x
+2 < result
->width
) pixel_set_trans(bitsPixel
++, andVal
>>5&1);
371 if (x
+3 < result
->width
) pixel_set_trans(bitsPixel
++, andVal
>>4&1);
372 if (x
+4 < result
->width
) pixel_set_trans(bitsPixel
++, andVal
>>3&1);
373 if (x
+5 < result
->width
) pixel_set_trans(bitsPixel
++, andVal
>>2&1);
374 if (x
+6 < result
->width
) pixel_set_trans(bitsPixel
++, andVal
>>1&1);
375 if (x
+7 < result
->width
) pixel_set_trans(bitsPixel
++, andVal
&1);
378 bitsRow
+= bitsStride
;
382 HeapFree(GetProcessHeap(), 0, tempdata
);
386 IWICBitmapDecoder_Release(decoder
);
392 static HRESULT
ReadIcoPng(IStream
*stream
, IcoFrameDecode
*result
)
394 IWICBitmapDecoder
*decoder
= NULL
;
395 IWICBitmapFrameDecode
*sourceFrame
= NULL
;
396 IWICBitmapSource
*sourceBitmap
= NULL
;
400 hr
= PngDecoder_CreateInstance(&IID_IWICBitmapDecoder
, (void**)&decoder
);
403 hr
= IWICBitmapDecoder_Initialize(decoder
, stream
, WICDecodeMetadataCacheOnLoad
);
406 hr
= IWICBitmapDecoder_GetFrame(decoder
, 0, &sourceFrame
);
409 hr
= WICConvertBitmapSource(&GUID_WICPixelFormat32bppBGRA
, (IWICBitmapSource
*)sourceFrame
, &sourceBitmap
);
412 hr
= IWICBitmapFrameDecode_GetSize(sourceFrame
, &result
->width
, &result
->height
);
415 hr
= IWICBitmapFrameDecode_GetResolution(sourceFrame
, &result
->dpiX
, &result
->dpiY
);
418 result
->bits
= HeapAlloc(GetProcessHeap(), 0, 4 * result
->width
* result
->height
);
419 if (result
->bits
== NULL
)
426 rect
.Width
= result
->width
;
427 rect
.Height
= result
->height
;
428 hr
= IWICBitmapSource_CopyPixels(sourceBitmap
, &rect
, 4*result
->width
,
429 4*result
->width
*result
->height
, result
->bits
);
433 IWICBitmapDecoder_Release(decoder
);
434 if (sourceFrame
!= NULL
)
435 IWICBitmapFrameDecode_Release(sourceFrame
);
436 if (sourceBitmap
!= NULL
)
437 IWICBitmapSource_Release(sourceBitmap
);
441 static HRESULT WINAPI
IcoDecoder_QueryInterface(IWICBitmapDecoder
*iface
, REFIID iid
,
444 IcoDecoder
*This
= impl_from_IWICBitmapDecoder(iface
);
445 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
447 if (!ppv
) return E_INVALIDARG
;
449 if (IsEqualIID(&IID_IUnknown
, iid
) ||
450 IsEqualIID(&IID_IWICBitmapDecoder
, iid
))
452 *ppv
= &This
->IWICBitmapDecoder_iface
;
457 return E_NOINTERFACE
;
460 IUnknown_AddRef((IUnknown
*)*ppv
);
464 static ULONG WINAPI
IcoDecoder_AddRef(IWICBitmapDecoder
*iface
)
466 IcoDecoder
*This
= impl_from_IWICBitmapDecoder(iface
);
467 ULONG ref
= InterlockedIncrement(&This
->ref
);
469 TRACE("(%p) refcount=%u\n", iface
, ref
);
474 static ULONG WINAPI
IcoDecoder_Release(IWICBitmapDecoder
*iface
)
476 IcoDecoder
*This
= impl_from_IWICBitmapDecoder(iface
);
477 ULONG ref
= InterlockedDecrement(&This
->ref
);
479 TRACE("(%p) refcount=%u\n", iface
, ref
);
483 This
->lock
.DebugInfo
->Spare
[0] = 0;
484 DeleteCriticalSection(&This
->lock
);
485 if (This
->stream
) IStream_Release(This
->stream
);
486 HeapFree(GetProcessHeap(), 0, This
);
492 static HRESULT WINAPI
IcoDecoder_QueryCapability(IWICBitmapDecoder
*iface
, IStream
*stream
,
497 TRACE("(%p,%p,%p)\n", iface
, stream
, capability
);
499 if (!stream
|| !capability
) return E_INVALIDARG
;
501 hr
= IWICBitmapDecoder_Initialize(iface
, stream
, WICDecodeMetadataCacheOnDemand
);
502 if (hr
!= S_OK
) return hr
;
504 *capability
= WICBitmapDecoderCapabilityCanDecodeAllImages
;
508 static HRESULT WINAPI
IcoDecoder_Initialize(IWICBitmapDecoder
*iface
, IStream
*pIStream
,
509 WICDecodeOptions cacheOptions
)
511 IcoDecoder
*This
= impl_from_IWICBitmapDecoder(iface
);
515 TRACE("(%p,%p,%x)\n", iface
, pIStream
, cacheOptions
);
517 EnterCriticalSection(&This
->lock
);
519 if (This
->initialized
)
521 hr
= WINCODEC_ERR_WRONGSTATE
;
526 hr
= IStream_Seek(pIStream
, seek
, STREAM_SEEK_SET
, NULL
);
527 if (FAILED(hr
)) goto end
;
529 hr
= IStream_Read(pIStream
, &This
->header
, sizeof(ICONHEADER
), &bytesread
);
530 if (FAILED(hr
)) goto end
;
531 if (bytesread
!= sizeof(ICONHEADER
) ||
532 This
->header
.idReserved
!= 0 ||
533 This
->header
.idType
!= 1)
539 This
->initialized
= TRUE
;
540 This
->stream
= pIStream
;
541 IStream_AddRef(pIStream
);
545 LeaveCriticalSection(&This
->lock
);
550 static HRESULT WINAPI
IcoDecoder_GetContainerFormat(IWICBitmapDecoder
*iface
,
551 GUID
*pguidContainerFormat
)
553 memcpy(pguidContainerFormat
, &GUID_ContainerFormatIco
, sizeof(GUID
));
557 static HRESULT WINAPI
IcoDecoder_GetDecoderInfo(IWICBitmapDecoder
*iface
,
558 IWICBitmapDecoderInfo
**ppIDecoderInfo
)
561 IWICComponentInfo
*compinfo
;
563 TRACE("(%p,%p)\n", iface
, ppIDecoderInfo
);
565 hr
= CreateComponentInfo(&CLSID_WICIcoDecoder
, &compinfo
);
566 if (FAILED(hr
)) return hr
;
568 hr
= IWICComponentInfo_QueryInterface(compinfo
, &IID_IWICBitmapDecoderInfo
,
569 (void**)ppIDecoderInfo
);
571 IWICComponentInfo_Release(compinfo
);
576 static HRESULT WINAPI
IcoDecoder_CopyPalette(IWICBitmapDecoder
*iface
,
577 IWICPalette
*pIPalette
)
579 TRACE("(%p,%p)\n", iface
, pIPalette
);
580 return WINCODEC_ERR_PALETTEUNAVAILABLE
;
583 static HRESULT WINAPI
IcoDecoder_GetMetadataQueryReader(IWICBitmapDecoder
*iface
,
584 IWICMetadataQueryReader
**ppIMetadataQueryReader
)
586 TRACE("(%p,%p)\n", iface
, ppIMetadataQueryReader
);
587 return WINCODEC_ERR_UNSUPPORTEDOPERATION
;
590 static HRESULT WINAPI
IcoDecoder_GetPreview(IWICBitmapDecoder
*iface
,
591 IWICBitmapSource
**ppIBitmapSource
)
593 TRACE("(%p,%p)\n", iface
, ppIBitmapSource
);
594 return WINCODEC_ERR_UNSUPPORTEDOPERATION
;
597 static HRESULT WINAPI
IcoDecoder_GetColorContexts(IWICBitmapDecoder
*iface
,
598 UINT cCount
, IWICColorContext
**ppIColorContexts
, UINT
*pcActualCount
)
600 TRACE("(%p,%u,%p,%p)\n", iface
, cCount
, ppIColorContexts
, pcActualCount
);
601 return WINCODEC_ERR_UNSUPPORTEDOPERATION
;
604 static HRESULT WINAPI
IcoDecoder_GetThumbnail(IWICBitmapDecoder
*iface
,
605 IWICBitmapSource
**ppIThumbnail
)
607 TRACE("(%p,%p)\n", iface
, ppIThumbnail
);
608 return WINCODEC_ERR_CODECNOTHUMBNAIL
;
611 static HRESULT WINAPI
IcoDecoder_GetFrameCount(IWICBitmapDecoder
*iface
,
614 IcoDecoder
*This
= impl_from_IWICBitmapDecoder(iface
);
616 if (!pCount
) return E_INVALIDARG
;
618 EnterCriticalSection(&This
->lock
);
619 *pCount
= This
->initialized
? This
->header
.idCount
: 0;
620 LeaveCriticalSection(&This
->lock
);
622 TRACE("(%p) <-- %d\n", iface
, *pCount
);
627 static HRESULT WINAPI
IcoDecoder_GetFrame(IWICBitmapDecoder
*iface
,
628 UINT index
, IWICBitmapFrameDecode
**ppIBitmapFrame
)
630 IcoDecoder
*This
= impl_from_IWICBitmapDecoder(iface
);
631 IcoFrameDecode
*result
=NULL
;
633 ULARGE_INTEGER offset
, length
;
637 IWICStream
*substream
=NULL
;
639 TRACE("(%p,%u,%p)\n", iface
, index
, ppIBitmapFrame
);
641 EnterCriticalSection(&This
->lock
);
643 if (!This
->initialized
)
645 hr
= WINCODEC_ERR_FRAMEMISSING
;
649 if (This
->header
.idCount
< index
)
655 result
= HeapAlloc(GetProcessHeap(), 0, sizeof(IcoFrameDecode
));
662 result
->IWICBitmapFrameDecode_iface
.lpVtbl
= &IcoFrameDecode_Vtbl
;
666 /* read the icon entry */
667 seek
.QuadPart
= sizeof(ICONHEADER
) + sizeof(ICONDIRENTRY
) * index
;
668 hr
= IStream_Seek(This
->stream
, seek
, STREAM_SEEK_SET
, 0);
669 if (FAILED(hr
)) goto fail
;
671 hr
= IStream_Read(This
->stream
, &entry
, sizeof(ICONDIRENTRY
), &bytesread
);
672 if (FAILED(hr
) || bytesread
!= sizeof(ICONDIRENTRY
)) goto fail
;
674 /* create a stream object for this icon */
675 hr
= StreamImpl_Create(&substream
);
676 if (FAILED(hr
)) goto fail
;
678 offset
.QuadPart
= entry
.dwDIBOffset
;
679 length
.QuadPart
= entry
.dwDIBSize
;
680 hr
= IWICStream_InitializeFromIStreamRegion(substream
, This
->stream
, offset
, length
);
681 if (FAILED(hr
)) goto fail
;
683 /* read the bitmapinfo size or magic number */
684 hr
= IWICStream_Read(substream
, &magic
, sizeof(magic
), &bytesread
);
685 if (FAILED(hr
) || bytesread
!= sizeof(magic
)) goto fail
;
687 /* forward to the appropriate decoding function based on the magic number */
690 case sizeof(BITMAPCOREHEADER
):
691 case 64: /* sizeof(BITMAPCOREHEADER2) */
692 case sizeof(BITMAPINFOHEADER
):
693 case sizeof(BITMAPV4HEADER
):
694 case sizeof(BITMAPV5HEADER
):
695 hr
= ReadIcoDib((IStream
*)substream
, result
);
698 hr
= ReadIcoPng((IStream
*)substream
, result
);
701 FIXME("Unrecognized ICO frame magic: %x\n", magic
);
705 if (FAILED(hr
)) goto fail
;
707 *ppIBitmapFrame
= &result
->IWICBitmapFrameDecode_iface
;
709 LeaveCriticalSection(&This
->lock
);
711 IWICStream_Release(substream
);
716 LeaveCriticalSection(&This
->lock
);
717 HeapFree(GetProcessHeap(), 0, result
);
718 if (substream
) IWICStream_Release(substream
);
719 if (SUCCEEDED(hr
)) hr
= E_FAIL
;
720 TRACE("<-- %x\n", hr
);
724 static const IWICBitmapDecoderVtbl IcoDecoder_Vtbl
= {
725 IcoDecoder_QueryInterface
,
728 IcoDecoder_QueryCapability
,
729 IcoDecoder_Initialize
,
730 IcoDecoder_GetContainerFormat
,
731 IcoDecoder_GetDecoderInfo
,
732 IcoDecoder_CopyPalette
,
733 IcoDecoder_GetMetadataQueryReader
,
734 IcoDecoder_GetPreview
,
735 IcoDecoder_GetColorContexts
,
736 IcoDecoder_GetThumbnail
,
737 IcoDecoder_GetFrameCount
,
741 HRESULT
IcoDecoder_CreateInstance(REFIID iid
, void** ppv
)
746 TRACE("(%s,%p)\n", debugstr_guid(iid
), ppv
);
750 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(IcoDecoder
));
751 if (!This
) return E_OUTOFMEMORY
;
753 This
->IWICBitmapDecoder_iface
.lpVtbl
= &IcoDecoder_Vtbl
;
756 This
->initialized
= FALSE
;
757 InitializeCriticalSection(&This
->lock
);
758 This
->lock
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": IcoDecoder.lock");
760 ret
= IWICBitmapDecoder_QueryInterface(&This
->IWICBitmapDecoder_iface
, iid
, ppv
);
761 IWICBitmapDecoder_Release(&This
->IWICBitmapDecoder_iface
);