csetupapi: Update Japanese translation.
[wine/wine-gecko.git] / dlls / windowscodecs / imgfactory.c
bloba98aeb8129570e2a82bfd0301b039a0641d4a641
1 /*
2 * Copyright 2009 Vincent Povirk 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
19 #include "config.h"
21 #include <stdarg.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winreg.h"
28 #include "objbase.h"
29 #include "wincodec.h"
31 #include "wincodecs_private.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
37 typedef struct {
38 const IWICImagingFactoryVtbl *lpIWICImagingFactoryVtbl;
39 LONG ref;
40 } ImagingFactory;
42 static HRESULT WINAPI ImagingFactory_QueryInterface(IWICImagingFactory *iface, REFIID iid,
43 void **ppv)
45 ImagingFactory *This = (ImagingFactory*)iface;
46 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
48 if (!ppv) return E_INVALIDARG;
50 if (IsEqualIID(&IID_IUnknown, iid) || IsEqualIID(&IID_IWICImagingFactory, iid))
52 *ppv = This;
54 else
56 *ppv = NULL;
57 return E_NOINTERFACE;
60 IUnknown_AddRef((IUnknown*)*ppv);
61 return S_OK;
64 static ULONG WINAPI ImagingFactory_AddRef(IWICImagingFactory *iface)
66 ImagingFactory *This = (ImagingFactory*)iface;
67 ULONG ref = InterlockedIncrement(&This->ref);
69 TRACE("(%p) refcount=%u\n", iface, ref);
71 return ref;
74 static ULONG WINAPI ImagingFactory_Release(IWICImagingFactory *iface)
76 ImagingFactory *This = (ImagingFactory*)iface;
77 ULONG ref = InterlockedDecrement(&This->ref);
79 TRACE("(%p) refcount=%u\n", iface, ref);
81 if (ref == 0)
82 HeapFree(GetProcessHeap(), 0, This);
84 return ref;
87 static HRESULT WINAPI ImagingFactory_CreateDecoderFromFilename(
88 IWICImagingFactory *iface, LPCWSTR wzFilename, const GUID *pguidVendor,
89 DWORD dwDesiredAccess, WICDecodeOptions metadataOptions,
90 IWICBitmapDecoder **ppIDecoder)
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;
97 static HRESULT WINAPI ImagingFactory_CreateDecoderFromStream(
98 IWICImagingFactory *iface, IStream *pIStream, const GUID *pguidVendor,
99 WICDecodeOptions metadataOptions, IWICBitmapDecoder **ppIDecoder)
101 static int fixme=0;
102 IEnumUnknown *enumdecoders;
103 IUnknown *unkdecoderinfo;
104 IWICBitmapDecoderInfo *decoderinfo;
105 IWICBitmapDecoder *decoder=NULL;
106 HRESULT res=S_OK;
107 ULONG num_fetched;
108 BOOL matches;
110 TRACE("(%p,%p,%s,%u,%p)\n", iface, pIStream, debugstr_guid(pguidVendor),
111 metadataOptions, ppIDecoder);
113 if (pguidVendor && !fixme++)
114 FIXME("ignoring vendor GUID\n");
116 res = CreateComponentEnumerator(WICDecoder, WICComponentEnumerateDefault, &enumdecoders);
117 if (FAILED(res)) return res;
119 while (!decoder)
121 res = IEnumUnknown_Next(enumdecoders, 1, &unkdecoderinfo, &num_fetched);
123 if (res == S_OK)
125 res = IUnknown_QueryInterface(unkdecoderinfo, &IID_IWICBitmapDecoderInfo, (void**)&decoderinfo);
127 if (SUCCEEDED(res))
129 res = IWICBitmapDecoderInfo_MatchesPattern(decoderinfo, pIStream, &matches);
131 if (SUCCEEDED(res) && matches)
133 res = IWICBitmapDecoderInfo_CreateInstance(decoderinfo, &decoder);
135 /* FIXME: should use QueryCapability to choose a decoder */
137 if (SUCCEEDED(res))
139 res = IWICBitmapDecoder_Initialize(decoder, pIStream, metadataOptions);
141 if (FAILED(res))
143 IWICBitmapDecoder_Release(decoder);
144 decoder = NULL;
149 IWICBitmapDecoderInfo_Release(decoderinfo);
152 IUnknown_Release(unkdecoderinfo);
154 else
155 break;
158 IEnumUnknown_Release(enumdecoders);
160 if (decoder)
162 *ppIDecoder = decoder;
163 return S_OK;
165 else
167 if (WARN_ON(wincodecs))
169 LARGE_INTEGER seek;
170 BYTE data[4];
171 ULONG bytesread;
173 WARN("failed to load from a stream\n");
175 seek.QuadPart = 0;
176 res = IStream_Seek(pIStream, seek, STREAM_SEEK_SET, NULL);
177 if (SUCCEEDED(res))
178 res = IStream_Read(pIStream, data, 4, &bytesread);
179 if (SUCCEEDED(res))
180 WARN("first %i bytes of stream=%x %x %x %x\n", bytesread, data[0], data[1], data[2], data[3]);
182 *ppIDecoder = NULL;
183 return WINCODEC_ERR_COMPONENTNOTFOUND;
187 static HRESULT WINAPI ImagingFactory_CreateDecoderFromFileHandle(
188 IWICImagingFactory *iface, ULONG_PTR hFile, const GUID *pguidVendor,
189 WICDecodeOptions metadataOptions, IWICBitmapDecoder **ppIDecoder)
191 FIXME("(%p,%lx,%s,%u,%p): stub\n", iface, hFile, debugstr_guid(pguidVendor),
192 metadataOptions, ppIDecoder);
193 return E_NOTIMPL;
196 static HRESULT WINAPI ImagingFactory_CreateComponentInfo(IWICImagingFactory *iface,
197 REFCLSID clsidComponent, IWICComponentInfo **ppIInfo)
199 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(clsidComponent), ppIInfo);
200 return CreateComponentInfo(clsidComponent, ppIInfo);
203 static HRESULT WINAPI ImagingFactory_CreateDecoder(IWICImagingFactory *iface,
204 REFGUID guidContainerFormat, const GUID *pguidVendor,
205 IWICBitmapDecoder **ppIDecoder)
207 FIXME("(%p,%s,%s,%p): stub\n", iface, debugstr_guid(guidContainerFormat),
208 debugstr_guid(pguidVendor), ppIDecoder);
209 return E_NOTIMPL;
212 static HRESULT WINAPI ImagingFactory_CreateEncoder(IWICImagingFactory *iface,
213 REFGUID guidContainerFormat, const GUID *pguidVendor,
214 IWICBitmapEncoder **ppIEncoder)
216 FIXME("(%p,%s,%s,%p): stub\n", iface, debugstr_guid(guidContainerFormat),
217 debugstr_guid(pguidVendor), ppIEncoder);
218 return E_NOTIMPL;
221 static HRESULT WINAPI ImagingFactory_CreatePalette(IWICImagingFactory *iface,
222 IWICPalette **ppIPalette)
224 TRACE("(%p,%p)\n", iface, ppIPalette);
225 return PaletteImpl_Create(ppIPalette);
228 static HRESULT WINAPI ImagingFactory_CreateFormatConverter(IWICImagingFactory *iface,
229 IWICFormatConverter **ppIFormatConverter)
231 FIXME("(%p,%p): stub\n", iface, ppIFormatConverter);
232 return E_NOTIMPL;
235 static HRESULT WINAPI ImagingFactory_CreateBitmapScaler(IWICImagingFactory *iface,
236 IWICBitmapScaler **ppIBitmapScaler)
238 FIXME("(%p,%p): stub\n", iface, ppIBitmapScaler);
239 return E_NOTIMPL;
242 static HRESULT WINAPI ImagingFactory_CreateBitmapClipper(IWICImagingFactory *iface,
243 IWICBitmapClipper **ppIBitmapClipper)
245 FIXME("(%p,%p): stub\n", iface, ppIBitmapClipper);
246 return E_NOTIMPL;
249 static HRESULT WINAPI ImagingFactory_CreateBitmapFlipRotator(IWICImagingFactory *iface,
250 IWICBitmapFlipRotator **ppIBitmapFlipRotator)
252 FIXME("(%p,%p): stub\n", iface, ppIBitmapFlipRotator);
253 return E_NOTIMPL;
256 static HRESULT WINAPI ImagingFactory_CreateStream(IWICImagingFactory *iface,
257 IWICStream **ppIWICStream)
259 TRACE("(%p,%p)\n", iface, ppIWICStream);
260 return StreamImpl_Create(ppIWICStream);
263 static HRESULT WINAPI ImagingFactory_CreateColorContext(IWICImagingFactory *iface,
264 IWICColorContext **ppIColorContext)
266 FIXME("(%p,%p): stub\n", iface, ppIColorContext);
267 return E_NOTIMPL;
270 static HRESULT WINAPI ImagingFactory_CreateColorTransformer(IWICImagingFactory *iface,
271 IWICColorTransform **ppIColorTransform)
273 FIXME("(%p,%p): stub\n", iface, ppIColorTransform);
274 return E_NOTIMPL;
277 static HRESULT WINAPI ImagingFactory_CreateBitmap(IWICImagingFactory *iface,
278 UINT uiWidth, UINT uiHeight, REFWICPixelFormatGUID pixelFormat,
279 WICBitmapCreateCacheOption option, IWICBitmap **ppIBitmap)
281 FIXME("(%p,%u,%u,%s,%u,%p): stub\n", iface, uiWidth, uiHeight,
282 debugstr_guid(pixelFormat), option, ppIBitmap);
283 return E_NOTIMPL;
286 static HRESULT WINAPI ImagingFactory_CreateBitmapFromSource(IWICImagingFactory *iface,
287 IWICBitmapSource *piBitmapSource, WICBitmapCreateCacheOption option,
288 IWICBitmap **ppIBitmap)
290 FIXME("(%p,%p,%u,%p): stub\n", iface, piBitmapSource, option, ppIBitmap);
291 return E_NOTIMPL;
294 static HRESULT WINAPI ImagingFactory_CreateBitmapFromSourceRect(IWICImagingFactory *iface,
295 IWICBitmapSource *piBitmapSource, UINT x, UINT y, UINT width, UINT height,
296 IWICBitmap **ppIBitmap)
298 FIXME("(%p,%p,%u,%u,%u,%u,%p): stub\n", iface, piBitmapSource, x, y, width,
299 height, ppIBitmap);
300 return E_NOTIMPL;
303 static HRESULT WINAPI ImagingFactory_CreateBitmapFromMemory(IWICImagingFactory *iface,
304 UINT uiWidth, UINT uiHeight, REFWICPixelFormatGUID pixelFormat, UINT cbStride,
305 UINT cbBufferSize, BYTE *pbBuffer, IWICBitmap **ppIBitmap)
307 FIXME("(%p,%u,%u,%s,%u,%u,%p,%p): stub\n", iface, uiWidth, uiHeight,
308 debugstr_guid(pixelFormat), cbStride, cbBufferSize, pbBuffer, ppIBitmap);
309 return E_NOTIMPL;
312 static HRESULT WINAPI ImagingFactory_CreateBitmapFromHBITMAP(IWICImagingFactory *iface,
313 HBITMAP hBitmap, HPALETTE hPalette, WICBitmapAlphaChannelOption options,
314 IWICBitmap **ppIBitmap)
316 FIXME("(%p,%p,%p,%u,%p): stub\n", iface, hBitmap, hPalette, options, ppIBitmap);
317 return E_NOTIMPL;
320 static HRESULT WINAPI ImagingFactory_CreateBitmapFromHICON(IWICImagingFactory *iface,
321 HICON hIcon, IWICBitmap **ppIBitmap)
323 FIXME("(%p,%p,%p): stub\n", iface, hIcon, ppIBitmap);
324 return E_NOTIMPL;
327 static HRESULT WINAPI ImagingFactory_CreateComponentEnumerator(IWICImagingFactory *iface,
328 DWORD componentTypes, DWORD options, IEnumUnknown **ppIEnumUnknown)
330 TRACE("(%p,%u,%u,%p)\n", iface, componentTypes, options, ppIEnumUnknown);
331 return CreateComponentEnumerator(componentTypes, options, ppIEnumUnknown);
334 static HRESULT WINAPI ImagingFactory_CreateFastMetadataEncoderFromDecoder(
335 IWICImagingFactory *iface, IWICBitmapDecoder *pIDecoder,
336 IWICFastMetadataEncoder **ppIFastEncoder)
338 FIXME("(%p,%p,%p): stub\n", iface, pIDecoder, ppIFastEncoder);
339 return E_NOTIMPL;
342 static HRESULT WINAPI ImagingFactory_CreateFastMetadataEncoderFromFrameDecode(
343 IWICImagingFactory *iface, IWICBitmapFrameDecode *pIFrameDecoder,
344 IWICFastMetadataEncoder **ppIFastEncoder)
346 FIXME("(%p,%p,%p): stub\n", iface, pIFrameDecoder, ppIFastEncoder);
347 return E_NOTIMPL;
350 static HRESULT WINAPI ImagingFactory_CreateQueryWriter(IWICImagingFactory *iface,
351 REFGUID guidMetadataFormat, const GUID *pguidVendor,
352 IWICMetadataQueryWriter **ppIQueryWriter)
354 FIXME("(%p,%s,%s,%p): stub\n", iface, debugstr_guid(guidMetadataFormat),
355 debugstr_guid(pguidVendor), ppIQueryWriter);
356 return E_NOTIMPL;
359 static HRESULT WINAPI ImagingFactory_CreateQueryWriterFromReader(IWICImagingFactory *iface,
360 IWICMetadataQueryReader *pIQueryReader, const GUID *pguidVendor,
361 IWICMetadataQueryWriter **ppIQueryWriter)
363 FIXME("(%p,%p,%s,%p): stub\n", iface, pIQueryReader, debugstr_guid(pguidVendor),
364 ppIQueryWriter);
365 return E_NOTIMPL;
368 static const IWICImagingFactoryVtbl ImagingFactory_Vtbl = {
369 ImagingFactory_QueryInterface,
370 ImagingFactory_AddRef,
371 ImagingFactory_Release,
372 ImagingFactory_CreateDecoderFromFilename,
373 ImagingFactory_CreateDecoderFromStream,
374 ImagingFactory_CreateDecoderFromFileHandle,
375 ImagingFactory_CreateComponentInfo,
376 ImagingFactory_CreateDecoder,
377 ImagingFactory_CreateEncoder,
378 ImagingFactory_CreatePalette,
379 ImagingFactory_CreateFormatConverter,
380 ImagingFactory_CreateBitmapScaler,
381 ImagingFactory_CreateBitmapClipper,
382 ImagingFactory_CreateBitmapFlipRotator,
383 ImagingFactory_CreateStream,
384 ImagingFactory_CreateColorContext,
385 ImagingFactory_CreateColorTransformer,
386 ImagingFactory_CreateBitmap,
387 ImagingFactory_CreateBitmapFromSource,
388 ImagingFactory_CreateBitmapFromSourceRect,
389 ImagingFactory_CreateBitmapFromMemory,
390 ImagingFactory_CreateBitmapFromHBITMAP,
391 ImagingFactory_CreateBitmapFromHICON,
392 ImagingFactory_CreateComponentEnumerator,
393 ImagingFactory_CreateFastMetadataEncoderFromDecoder,
394 ImagingFactory_CreateFastMetadataEncoderFromFrameDecode,
395 ImagingFactory_CreateQueryWriter,
396 ImagingFactory_CreateQueryWriterFromReader
399 HRESULT ImagingFactory_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
401 ImagingFactory *This;
402 HRESULT ret;
404 TRACE("(%p,%s,%p)\n", pUnkOuter, debugstr_guid(iid), ppv);
406 *ppv = NULL;
408 if (pUnkOuter) return CLASS_E_NOAGGREGATION;
410 This = HeapAlloc(GetProcessHeap(), 0, sizeof(ImagingFactory));
411 if (!This) return E_OUTOFMEMORY;
413 This->lpIWICImagingFactoryVtbl = &ImagingFactory_Vtbl;
414 This->ref = 1;
416 ret = IUnknown_QueryInterface((IUnknown*)This, iid, ppv);
417 IUnknown_Release((IUnknown*)This);
419 return ret;