crypt32: Make sure we show Unicode characters (Dutch translation).
[wine] / dlls / windowscodecs / imgfactory.c
1 /*
2  * Copyright 2009 Vincent Povirk 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 "winreg.h"
28 #include "objbase.h"
29 #include "wincodec.h"
30
31 #include "wincodecs_private.h"
32
33 #include "wine/debug.h"
34
35 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
36
37 typedef struct {
38     const IWICImagingFactoryVtbl    *lpIWICImagingFactoryVtbl;
39     LONG ref;
40 } ImagingFactory;
41
42 static HRESULT WINAPI ImagingFactory_QueryInterface(IWICImagingFactory *iface, REFIID iid,
43     void **ppv)
44 {
45     ImagingFactory *This = (ImagingFactory*)iface;
46     TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
47
48     if (!ppv) return E_INVALIDARG;
49
50     if (IsEqualIID(&IID_IUnknown, iid) || IsEqualIID(&IID_IWICImagingFactory, iid))
51     {
52         *ppv = This;
53     }
54     else
55     {
56         *ppv = NULL;
57         return E_NOINTERFACE;
58     }
59
60     IUnknown_AddRef((IUnknown*)*ppv);
61     return S_OK;
62 }
63
64 static ULONG WINAPI ImagingFactory_AddRef(IWICImagingFactory *iface)
65 {
66     ImagingFactory *This = (ImagingFactory*)iface;
67     ULONG ref = InterlockedIncrement(&This->ref);
68
69     TRACE("(%p) refcount=%u\n", iface, ref);
70
71     return ref;
72 }
73
74 static ULONG WINAPI ImagingFactory_Release(IWICImagingFactory *iface)
75 {
76     ImagingFactory *This = (ImagingFactory*)iface;
77     ULONG ref = InterlockedDecrement(&This->ref);
78
79     TRACE("(%p) refcount=%u\n", iface, ref);
80
81     if (ref == 0)
82         HeapFree(GetProcessHeap(), 0, This);
83
84     return ref;
85 }
86
87 static HRESULT WINAPI ImagingFactory_CreateDecoderFromFilename(
88     IWICImagingFactory *iface, LPCWSTR wzFilename, const GUID *pguidVendor,
89     DWORD dwDesiredAccess, WICDecodeOptions metadataOptions,
90     IWICBitmapDecoder **ppIDecoder)
91 {
92     FIXME("(%p,%s,%s,%u,%u,%p): stub\n", iface, debugstr_w(wzFilename),
93         debugstr_guid(pguidVendor), dwDesiredAccess, metadataOptions, ppIDecoder);
94     return E_NOTIMPL;
95 }
96
97 static HRESULT WINAPI ImagingFactory_CreateDecoderFromStream(
98     IWICImagingFactory *iface, IStream *pIStream, const GUID *pguidVendor,
99     WICDecodeOptions metadataOptions, IWICBitmapDecoder **ppIDecoder)
100 {
101     FIXME("(%p,%p,%s,%u,%p): stub\n", iface, pIStream, debugstr_guid(pguidVendor),
102         metadataOptions, ppIDecoder);
103     return E_NOTIMPL;
104 }
105
106 static HRESULT WINAPI ImagingFactory_CreateDecoderFromFileHandle(
107     IWICImagingFactory *iface, ULONG_PTR hFile, const GUID *pguidVendor,
108     WICDecodeOptions metadataOptions, IWICBitmapDecoder **ppIDecoder)
109 {
110     FIXME("(%p,%lx,%s,%u,%p): stub\n", iface, hFile, debugstr_guid(pguidVendor),
111         metadataOptions, ppIDecoder);
112     return E_NOTIMPL;
113 }
114
115 static HRESULT WINAPI ImagingFactory_CreateComponentInfo(IWICImagingFactory *iface,
116     REFCLSID clsidComponent, IWICComponentInfo **ppIInfo)
117 {
118     FIXME("(%p,%s,%p): stub\n", iface, debugstr_guid(clsidComponent), ppIInfo);
119     return E_NOTIMPL;
120 }
121
122 static HRESULT WINAPI ImagingFactory_CreateDecoder(IWICImagingFactory *iface,
123     REFGUID guidContainerFormat, const GUID *pguidVendor,
124     IWICBitmapDecoder **ppIDecoder)
125 {
126     FIXME("(%p,%s,%s,%p): stub\n", iface, debugstr_guid(guidContainerFormat),
127         debugstr_guid(pguidVendor), ppIDecoder);
128     return E_NOTIMPL;
129 }
130
131 static HRESULT WINAPI ImagingFactory_CreateEncoder(IWICImagingFactory *iface,
132     REFGUID guidContainerFormat, const GUID *pguidVendor,
133     IWICBitmapEncoder **ppIEncoder)
134 {
135     FIXME("(%p,%s,%s,%p): stub\n", iface, debugstr_guid(guidContainerFormat),
136         debugstr_guid(pguidVendor), ppIEncoder);
137     return E_NOTIMPL;
138 }
139
140 static HRESULT WINAPI ImagingFactory_CreatePalette(IWICImagingFactory *iface,
141     IWICPalette **ppIPalette)
142 {
143     TRACE("(%p,%p)\n", iface, ppIPalette);
144     return PaletteImpl_Create(ppIPalette);
145 }
146
147 static HRESULT WINAPI ImagingFactory_CreateFormatConverter(IWICImagingFactory *iface,
148     IWICFormatConverter **ppIFormatConverter)
149 {
150     FIXME("(%p,%p): stub\n", iface, ppIFormatConverter);
151     return E_NOTIMPL;
152 }
153
154 static HRESULT WINAPI ImagingFactory_CreateBitmapScaler(IWICImagingFactory *iface,
155     IWICBitmapScaler **ppIBitmapScaler)
156 {
157     FIXME("(%p,%p): stub\n", iface, ppIBitmapScaler);
158     return E_NOTIMPL;
159 }
160
161 static HRESULT WINAPI ImagingFactory_CreateBitmapClipper(IWICImagingFactory *iface,
162     IWICBitmapClipper **ppIBitmapClipper)
163 {
164     FIXME("(%p,%p): stub\n", iface, ppIBitmapClipper);
165     return E_NOTIMPL;
166 }
167
168 static HRESULT WINAPI ImagingFactory_CreateBitmapFlipRotator(IWICImagingFactory *iface,
169     IWICBitmapFlipRotator **ppIBitmapFlipRotator)
170 {
171     FIXME("(%p,%p): stub\n", iface, ppIBitmapFlipRotator);
172     return E_NOTIMPL;
173 }
174
175 static HRESULT WINAPI ImagingFactory_CreateStream(IWICImagingFactory *iface,
176     IWICStream **ppIWICStream)
177 {
178     FIXME("(%p,%p): stub\n", iface, ppIWICStream);
179     return E_NOTIMPL;
180 }
181
182 static HRESULT WINAPI ImagingFactory_CreateColorContext(IWICImagingFactory *iface,
183     IWICColorContext **ppIColorContext)
184 {
185     FIXME("(%p,%p): stub\n", iface, ppIColorContext);
186     return E_NOTIMPL;
187 }
188
189 static HRESULT WINAPI ImagingFactory_CreateColorTransformer(IWICImagingFactory *iface,
190     IWICColorTransform **ppIColorTransform)
191 {
192     FIXME("(%p,%p): stub\n", iface, ppIColorTransform);
193     return E_NOTIMPL;
194 }
195
196 static HRESULT WINAPI ImagingFactory_CreateBitmap(IWICImagingFactory *iface,
197     UINT uiWidth, UINT uiHeight, REFWICPixelFormatGUID pixelFormat,
198     WICBitmapCreateCacheOption option, IWICBitmap **ppIBitmap)
199 {
200     FIXME("(%p,%u,%u,%s,%u,%p): stub\n", iface, uiWidth, uiHeight,
201         debugstr_guid(pixelFormat), option, ppIBitmap);
202     return E_NOTIMPL;
203 }
204
205 static HRESULT WINAPI ImagingFactory_CreateBitmapFromSource(IWICImagingFactory *iface,
206     IWICBitmapSource *piBitmapSource, WICBitmapCreateCacheOption option,
207     IWICBitmap **ppIBitmap)
208 {
209     FIXME("(%p,%p,%u,%p): stub\n", iface, piBitmapSource, option, ppIBitmap);
210     return E_NOTIMPL;
211 }
212
213 static HRESULT WINAPI ImagingFactory_CreateBitmapFromSourceRect(IWICImagingFactory *iface,
214     IWICBitmapSource *piBitmapSource, UINT x, UINT y, UINT width, UINT height,
215     IWICBitmap **ppIBitmap)
216 {
217     FIXME("(%p,%p,%u,%u,%u,%u,%p): stub\n", iface, piBitmapSource, x, y, width,
218         height, ppIBitmap);
219     return E_NOTIMPL;
220 }
221
222 static HRESULT WINAPI ImagingFactory_CreateBitmapFromMemory(IWICImagingFactory *iface,
223     UINT uiWidth, UINT uiHeight, REFWICPixelFormatGUID pixelFormat, UINT cbStride,
224     UINT cbBufferSize, BYTE *pbBuffer, IWICBitmap **ppIBitmap)
225 {
226     FIXME("(%p,%u,%u,%s,%u,%u,%p,%p): stub\n", iface, uiWidth, uiHeight,
227         debugstr_guid(pixelFormat), cbStride, cbBufferSize, pbBuffer, ppIBitmap);
228     return E_NOTIMPL;
229 }
230
231 static HRESULT WINAPI ImagingFactory_CreateBitmapFromHBITMAP(IWICImagingFactory *iface,
232     HBITMAP hBitmap, HPALETTE hPalette, WICBitmapAlphaChannelOption options,
233     IWICBitmap **ppIBitmap)
234 {
235     FIXME("(%p,%p,%p,%u,%p): stub\n", iface, hBitmap, hPalette, options, ppIBitmap);
236     return E_NOTIMPL;
237 }
238
239 static HRESULT WINAPI ImagingFactory_CreateBitmapFromHICON(IWICImagingFactory *iface,
240     HICON hIcon, IWICBitmap **ppIBitmap)
241 {
242     FIXME("(%p,%p,%p): stub\n", iface, hIcon, ppIBitmap);
243     return E_NOTIMPL;
244 }
245
246 static HRESULT WINAPI ImagingFactory_CreateComponentEnumerator(IWICImagingFactory *iface,
247     DWORD componentTypes, DWORD options, IEnumUnknown **ppIEnumUnknown)
248 {
249     FIXME("(%p,%u,%u,%p): stub\n", iface, componentTypes, options, ppIEnumUnknown);
250     return E_NOTIMPL;
251 }
252
253 static HRESULT WINAPI ImagingFactory_CreateFastMetadataEncoderFromDecoder(
254     IWICImagingFactory *iface, IWICBitmapDecoder *pIDecoder,
255     IWICFastMetadataEncoder **ppIFastEncoder)
256 {
257     FIXME("(%p,%p,%p): stub\n", iface, pIDecoder, ppIFastEncoder);
258     return E_NOTIMPL;
259 }
260
261 static HRESULT WINAPI ImagingFactory_CreateFastMetadataEncoderFromFrameDecode(
262     IWICImagingFactory *iface, IWICBitmapFrameDecode *pIFrameDecoder,
263     IWICFastMetadataEncoder **ppIFastEncoder)
264 {
265     FIXME("(%p,%p,%p): stub\n", iface, pIFrameDecoder, ppIFastEncoder);
266     return E_NOTIMPL;
267 }
268
269 static HRESULT WINAPI ImagingFactory_CreateQueryWriter(IWICImagingFactory *iface,
270     REFGUID guidMetadataFormat, const GUID *pguidVendor,
271     IWICMetadataQueryWriter **ppIQueryWriter)
272 {
273     FIXME("(%p,%s,%s,%p): stub\n", iface, debugstr_guid(guidMetadataFormat),
274         debugstr_guid(pguidVendor), ppIQueryWriter);
275     return E_NOTIMPL;
276 }
277
278 static HRESULT WINAPI ImagingFactory_CreateQueryWriterFromReader(IWICImagingFactory *iface,
279     IWICMetadataQueryReader *pIQueryReader, const GUID *pguidVendor,
280     IWICMetadataQueryWriter **ppIQueryWriter)
281 {
282     FIXME("(%p,%p,%s,%p): stub\n", iface, pIQueryReader, debugstr_guid(pguidVendor),
283         ppIQueryWriter);
284     return E_NOTIMPL;
285 }
286
287 static const IWICImagingFactoryVtbl ImagingFactory_Vtbl = {
288     ImagingFactory_QueryInterface,
289     ImagingFactory_AddRef,
290     ImagingFactory_Release,
291     ImagingFactory_CreateDecoderFromFilename,
292     ImagingFactory_CreateDecoderFromStream,
293     ImagingFactory_CreateDecoderFromFileHandle,
294     ImagingFactory_CreateComponentInfo,
295     ImagingFactory_CreateDecoder,
296     ImagingFactory_CreateEncoder,
297     ImagingFactory_CreatePalette,
298     ImagingFactory_CreateFormatConverter,
299     ImagingFactory_CreateBitmapScaler,
300     ImagingFactory_CreateBitmapClipper,
301     ImagingFactory_CreateBitmapFlipRotator,
302     ImagingFactory_CreateStream,
303     ImagingFactory_CreateColorContext,
304     ImagingFactory_CreateColorTransformer,
305     ImagingFactory_CreateBitmap,
306     ImagingFactory_CreateBitmapFromSource,
307     ImagingFactory_CreateBitmapFromSourceRect,
308     ImagingFactory_CreateBitmapFromMemory,
309     ImagingFactory_CreateBitmapFromHBITMAP,
310     ImagingFactory_CreateBitmapFromHICON,
311     ImagingFactory_CreateComponentEnumerator,
312     ImagingFactory_CreateFastMetadataEncoderFromDecoder,
313     ImagingFactory_CreateFastMetadataEncoderFromFrameDecode,
314     ImagingFactory_CreateQueryWriter,
315     ImagingFactory_CreateQueryWriterFromReader
316 };
317
318 HRESULT ImagingFactory_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
319 {
320     ImagingFactory *This;
321     HRESULT ret;
322
323     TRACE("(%p,%s,%p)\n", pUnkOuter, debugstr_guid(iid), ppv);
324
325     *ppv = NULL;
326
327     if (pUnkOuter) return CLASS_E_NOAGGREGATION;
328
329     This = HeapAlloc(GetProcessHeap(), 0, sizeof(ImagingFactory));
330     if (!This) return E_OUTOFMEMORY;
331
332     This->lpIWICImagingFactoryVtbl = &ImagingFactory_Vtbl;
333     This->ref = 1;
334
335     ret = IUnknown_QueryInterface((IUnknown*)This, iid, ppv);
336     IUnknown_Release((IUnknown*)This);
337
338     return ret;
339 }