2 * Copyright 2012 Hans Leidekker 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);
36 typedef struct ColorContext {
37 IWICColorContext IWICColorContext_iface;
39 WICColorContextType type;
44 static inline ColorContext *impl_from_IWICColorContext(IWICColorContext *iface)
46 return CONTAINING_RECORD(iface, ColorContext, IWICColorContext_iface);
49 static HRESULT WINAPI ColorContext_QueryInterface(IWICColorContext *iface, REFIID iid,
52 ColorContext *This = impl_from_IWICColorContext(iface);
53 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
55 if (!ppv) return E_INVALIDARG;
57 if (IsEqualIID(&IID_IUnknown, iid) ||
58 IsEqualIID(&IID_IWICColorContext, iid))
60 *ppv = &This->IWICColorContext_iface;
68 IUnknown_AddRef((IUnknown*)*ppv);
72 static ULONG WINAPI ColorContext_AddRef(IWICColorContext *iface)
74 ColorContext *This = impl_from_IWICColorContext(iface);
75 ULONG ref = InterlockedIncrement(&This->ref);
77 TRACE("(%p) refcount=%u\n", iface, ref);
82 static ULONG WINAPI ColorContext_Release(IWICColorContext *iface)
84 ColorContext *This = impl_from_IWICColorContext(iface);
85 ULONG ref = InterlockedDecrement(&This->ref);
87 TRACE("(%p) refcount=%u\n", iface, ref);
91 HeapFree(GetProcessHeap(), 0, This->profile);
92 HeapFree(GetProcessHeap(), 0, This);
98 static HRESULT WINAPI ColorContext_InitializeFromFilename(IWICColorContext *iface,
101 FIXME("(%p,%s)\n", iface, debugstr_w(wzFilename));
105 static HRESULT WINAPI ColorContext_InitializeFromMemory(IWICColorContext *iface,
106 const BYTE *pbBuffer, UINT cbBufferSize)
108 ColorContext *This = impl_from_IWICColorContext(iface);
109 TRACE("(%p,%p,%u)\n", iface, pbBuffer, cbBufferSize);
111 if (This->type != WICColorContextUninitialized)
112 return WINCODEC_ERR_WRONGSTATE;
114 HeapFree(GetProcessHeap(), 0, This->profile);
115 if (!(This->profile = HeapAlloc(GetProcessHeap(), 0, cbBufferSize)))
116 return E_OUTOFMEMORY;
118 memcpy(This->profile, pbBuffer, cbBufferSize);
119 This->profile_len = cbBufferSize;
120 This->type = WICColorContextProfile;
125 static HRESULT WINAPI ColorContext_InitializeFromExifColorSpace(IWICColorContext *iface,
128 FIXME("(%p,%u)\n", iface, value);
132 static HRESULT WINAPI ColorContext_GetType(IWICColorContext *iface,
133 WICColorContextType *pType)
135 ColorContext *This = impl_from_IWICColorContext(iface);
136 TRACE("(%p,%p)\n", iface, pType);
142 static HRESULT WINAPI ColorContext_GetProfileBytes(IWICColorContext *iface,
143 UINT cbBuffer, BYTE *pbBuffer, UINT *pcbActual)
145 FIXME("(%p,%u,%p,%p)\n", iface, cbBuffer, pbBuffer, pcbActual);
149 static HRESULT WINAPI ColorContext_GetExifColorSpace(IWICColorContext *iface,
152 FIXME("(%p,%p)\n", iface, pValue);
156 static const IWICColorContextVtbl ColorContext_Vtbl = {
157 ColorContext_QueryInterface,
159 ColorContext_Release,
160 ColorContext_InitializeFromFilename,
161 ColorContext_InitializeFromMemory,
162 ColorContext_InitializeFromExifColorSpace,
163 ColorContext_GetType,
164 ColorContext_GetProfileBytes,
165 ColorContext_GetExifColorSpace
168 HRESULT ColorContext_Create(IWICColorContext **colorcontext)
172 This = HeapAlloc(GetProcessHeap(), 0, sizeof(ColorContext));
173 if (!This) return E_OUTOFMEMORY;
175 This->IWICColorContext_iface.lpVtbl = &ColorContext_Vtbl;
178 This->profile = NULL;
179 This->profile_len = 0;
181 *colorcontext = &This->IWICColorContext_iface;