windowscodecs: Implement IWICColorContext::GetType.
[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     WICColorContextType type;
40 } ColorContext;
41
42 static inline ColorContext *impl_from_IWICColorContext(IWICColorContext *iface)
43 {
44     return CONTAINING_RECORD(iface, ColorContext, IWICColorContext_iface);
45 }
46
47 static HRESULT WINAPI ColorContext_QueryInterface(IWICColorContext *iface, REFIID iid,
48     void **ppv)
49 {
50     ColorContext *This = impl_from_IWICColorContext(iface);
51     TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
52
53     if (!ppv) return E_INVALIDARG;
54
55     if (IsEqualIID(&IID_IUnknown, iid) ||
56         IsEqualIID(&IID_IWICColorContext, iid))
57     {
58         *ppv = &This->IWICColorContext_iface;
59     }
60     else
61     {
62         *ppv = NULL;
63         return E_NOINTERFACE;
64     }
65
66     IUnknown_AddRef((IUnknown*)*ppv);
67     return S_OK;
68 }
69
70 static ULONG WINAPI ColorContext_AddRef(IWICColorContext *iface)
71 {
72     ColorContext *This = impl_from_IWICColorContext(iface);
73     ULONG ref = InterlockedIncrement(&This->ref);
74
75     TRACE("(%p) refcount=%u\n", iface, ref);
76
77     return ref;
78 }
79
80 static ULONG WINAPI ColorContext_Release(IWICColorContext *iface)
81 {
82     ColorContext *This = impl_from_IWICColorContext(iface);
83     ULONG ref = InterlockedDecrement(&This->ref);
84
85     TRACE("(%p) refcount=%u\n", iface, ref);
86
87     if (ref == 0)
88     {
89         HeapFree(GetProcessHeap(), 0, This);
90     }
91
92     return ref;
93 }
94
95 static HRESULT WINAPI ColorContext_InitializeFromFilename(IWICColorContext *iface,
96     LPCWSTR wzFilename)
97 {
98     FIXME("(%p,%s)\n", iface, debugstr_w(wzFilename));
99     return E_NOTIMPL;
100 }
101
102 static HRESULT WINAPI ColorContext_InitializeFromMemory(IWICColorContext *iface,
103     const BYTE *pbBuffer, UINT cbBufferSize)
104 {
105     FIXME("(%p,%p,%u)\n", iface, pbBuffer, cbBufferSize);
106     return E_NOTIMPL;
107 }
108
109 static HRESULT WINAPI ColorContext_InitializeFromExifColorSpace(IWICColorContext *iface,
110     UINT value)
111 {
112     FIXME("(%p,%u)\n", iface, value);
113     return E_NOTIMPL;
114 }
115
116 static HRESULT WINAPI ColorContext_GetType(IWICColorContext *iface,
117     WICColorContextType *pType)
118 {
119     ColorContext *This = impl_from_IWICColorContext(iface);
120     TRACE("(%p,%p)\n", iface, pType);
121
122     *pType = This->type;
123     return S_OK;
124 }
125
126 static HRESULT WINAPI ColorContext_GetProfileBytes(IWICColorContext *iface,
127     UINT cbBuffer, BYTE *pbBuffer, UINT *pcbActual)
128 {
129     FIXME("(%p,%u,%p,%p)\n", iface, cbBuffer, pbBuffer, pcbActual);
130     return E_NOTIMPL;
131 }
132
133 static HRESULT WINAPI ColorContext_GetExifColorSpace(IWICColorContext *iface,
134     UINT *pValue)
135 {
136     FIXME("(%p,%p)\n", iface, pValue);
137     return E_NOTIMPL;
138 }
139
140 static const IWICColorContextVtbl ColorContext_Vtbl = {
141     ColorContext_QueryInterface,
142     ColorContext_AddRef,
143     ColorContext_Release,
144     ColorContext_InitializeFromFilename,
145     ColorContext_InitializeFromMemory,
146     ColorContext_InitializeFromExifColorSpace,
147     ColorContext_GetType,
148     ColorContext_GetProfileBytes,
149     ColorContext_GetExifColorSpace
150 };
151
152 HRESULT ColorContext_Create(IWICColorContext **colorcontext)
153 {
154     ColorContext *This;
155
156     This = HeapAlloc(GetProcessHeap(), 0, sizeof(ColorContext));
157     if (!This) return E_OUTOFMEMORY;
158
159     This->IWICColorContext_iface.lpVtbl = &ColorContext_Vtbl;
160     This->ref = 1;
161     This->type = 0;
162
163     *colorcontext = &This->IWICColorContext_iface;
164
165     return S_OK;
166 }