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
31 #include "wincodecs_private.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
38 const IWICImagingFactoryVtbl *lpIWICImagingFactoryVtbl;
42 static HRESULT WINAPI ImagingFactory_QueryInterface(IWICImagingFactory *iface, REFIID iid,
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))
60 IUnknown_AddRef((IUnknown*)*ppv);
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);
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);
82 HeapFree(GetProcessHeap(), 0, This);
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);
97 static HRESULT WINAPI ImagingFactory_CreateDecoderFromStream(
98 IWICImagingFactory *iface, IStream *pIStream, const GUID *pguidVendor,
99 WICDecodeOptions metadataOptions, IWICBitmapDecoder **ppIDecoder)
102 IEnumUnknown *enumdecoders;
103 IUnknown *unkdecoderinfo;
104 IWICBitmapDecoderInfo *decoderinfo;
105 IWICBitmapDecoder *decoder=NULL;
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;
121 res = IEnumUnknown_Next(enumdecoders, 1, &unkdecoderinfo, &num_fetched);
125 res = IUnknown_QueryInterface(unkdecoderinfo, &IID_IWICBitmapDecoderInfo, (void**)&decoderinfo);
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 */
139 res = IWICBitmapDecoder_Initialize(decoder, pIStream, metadataOptions);
143 IWICBitmapDecoder_Release(decoder);
149 IWICBitmapDecoderInfo_Release(decoderinfo);
152 IUnknown_Release(unkdecoderinfo);
158 IEnumUnknown_Release(enumdecoders);
162 *ppIDecoder = decoder;
168 return WINCODEC_ERR_COMPONENTNOTFOUND;
172 static HRESULT WINAPI ImagingFactory_CreateDecoderFromFileHandle(
173 IWICImagingFactory *iface, ULONG_PTR hFile, const GUID *pguidVendor,
174 WICDecodeOptions metadataOptions, IWICBitmapDecoder **ppIDecoder)
176 FIXME("(%p,%lx,%s,%u,%p): stub\n", iface, hFile, debugstr_guid(pguidVendor),
177 metadataOptions, ppIDecoder);
181 static HRESULT WINAPI ImagingFactory_CreateComponentInfo(IWICImagingFactory *iface,
182 REFCLSID clsidComponent, IWICComponentInfo **ppIInfo)
184 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(clsidComponent), ppIInfo);
185 return CreateComponentInfo(clsidComponent, ppIInfo);
188 static HRESULT WINAPI ImagingFactory_CreateDecoder(IWICImagingFactory *iface,
189 REFGUID guidContainerFormat, const GUID *pguidVendor,
190 IWICBitmapDecoder **ppIDecoder)
192 FIXME("(%p,%s,%s,%p): stub\n", iface, debugstr_guid(guidContainerFormat),
193 debugstr_guid(pguidVendor), ppIDecoder);
197 static HRESULT WINAPI ImagingFactory_CreateEncoder(IWICImagingFactory *iface,
198 REFGUID guidContainerFormat, const GUID *pguidVendor,
199 IWICBitmapEncoder **ppIEncoder)
201 FIXME("(%p,%s,%s,%p): stub\n", iface, debugstr_guid(guidContainerFormat),
202 debugstr_guid(pguidVendor), ppIEncoder);
206 static HRESULT WINAPI ImagingFactory_CreatePalette(IWICImagingFactory *iface,
207 IWICPalette **ppIPalette)
209 TRACE("(%p,%p)\n", iface, ppIPalette);
210 return PaletteImpl_Create(ppIPalette);
213 static HRESULT WINAPI ImagingFactory_CreateFormatConverter(IWICImagingFactory *iface,
214 IWICFormatConverter **ppIFormatConverter)
216 FIXME("(%p,%p): stub\n", iface, ppIFormatConverter);
220 static HRESULT WINAPI ImagingFactory_CreateBitmapScaler(IWICImagingFactory *iface,
221 IWICBitmapScaler **ppIBitmapScaler)
223 FIXME("(%p,%p): stub\n", iface, ppIBitmapScaler);
227 static HRESULT WINAPI ImagingFactory_CreateBitmapClipper(IWICImagingFactory *iface,
228 IWICBitmapClipper **ppIBitmapClipper)
230 FIXME("(%p,%p): stub\n", iface, ppIBitmapClipper);
234 static HRESULT WINAPI ImagingFactory_CreateBitmapFlipRotator(IWICImagingFactory *iface,
235 IWICBitmapFlipRotator **ppIBitmapFlipRotator)
237 FIXME("(%p,%p): stub\n", iface, ppIBitmapFlipRotator);
241 static HRESULT WINAPI ImagingFactory_CreateStream(IWICImagingFactory *iface,
242 IWICStream **ppIWICStream)
244 FIXME("(%p,%p): stub\n", iface, ppIWICStream);
248 static HRESULT WINAPI ImagingFactory_CreateColorContext(IWICImagingFactory *iface,
249 IWICColorContext **ppIColorContext)
251 FIXME("(%p,%p): stub\n", iface, ppIColorContext);
255 static HRESULT WINAPI ImagingFactory_CreateColorTransformer(IWICImagingFactory *iface,
256 IWICColorTransform **ppIColorTransform)
258 FIXME("(%p,%p): stub\n", iface, ppIColorTransform);
262 static HRESULT WINAPI ImagingFactory_CreateBitmap(IWICImagingFactory *iface,
263 UINT uiWidth, UINT uiHeight, REFWICPixelFormatGUID pixelFormat,
264 WICBitmapCreateCacheOption option, IWICBitmap **ppIBitmap)
266 FIXME("(%p,%u,%u,%s,%u,%p): stub\n", iface, uiWidth, uiHeight,
267 debugstr_guid(pixelFormat), option, ppIBitmap);
271 static HRESULT WINAPI ImagingFactory_CreateBitmapFromSource(IWICImagingFactory *iface,
272 IWICBitmapSource *piBitmapSource, WICBitmapCreateCacheOption option,
273 IWICBitmap **ppIBitmap)
275 FIXME("(%p,%p,%u,%p): stub\n", iface, piBitmapSource, option, ppIBitmap);
279 static HRESULT WINAPI ImagingFactory_CreateBitmapFromSourceRect(IWICImagingFactory *iface,
280 IWICBitmapSource *piBitmapSource, UINT x, UINT y, UINT width, UINT height,
281 IWICBitmap **ppIBitmap)
283 FIXME("(%p,%p,%u,%u,%u,%u,%p): stub\n", iface, piBitmapSource, x, y, width,
288 static HRESULT WINAPI ImagingFactory_CreateBitmapFromMemory(IWICImagingFactory *iface,
289 UINT uiWidth, UINT uiHeight, REFWICPixelFormatGUID pixelFormat, UINT cbStride,
290 UINT cbBufferSize, BYTE *pbBuffer, IWICBitmap **ppIBitmap)
292 FIXME("(%p,%u,%u,%s,%u,%u,%p,%p): stub\n", iface, uiWidth, uiHeight,
293 debugstr_guid(pixelFormat), cbStride, cbBufferSize, pbBuffer, ppIBitmap);
297 static HRESULT WINAPI ImagingFactory_CreateBitmapFromHBITMAP(IWICImagingFactory *iface,
298 HBITMAP hBitmap, HPALETTE hPalette, WICBitmapAlphaChannelOption options,
299 IWICBitmap **ppIBitmap)
301 FIXME("(%p,%p,%p,%u,%p): stub\n", iface, hBitmap, hPalette, options, ppIBitmap);
305 static HRESULT WINAPI ImagingFactory_CreateBitmapFromHICON(IWICImagingFactory *iface,
306 HICON hIcon, IWICBitmap **ppIBitmap)
308 FIXME("(%p,%p,%p): stub\n", iface, hIcon, ppIBitmap);
312 static HRESULT WINAPI ImagingFactory_CreateComponentEnumerator(IWICImagingFactory *iface,
313 DWORD componentTypes, DWORD options, IEnumUnknown **ppIEnumUnknown)
315 TRACE("(%p,%u,%u,%p)\n", iface, componentTypes, options, ppIEnumUnknown);
316 return CreateComponentEnumerator(componentTypes, options, ppIEnumUnknown);
319 static HRESULT WINAPI ImagingFactory_CreateFastMetadataEncoderFromDecoder(
320 IWICImagingFactory *iface, IWICBitmapDecoder *pIDecoder,
321 IWICFastMetadataEncoder **ppIFastEncoder)
323 FIXME("(%p,%p,%p): stub\n", iface, pIDecoder, ppIFastEncoder);
327 static HRESULT WINAPI ImagingFactory_CreateFastMetadataEncoderFromFrameDecode(
328 IWICImagingFactory *iface, IWICBitmapFrameDecode *pIFrameDecoder,
329 IWICFastMetadataEncoder **ppIFastEncoder)
331 FIXME("(%p,%p,%p): stub\n", iface, pIFrameDecoder, ppIFastEncoder);
335 static HRESULT WINAPI ImagingFactory_CreateQueryWriter(IWICImagingFactory *iface,
336 REFGUID guidMetadataFormat, const GUID *pguidVendor,
337 IWICMetadataQueryWriter **ppIQueryWriter)
339 FIXME("(%p,%s,%s,%p): stub\n", iface, debugstr_guid(guidMetadataFormat),
340 debugstr_guid(pguidVendor), ppIQueryWriter);
344 static HRESULT WINAPI ImagingFactory_CreateQueryWriterFromReader(IWICImagingFactory *iface,
345 IWICMetadataQueryReader *pIQueryReader, const GUID *pguidVendor,
346 IWICMetadataQueryWriter **ppIQueryWriter)
348 FIXME("(%p,%p,%s,%p): stub\n", iface, pIQueryReader, debugstr_guid(pguidVendor),
353 static const IWICImagingFactoryVtbl ImagingFactory_Vtbl = {
354 ImagingFactory_QueryInterface,
355 ImagingFactory_AddRef,
356 ImagingFactory_Release,
357 ImagingFactory_CreateDecoderFromFilename,
358 ImagingFactory_CreateDecoderFromStream,
359 ImagingFactory_CreateDecoderFromFileHandle,
360 ImagingFactory_CreateComponentInfo,
361 ImagingFactory_CreateDecoder,
362 ImagingFactory_CreateEncoder,
363 ImagingFactory_CreatePalette,
364 ImagingFactory_CreateFormatConverter,
365 ImagingFactory_CreateBitmapScaler,
366 ImagingFactory_CreateBitmapClipper,
367 ImagingFactory_CreateBitmapFlipRotator,
368 ImagingFactory_CreateStream,
369 ImagingFactory_CreateColorContext,
370 ImagingFactory_CreateColorTransformer,
371 ImagingFactory_CreateBitmap,
372 ImagingFactory_CreateBitmapFromSource,
373 ImagingFactory_CreateBitmapFromSourceRect,
374 ImagingFactory_CreateBitmapFromMemory,
375 ImagingFactory_CreateBitmapFromHBITMAP,
376 ImagingFactory_CreateBitmapFromHICON,
377 ImagingFactory_CreateComponentEnumerator,
378 ImagingFactory_CreateFastMetadataEncoderFromDecoder,
379 ImagingFactory_CreateFastMetadataEncoderFromFrameDecode,
380 ImagingFactory_CreateQueryWriter,
381 ImagingFactory_CreateQueryWriterFromReader
384 HRESULT ImagingFactory_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
386 ImagingFactory *This;
389 TRACE("(%p,%s,%p)\n", pUnkOuter, debugstr_guid(iid), ppv);
393 if (pUnkOuter) return CLASS_E_NOAGGREGATION;
395 This = HeapAlloc(GetProcessHeap(), 0, sizeof(ImagingFactory));
396 if (!This) return E_OUTOFMEMORY;
398 This->lpIWICImagingFactoryVtbl = &ImagingFactory_Vtbl;
401 ret = IUnknown_QueryInterface((IUnknown*)This, iid, ppv);
402 IUnknown_Release((IUnknown*)This);