msvcrt: Move btowc implementation to mbcs.c file.
[wine.git] / dlls / windowscodecs / icnsformat.c
blobc74e4b24d713971b43825a185dfce51968f6e475
1 /*
2 * Copyright 2010 Damjan Jovanovic
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"
20 #include "wine/port.h"
22 #include <stdarg.h>
24 #ifdef HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H
25 #define GetCurrentProcess GetCurrentProcess_Mac
26 #define GetCurrentThread GetCurrentThread_Mac
27 #define LoadResource LoadResource_Mac
28 #define AnimatePalette AnimatePalette_Mac
29 #define EqualRgn EqualRgn_Mac
30 #define FillRgn FillRgn_Mac
31 #define FrameRgn FrameRgn_Mac
32 #define GetPixel GetPixel_Mac
33 #define InvertRgn InvertRgn_Mac
34 #define LineTo LineTo_Mac
35 #define OffsetRgn OffsetRgn_Mac
36 #define PaintRgn PaintRgn_Mac
37 #define Polygon Polygon_Mac
38 #define ResizePalette ResizePalette_Mac
39 #define SetRectRgn SetRectRgn_Mac
40 #define EqualRect EqualRect_Mac
41 #define FillRect FillRect_Mac
42 #define FrameRect FrameRect_Mac
43 #define GetCursor GetCursor_Mac
44 #define InvertRect InvertRect_Mac
45 #define OffsetRect OffsetRect_Mac
46 #define PtInRect PtInRect_Mac
47 #define SetCursor SetCursor_Mac
48 #define SetRect SetRect_Mac
49 #define ShowCursor ShowCursor_Mac
50 #define UnionRect UnionRect_Mac
51 #include <ApplicationServices/ApplicationServices.h>
52 #undef GetCurrentProcess
53 #undef GetCurrentThread
54 #undef LoadResource
55 #undef AnimatePalette
56 #undef EqualRgn
57 #undef FillRgn
58 #undef FrameRgn
59 #undef GetPixel
60 #undef InvertRgn
61 #undef LineTo
62 #undef OffsetRgn
63 #undef PaintRgn
64 #undef Polygon
65 #undef ResizePalette
66 #undef SetRectRgn
67 #undef EqualRect
68 #undef FillRect
69 #undef FrameRect
70 #undef GetCursor
71 #undef InvertRect
72 #undef OffsetRect
73 #undef PtInRect
74 #undef SetCursor
75 #undef SetRect
76 #undef ShowCursor
77 #undef UnionRect
78 #endif
80 #define COBJMACROS
82 #include "windef.h"
83 #include "winbase.h"
84 #include "objbase.h"
86 #include "wincodecs_private.h"
88 #include "wine/debug.h"
90 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
92 #if defined(HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H) && \
93 MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_4
95 typedef struct IcnsEncoder {
96 IWICBitmapEncoder IWICBitmapEncoder_iface;
97 LONG ref;
98 IStream *stream;
99 IconFamilyHandle icns_family;
100 BOOL any_frame_committed;
101 int outstanding_commits;
102 BOOL committed;
103 CRITICAL_SECTION lock;
104 } IcnsEncoder;
106 static inline IcnsEncoder *impl_from_IWICBitmapEncoder(IWICBitmapEncoder *iface)
108 return CONTAINING_RECORD(iface, IcnsEncoder, IWICBitmapEncoder_iface);
111 typedef struct IcnsFrameEncode {
112 IWICBitmapFrameEncode IWICBitmapFrameEncode_iface;
113 IcnsEncoder *encoder;
114 LONG ref;
115 BOOL initialized;
116 UINT size;
117 OSType icns_type;
118 BYTE* icns_image;
119 int lines_written;
120 BOOL committed;
121 } IcnsFrameEncode;
123 static inline IcnsFrameEncode *impl_from_IWICBitmapFrameEncode(IWICBitmapFrameEncode *iface)
125 return CONTAINING_RECORD(iface, IcnsFrameEncode, IWICBitmapFrameEncode_iface);
128 static HRESULT WINAPI IcnsFrameEncode_QueryInterface(IWICBitmapFrameEncode *iface, REFIID iid,
129 void **ppv)
131 IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
132 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
134 if (!ppv) return E_INVALIDARG;
136 if (IsEqualIID(&IID_IUnknown, iid) ||
137 IsEqualIID(&IID_IWICBitmapFrameEncode, iid))
139 *ppv = &This->IWICBitmapFrameEncode_iface;
141 else
143 *ppv = NULL;
144 return E_NOINTERFACE;
147 IUnknown_AddRef((IUnknown*)*ppv);
148 return S_OK;
151 static ULONG WINAPI IcnsFrameEncode_AddRef(IWICBitmapFrameEncode *iface)
153 IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
154 ULONG ref = InterlockedIncrement(&This->ref);
156 TRACE("(%p) refcount=%u\n", iface, ref);
158 return ref;
161 static ULONG WINAPI IcnsFrameEncode_Release(IWICBitmapFrameEncode *iface)
163 IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
164 ULONG ref = InterlockedDecrement(&This->ref);
166 TRACE("(%p) refcount=%u\n", iface, ref);
168 if (ref == 0)
170 if (!This->committed)
172 EnterCriticalSection(&This->encoder->lock);
173 This->encoder->outstanding_commits--;
174 LeaveCriticalSection(&This->encoder->lock);
176 HeapFree(GetProcessHeap(), 0, This->icns_image);
178 IWICBitmapEncoder_Release(&This->encoder->IWICBitmapEncoder_iface);
179 HeapFree(GetProcessHeap(), 0, This);
182 return ref;
185 static HRESULT WINAPI IcnsFrameEncode_Initialize(IWICBitmapFrameEncode *iface,
186 IPropertyBag2 *pIEncoderOptions)
188 IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
189 HRESULT hr = S_OK;
191 TRACE("(%p,%p)\n", iface, pIEncoderOptions);
193 EnterCriticalSection(&This->encoder->lock);
195 if (This->initialized)
197 hr = WINCODEC_ERR_WRONGSTATE;
198 goto end;
200 This->initialized = TRUE;
202 end:
203 LeaveCriticalSection(&This->encoder->lock);
204 return hr;
207 static HRESULT WINAPI IcnsFrameEncode_SetSize(IWICBitmapFrameEncode *iface,
208 UINT uiWidth, UINT uiHeight)
210 IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
211 HRESULT hr = S_OK;
213 TRACE("(%p,%u,%u)\n", iface, uiWidth, uiHeight);
215 EnterCriticalSection(&This->encoder->lock);
217 if (!This->initialized || This->icns_image)
219 hr = WINCODEC_ERR_WRONGSTATE;
220 goto end;
223 if (uiWidth != uiHeight)
225 WARN("cannot generate ICNS icon from %dx%d image\n", uiWidth, uiHeight);
226 hr = E_INVALIDARG;
227 goto end;
230 switch (uiWidth)
232 case 16:
233 case 32:
234 case 48:
235 case 128:
236 case 256:
237 case 512:
238 break;
239 default:
240 WARN("cannot generate ICNS icon from %dx%d image\n", This->size, This->size);
241 hr = E_INVALIDARG;
242 goto end;
245 This->size = uiWidth;
247 end:
248 LeaveCriticalSection(&This->encoder->lock);
249 return hr;
252 static HRESULT WINAPI IcnsFrameEncode_SetResolution(IWICBitmapFrameEncode *iface,
253 double dpiX, double dpiY)
255 IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
256 HRESULT hr = S_OK;
258 TRACE("(%p,%0.2f,%0.2f)\n", iface, dpiX, dpiY);
260 EnterCriticalSection(&This->encoder->lock);
262 if (!This->initialized || This->icns_image)
264 hr = WINCODEC_ERR_WRONGSTATE;
265 goto end;
268 end:
269 LeaveCriticalSection(&This->encoder->lock);
270 return S_OK;
273 static HRESULT WINAPI IcnsFrameEncode_SetPixelFormat(IWICBitmapFrameEncode *iface,
274 WICPixelFormatGUID *pPixelFormat)
276 IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
277 HRESULT hr = S_OK;
279 TRACE("(%p,%s)\n", iface, debugstr_guid(pPixelFormat));
281 EnterCriticalSection(&This->encoder->lock);
283 if (!This->initialized || This->icns_image)
285 hr = WINCODEC_ERR_WRONGSTATE;
286 goto end;
289 memcpy(pPixelFormat, &GUID_WICPixelFormat32bppBGRA, sizeof(GUID));
291 end:
292 LeaveCriticalSection(&This->encoder->lock);
293 return S_OK;
296 static HRESULT WINAPI IcnsFrameEncode_SetColorContexts(IWICBitmapFrameEncode *iface,
297 UINT cCount, IWICColorContext **ppIColorContext)
299 FIXME("(%p,%u,%p): stub\n", iface, cCount, ppIColorContext);
300 return E_NOTIMPL;
303 static HRESULT WINAPI IcnsFrameEncode_SetPalette(IWICBitmapFrameEncode *iface,
304 IWICPalette *pIPalette)
306 FIXME("(%p,%p): stub\n", iface, pIPalette);
307 return WINCODEC_ERR_UNSUPPORTEDOPERATION;
310 static HRESULT WINAPI IcnsFrameEncode_SetThumbnail(IWICBitmapFrameEncode *iface,
311 IWICBitmapSource *pIThumbnail)
313 FIXME("(%p,%p): stub\n", iface, pIThumbnail);
314 return WINCODEC_ERR_UNSUPPORTEDOPERATION;
317 static HRESULT WINAPI IcnsFrameEncode_WritePixels(IWICBitmapFrameEncode *iface,
318 UINT lineCount, UINT cbStride, UINT cbBufferSize, BYTE *pbPixels)
320 IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
321 HRESULT hr = S_OK;
322 UINT i;
324 TRACE("(%p,%u,%u,%u,%p)\n", iface, lineCount, cbStride, cbBufferSize, pbPixels);
326 EnterCriticalSection(&This->encoder->lock);
328 if (!This->initialized || !This->size)
330 hr = WINCODEC_ERR_WRONGSTATE;
331 goto end;
333 if (lineCount == 0 || lineCount + This->lines_written > This->size)
335 hr = E_INVALIDARG;
336 goto end;
339 if (!This->icns_image)
341 switch (This->size)
343 case 16: This->icns_type = kIconServices16PixelDataARGB; break;
344 case 32: This->icns_type = kIconServices32PixelDataARGB; break;
345 case 48: This->icns_type = kIconServices48PixelDataARGB; break;
346 case 128: This->icns_type = kIconServices128PixelDataARGB; break;
347 case 256: This->icns_type = kIconServices256PixelDataARGB; break;
348 case 512: This->icns_type = kIconServices512PixelDataARGB; break;
349 default:
350 WARN("cannot generate ICNS icon from %dx%d image\n", This->size, This->size);
351 hr = E_INVALIDARG;
352 goto end;
354 This->icns_image = HeapAlloc(GetProcessHeap(), 0, This->size * This->size * 4);
355 if (!This->icns_image)
357 WARN("failed to allocate image buffer\n");
358 hr = E_FAIL;
359 goto end;
363 for (i = 0; i < lineCount; i++)
365 BYTE *src_row, *dst_row;
366 UINT j;
367 src_row = pbPixels + cbStride * i;
368 dst_row = This->icns_image + (This->lines_written + i)*(This->size*4);
369 /* swap bgr -> rgb */
370 for (j = 0; j < This->size*4; j += 4)
372 dst_row[j] = src_row[j+3];
373 dst_row[j+1] = src_row[j+2];
374 dst_row[j+2] = src_row[j+1];
375 dst_row[j+3] = src_row[j];
378 This->lines_written += lineCount;
380 end:
381 LeaveCriticalSection(&This->encoder->lock);
382 return hr;
385 static HRESULT WINAPI IcnsFrameEncode_WriteSource(IWICBitmapFrameEncode *iface,
386 IWICBitmapSource *pIBitmapSource, WICRect *prc)
388 IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
389 HRESULT hr;
391 TRACE("(%p,%p,%s)\n", iface, pIBitmapSource, debug_wic_rect(prc));
393 if (!This->initialized)
394 return WINCODEC_ERR_WRONGSTATE;
396 hr = configure_write_source(iface, pIBitmapSource, prc,
397 &GUID_WICPixelFormat32bppBGRA, This->size, This->size,
398 1.0, 1.0);
400 if (SUCCEEDED(hr))
402 hr = write_source(iface, pIBitmapSource, prc,
403 &GUID_WICPixelFormat32bppBGRA, 32, FALSE, This->size, This->size);
406 return hr;
409 static HRESULT WINAPI IcnsFrameEncode_Commit(IWICBitmapFrameEncode *iface)
411 IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
412 Handle handle;
413 OSErr ret;
414 HRESULT hr = S_OK;
416 TRACE("(%p)\n", iface);
418 EnterCriticalSection(&This->encoder->lock);
420 if (!This->icns_image || This->lines_written != This->size || This->committed)
422 hr = WINCODEC_ERR_WRONGSTATE;
423 goto end;
426 ret = PtrToHand(This->icns_image, &handle, This->size * This->size * 4);
427 if (ret != noErr || !handle)
429 WARN("PtrToHand failed with error %d\n", ret);
430 hr = E_FAIL;
431 goto end;
434 ret = SetIconFamilyData(This->encoder->icns_family, This->icns_type, handle);
435 DisposeHandle(handle);
437 if (ret != noErr)
439 WARN("SetIconFamilyData failed for image with error %d\n", ret);
440 hr = E_FAIL;
441 goto end;
444 This->committed = TRUE;
445 This->encoder->any_frame_committed = TRUE;
446 This->encoder->outstanding_commits--;
448 end:
449 LeaveCriticalSection(&This->encoder->lock);
450 return hr;
453 static HRESULT WINAPI IcnsFrameEncode_GetMetadataQueryWriter(IWICBitmapFrameEncode *iface,
454 IWICMetadataQueryWriter **ppIMetadataQueryWriter)
456 FIXME("(%p, %p): stub\n", iface, ppIMetadataQueryWriter);
457 return E_NOTIMPL;
460 static const IWICBitmapFrameEncodeVtbl IcnsEncoder_FrameVtbl = {
461 IcnsFrameEncode_QueryInterface,
462 IcnsFrameEncode_AddRef,
463 IcnsFrameEncode_Release,
464 IcnsFrameEncode_Initialize,
465 IcnsFrameEncode_SetSize,
466 IcnsFrameEncode_SetResolution,
467 IcnsFrameEncode_SetPixelFormat,
468 IcnsFrameEncode_SetColorContexts,
469 IcnsFrameEncode_SetPalette,
470 IcnsFrameEncode_SetThumbnail,
471 IcnsFrameEncode_WritePixels,
472 IcnsFrameEncode_WriteSource,
473 IcnsFrameEncode_Commit,
474 IcnsFrameEncode_GetMetadataQueryWriter
477 static HRESULT WINAPI IcnsEncoder_QueryInterface(IWICBitmapEncoder *iface, REFIID iid,
478 void **ppv)
480 IcnsEncoder *This = impl_from_IWICBitmapEncoder(iface);
481 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
483 if (!ppv) return E_INVALIDARG;
485 if (IsEqualIID(&IID_IUnknown, iid) ||
486 IsEqualIID(&IID_IWICBitmapEncoder, iid))
488 *ppv = &This->IWICBitmapEncoder_iface;
490 else
492 *ppv = NULL;
493 return E_NOINTERFACE;
496 IUnknown_AddRef((IUnknown*)*ppv);
497 return S_OK;
500 static ULONG WINAPI IcnsEncoder_AddRef(IWICBitmapEncoder *iface)
502 IcnsEncoder *This = impl_from_IWICBitmapEncoder(iface);
503 ULONG ref = InterlockedIncrement(&This->ref);
505 TRACE("(%p) refcount=%u\n", iface, ref);
507 return ref;
510 static ULONG WINAPI IcnsEncoder_Release(IWICBitmapEncoder *iface)
512 IcnsEncoder *This = impl_from_IWICBitmapEncoder(iface);
513 ULONG ref = InterlockedDecrement(&This->ref);
515 TRACE("(%p) refcount=%u\n", iface, ref);
517 if (ref == 0)
519 This->lock.DebugInfo->Spare[0] = 0;
520 DeleteCriticalSection(&This->lock);
521 if (This->icns_family)
522 DisposeHandle((Handle)This->icns_family);
523 if (This->stream)
524 IStream_Release(This->stream);
525 HeapFree(GetProcessHeap(), 0, This);
528 return ref;
531 static HRESULT WINAPI IcnsEncoder_Initialize(IWICBitmapEncoder *iface,
532 IStream *pIStream, WICBitmapEncoderCacheOption cacheOption)
534 IcnsEncoder *This = impl_from_IWICBitmapEncoder(iface);
535 HRESULT hr = S_OK;
537 TRACE("(%p,%p,%u)\n", iface, pIStream, cacheOption);
539 EnterCriticalSection(&This->lock);
541 if (This->icns_family)
543 hr = WINCODEC_ERR_WRONGSTATE;
544 goto end;
546 This->icns_family = (IconFamilyHandle)NewHandle(0);
547 if (!This->icns_family)
549 WARN("error creating icns family\n");
550 hr = E_FAIL;
551 goto end;
553 IStream_AddRef(pIStream);
554 This->stream = pIStream;
556 end:
557 LeaveCriticalSection(&This->lock);
559 return hr;
562 static HRESULT WINAPI IcnsEncoder_GetContainerFormat(IWICBitmapEncoder *iface,
563 GUID *pguidContainerFormat)
565 FIXME("(%p,%s): stub\n", iface, debugstr_guid(pguidContainerFormat));
566 return E_NOTIMPL;
569 static HRESULT WINAPI IcnsEncoder_GetEncoderInfo(IWICBitmapEncoder *iface,
570 IWICBitmapEncoderInfo **ppIEncoderInfo)
572 FIXME("(%p,%p): stub\n", iface, ppIEncoderInfo);
573 return E_NOTIMPL;
576 static HRESULT WINAPI IcnsEncoder_SetColorContexts(IWICBitmapEncoder *iface,
577 UINT cCount, IWICColorContext **ppIColorContext)
579 FIXME("(%p,%u,%p): stub\n", iface, cCount, ppIColorContext);
580 return E_NOTIMPL;
583 static HRESULT WINAPI IcnsEncoder_SetPalette(IWICBitmapEncoder *iface, IWICPalette *pIPalette)
585 TRACE("(%p,%p)\n", iface, pIPalette);
586 return WINCODEC_ERR_UNSUPPORTEDOPERATION;
589 static HRESULT WINAPI IcnsEncoder_SetThumbnail(IWICBitmapEncoder *iface, IWICBitmapSource *pIThumbnail)
591 TRACE("(%p,%p)\n", iface, pIThumbnail);
592 return WINCODEC_ERR_UNSUPPORTEDOPERATION;
595 static HRESULT WINAPI IcnsEncoder_SetPreview(IWICBitmapEncoder *iface, IWICBitmapSource *pIPreview)
597 TRACE("(%p,%p)\n", iface, pIPreview);
598 return WINCODEC_ERR_UNSUPPORTEDOPERATION;
601 static HRESULT WINAPI IcnsEncoder_CreateNewFrame(IWICBitmapEncoder *iface,
602 IWICBitmapFrameEncode **ppIFrameEncode, IPropertyBag2 **ppIEncoderOptions)
604 IcnsEncoder *This = impl_from_IWICBitmapEncoder(iface);
605 HRESULT hr = S_OK;
606 IcnsFrameEncode *frameEncode = NULL;
608 TRACE("(%p,%p,%p)\n", iface, ppIFrameEncode, ppIEncoderOptions);
610 EnterCriticalSection(&This->lock);
612 if (!This->icns_family)
614 hr = WINCODEC_ERR_NOTINITIALIZED;
615 goto end;
618 if (ppIEncoderOptions)
620 hr = CreatePropertyBag2(NULL, 0, ppIEncoderOptions);
621 if (FAILED(hr))
622 goto end;
625 frameEncode = HeapAlloc(GetProcessHeap(), 0, sizeof(IcnsFrameEncode));
626 if (frameEncode == NULL)
628 hr = E_OUTOFMEMORY;
629 goto end;
631 frameEncode->IWICBitmapFrameEncode_iface.lpVtbl = &IcnsEncoder_FrameVtbl;
632 frameEncode->encoder = This;
633 frameEncode->ref = 1;
634 frameEncode->initialized = FALSE;
635 frameEncode->size = 0;
636 frameEncode->icns_image = NULL;
637 frameEncode->lines_written = 0;
638 frameEncode->committed = FALSE;
639 *ppIFrameEncode = &frameEncode->IWICBitmapFrameEncode_iface;
640 This->outstanding_commits++;
641 IWICBitmapEncoder_AddRef(&This->IWICBitmapEncoder_iface);
643 end:
644 LeaveCriticalSection(&This->lock);
646 return hr;
649 static HRESULT WINAPI IcnsEncoder_Commit(IWICBitmapEncoder *iface)
651 IcnsEncoder *This = impl_from_IWICBitmapEncoder(iface);
652 size_t buffer_size;
653 HRESULT hr = S_OK;
654 ULONG byteswritten;
656 TRACE("(%p)\n", iface);
658 EnterCriticalSection(&This->lock);
660 if (!This->any_frame_committed || This->outstanding_commits > 0 || This->committed)
662 hr = WINCODEC_ERR_WRONGSTATE;
663 goto end;
666 buffer_size = GetHandleSize((Handle)This->icns_family);
667 hr = IStream_Write(This->stream, *This->icns_family, buffer_size, &byteswritten);
668 if (FAILED(hr) || byteswritten != buffer_size)
670 WARN("writing file failed, hr = 0x%08X\n", hr);
671 hr = E_FAIL;
672 goto end;
675 This->committed = TRUE;
677 end:
678 LeaveCriticalSection(&This->lock);
679 return hr;
682 static HRESULT WINAPI IcnsEncoder_GetMetadataQueryWriter(IWICBitmapEncoder *iface,
683 IWICMetadataQueryWriter **ppIMetadataQueryWriter)
685 FIXME("(%p,%p): stub\n", iface, ppIMetadataQueryWriter);
686 return E_NOTIMPL;
689 static const IWICBitmapEncoderVtbl IcnsEncoder_Vtbl = {
690 IcnsEncoder_QueryInterface,
691 IcnsEncoder_AddRef,
692 IcnsEncoder_Release,
693 IcnsEncoder_Initialize,
694 IcnsEncoder_GetContainerFormat,
695 IcnsEncoder_GetEncoderInfo,
696 IcnsEncoder_SetColorContexts,
697 IcnsEncoder_SetPalette,
698 IcnsEncoder_SetThumbnail,
699 IcnsEncoder_SetPreview,
700 IcnsEncoder_CreateNewFrame,
701 IcnsEncoder_Commit,
702 IcnsEncoder_GetMetadataQueryWriter
705 HRESULT IcnsEncoder_CreateInstance(REFIID iid, void** ppv)
707 IcnsEncoder *This;
708 HRESULT ret;
710 TRACE("(%s,%p)\n", debugstr_guid(iid), ppv);
712 *ppv = NULL;
714 This = HeapAlloc(GetProcessHeap(), 0, sizeof(IcnsEncoder));
715 if (!This) return E_OUTOFMEMORY;
717 This->IWICBitmapEncoder_iface.lpVtbl = &IcnsEncoder_Vtbl;
718 This->ref = 1;
719 This->stream = NULL;
720 This->icns_family = NULL;
721 This->any_frame_committed = FALSE;
722 This->outstanding_commits = 0;
723 This->committed = FALSE;
724 InitializeCriticalSection(&This->lock);
725 This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IcnsEncoder.lock");
727 ret = IWICBitmapEncoder_QueryInterface(&This->IWICBitmapEncoder_iface, iid, ppv);
728 IWICBitmapEncoder_Release(&This->IWICBitmapEncoder_iface);
730 return ret;
733 #else /* !defined(HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H) ||
734 MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4 */
736 HRESULT IcnsEncoder_CreateInstance(REFIID iid, void** ppv)
738 ERR("Trying to save ICNS picture, but ICNS support is not compiled in.\n");
739 return E_FAIL;
742 #endif