windowscodecs: Add a stub IWICColorContext implementation.
[wine] / dlls / windowscodecs / colorcontext.c
1 /*
2  * Copyright 2012 Hans Leidekker for CodeWeavers
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include "config.h"
20
21 #include <stdarg.h>
22
23 #define COBJMACROS
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "objbase.h"
28 #include "wincodec.h"
29
30 #include "wincodecs_private.h"
31
32 #include "wine/debug.h"
33
34 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
35
36 typedef struct ColorContext {
37     IWICColorContext IWICColorContext_iface;
38     LONG ref;
39 } ColorContext;
40
41 static inline ColorContext *impl_from_IWICColorContext(IWICColorContext *iface)
42 {
43     return CONTAINING_RECORD(iface, ColorContext, IWICColorContext_iface);
44 }
45
46 static HRESULT WINAPI ColorContext_QueryInterface(IWICColorContext *iface, REFIID iid,
47     void **ppv)
48 {
49     ColorContext *This = impl_from_IWICColorContext(iface);
50     TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
51
52     if (!ppv) return E_INVALIDARG;
53
54     if (IsEqualIID(&IID_IUnknown, iid) ||
55         IsEqualIID(&IID_IWICColorContext, iid))
56     {
57         *ppv = &This->IWICColorContext_iface;
58     }
59     else
60     {
61         *ppv = NULL;
62         return E_NOINTERFACE;
63     }
64
65     IUnknown_AddRef((IUnknown*)*ppv);
66     return S_OK;
67 }
68
69 static ULONG WINAPI ColorContext_AddRef(IWICColorContext *iface)
70 {
71     ColorContext *This = impl_from_IWICColorContext(iface);
72     ULONG ref = InterlockedIncrement(&This->ref);
73
74     TRACE("(%p) refcount=%u\n", iface, ref);
75
76     return ref;
77 }
78
79 static ULONG WINAPI ColorContext_Release(IWICColorContext *iface)
80 {
81     ColorContext *This = impl_from_IWICColorContext(iface);
82     ULONG ref = InterlockedDecrement(&This->ref);
83
84     TRACE("(%p) refcount=%u\n", iface, ref);
85
86     if (ref == 0)
87     {
88         HeapFree(GetProcessHeap(), 0, This);
89     }
90
91     return ref;
92 }
93
94 static HRESULT WINAPI ColorContext_InitializeFromFilename(IWICColorContext *iface,
95     LPCWSTR wzFilename)
96 {
97     FIXME("(%p,%s)\n", iface, debugstr_w(wzFilename));
98     return E_NOTIMPL;
99 }
100
101 static HRESULT WINAPI ColorContext_InitializeFromMemory(IWICColorContext *iface,
102     const BYTE *pbBuffer, UINT cbBufferSize)
103 {
104     FIXME("(%p,%p,%u)\n", iface, pbBuffer, cbBufferSize);
105     return E_NOTIMPL;
106 }
107
108 static HRESULT WINAPI ColorContext_InitializeFromExifColorSpace(IWICColorContext *iface,
109     UINT value)
110 {
111     FIXME("(%p,%u)\n", iface, value);
112     return E_NOTIMPL;
113 }
114
115 static HRESULT WINAPI ColorContext_GetType(IWICColorContext *iface,
116     WICColorContextType *pType)
117 {
118     FIXME("(%p,%p)\n", iface, pType);
119     return E_NOTIMPL;
120 }
121
122 static HRESULT WINAPI ColorContext_GetProfileBytes(IWICColorContext *iface,
123     UINT cbBuffer, BYTE *pbBuffer, UINT *pcbActual)
124 {
125     FIXME("(%p,%u,%p,%p)\n", iface, cbBuffer, pbBuffer, pcbActual);
126     return E_NOTIMPL;
127 }
128
129 static HRESULT WINAPI ColorContext_GetExifColorSpace(IWICColorContext *iface,
130     UINT *pValue)
131 {
132     FIXME("(%p,%p)\n", iface, pValue);
133     return E_NOTIMPL;
134 }
135
136 static const IWICColorContextVtbl ColorContext_Vtbl = {
137     ColorContext_QueryInterface,
138     ColorContext_AddRef,
139     ColorContext_Release,
140     ColorContext_InitializeFromFilename,
141     ColorContext_InitializeFromMemory,
142     ColorContext_InitializeFromExifColorSpace,
143     ColorContext_GetType,
144     ColorContext_GetProfileBytes,
145     ColorContext_GetExifColorSpace
146 };
147
148 HRESULT ColorContext_Create(IWICColorContext **colorcontext)
149 {
150     ColorContext *This;
151
152     This = HeapAlloc(GetProcessHeap(), 0, sizeof(ColorContext));
153     if (!This) return E_OUTOFMEMORY;
154
155     This->IWICColorContext_iface.lpVtbl = &ColorContext_Vtbl;
156     This->ref = 1;
157
158     *colorcontext = &This->IWICColorContext_iface;
159
160     return S_OK;
161 }