wined3d: Avoid the deprecated syntax for SM3 varyings on core profile.
[wine/multimedia.git] / dlls / windowscodecs / icnsformat.c
blob5d48a1afa9c117179b033771ff2d6bf9d6d6d279
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 #undef DPRINTF
79 #endif
81 #define COBJMACROS
83 #include "windef.h"
84 #include "winbase.h"
85 #include "objbase.h"
86 #include "wincodec.h"
88 #include "wincodecs_private.h"
90 #include "wine/debug.h"
91 #include "wine/library.h"
93 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
95 #if defined(HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H) && \
96 MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_4
98 typedef struct IcnsEncoder {
99 IWICBitmapEncoder IWICBitmapEncoder_iface;
100 LONG ref;
101 IStream *stream;
102 IconFamilyHandle icns_family;
103 BOOL any_frame_committed;
104 int outstanding_commits;
105 BOOL committed;
106 CRITICAL_SECTION lock;
107 } IcnsEncoder;
109 static inline IcnsEncoder *impl_from_IWICBitmapEncoder(IWICBitmapEncoder *iface)
111 return CONTAINING_RECORD(iface, IcnsEncoder, IWICBitmapEncoder_iface);
114 typedef struct IcnsFrameEncode {
115 IWICBitmapFrameEncode IWICBitmapFrameEncode_iface;
116 IcnsEncoder *encoder;
117 LONG ref;
118 BOOL initialized;
119 UINT size;
120 OSType icns_type;
121 BYTE* icns_image;
122 int lines_written;
123 BOOL committed;
124 } IcnsFrameEncode;
126 static inline IcnsFrameEncode *impl_from_IWICBitmapFrameEncode(IWICBitmapFrameEncode *iface)
128 return CONTAINING_RECORD(iface, IcnsFrameEncode, IWICBitmapFrameEncode_iface);
131 static HRESULT WINAPI IcnsFrameEncode_QueryInterface(IWICBitmapFrameEncode *iface, REFIID iid,
132 void **ppv)
134 IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
135 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
137 if (!ppv) return E_INVALIDARG;
139 if (IsEqualIID(&IID_IUnknown, iid) ||
140 IsEqualIID(&IID_IWICBitmapFrameEncode, iid))
142 *ppv = &This->IWICBitmapFrameEncode_iface;
144 else
146 *ppv = NULL;
147 return E_NOINTERFACE;
150 IUnknown_AddRef((IUnknown*)*ppv);
151 return S_OK;
154 static ULONG WINAPI IcnsFrameEncode_AddRef(IWICBitmapFrameEncode *iface)
156 IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
157 ULONG ref = InterlockedIncrement(&This->ref);
159 TRACE("(%p) refcount=%u\n", iface, ref);
161 return ref;
164 static ULONG WINAPI IcnsFrameEncode_Release(IWICBitmapFrameEncode *iface)
166 IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
167 ULONG ref = InterlockedDecrement(&This->ref);
169 TRACE("(%p) refcount=%u\n", iface, ref);
171 if (ref == 0)
173 if (!This->committed)
175 EnterCriticalSection(&This->encoder->lock);
176 This->encoder->outstanding_commits--;
177 LeaveCriticalSection(&This->encoder->lock);
179 if (This->icns_image != NULL)
180 HeapFree(GetProcessHeap(), 0, This->icns_image);
182 IWICBitmapEncoder_Release(&This->encoder->IWICBitmapEncoder_iface);
183 HeapFree(GetProcessHeap(), 0, This);
186 return ref;
189 static HRESULT WINAPI IcnsFrameEncode_Initialize(IWICBitmapFrameEncode *iface,
190 IPropertyBag2 *pIEncoderOptions)
192 IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
193 HRESULT hr = S_OK;
195 TRACE("(%p,%p)\n", iface, pIEncoderOptions);
197 EnterCriticalSection(&This->encoder->lock);
199 if (This->initialized)
201 hr = WINCODEC_ERR_WRONGSTATE;
202 goto end;
204 This->initialized = TRUE;
206 end:
207 LeaveCriticalSection(&This->encoder->lock);
208 return hr;
211 static HRESULT WINAPI IcnsFrameEncode_SetSize(IWICBitmapFrameEncode *iface,
212 UINT uiWidth, UINT uiHeight)
214 IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
215 HRESULT hr = S_OK;
217 TRACE("(%p,%u,%u)\n", iface, uiWidth, uiHeight);
219 EnterCriticalSection(&This->encoder->lock);
221 if (!This->initialized || This->icns_image)
223 hr = WINCODEC_ERR_WRONGSTATE;
224 goto end;
227 if (uiWidth != uiHeight)
229 WARN("cannot generate ICNS icon from %dx%d image\n", uiWidth, uiHeight);
230 hr = E_INVALIDARG;
231 goto end;
234 switch (uiWidth)
236 case 16:
237 case 32:
238 case 48:
239 case 128:
240 case 256:
241 case 512:
242 break;
243 default:
244 WARN("cannot generate ICNS icon from %dx%d image\n", This->size, This->size);
245 hr = E_INVALIDARG;
246 goto end;
249 This->size = uiWidth;
251 end:
252 LeaveCriticalSection(&This->encoder->lock);
253 return hr;
256 static HRESULT WINAPI IcnsFrameEncode_SetResolution(IWICBitmapFrameEncode *iface,
257 double dpiX, double dpiY)
259 IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
260 HRESULT hr = S_OK;
262 TRACE("(%p,%0.2f,%0.2f)\n", iface, dpiX, dpiY);
264 EnterCriticalSection(&This->encoder->lock);
266 if (!This->initialized || This->icns_image)
268 hr = WINCODEC_ERR_WRONGSTATE;
269 goto end;
272 end:
273 LeaveCriticalSection(&This->encoder->lock);
274 return S_OK;
277 static HRESULT WINAPI IcnsFrameEncode_SetPixelFormat(IWICBitmapFrameEncode *iface,
278 WICPixelFormatGUID *pPixelFormat)
280 IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
281 HRESULT hr = S_OK;
283 TRACE("(%p,%s)\n", iface, debugstr_guid(pPixelFormat));
285 EnterCriticalSection(&This->encoder->lock);
287 if (!This->initialized || This->icns_image)
289 hr = WINCODEC_ERR_WRONGSTATE;
290 goto end;
293 memcpy(pPixelFormat, &GUID_WICPixelFormat32bppBGRA, sizeof(GUID));
295 end:
296 LeaveCriticalSection(&This->encoder->lock);
297 return S_OK;
300 static HRESULT WINAPI IcnsFrameEncode_SetColorContexts(IWICBitmapFrameEncode *iface,
301 UINT cCount, IWICColorContext **ppIColorContext)
303 FIXME("(%p,%u,%p): stub\n", iface, cCount, ppIColorContext);
304 return E_NOTIMPL;
307 static HRESULT WINAPI IcnsFrameEncode_SetPalette(IWICBitmapFrameEncode *iface,
308 IWICPalette *pIPalette)
310 FIXME("(%p,%p): stub\n", iface, pIPalette);
311 return WINCODEC_ERR_UNSUPPORTEDOPERATION;
314 static HRESULT WINAPI IcnsFrameEncode_SetThumbnail(IWICBitmapFrameEncode *iface,
315 IWICBitmapSource *pIThumbnail)
317 FIXME("(%p,%p): stub\n", iface, pIThumbnail);
318 return WINCODEC_ERR_UNSUPPORTEDOPERATION;
321 static HRESULT WINAPI IcnsFrameEncode_WritePixels(IWICBitmapFrameEncode *iface,
322 UINT lineCount, UINT cbStride, UINT cbBufferSize, BYTE *pbPixels)
324 IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
325 HRESULT hr = S_OK;
326 UINT i;
328 TRACE("(%p,%u,%u,%u,%p)\n", iface, lineCount, cbStride, cbBufferSize, pbPixels);
330 EnterCriticalSection(&This->encoder->lock);
332 if (!This->initialized || !This->size)
334 hr = WINCODEC_ERR_WRONGSTATE;
335 goto end;
337 if (lineCount == 0 || lineCount + This->lines_written > This->size)
339 hr = E_INVALIDARG;
340 goto end;
343 if (!This->icns_image)
345 switch (This->size)
347 case 16: This->icns_type = kIconServices16PixelDataARGB; break;
348 case 32: This->icns_type = kIconServices32PixelDataARGB; break;
349 case 48: This->icns_type = kIconServices48PixelDataARGB; break;
350 case 128: This->icns_type = kIconServices128PixelDataARGB; break;
351 case 256: This->icns_type = kIconServices256PixelDataARGB; break;
352 case 512: This->icns_type = kIconServices512PixelDataARGB; break;
353 default:
354 WARN("cannot generate ICNS icon from %dx%d image\n", This->size, This->size);
355 hr = E_INVALIDARG;
356 goto end;
358 This->icns_image = HeapAlloc(GetProcessHeap(), 0, This->size * This->size * 4);
359 if (!This->icns_image)
361 WARN("failed to allocate image buffer\n");
362 hr = E_FAIL;
363 goto end;
367 for (i = 0; i < lineCount; i++)
369 BYTE *src_row, *dst_row;
370 UINT j;
371 src_row = pbPixels + cbStride * i;
372 dst_row = This->icns_image + (This->lines_written + i)*(This->size*4);
373 /* swap bgr -> rgb */
374 for (j = 0; j < This->size*4; j += 4)
376 dst_row[j] = src_row[j+3];
377 dst_row[j+1] = src_row[j+2];
378 dst_row[j+2] = src_row[j+1];
379 dst_row[j+3] = src_row[j];
382 This->lines_written += lineCount;
384 end:
385 LeaveCriticalSection(&This->encoder->lock);
386 return hr;
389 static HRESULT WINAPI IcnsFrameEncode_WriteSource(IWICBitmapFrameEncode *iface,
390 IWICBitmapSource *pIBitmapSource, WICRect *prc)
392 IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
393 HRESULT hr;
395 TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc);
397 if (!This->initialized)
398 return WINCODEC_ERR_WRONGSTATE;
400 hr = configure_write_source(iface, pIBitmapSource, prc,
401 &GUID_WICPixelFormat32bppBGRA, This->size, This->size,
402 1.0, 1.0);
404 if (SUCCEEDED(hr))
406 hr = write_source(iface, pIBitmapSource, prc,
407 &GUID_WICPixelFormat32bppBGRA, 32, This->size, This->size);
410 return hr;
413 static HRESULT WINAPI IcnsFrameEncode_Commit(IWICBitmapFrameEncode *iface)
415 IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
416 Handle handle;
417 OSErr ret;
418 HRESULT hr = S_OK;
420 TRACE("(%p): stub\n", iface);
422 EnterCriticalSection(&This->encoder->lock);
424 if (!This->icns_image || This->lines_written != This->size || This->committed)
426 hr = WINCODEC_ERR_WRONGSTATE;
427 goto end;
430 ret = PtrToHand(This->icns_image, &handle, This->size * This->size * 4);
431 if (ret != noErr || !handle)
433 WARN("PtrToHand failed with error %d\n", ret);
434 hr = E_FAIL;
435 goto end;
438 ret = SetIconFamilyData(This->encoder->icns_family, This->icns_type, handle);
439 DisposeHandle(handle);
441 if (ret != noErr)
443 WARN("SetIconFamilyData failed for image with error %d\n", ret);
444 hr = E_FAIL;
445 goto end;
448 This->committed = TRUE;
449 This->encoder->any_frame_committed = TRUE;
450 This->encoder->outstanding_commits--;
452 end:
453 LeaveCriticalSection(&This->encoder->lock);
454 return hr;
457 static HRESULT WINAPI IcnsFrameEncode_GetMetadataQueryWriter(IWICBitmapFrameEncode *iface,
458 IWICMetadataQueryWriter **ppIMetadataQueryWriter)
460 FIXME("(%p, %p): stub\n", iface, ppIMetadataQueryWriter);
461 return E_NOTIMPL;
464 static const IWICBitmapFrameEncodeVtbl IcnsEncoder_FrameVtbl = {
465 IcnsFrameEncode_QueryInterface,
466 IcnsFrameEncode_AddRef,
467 IcnsFrameEncode_Release,
468 IcnsFrameEncode_Initialize,
469 IcnsFrameEncode_SetSize,
470 IcnsFrameEncode_SetResolution,
471 IcnsFrameEncode_SetPixelFormat,
472 IcnsFrameEncode_SetColorContexts,
473 IcnsFrameEncode_SetPalette,
474 IcnsFrameEncode_SetThumbnail,
475 IcnsFrameEncode_WritePixels,
476 IcnsFrameEncode_WriteSource,
477 IcnsFrameEncode_Commit,
478 IcnsFrameEncode_GetMetadataQueryWriter
481 static HRESULT WINAPI IcnsEncoder_QueryInterface(IWICBitmapEncoder *iface, REFIID iid,
482 void **ppv)
484 IcnsEncoder *This = impl_from_IWICBitmapEncoder(iface);
485 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
487 if (!ppv) return E_INVALIDARG;
489 if (IsEqualIID(&IID_IUnknown, iid) ||
490 IsEqualIID(&IID_IWICBitmapEncoder, iid))
492 *ppv = &This->IWICBitmapEncoder_iface;
494 else
496 *ppv = NULL;
497 return E_NOINTERFACE;
500 IUnknown_AddRef((IUnknown*)*ppv);
501 return S_OK;
504 static ULONG WINAPI IcnsEncoder_AddRef(IWICBitmapEncoder *iface)
506 IcnsEncoder *This = impl_from_IWICBitmapEncoder(iface);
507 ULONG ref = InterlockedIncrement(&This->ref);
509 TRACE("(%p) refcount=%u\n", iface, ref);
511 return ref;
514 static ULONG WINAPI IcnsEncoder_Release(IWICBitmapEncoder *iface)
516 IcnsEncoder *This = impl_from_IWICBitmapEncoder(iface);
517 ULONG ref = InterlockedDecrement(&This->ref);
519 TRACE("(%p) refcount=%u\n", iface, ref);
521 if (ref == 0)
523 This->lock.DebugInfo->Spare[0] = 0;
524 DeleteCriticalSection(&This->lock);
525 if (This->icns_family)
526 DisposeHandle((Handle)This->icns_family);
527 if (This->stream)
528 IStream_Release(This->stream);
529 HeapFree(GetProcessHeap(), 0, This);
532 return ref;
535 static HRESULT WINAPI IcnsEncoder_Initialize(IWICBitmapEncoder *iface,
536 IStream *pIStream, WICBitmapEncoderCacheOption cacheOption)
538 IcnsEncoder *This = impl_from_IWICBitmapEncoder(iface);
539 HRESULT hr = S_OK;
541 TRACE("(%p,%p,%u)\n", iface, pIStream, cacheOption);
543 EnterCriticalSection(&This->lock);
545 if (This->icns_family)
547 hr = WINCODEC_ERR_WRONGSTATE;
548 goto end;
550 This->icns_family = (IconFamilyHandle)NewHandle(0);
551 if (!This->icns_family)
553 WARN("error creating icns family\n");
554 hr = E_FAIL;
555 goto end;
557 IStream_AddRef(pIStream);
558 This->stream = pIStream;
560 end:
561 LeaveCriticalSection(&This->lock);
563 return hr;
566 static HRESULT WINAPI IcnsEncoder_GetContainerFormat(IWICBitmapEncoder *iface,
567 GUID *pguidContainerFormat)
569 FIXME("(%p,%s): stub\n", iface, debugstr_guid(pguidContainerFormat));
570 return E_NOTIMPL;
573 static HRESULT WINAPI IcnsEncoder_GetEncoderInfo(IWICBitmapEncoder *iface,
574 IWICBitmapEncoderInfo **ppIEncoderInfo)
576 FIXME("(%p,%p): stub\n", iface, ppIEncoderInfo);
577 return E_NOTIMPL;
580 static HRESULT WINAPI IcnsEncoder_SetColorContexts(IWICBitmapEncoder *iface,
581 UINT cCount, IWICColorContext **ppIColorContext)
583 FIXME("(%p,%u,%p): stub\n", iface, cCount, ppIColorContext);
584 return E_NOTIMPL;
587 static HRESULT WINAPI IcnsEncoder_SetPalette(IWICBitmapEncoder *iface, IWICPalette *pIPalette)
589 TRACE("(%p,%p)\n", iface, pIPalette);
590 return WINCODEC_ERR_UNSUPPORTEDOPERATION;
593 static HRESULT WINAPI IcnsEncoder_SetThumbnail(IWICBitmapEncoder *iface, IWICBitmapSource *pIThumbnail)
595 TRACE("(%p,%p)\n", iface, pIThumbnail);
596 return WINCODEC_ERR_UNSUPPORTEDOPERATION;
599 static HRESULT WINAPI IcnsEncoder_SetPreview(IWICBitmapEncoder *iface, IWICBitmapSource *pIPreview)
601 TRACE("(%p,%p)\n", iface, pIPreview);
602 return WINCODEC_ERR_UNSUPPORTEDOPERATION;
605 static HRESULT WINAPI IcnsEncoder_CreateNewFrame(IWICBitmapEncoder *iface,
606 IWICBitmapFrameEncode **ppIFrameEncode, IPropertyBag2 **ppIEncoderOptions)
608 IcnsEncoder *This = impl_from_IWICBitmapEncoder(iface);
609 HRESULT hr = S_OK;
610 IcnsFrameEncode *frameEncode = NULL;
612 TRACE("(%p,%p,%p)\n", iface, ppIFrameEncode, ppIEncoderOptions);
614 EnterCriticalSection(&This->lock);
616 if (!This->icns_family)
618 hr = WINCODEC_ERR_NOTINITIALIZED;
619 goto end;
622 hr = CreatePropertyBag2(NULL, 0, ppIEncoderOptions);
623 if (FAILED(hr))
624 goto end;
626 frameEncode = HeapAlloc(GetProcessHeap(), 0, sizeof(IcnsFrameEncode));
627 if (frameEncode == NULL)
629 hr = E_OUTOFMEMORY;
630 goto end;
632 frameEncode->IWICBitmapFrameEncode_iface.lpVtbl = &IcnsEncoder_FrameVtbl;
633 frameEncode->encoder = This;
634 frameEncode->ref = 1;
635 frameEncode->initialized = FALSE;
636 frameEncode->size = 0;
637 frameEncode->icns_image = NULL;
638 frameEncode->lines_written = 0;
639 frameEncode->committed = FALSE;
640 *ppIFrameEncode = &frameEncode->IWICBitmapFrameEncode_iface;
641 This->outstanding_commits++;
642 IWICBitmapEncoder_AddRef(&This->IWICBitmapEncoder_iface);
644 end:
645 LeaveCriticalSection(&This->lock);
647 return hr;
650 static HRESULT WINAPI IcnsEncoder_Commit(IWICBitmapEncoder *iface)
652 IcnsEncoder *This = impl_from_IWICBitmapEncoder(iface);
653 size_t buffer_size;
654 HRESULT hr = S_OK;
655 ULONG byteswritten;
657 TRACE("(%p)\n", iface);
659 EnterCriticalSection(&This->lock);
661 if (!This->any_frame_committed || This->outstanding_commits > 0 || This->committed)
663 hr = WINCODEC_ERR_WRONGSTATE;
664 goto end;
667 buffer_size = GetHandleSize((Handle)This->icns_family);
668 hr = IStream_Write(This->stream, *This->icns_family, buffer_size, &byteswritten);
669 if (FAILED(hr) || byteswritten != buffer_size)
671 WARN("writing file failed, hr = 0x%08X\n", hr);
672 hr = E_FAIL;
673 goto end;
676 This->committed = TRUE;
678 end:
679 LeaveCriticalSection(&This->lock);
680 return hr;
683 static HRESULT WINAPI IcnsEncoder_GetMetadataQueryWriter(IWICBitmapEncoder *iface,
684 IWICMetadataQueryWriter **ppIMetadataQueryWriter)
686 FIXME("(%p,%p): stub\n", iface, ppIMetadataQueryWriter);
687 return E_NOTIMPL;
690 static const IWICBitmapEncoderVtbl IcnsEncoder_Vtbl = {
691 IcnsEncoder_QueryInterface,
692 IcnsEncoder_AddRef,
693 IcnsEncoder_Release,
694 IcnsEncoder_Initialize,
695 IcnsEncoder_GetContainerFormat,
696 IcnsEncoder_GetEncoderInfo,
697 IcnsEncoder_SetColorContexts,
698 IcnsEncoder_SetPalette,
699 IcnsEncoder_SetThumbnail,
700 IcnsEncoder_SetPreview,
701 IcnsEncoder_CreateNewFrame,
702 IcnsEncoder_Commit,
703 IcnsEncoder_GetMetadataQueryWriter
706 HRESULT IcnsEncoder_CreateInstance(REFIID iid, void** ppv)
708 IcnsEncoder *This;
709 HRESULT ret;
711 TRACE("(%s,%p)\n", debugstr_guid(iid), ppv);
713 *ppv = NULL;
715 This = HeapAlloc(GetProcessHeap(), 0, sizeof(IcnsEncoder));
716 if (!This) return E_OUTOFMEMORY;
718 This->IWICBitmapEncoder_iface.lpVtbl = &IcnsEncoder_Vtbl;
719 This->ref = 1;
720 This->stream = NULL;
721 This->icns_family = NULL;
722 This->any_frame_committed = FALSE;
723 This->outstanding_commits = 0;
724 This->committed = FALSE;
725 InitializeCriticalSection(&This->lock);
726 This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IcnsEncoder.lock");
728 ret = IWICBitmapEncoder_QueryInterface(&This->IWICBitmapEncoder_iface, iid, ppv);
729 IWICBitmapEncoder_Release(&This->IWICBitmapEncoder_iface);
731 return ret;
734 #else /* !defined(HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H) ||
735 MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4 */
737 HRESULT IcnsEncoder_CreateInstance(REFIID iid, void** ppv)
739 ERR("Trying to save ICNS picture, but ICNS support is not compiled in.\n");
740 return E_FAIL;
743 #endif