wininet: Update Lithuanian translation.
[wine/multimedia.git] / dlls / windowscodecs / icoformat.c
blobe6a590fee499cf227c98cf02bba6d9cf416cc0a3
1 /*
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
19 #include "config.h"
21 #include <stdarg.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "wingdi.h"
28 #include "objbase.h"
29 #include "wincodec.h"
31 #include "wincodecs_private.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
37 #include "pshpack1.h"
39 typedef struct {
40 BYTE bWidth;
41 BYTE bHeight;
42 BYTE bColorCount;
43 BYTE bReserved;
44 WORD wPlanes;
45 WORD wBitCount;
46 DWORD dwDIBSize;
47 DWORD dwDIBOffset;
48 } ICONDIRENTRY;
50 typedef struct
52 WORD idReserved;
53 WORD idType;
54 WORD idCount;
55 } ICONHEADER;
57 #include "poppack.h"
59 typedef struct {
60 IWICBitmapDecoder IWICBitmapDecoder_iface;
61 LONG ref;
62 BOOL initialized;
63 IStream *stream;
64 ICONHEADER header;
65 CRITICAL_SECTION lock; /* must be held when accessing stream */
66 } IcoDecoder;
68 typedef struct {
69 IWICBitmapFrameDecode IWICBitmapFrameDecode_iface;
70 LONG ref;
71 UINT width, height;
72 BYTE *bits;
73 } IcoFrameDecode;
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,
86 void **ppv)
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;
99 else
101 *ppv = NULL;
102 return E_NOINTERFACE;
105 IUnknown_AddRef((IUnknown*)*ppv);
106 return S_OK;
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);
116 return 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);
126 if (ref == 0)
128 HeapFree(GetProcessHeap(), 0, This->bits);
129 HeapFree(GetProcessHeap(), 0, This);
132 return ref;
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);
145 return S_OK;
148 static HRESULT WINAPI IcoFrameDecode_GetPixelFormat(IWICBitmapFrameDecode *iface,
149 WICPixelFormatGUID *pPixelFormat)
151 memcpy(pPixelFormat, &GUID_WICPixelFormat32bppBGRA, sizeof(GUID));
152 return S_OK;
155 static HRESULT WINAPI IcoFrameDecode_GetResolution(IWICBitmapFrameDecode *iface,
156 double *pDpiX, double *pDpiY)
158 FIXME("(%p,%p,%p): stub\n", iface, pDpiX, pDpiY);
159 return E_NOTIMPL;
162 static HRESULT WINAPI IcoFrameDecode_CopyPalette(IWICBitmapFrameDecode *iface,
163 IWICPalette *pIPalette)
165 TRACE("(%p,%p)\n", iface, pIPalette);
166 return WINCODEC_ERR_PALETTEUNAVAILABLE;
169 static HRESULT WINAPI IcoFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface,
170 const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
172 IcoFrameDecode *This = impl_from_IWICBitmapFrameDecode(iface);
173 TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer);
175 return copy_pixels(32, This->bits, This->width, This->height, This->width * 4,
176 prc, cbStride, cbBufferSize, pbBuffer);
179 static HRESULT WINAPI IcoFrameDecode_GetMetadataQueryReader(IWICBitmapFrameDecode *iface,
180 IWICMetadataQueryReader **ppIMetadataQueryReader)
182 TRACE("(%p,%p)\n", iface, ppIMetadataQueryReader);
183 return WINCODEC_ERR_UNSUPPORTEDOPERATION;
186 static HRESULT WINAPI IcoFrameDecode_GetColorContexts(IWICBitmapFrameDecode *iface,
187 UINT cCount, IWICColorContext **ppIColorContexts, UINT *pcActualCount)
189 TRACE("(%p,%u,%p,%p)\n", iface, cCount, ppIColorContexts, pcActualCount);
190 return WINCODEC_ERR_UNSUPPORTEDOPERATION;
193 static HRESULT WINAPI IcoFrameDecode_GetThumbnail(IWICBitmapFrameDecode *iface,
194 IWICBitmapSource **ppIThumbnail)
196 TRACE("(%p,%p)\n", iface, ppIThumbnail);
197 return WINCODEC_ERR_CODECNOTHUMBNAIL;
200 static const IWICBitmapFrameDecodeVtbl IcoFrameDecode_Vtbl = {
201 IcoFrameDecode_QueryInterface,
202 IcoFrameDecode_AddRef,
203 IcoFrameDecode_Release,
204 IcoFrameDecode_GetSize,
205 IcoFrameDecode_GetPixelFormat,
206 IcoFrameDecode_GetResolution,
207 IcoFrameDecode_CopyPalette,
208 IcoFrameDecode_CopyPixels,
209 IcoFrameDecode_GetMetadataQueryReader,
210 IcoFrameDecode_GetColorContexts,
211 IcoFrameDecode_GetThumbnail
214 static inline void pixel_set_trans(DWORD* pixel, BOOL transparent)
216 if (transparent) *pixel = 0;
217 else *pixel |= 0xff000000;
220 static HRESULT ReadIcoDib(IStream *stream, IcoFrameDecode *result)
222 HRESULT hr;
223 IWICBitmapDecoder *decoder;
224 IWICBitmapFrameDecode *framedecode;
225 WICPixelFormatGUID pixelformat;
226 IWICBitmapSource *source;
227 int has_alpha=FALSE; /* if TRUE, alpha data might be in the image data */
228 WICRect rc;
230 hr = IcoDibDecoder_CreateInstance(NULL, &IID_IWICBitmapDecoder, (void**)&decoder);
231 if (SUCCEEDED(hr))
233 hr = IWICBitmapDecoder_Initialize(decoder, stream, WICDecodeMetadataCacheOnLoad);
235 if (SUCCEEDED(hr))
236 hr = IWICBitmapDecoder_GetFrame(decoder, 0, &framedecode);
238 if (SUCCEEDED(hr))
240 hr = IWICBitmapFrameDecode_GetSize(framedecode, &result->width, &result->height);
242 if (SUCCEEDED(hr))
244 result->bits = HeapAlloc(GetProcessHeap(), 0, result->width * result->height * 4);
245 if (!result->bits) hr = E_OUTOFMEMORY;
248 if (SUCCEEDED(hr))
249 hr = IWICBitmapFrameDecode_GetPixelFormat(framedecode, &pixelformat);
251 if (IsEqualGUID(&pixelformat, &GUID_WICPixelFormat32bppBGR) ||
252 IsEqualGUID(&pixelformat, &GUID_WICPixelFormat32bppBGRA))
254 source = (IWICBitmapSource*)framedecode;
255 IWICBitmapSource_AddRef(source);
256 has_alpha = TRUE;
258 else
260 hr = WICConvertBitmapSource(&GUID_WICPixelFormat32bppBGRA,
261 (IWICBitmapSource*)framedecode, &source);
262 has_alpha = FALSE;
265 if (SUCCEEDED(hr))
267 rc.X = 0;
268 rc.Y = 0;
269 rc.Width = result->width;
270 rc.Height = result->height;
271 hr = IWICBitmapSource_CopyPixels(source, &rc, result->width * 4,
272 result->width * result->height * 4, result->bits);
274 IWICBitmapSource_Release(source);
277 IWICBitmapFrameDecode_Release(framedecode);
280 if (SUCCEEDED(hr) && !has_alpha)
282 /* set alpha data based on the AND mask */
283 UINT andBytesPerRow = (result->width+31)/32*4;
284 UINT andBytes = andBytesPerRow * result->height;
285 INT andStride;
286 BYTE *tempdata=NULL;
287 BYTE *andRow;
288 BYTE *bitsRow;
289 UINT bitsStride = result->width * 4;
290 UINT x, y;
291 ULONG offset;
292 ULONG bytesread;
293 LARGE_INTEGER seek;
294 int topdown;
296 BmpDecoder_FindIconMask(decoder, &offset, &topdown);
298 if (offset)
300 seek.QuadPart = offset;
302 hr = IStream_Seek(stream, seek, STREAM_SEEK_SET, 0);
304 if (SUCCEEDED(hr))
306 tempdata = HeapAlloc(GetProcessHeap(), 0, andBytes);
307 if (!tempdata) hr = E_OUTOFMEMORY;
310 if (SUCCEEDED(hr))
311 hr = IStream_Read(stream, tempdata, andBytes, &bytesread);
313 if (SUCCEEDED(hr) && bytesread == andBytes)
315 if (topdown)
317 andStride = andBytesPerRow;
318 andRow = tempdata;
320 else
322 andStride = -andBytesPerRow;
323 andRow = tempdata + (result->height-1)*andBytesPerRow;
326 bitsRow = result->bits;
327 for (y=0; y<result->height; y++) {
328 BYTE *andByte=andRow;
329 DWORD *bitsPixel=(DWORD*)bitsRow;
330 for (x=0; x<result->width; x+=8) {
331 BYTE andVal=*andByte++;
332 pixel_set_trans(bitsPixel++, andVal>>7&1);
333 if (x+1 < result->width) pixel_set_trans(bitsPixel++, andVal>>6&1);
334 if (x+2 < result->width) pixel_set_trans(bitsPixel++, andVal>>5&1);
335 if (x+3 < result->width) pixel_set_trans(bitsPixel++, andVal>>4&1);
336 if (x+4 < result->width) pixel_set_trans(bitsPixel++, andVal>>3&1);
337 if (x+5 < result->width) pixel_set_trans(bitsPixel++, andVal>>2&1);
338 if (x+6 < result->width) pixel_set_trans(bitsPixel++, andVal>>1&1);
339 if (x+7 < result->width) pixel_set_trans(bitsPixel++, andVal&1);
341 andRow += andStride;
342 bitsRow += bitsStride;
346 HeapFree(GetProcessHeap(), 0, tempdata);
350 IWICBitmapDecoder_Release(decoder);
353 return hr;
356 static HRESULT ReadIcoPng(IStream *stream, IcoFrameDecode *result)
358 IWICBitmapDecoder *decoder = NULL;
359 IWICBitmapFrameDecode *sourceFrame = NULL;
360 IWICBitmapSource *sourceBitmap = NULL;
361 WICRect rect;
362 HRESULT hr;
364 hr = PngDecoder_CreateInstance(NULL, &IID_IWICBitmapDecoder, (void**)&decoder);
365 if (FAILED(hr))
366 goto end;
367 hr = IWICBitmapDecoder_Initialize(decoder, stream, WICDecodeMetadataCacheOnLoad);
368 if (FAILED(hr))
369 goto end;
370 hr = IWICBitmapDecoder_GetFrame(decoder, 0, &sourceFrame);
371 if (FAILED(hr))
372 goto end;
373 hr = WICConvertBitmapSource(&GUID_WICPixelFormat32bppBGRA, (IWICBitmapSource*)sourceFrame, &sourceBitmap);
374 if (FAILED(hr))
375 goto end;
376 hr = IWICBitmapFrameDecode_GetSize(sourceFrame, &result->width, &result->height);
377 if (FAILED(hr))
378 goto end;
379 result->bits = HeapAlloc(GetProcessHeap(), 0, 4 * result->width * result->height);
380 if (result->bits == NULL)
382 hr = E_OUTOFMEMORY;
383 goto end;
385 rect.X = 0;
386 rect.Y = 0;
387 rect.Width = result->width;
388 rect.Height = result->height;
389 hr = IWICBitmapSource_CopyPixels(sourceBitmap, &rect, 4*result->width,
390 4*result->width*result->height, result->bits);
392 end:
393 if (decoder != NULL)
394 IWICBitmapDecoder_Release(decoder);
395 if (sourceFrame != NULL)
396 IWICBitmapFrameDecode_Release(sourceFrame);
397 if (sourceBitmap != NULL)
398 IWICBitmapSource_Release(sourceBitmap);
399 return hr;
402 static HRESULT WINAPI IcoDecoder_QueryInterface(IWICBitmapDecoder *iface, REFIID iid,
403 void **ppv)
405 IcoDecoder *This = impl_from_IWICBitmapDecoder(iface);
406 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
408 if (!ppv) return E_INVALIDARG;
410 if (IsEqualIID(&IID_IUnknown, iid) || IsEqualIID(&IID_IWICBitmapDecoder, iid))
412 *ppv = This;
414 else
416 *ppv = NULL;
417 return E_NOINTERFACE;
420 IUnknown_AddRef((IUnknown*)*ppv);
421 return S_OK;
424 static ULONG WINAPI IcoDecoder_AddRef(IWICBitmapDecoder *iface)
426 IcoDecoder *This = impl_from_IWICBitmapDecoder(iface);
427 ULONG ref = InterlockedIncrement(&This->ref);
429 TRACE("(%p) refcount=%u\n", iface, ref);
431 return ref;
434 static ULONG WINAPI IcoDecoder_Release(IWICBitmapDecoder *iface)
436 IcoDecoder *This = impl_from_IWICBitmapDecoder(iface);
437 ULONG ref = InterlockedDecrement(&This->ref);
439 TRACE("(%p) refcount=%u\n", iface, ref);
441 if (ref == 0)
443 This->lock.DebugInfo->Spare[0] = 0;
444 DeleteCriticalSection(&This->lock);
445 if (This->stream) IStream_Release(This->stream);
446 HeapFree(GetProcessHeap(), 0, This);
449 return ref;
452 static HRESULT WINAPI IcoDecoder_QueryCapability(IWICBitmapDecoder *iface, IStream *pIStream,
453 DWORD *pdwCapability)
455 FIXME("(%p,%p,%p): stub\n", iface, pIStream, pdwCapability);
456 return E_NOTIMPL;
459 static HRESULT WINAPI IcoDecoder_Initialize(IWICBitmapDecoder *iface, IStream *pIStream,
460 WICDecodeOptions cacheOptions)
462 IcoDecoder *This = impl_from_IWICBitmapDecoder(iface);
463 LARGE_INTEGER seek;
464 HRESULT hr;
465 ULONG bytesread;
466 TRACE("(%p,%p,%x)\n", iface, pIStream, cacheOptions);
468 EnterCriticalSection(&This->lock);
470 if (This->initialized)
472 hr = WINCODEC_ERR_WRONGSTATE;
473 goto end;
476 seek.QuadPart = 0;
477 hr = IStream_Seek(pIStream, seek, STREAM_SEEK_SET, NULL);
478 if (FAILED(hr)) goto end;
480 hr = IStream_Read(pIStream, &This->header, sizeof(ICONHEADER), &bytesread);
481 if (FAILED(hr)) goto end;
482 if (bytesread != sizeof(ICONHEADER) ||
483 This->header.idReserved != 0 ||
484 This->header.idType != 1)
486 hr = E_FAIL;
487 goto end;
490 This->initialized = TRUE;
491 This->stream = pIStream;
492 IStream_AddRef(pIStream);
494 end:
496 LeaveCriticalSection(&This->lock);
498 return hr;
501 static HRESULT WINAPI IcoDecoder_GetContainerFormat(IWICBitmapDecoder *iface,
502 GUID *pguidContainerFormat)
504 FIXME("(%p,%p): stub\n", iface, pguidContainerFormat);
505 return E_NOTIMPL;
508 static HRESULT WINAPI IcoDecoder_GetDecoderInfo(IWICBitmapDecoder *iface,
509 IWICBitmapDecoderInfo **ppIDecoderInfo)
511 FIXME("(%p,%p): stub\n", iface, ppIDecoderInfo);
512 return E_NOTIMPL;
515 static HRESULT WINAPI IcoDecoder_CopyPalette(IWICBitmapDecoder *iface,
516 IWICPalette *pIPalette)
518 TRACE("(%p,%p)\n", iface, pIPalette);
519 return WINCODEC_ERR_PALETTEUNAVAILABLE;
522 static HRESULT WINAPI IcoDecoder_GetMetadataQueryReader(IWICBitmapDecoder *iface,
523 IWICMetadataQueryReader **ppIMetadataQueryReader)
525 TRACE("(%p,%p)\n", iface, ppIMetadataQueryReader);
526 return WINCODEC_ERR_UNSUPPORTEDOPERATION;
529 static HRESULT WINAPI IcoDecoder_GetPreview(IWICBitmapDecoder *iface,
530 IWICBitmapSource **ppIBitmapSource)
532 TRACE("(%p,%p)\n", iface, ppIBitmapSource);
533 return WINCODEC_ERR_UNSUPPORTEDOPERATION;
536 static HRESULT WINAPI IcoDecoder_GetColorContexts(IWICBitmapDecoder *iface,
537 UINT cCount, IWICColorContext **ppIColorContexts, UINT *pcActualCount)
539 TRACE("(%p,%u,%p,%p)\n", iface, cCount, ppIColorContexts, pcActualCount);
540 return WINCODEC_ERR_UNSUPPORTEDOPERATION;
543 static HRESULT WINAPI IcoDecoder_GetThumbnail(IWICBitmapDecoder *iface,
544 IWICBitmapSource **ppIThumbnail)
546 TRACE("(%p,%p)\n", iface, ppIThumbnail);
547 return WINCODEC_ERR_CODECNOTHUMBNAIL;
550 static HRESULT WINAPI IcoDecoder_GetFrameCount(IWICBitmapDecoder *iface,
551 UINT *pCount)
553 IcoDecoder *This = impl_from_IWICBitmapDecoder(iface);
554 TRACE("(%p,%p)\n", iface, pCount);
556 if (!This->initialized) return WINCODEC_ERR_NOTINITIALIZED;
558 *pCount = This->header.idCount;
559 TRACE("<-- %u\n", *pCount);
561 return S_OK;
564 static HRESULT WINAPI IcoDecoder_GetFrame(IWICBitmapDecoder *iface,
565 UINT index, IWICBitmapFrameDecode **ppIBitmapFrame)
567 IcoDecoder *This = impl_from_IWICBitmapDecoder(iface);
568 IcoFrameDecode *result=NULL;
569 LARGE_INTEGER seek;
570 ULARGE_INTEGER offset, length;
571 HRESULT hr;
572 ULONG bytesread;
573 ICONDIRENTRY entry;
574 IWICStream *substream=NULL;
575 DWORD magic;
576 TRACE("(%p,%u,%p)\n", iface, index, ppIBitmapFrame);
578 EnterCriticalSection(&This->lock);
580 if (!This->initialized)
582 hr = WINCODEC_ERR_NOTINITIALIZED;
583 goto fail;
586 if (This->header.idCount < index)
588 hr = E_INVALIDARG;
589 goto fail;
592 result = HeapAlloc(GetProcessHeap(), 0, sizeof(IcoFrameDecode));
593 if (!result)
595 hr = E_OUTOFMEMORY;
596 goto fail;
599 result->IWICBitmapFrameDecode_iface.lpVtbl = &IcoFrameDecode_Vtbl;
600 result->ref = 1;
601 result->bits = NULL;
603 /* read the icon entry */
604 seek.QuadPart = sizeof(ICONHEADER) + sizeof(ICONDIRENTRY) * index;
605 hr = IStream_Seek(This->stream, seek, STREAM_SEEK_SET, 0);
606 if (FAILED(hr)) goto fail;
608 hr = IStream_Read(This->stream, &entry, sizeof(ICONDIRENTRY), &bytesread);
609 if (FAILED(hr) || bytesread != sizeof(ICONDIRENTRY)) goto fail;
611 /* create a stream object for this icon */
612 hr = StreamImpl_Create(&substream);
613 if (FAILED(hr)) goto fail;
615 offset.QuadPart = entry.dwDIBOffset;
616 length.QuadPart = entry.dwDIBSize;
617 hr = IWICStream_InitializeFromIStreamRegion(substream, This->stream, offset, length);
618 if (FAILED(hr)) goto fail;
620 /* read the bitmapinfo size or magic number */
621 hr = IWICStream_Read(substream, &magic, sizeof(magic), &bytesread);
622 if (FAILED(hr) || bytesread != sizeof(magic)) goto fail;
624 /* forward to the appropriate decoding function based on the magic number */
625 switch (magic)
627 case sizeof(BITMAPCOREHEADER):
628 case 64: /* sizeof(BITMAPCOREHEADER2) */
629 case sizeof(BITMAPINFOHEADER):
630 case sizeof(BITMAPV4HEADER):
631 case sizeof(BITMAPV5HEADER):
632 hr = ReadIcoDib((IStream*)substream, result);
633 break;
634 case 0x474e5089:
635 hr = ReadIcoPng((IStream*)substream, result);
636 break;
637 default:
638 FIXME("Unrecognized ICO frame magic: %x\n", magic);
639 hr = E_FAIL;
640 break;
642 if (FAILED(hr)) goto fail;
644 *ppIBitmapFrame = (IWICBitmapFrameDecode*)result;
646 LeaveCriticalSection(&This->lock);
648 return S_OK;
650 fail:
651 LeaveCriticalSection(&This->lock);
652 HeapFree(GetProcessHeap(), 0, result);
653 if (substream) IStream_Release(substream);
654 if (SUCCEEDED(hr)) hr = E_FAIL;
655 TRACE("<-- %x\n", hr);
656 return hr;
659 static const IWICBitmapDecoderVtbl IcoDecoder_Vtbl = {
660 IcoDecoder_QueryInterface,
661 IcoDecoder_AddRef,
662 IcoDecoder_Release,
663 IcoDecoder_QueryCapability,
664 IcoDecoder_Initialize,
665 IcoDecoder_GetContainerFormat,
666 IcoDecoder_GetDecoderInfo,
667 IcoDecoder_CopyPalette,
668 IcoDecoder_GetMetadataQueryReader,
669 IcoDecoder_GetPreview,
670 IcoDecoder_GetColorContexts,
671 IcoDecoder_GetThumbnail,
672 IcoDecoder_GetFrameCount,
673 IcoDecoder_GetFrame
676 HRESULT IcoDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
678 IcoDecoder *This;
679 HRESULT ret;
681 TRACE("(%p,%s,%p)\n", pUnkOuter, debugstr_guid(iid), ppv);
683 *ppv = NULL;
685 if (pUnkOuter) return CLASS_E_NOAGGREGATION;
687 This = HeapAlloc(GetProcessHeap(), 0, sizeof(IcoDecoder));
688 if (!This) return E_OUTOFMEMORY;
690 This->IWICBitmapDecoder_iface.lpVtbl = &IcoDecoder_Vtbl;
691 This->ref = 1;
692 This->stream = NULL;
693 This->initialized = FALSE;
694 InitializeCriticalSection(&This->lock);
695 This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IcoDecoder.lock");
697 ret = IUnknown_QueryInterface((IUnknown*)This, iid, ppv);
698 IUnknown_Release((IUnknown*)This);
700 return ret;