gdiplus: Don't use CoCreateInstance in decode_image_wic.

This commit is contained in:
Piotr Caban 2015-03-06 11:20:33 +01:00 committed by Alexandre Julliard
parent df9ec3c178
commit b03c60d85c
1 changed files with 15 additions and 11 deletions

View File

@ -40,6 +40,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(gdiplus); WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
HRESULT WINAPI WICCreateImagingFactory_Proxy(UINT, IWICImagingFactory**);
#define PIXELFORMATBPP(x) ((x) ? ((x) >> 8) & 255 : 24) #define PIXELFORMATBPP(x) ((x) ? ((x) >> 8) & 255 : 24)
static const struct static const struct
@ -3403,12 +3405,13 @@ static void gif_metadata_reader(GpBitmap *bitmap, IWICBitmapDecoder *decoder, UI
typedef void (*metadata_reader_func)(GpBitmap *bitmap, IWICBitmapDecoder *decoder, UINT frame); typedef void (*metadata_reader_func)(GpBitmap *bitmap, IWICBitmapDecoder *decoder, UINT frame);
static GpStatus decode_image_wic(IStream *stream, GDIPCONST CLSID *clsid, static GpStatus decode_image_wic(IStream *stream, REFGUID container,
UINT active_frame, metadata_reader_func metadata_reader, GpImage **image) UINT active_frame, metadata_reader_func metadata_reader, GpImage **image)
{ {
GpStatus status=Ok; GpStatus status=Ok;
GpBitmap *bitmap; GpBitmap *bitmap;
HRESULT hr; HRESULT hr;
IWICImagingFactory *factory;
IWICBitmapDecoder *decoder; IWICBitmapDecoder *decoder;
IWICBitmapFrameDecode *frame; IWICBitmapFrameDecode *frame;
IWICBitmapSource *source=NULL; IWICBitmapSource *source=NULL;
@ -3423,12 +3426,13 @@ static GpStatus decode_image_wic(IStream *stream, GDIPCONST CLSID *clsid,
WICRect wrc; WICRect wrc;
HRESULT initresult; HRESULT initresult;
TRACE("%p,%s,%u,%p\n", stream, wine_dbgstr_guid(clsid), active_frame, image); TRACE("%p,%s,%u,%p\n", stream, wine_dbgstr_guid(container), active_frame, image);
initresult = CoInitialize(NULL); initresult = CoInitialize(NULL);
hr = WICCreateImagingFactory_Proxy(WINCODEC_SDK_VERSION, &factory);
hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, if (FAILED(hr)) goto end;
&IID_IWICBitmapDecoder, (void**)&decoder); hr = IWICImagingFactory_CreateDecoder(factory, container, NULL, &decoder);
IWICImagingFactory_Release(factory);
if (FAILED(hr)) goto end; if (FAILED(hr)) goto end;
hr = IWICBitmapDecoder_Initialize(decoder, stream, WICDecodeMetadataCacheOnLoad); hr = IWICBitmapDecoder_Initialize(decoder, stream, WICDecodeMetadataCacheOnLoad);
@ -3571,7 +3575,7 @@ end:
static GpStatus decode_image_icon(IStream* stream, REFCLSID clsid, UINT active_frame, GpImage **image) static GpStatus decode_image_icon(IStream* stream, REFCLSID clsid, UINT active_frame, GpImage **image)
{ {
return decode_image_wic(stream, &CLSID_WICIcoDecoder, active_frame, NULL, image); return decode_image_wic(stream, &GUID_ContainerFormatIco, active_frame, NULL, image);
} }
static GpStatus decode_image_bmp(IStream* stream, REFCLSID clsid, UINT active_frame, GpImage **image) static GpStatus decode_image_bmp(IStream* stream, REFCLSID clsid, UINT active_frame, GpImage **image)
@ -3579,7 +3583,7 @@ static GpStatus decode_image_bmp(IStream* stream, REFCLSID clsid, UINT active_fr
GpStatus status; GpStatus status;
GpBitmap* bitmap; GpBitmap* bitmap;
status = decode_image_wic(stream, &CLSID_WICBmpDecoder, active_frame, NULL, image); status = decode_image_wic(stream, &GUID_ContainerFormatBmp, active_frame, NULL, image);
bitmap = (GpBitmap*)*image; bitmap = (GpBitmap*)*image;
@ -3594,22 +3598,22 @@ static GpStatus decode_image_bmp(IStream* stream, REFCLSID clsid, UINT active_fr
static GpStatus decode_image_jpeg(IStream* stream, REFCLSID clsid, UINT active_frame, GpImage **image) static GpStatus decode_image_jpeg(IStream* stream, REFCLSID clsid, UINT active_frame, GpImage **image)
{ {
return decode_image_wic(stream, &CLSID_WICJpegDecoder, active_frame, NULL, image); return decode_image_wic(stream, &GUID_ContainerFormatJpeg, active_frame, NULL, image);
} }
static GpStatus decode_image_png(IStream* stream, REFCLSID clsid, UINT active_frame, GpImage **image) static GpStatus decode_image_png(IStream* stream, REFCLSID clsid, UINT active_frame, GpImage **image)
{ {
return decode_image_wic(stream, &CLSID_WICPngDecoder, active_frame, NULL, image); return decode_image_wic(stream, &GUID_ContainerFormatPng, active_frame, NULL, image);
} }
static GpStatus decode_image_gif(IStream* stream, REFCLSID clsid, UINT active_frame, GpImage **image) static GpStatus decode_image_gif(IStream* stream, REFCLSID clsid, UINT active_frame, GpImage **image)
{ {
return decode_image_wic(stream, &CLSID_WICGifDecoder, active_frame, gif_metadata_reader, image); return decode_image_wic(stream, &GUID_ContainerFormatGif, active_frame, gif_metadata_reader, image);
} }
static GpStatus decode_image_tiff(IStream* stream, REFCLSID clsid, UINT active_frame, GpImage **image) static GpStatus decode_image_tiff(IStream* stream, REFCLSID clsid, UINT active_frame, GpImage **image)
{ {
return decode_image_wic(stream, &CLSID_WICTiffDecoder, active_frame, NULL, image); return decode_image_wic(stream, &GUID_ContainerFormatTiff, active_frame, NULL, image);
} }
static GpStatus decode_image_olepicture_metafile(IStream* stream, REFCLSID clsid, UINT active_frame, GpImage **image) static GpStatus decode_image_olepicture_metafile(IStream* stream, REFCLSID clsid, UINT active_frame, GpImage **image)