[WINDOWSCODECS] Sync with Wine Staging 4.0. CORE-15682
authorAmine Khaldi <amine.khaldi@reactos.org>
Mon, 4 Feb 2019 12:12:26 +0000 (13:12 +0100)
committerAmine Khaldi <amine.khaldi@reactos.org>
Mon, 4 Feb 2019 12:12:26 +0000 (13:12 +0100)
27 files changed:
dll/win32/windowscodecs/bitmap.c
dll/win32/windowscodecs/bmpdecode.c
dll/win32/windowscodecs/bmpencode.c
dll/win32/windowscodecs/clipper.c
dll/win32/windowscodecs/clsfactory.c
dll/win32/windowscodecs/colortransform.c
dll/win32/windowscodecs/converter.c
dll/win32/windowscodecs/fliprotate.c
dll/win32/windowscodecs/gifformat.c
dll/win32/windowscodecs/icnsformat.c
dll/win32/windowscodecs/icoformat.c
dll/win32/windowscodecs/imgfactory.c
dll/win32/windowscodecs/info.c
dll/win32/windowscodecs/jpegformat.c
dll/win32/windowscodecs/main.c
dll/win32/windowscodecs/metadataquery.c
dll/win32/windowscodecs/palette.c
dll/win32/windowscodecs/pngformat.c
dll/win32/windowscodecs/proxy.c
dll/win32/windowscodecs/regsvr.c
dll/win32/windowscodecs/scaler.c
dll/win32/windowscodecs/stream.c
dll/win32/windowscodecs/tgaformat.c
dll/win32/windowscodecs/tiffformat.c
dll/win32/windowscodecs/wincodecs_private.h
dll/win32/windowscodecs/windowscodecs.spec
media/doc/README.WINE

index 734c211..a44f5bd 100644 (file)
@@ -361,7 +361,7 @@ static HRESULT WINAPI BitmapImpl_CopyPixels(IWICBitmap *iface,
     const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
 {
     BitmapImpl *This = impl_from_IWICBitmap(iface);
-    TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer);
+    TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
 
     return copy_pixels(This->bpp, This->data, This->width, This->height,
         This->stride, prc, cbStride, cbBufferSize, pbBuffer);
@@ -374,7 +374,7 @@ static HRESULT WINAPI BitmapImpl_Lock(IWICBitmap *iface, const WICRect *prcLock,
     BitmapLockImpl *result;
     WICRect rc;
 
-    TRACE("(%p,%p,%x,%p)\n", iface, prcLock, flags, ppILock);
+    TRACE("(%p,%s,%x,%p)\n", iface, debug_wic_rect(prcLock), flags, ppILock);
 
     if (!(flags & (WICBitmapLockRead|WICBitmapLockWrite)) || !ppILock)
         return E_INVALIDARG;
@@ -568,7 +568,7 @@ static HRESULT WINAPI IMILBitmapImpl_GetPixelFormat(IMILBitmapSource *iface,
 
     *format = 0;
 
-    for (i = 0; i < sizeof(pixel_fmt_map)/sizeof(pixel_fmt_map[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(pixel_fmt_map); i++)
     {
         if (IsEqualGUID(pixel_fmt_map[i].WIC_format, &This->pixelformat))
         {
index 1b8e4d1..f5a2589 100644 (file)
@@ -321,7 +321,7 @@ static HRESULT WINAPI BmpFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface,
     BmpDecoder *This = impl_from_IWICBitmapFrameDecode(iface);
     HRESULT hr=S_OK;
     UINT width, height;
-    TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer);
+    TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
 
     EnterCriticalSection(&This->lock);
     if (!This->imagedata)
index a81cc53..3b77517 100644 (file)
@@ -189,6 +189,11 @@ static HRESULT WINAPI BmpFrameEncode_SetPixelFormat(IWICBitmapFrameEncode *iface
 
     if (!This->initialized || This->bits) return WINCODEC_ERR_WRONGSTATE;
 
+    if (IsEqualGUID(pPixelFormat, &GUID_WICPixelFormatBlackWhite))
+        *pPixelFormat = GUID_WICPixelFormat1bppIndexed;
+    else if (IsEqualGUID(pPixelFormat, &GUID_WICPixelFormat2bppIndexed))
+        *pPixelFormat = GUID_WICPixelFormat4bppIndexed;
+
     for (i=0; formats[i].guid; i++)
     {
         if (IsEqualGUID(formats[i].guid, pPixelFormat))
@@ -196,8 +201,6 @@ static HRESULT WINAPI BmpFrameEncode_SetPixelFormat(IWICBitmapFrameEncode *iface
     }
 
     if (!formats[i].guid) i = 0;
-    else if (IsEqualGUID(pPixelFormat, &GUID_WICPixelFormatBlackWhite))
-        i = 2; /* GUID_WICPixelFormat1bppIndexed */
 
     This->format = &formats[i];
     memcpy(pPixelFormat, This->format->guid, sizeof(GUID));
@@ -301,7 +304,7 @@ static HRESULT WINAPI BmpFrameEncode_WriteSource(IWICBitmapFrameEncode *iface,
 {
     BmpFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
     HRESULT hr;
-    TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc);
+    TRACE("(%p,%p,%s)\n", iface, pIBitmapSource, debug_wic_rect(prc));
 
     if (!This->initialized)
         return WINCODEC_ERR_WRONGSTATE;
@@ -498,6 +501,11 @@ static HRESULT WINAPI BmpEncoder_Initialize(IWICBitmapEncoder *iface,
 static HRESULT WINAPI BmpEncoder_GetContainerFormat(IWICBitmapEncoder *iface,
     GUID *pguidContainerFormat)
 {
+    TRACE("(%p,%p)\n", iface, pguidContainerFormat);
+
+    if (!pguidContainerFormat)
+        return E_INVALIDARG;
+
     memcpy(pguidContainerFormat, &GUID_ContainerFormatBmp, sizeof(GUID));
     return S_OK;
 }
@@ -566,7 +574,7 @@ static HRESULT WINAPI BmpEncoder_CreateNewFrame(IWICBitmapEncoder *iface,
 
     if (ppIEncoderOptions)
     {
-        hr = CreatePropertyBag2(opts, sizeof(opts)/sizeof(opts[0]), ppIEncoderOptions);
+        hr = CreatePropertyBag2(opts, ARRAY_SIZE(opts), ppIEncoderOptions);
         if (FAILED(hr)) return hr;
     }
 
index 94127f3..02e0d96 100644 (file)
@@ -167,7 +167,7 @@ static HRESULT WINAPI BitmapClipper_CopyPixels(IWICBitmapClipper *iface,
     BitmapClipper *This = impl_from_IWICBitmapClipper(iface);
     WICRect rect;
 
-    TRACE("(%p,%p,%u,%u,%p)\n", iface, rc, stride, buffer_size, buffer);
+    TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(rc), stride, buffer_size, buffer);
 
     if (!This->source)
         return WINCODEC_ERR_WRONGSTATE;
@@ -199,7 +199,7 @@ static HRESULT WINAPI BitmapClipper_Initialize(IWICBitmapClipper *iface,
     UINT width, height;
     HRESULT hr = S_OK;
 
-    TRACE("(%p,%p,%p)\n", iface, source, rc);
+    TRACE("(%p,%p,%s)\n", iface, source, debug_wic_rect(rc));
 
     EnterCriticalSection(&This->lock);
 
index 98938eb..2de518a 100644 (file)
@@ -43,7 +43,8 @@ typedef struct {
 } classinfo;
 
 static const classinfo wic_classes[] = {
-    {&CLSID_WICImagingFactory, ComponentFactory_CreateInstance},
+    {&CLSID_WICImagingFactory, ImagingFactory_CreateInstance},
+    {&CLSID_WICImagingFactory2, ImagingFactory_CreateInstance},
     {&CLSID_WICBmpDecoder, BmpDecoder_CreateInstance},
     {&CLSID_WICPngDecoder, PngDecoder_CreateInstance},
     {&CLSID_WICPngEncoder, PngEncoder_CreateInstance},
index 5b1c7e8..af66c67 100644 (file)
@@ -133,7 +133,7 @@ static HRESULT WINAPI ColorTransform_CopyPixels(IWICColorTransform *iface,
     const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
 {
     ColorTransform *This = impl_from_IWICColorTransform(iface);
-    TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer);
+    TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
 
     return IWICBitmapSource_CopyPixels(This->dst, prc, cbStride, cbBufferSize, pbBuffer);
 }
index 0d3414a..c3476c3 100644 (file)
@@ -1583,7 +1583,7 @@ static HRESULT WINAPI FormatConverter_CopyPixels(IWICFormatConverter *iface,
     FormatConverter *This = impl_from_IWICFormatConverter(iface);
     WICRect rc;
     HRESULT hr;
-    TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer);
+    TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
 
     if (This->source)
     {
index 72d1e8a..4640223 100644 (file)
@@ -161,7 +161,7 @@ static HRESULT WINAPI FlipRotator_CopyPixels(IWICBitmapFlipRotator *iface,
     WICRect rc;
     WICRect rect;
 
-    TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer);
+    TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
 
     if (!This->source) return WINCODEC_ERR_WRONGSTATE;
 
index 78ac427..d4d23ff 100644 (file)
@@ -801,7 +801,7 @@ static HRESULT WINAPI GifFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface,
     const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
 {
     GifFrameDecode *This = impl_from_IWICBitmapFrameDecode(iface);
-    TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer);
+    TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
 
     if (This->frame->ImageDesc.Interlace)
     {
index aa96404..02e8ee9 100644 (file)
@@ -390,7 +390,7 @@ static HRESULT WINAPI IcnsFrameEncode_WriteSource(IWICBitmapFrameEncode *iface,
     IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
     HRESULT hr;
 
-    TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc);
+    TRACE("(%p,%p,%s)\n", iface, pIBitmapSource, debug_wic_rect(prc));
 
     if (!This->initialized)
         return WINCODEC_ERR_WRONGSTATE;
index 5e38ee0..d2a6196 100644 (file)
@@ -176,7 +176,7 @@ static HRESULT WINAPI IcoFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface,
     const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
 {
     IcoFrameDecode *This = impl_from_IWICBitmapFrameDecode(iface);
-    TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer);
+    TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
 
     return copy_pixels(32, This->bits, This->width, This->height, This->width * 4,
         prc, cbStride, cbBufferSize, pbBuffer);
@@ -511,6 +511,9 @@ static HRESULT WINAPI IcoDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p
     LARGE_INTEGER seek;
     HRESULT hr;
     ULONG bytesread;
+    STATSTG statstg;
+    unsigned int i;
+
     TRACE("(%p,%p,%x)\n", iface, pIStream, cacheOptions);
 
     EnterCriticalSection(&This->lock);
@@ -527,14 +530,41 @@ static HRESULT WINAPI IcoDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p
 
     hr = IStream_Read(pIStream, &This->header, sizeof(ICONHEADER), &bytesread);
     if (FAILED(hr)) goto end;
-    if (bytesread != sizeof(ICONHEADER) ||
-        This->header.idReserved != 0 ||
+
+    if (bytesread != sizeof(ICONHEADER))
+    {
+        hr = WINCODEC_ERR_STREAMREAD;
+        goto end;
+    }
+
+    if (This->header.idReserved != 0 ||
         This->header.idType != 1)
     {
         hr = E_FAIL;
         goto end;
     }
 
+    hr = IStream_Stat(pIStream, &statstg, STATFLAG_NONAME);
+    if (FAILED(hr))
+    {
+        WARN("Stat() failed, hr %#x.\n", hr);
+        goto end;
+    }
+
+    for (i = 0; i < This->header.idCount; i++)
+    {
+        ICONDIRENTRY direntry;
+
+        hr = IStream_Read(pIStream, &direntry, sizeof(direntry), &bytesread);
+        if (FAILED(hr)) goto end;
+
+        if (bytesread != sizeof(direntry) || (direntry.dwDIBSize + direntry.dwDIBOffset > statstg.cbSize.QuadPart))
+        {
+            hr = WINCODEC_ERR_BADIMAGE;
+            goto end;
+        }
+    }
+
     This->initialized = TRUE;
     This->stream = pIStream;
     IStream_AddRef(pIStream);
index 180e745..e127e40 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "config.h"
 
+#include <assert.h>
 #include <stdarg.h>
 
 #define COBJMACROS
 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
 
 typedef struct {
+    IWICImagingFactory2 IWICImagingFactory2_iface;
     IWICComponentFactory IWICComponentFactory_iface;
     LONG ref;
-} ComponentFactory;
+} ImagingFactory;
 
-static inline ComponentFactory *impl_from_IWICComponentFactory(IWICComponentFactory *iface)
+static inline ImagingFactory *impl_from_IWICComponentFactory(IWICComponentFactory *iface)
 {
-    return CONTAINING_RECORD(iface, ComponentFactory, IWICComponentFactory_iface);
+    return CONTAINING_RECORD(iface, ImagingFactory, IWICComponentFactory_iface);
 }
 
-static HRESULT WINAPI ComponentFactory_QueryInterface(IWICComponentFactory *iface, REFIID iid,
+static inline ImagingFactory *impl_from_IWICImagingFactory2(IWICImagingFactory2 *iface)
+{
+    return CONTAINING_RECORD(iface, ImagingFactory, IWICImagingFactory2_iface);
+}
+
+static HRESULT WINAPI ImagingFactory_QueryInterface(IWICImagingFactory2 *iface, REFIID iid,
     void **ppv)
 {
-    ComponentFactory *This = impl_from_IWICComponentFactory(iface);
+    ImagingFactory *This = impl_from_IWICImagingFactory2(iface);
     TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
 
     if (!ppv) return E_INVALIDARG;
@@ -59,6 +66,10 @@ static HRESULT WINAPI ComponentFactory_QueryInterface(IWICComponentFactory *ifac
     {
         *ppv = &This->IWICComponentFactory_iface;
     }
+    else if (IsEqualIID(&IID_IWICImagingFactory2, iid))
+    {
+        *ppv = &This->IWICImagingFactory2_iface;
+    }
     else
     {
         *ppv = NULL;
@@ -69,9 +80,9 @@ static HRESULT WINAPI ComponentFactory_QueryInterface(IWICComponentFactory *ifac
     return S_OK;
 }
 
-static ULONG WINAPI ComponentFactory_AddRef(IWICComponentFactory *iface)
+static ULONG WINAPI ImagingFactory_AddRef(IWICImagingFactory2 *iface)
 {
-    ComponentFactory *This = impl_from_IWICComponentFactory(iface);
+    ImagingFactory *This = impl_from_IWICImagingFactory2(iface);
     ULONG ref = InterlockedIncrement(&This->ref);
 
     TRACE("(%p) refcount=%u\n", iface, ref);
@@ -79,9 +90,9 @@ static ULONG WINAPI ComponentFactory_AddRef(IWICComponentFactory *iface)
     return ref;
 }
 
-static ULONG WINAPI ComponentFactory_Release(IWICComponentFactory *iface)
+static ULONG WINAPI ImagingFactory_Release(IWICImagingFactory2 *iface)
 {
-    ComponentFactory *This = impl_from_IWICComponentFactory(iface);
+    ImagingFactory *This = impl_from_IWICImagingFactory2(iface);
     ULONG ref = InterlockedDecrement(&This->ref);
 
     TRACE("(%p) refcount=%u\n", iface, ref);
@@ -92,8 +103,8 @@ static ULONG WINAPI ComponentFactory_Release(IWICComponentFactory *iface)
     return ref;
 }
 
-static HRESULT WINAPI ComponentFactory_CreateDecoderFromFilename(
-    IWICComponentFactory *iface, LPCWSTR wzFilename, const GUID *pguidVendor,
+static HRESULT WINAPI ImagingFactory_CreateDecoderFromFilename(
+    IWICImagingFactory2 *iface, LPCWSTR wzFilename, const GUID *pguidVendor,
     DWORD dwDesiredAccess, WICDecodeOptions metadataOptions,
     IWICBitmapDecoder **ppIDecoder)
 {
@@ -110,7 +121,7 @@ static HRESULT WINAPI ComponentFactory_CreateDecoderFromFilename(
 
         if (SUCCEEDED(hr))
         {
-            hr = IWICComponentFactory_CreateDecoderFromStream(iface, (IStream*)stream,
+            hr = IWICImagingFactory2_CreateDecoderFromStream(iface, (IStream*)stream,
                 pguidVendor, metadataOptions, ppIDecoder);
         }
 
@@ -174,6 +185,7 @@ static HRESULT find_decoder(IStream *pIStream, const GUID *pguidVendor,
                             IWICBitmapDecoder_Release(*decoder);
                             IWICBitmapDecoderInfo_Release(decoderinfo);
                             IUnknown_Release(unkdecoderinfo);
+                            IEnumUnknown_Release(enumdecoders);
                             *decoder = NULL;
                             return res;
                         }
@@ -194,8 +206,8 @@ static HRESULT find_decoder(IStream *pIStream, const GUID *pguidVendor,
     return WINCODEC_ERR_COMPONENTNOTFOUND;
 }
 
-static HRESULT WINAPI ComponentFactory_CreateDecoderFromStream(
-    IWICComponentFactory *iface, IStream *pIStream, const GUID *pguidVendor,
+static HRESULT WINAPI ImagingFactory_CreateDecoderFromStream(
+    IWICImagingFactory2 *iface, IStream *pIStream, const GUID *pguidVendor,
     WICDecodeOptions metadataOptions, IWICBitmapDecoder **ppIDecoder)
 {
     HRESULT res;
@@ -236,8 +248,8 @@ static HRESULT WINAPI ComponentFactory_CreateDecoderFromStream(
     }
 }
 
-static HRESULT WINAPI ComponentFactory_CreateDecoderFromFileHandle(
-    IWICComponentFactory *iface, ULONG_PTR hFile, const GUID *pguidVendor,
+static HRESULT WINAPI ImagingFactory_CreateDecoderFromFileHandle(
+    IWICImagingFactory2 *iface, ULONG_PTR hFile, const GUID *pguidVendor,
     WICDecodeOptions metadataOptions, IWICBitmapDecoder **ppIDecoder)
 {
     IWICStream *stream;
@@ -252,7 +264,7 @@ static HRESULT WINAPI ComponentFactory_CreateDecoderFromFileHandle(
         hr = stream_initialize_from_filehandle(stream, (HANDLE)hFile);
         if (SUCCEEDED(hr))
         {
-            hr = IWICComponentFactory_CreateDecoderFromStream(iface, (IStream*)stream,
+            hr = IWICImagingFactory2_CreateDecoderFromStream(iface, (IStream*)stream,
                 pguidVendor, metadataOptions, ppIDecoder);
         }
         IWICStream_Release(stream);
@@ -260,14 +272,14 @@ static HRESULT WINAPI ComponentFactory_CreateDecoderFromFileHandle(
     return hr;
 }
 
-static HRESULT WINAPI ComponentFactory_CreateComponentInfo(IWICComponentFactory *iface,
+static HRESULT WINAPI ImagingFactory_CreateComponentInfo(IWICImagingFactory2 *iface,
     REFCLSID clsidComponent, IWICComponentInfo **ppIInfo)
 {
     TRACE("(%p,%s,%p)\n", iface, debugstr_guid(clsidComponent), ppIInfo);
     return CreateComponentInfo(clsidComponent, ppIInfo);
 }
 
-static HRESULT WINAPI ComponentFactory_CreateDecoder(IWICComponentFactory *iface,
+static HRESULT WINAPI ImagingFactory_CreateDecoder(IWICImagingFactory2 *iface,
     REFGUID guidContainerFormat, const GUID *pguidVendor,
     IWICBitmapDecoder **ppIDecoder)
 {
@@ -350,7 +362,7 @@ static HRESULT WINAPI ComponentFactory_CreateDecoder(IWICComponentFactory *iface
     return WINCODEC_ERR_COMPONENTNOTFOUND;
 }
 
-static HRESULT WINAPI ComponentFactory_CreateEncoder(IWICComponentFactory *iface,
+static HRESULT WINAPI ImagingFactory_CreateEncoder(IWICImagingFactory2 *iface,
     REFGUID guidContainerFormat, const GUID *pguidVendor,
     IWICBitmapEncoder **ppIEncoder)
 {
@@ -415,20 +427,20 @@ static HRESULT WINAPI ComponentFactory_CreateEncoder(IWICComponentFactory *iface
     }
 }
 
-static HRESULT WINAPI ComponentFactory_CreatePalette(IWICComponentFactory *iface,
+static HRESULT WINAPI ImagingFactory_CreatePalette(IWICImagingFactory2 *iface,
     IWICPalette **ppIPalette)
 {
     TRACE("(%p,%p)\n", iface, ppIPalette);
     return PaletteImpl_Create(ppIPalette);
 }
 
-static HRESULT WINAPI ComponentFactory_CreateFormatConverter(IWICComponentFactory *iface,
+static HRESULT WINAPI ImagingFactory_CreateFormatConverter(IWICImagingFactory2 *iface,
     IWICFormatConverter **ppIFormatConverter)
 {
     return FormatConverter_CreateInstance(&IID_IWICFormatConverter, (void**)ppIFormatConverter);
 }
 
-static HRESULT WINAPI ComponentFactory_CreateBitmapScaler(IWICComponentFactory *iface,
+static HRESULT WINAPI ImagingFactory_CreateBitmapScaler(IWICImagingFactory2 *iface,
     IWICBitmapScaler **ppIBitmapScaler)
 {
     TRACE("(%p,%p)\n", iface, ppIBitmapScaler);
@@ -436,42 +448,42 @@ static HRESULT WINAPI ComponentFactory_CreateBitmapScaler(IWICComponentFactory *
     return BitmapScaler_Create(ppIBitmapScaler);
 }
 
-static HRESULT WINAPI ComponentFactory_CreateBitmapClipper(IWICComponentFactory *iface,
+static HRESULT WINAPI ImagingFactory_CreateBitmapClipper(IWICImagingFactory2 *iface,
     IWICBitmapClipper **ppIBitmapClipper)
 {
     TRACE("(%p,%p)\n", iface, ppIBitmapClipper);
     return BitmapClipper_Create(ppIBitmapClipper);
 }
 
-static HRESULT WINAPI ComponentFactory_CreateBitmapFlipRotator(IWICComponentFactory *iface,
+static HRESULT WINAPI ImagingFactory_CreateBitmapFlipRotator(IWICImagingFactory2 *iface,
     IWICBitmapFlipRotator **ppIBitmapFlipRotator)
 {
     TRACE("(%p,%p)\n", iface, ppIBitmapFlipRotator);
     return FlipRotator_Create(ppIBitmapFlipRotator);
 }
 
-static HRESULT WINAPI ComponentFactory_CreateStream(IWICComponentFactory *iface,
+static HRESULT WINAPI ImagingFactory_CreateStream(IWICImagingFactory2 *iface,
     IWICStream **ppIWICStream)
 {
     TRACE("(%p,%p)\n", iface, ppIWICStream);
     return StreamImpl_Create(ppIWICStream);
 }
 
-static HRESULT WINAPI ComponentFactory_CreateColorContext(IWICComponentFactory *iface,
+static HRESULT WINAPI ImagingFactory_CreateColorContext(IWICImagingFactory2 *iface,
     IWICColorContext **ppIColorContext)
 {
     TRACE("(%p,%p)\n", iface, ppIColorContext);
     return ColorContext_Create(ppIColorContext);
 }
 
-static HRESULT WINAPI ComponentFactory_CreateColorTransformer(IWICComponentFactory *iface,
+static HRESULT WINAPI ImagingFactory_CreateColorTransformer(IWICImagingFactory2 *iface,
     IWICColorTransform **ppIColorTransform)
 {
     TRACE("(%p,%p)\n", iface, ppIColorTransform);
     return ColorTransform_Create(ppIColorTransform);
 }
 
-static HRESULT WINAPI ComponentFactory_CreateBitmap(IWICComponentFactory *iface,
+static HRESULT WINAPI ImagingFactory_CreateBitmap(IWICImagingFactory2 *iface,
     UINT uiWidth, UINT uiHeight, REFWICPixelFormatGUID pixelFormat,
     WICBitmapCreateCacheOption option, IWICBitmap **ppIBitmap)
 {
@@ -480,9 +492,8 @@ static HRESULT WINAPI ComponentFactory_CreateBitmap(IWICComponentFactory *iface,
     return BitmapImpl_Create(uiWidth, uiHeight, 0, 0, NULL, 0, pixelFormat, option, ppIBitmap);
 }
 
-static HRESULT WINAPI ComponentFactory_CreateBitmapFromSource(IWICComponentFactory *iface,
-    IWICBitmapSource *piBitmapSource, WICBitmapCreateCacheOption option,
-    IWICBitmap **ppIBitmap)
+static HRESULT create_bitmap_from_source_rect(IWICBitmapSource *piBitmapSource, const WICRect *rect,
+    WICBitmapCreateCacheOption option, IWICBitmap **ppIBitmap)
 {
     IWICBitmap *result;
     IWICBitmapLock *lock;
@@ -496,13 +507,29 @@ static HRESULT WINAPI ComponentFactory_CreateBitmapFromSource(IWICComponentFacto
     IWICPixelFormatInfo2 *formatinfo;
     WICPixelFormatNumericRepresentation format_type;
 
-    TRACE("(%p,%p,%u,%p)\n", iface, piBitmapSource, option, ppIBitmap);
+    assert(!rect || option == WICBitmapCacheOnLoad);
 
     if (!piBitmapSource || !ppIBitmap)
         return E_INVALIDARG;
 
+    if (option == WICBitmapNoCache && SUCCEEDED(IWICBitmapSource_QueryInterface(piBitmapSource,
+            &IID_IWICBitmap, (void **)&result)))
+    {
+        *ppIBitmap = result;
+        return S_OK;
+    }
+
     hr = IWICBitmapSource_GetSize(piBitmapSource, &width, &height);
 
+    if (SUCCEEDED(hr) && rect)
+    {
+        if (rect->X >= width || rect->Y >= height || rect->Width == 0 || rect->Height == 0)
+            return E_INVALIDARG;
+
+        width = min(width - rect->X, rect->Width);
+        height = min(height - rect->Y, rect->Height);
+    }
+
     if (SUCCEEDED(hr))
         hr = IWICBitmapSource_GetPixelFormat(piBitmapSource, &pixelformat);
 
@@ -533,7 +560,14 @@ static HRESULT WINAPI ComponentFactory_CreateBitmapFromSource(IWICComponentFacto
         {
             UINT stride, buffersize;
             BYTE *buffer;
-            rc.X = rc.Y = 0;
+
+            if (rect)
+            {
+                rc.X = rect->X;
+                rc.Y = rect->Y;
+            }
+            else
+                rc.X = rc.Y = 0;
             rc.Width = width;
             rc.Height = height;
 
@@ -586,16 +620,33 @@ static HRESULT WINAPI ComponentFactory_CreateBitmapFromSource(IWICComponentFacto
     return hr;
 }
 
-static HRESULT WINAPI ComponentFactory_CreateBitmapFromSourceRect(IWICComponentFactory *iface,
+static HRESULT WINAPI ImagingFactory_CreateBitmapFromSource(IWICImagingFactory2 *iface,
+    IWICBitmapSource *piBitmapSource, WICBitmapCreateCacheOption option,
+    IWICBitmap **ppIBitmap)
+{
+    TRACE("(%p,%p,%u,%p)\n", iface, piBitmapSource, option, ppIBitmap);
+
+    return create_bitmap_from_source_rect(piBitmapSource, NULL, option, ppIBitmap);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateBitmapFromSourceRect(IWICImagingFactory2 *iface,
     IWICBitmapSource *piBitmapSource, UINT x, UINT y, UINT width, UINT height,
     IWICBitmap **ppIBitmap)
 {
-    FIXME("(%p,%p,%u,%u,%u,%u,%p): stub\n", iface, piBitmapSource, x, y, width,
+    WICRect rect;
+
+    TRACE("(%p,%p,%u,%u,%u,%u,%p)\n", iface, piBitmapSource, x, y, width,
         height, ppIBitmap);
-    return E_NOTIMPL;
+
+    rect.X = x;
+    rect.Y = y;
+    rect.Width = width;
+    rect.Height = height;
+
+    return create_bitmap_from_source_rect(piBitmapSource, &rect, WICBitmapCacheOnLoad, ppIBitmap);
 }
 
-static HRESULT WINAPI ComponentFactory_CreateBitmapFromMemory(IWICComponentFactory *iface,
+static HRESULT WINAPI ImagingFactory_CreateBitmapFromMemory(IWICImagingFactory2 *iface,
     UINT width, UINT height, REFWICPixelFormatGUID format, UINT stride,
     UINT size, BYTE *buffer, IWICBitmap **bitmap)
 {
@@ -671,7 +722,7 @@ static BOOL get_16bpp_format(HBITMAP hbm, WICPixelFormatGUID *format)
     return ret;
 }
 
-static HRESULT WINAPI ComponentFactory_CreateBitmapFromHBITMAP(IWICComponentFactory *iface,
+static HRESULT WINAPI ImagingFactory_CreateBitmapFromHBITMAP(IWICImagingFactory2 *iface,
     HBITMAP hbm, HPALETTE hpal, WICBitmapAlphaChannelOption option, IWICBitmap **bitmap)
 {
     BITMAP bm;
@@ -794,7 +845,7 @@ static HRESULT WINAPI ComponentFactory_CreateBitmapFromHBITMAP(IWICComponentFact
     return hr;
 }
 
-static HRESULT WINAPI ComponentFactory_CreateBitmapFromHICON(IWICComponentFactory *iface,
+static HRESULT WINAPI ImagingFactory_CreateBitmapFromHICON(IWICImagingFactory2 *iface,
     HICON hicon, IWICBitmap **bitmap)
 {
     IWICBitmapLock *lock;
@@ -931,30 +982,30 @@ failed:
     return hr;
 }
 
-static HRESULT WINAPI ComponentFactory_CreateComponentEnumerator(IWICComponentFactory *iface,
+static HRESULT WINAPI ImagingFactory_CreateComponentEnumerator(IWICImagingFactory2 *iface,
     DWORD componentTypes, DWORD options, IEnumUnknown **ppIEnumUnknown)
 {
     TRACE("(%p,%u,%u,%p)\n", iface, componentTypes, options, ppIEnumUnknown);
     return CreateComponentEnumerator(componentTypes, options, ppIEnumUnknown);
 }
 
-static HRESULT WINAPI ComponentFactory_CreateFastMetadataEncoderFromDecoder(
-    IWICComponentFactory *iface, IWICBitmapDecoder *pIDecoder,
+static HRESULT WINAPI ImagingFactory_CreateFastMetadataEncoderFromDecoder(
+    IWICImagingFactory2 *iface, IWICBitmapDecoder *pIDecoder,
     IWICFastMetadataEncoder **ppIFastEncoder)
 {
     FIXME("(%p,%p,%p): stub\n", iface, pIDecoder, ppIFastEncoder);
     return E_NOTIMPL;
 }
 
-static HRESULT WINAPI ComponentFactory_CreateFastMetadataEncoderFromFrameDecode(
-    IWICComponentFactory *iface, IWICBitmapFrameDecode *pIFrameDecoder,
+static HRESULT WINAPI ImagingFactory_CreateFastMetadataEncoderFromFrameDecode(
+    IWICImagingFactory2 *iface, IWICBitmapFrameDecode *pIFrameDecoder,
     IWICFastMetadataEncoder **ppIFastEncoder)
 {
     FIXME("(%p,%p,%p): stub\n", iface, pIFrameDecoder, ppIFastEncoder);
     return E_NOTIMPL;
 }
 
-static HRESULT WINAPI ComponentFactory_CreateQueryWriter(IWICComponentFactory *iface,
+static HRESULT WINAPI ImagingFactory_CreateQueryWriter(IWICImagingFactory2 *iface,
     REFGUID guidMetadataFormat, const GUID *pguidVendor,
     IWICMetadataQueryWriter **ppIQueryWriter)
 {
@@ -963,7 +1014,7 @@ static HRESULT WINAPI ComponentFactory_CreateQueryWriter(IWICComponentFactory *i
     return E_NOTIMPL;
 }
 
-static HRESULT WINAPI ComponentFactory_CreateQueryWriterFromReader(IWICComponentFactory *iface,
+static HRESULT WINAPI ImagingFactory_CreateQueryWriterFromReader(IWICImagingFactory2 *iface,
     IWICMetadataQueryReader *pIQueryReader, const GUID *pguidVendor,
     IWICMetadataQueryWriter **ppIQueryWriter)
 {
@@ -972,6 +1023,237 @@ static HRESULT WINAPI ComponentFactory_CreateQueryWriterFromReader(IWICComponent
     return E_NOTIMPL;
 }
 
+#ifndef __REACTOS__
+static HRESULT WINAPI ImagingFactory_CreateImageEncoder(IWICImagingFactory2 *iface, ID2D1Device *device, IWICImageEncoder **encoder)
+{
+    FIXME("%p,%p,%p stub.\n", iface, device, encoder);
+    return E_NOTIMPL;
+}
+#endif
+
+static const IWICImagingFactory2Vtbl ImagingFactory_Vtbl = {
+    ImagingFactory_QueryInterface,
+    ImagingFactory_AddRef,
+    ImagingFactory_Release,
+    ImagingFactory_CreateDecoderFromFilename,
+    ImagingFactory_CreateDecoderFromStream,
+    ImagingFactory_CreateDecoderFromFileHandle,
+    ImagingFactory_CreateComponentInfo,
+    ImagingFactory_CreateDecoder,
+    ImagingFactory_CreateEncoder,
+    ImagingFactory_CreatePalette,
+    ImagingFactory_CreateFormatConverter,
+    ImagingFactory_CreateBitmapScaler,
+    ImagingFactory_CreateBitmapClipper,
+    ImagingFactory_CreateBitmapFlipRotator,
+    ImagingFactory_CreateStream,
+    ImagingFactory_CreateColorContext,
+    ImagingFactory_CreateColorTransformer,
+    ImagingFactory_CreateBitmap,
+    ImagingFactory_CreateBitmapFromSource,
+    ImagingFactory_CreateBitmapFromSourceRect,
+    ImagingFactory_CreateBitmapFromMemory,
+    ImagingFactory_CreateBitmapFromHBITMAP,
+    ImagingFactory_CreateBitmapFromHICON,
+    ImagingFactory_CreateComponentEnumerator,
+    ImagingFactory_CreateFastMetadataEncoderFromDecoder,
+    ImagingFactory_CreateFastMetadataEncoderFromFrameDecode,
+    ImagingFactory_CreateQueryWriter,
+    ImagingFactory_CreateQueryWriterFromReader,
+#ifndef __REACTOS__
+    ImagingFactory_CreateImageEncoder,
+#endif
+};
+
+static HRESULT WINAPI ComponentFactory_QueryInterface(IWICComponentFactory *iface, REFIID iid, void **ppv)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_QueryInterface(&This->IWICImagingFactory2_iface, iid, ppv);
+}
+
+static ULONG WINAPI ComponentFactory_AddRef(IWICComponentFactory *iface)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_AddRef(&This->IWICImagingFactory2_iface);
+}
+
+static ULONG WINAPI ComponentFactory_Release(IWICComponentFactory *iface)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_Release(&This->IWICImagingFactory2_iface);
+}
+
+static HRESULT WINAPI ComponentFactory_CreateDecoderFromFilename(IWICComponentFactory *iface, LPCWSTR filename,
+    const GUID *vendor, DWORD desired_access, WICDecodeOptions options, IWICBitmapDecoder **decoder)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_CreateDecoderFromFilename(&This->IWICImagingFactory2_iface, filename, vendor,
+        desired_access, options, decoder);
+}
+
+static HRESULT WINAPI ComponentFactory_CreateDecoderFromStream(IWICComponentFactory *iface, IStream *stream,
+    const GUID *vendor, WICDecodeOptions options, IWICBitmapDecoder **decoder)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_CreateDecoderFromStream(&This->IWICImagingFactory2_iface, stream, vendor,
+        options, decoder);
+}
+
+static HRESULT WINAPI ComponentFactory_CreateDecoderFromFileHandle(IWICComponentFactory *iface, ULONG_PTR hFile,
+    const GUID *vendor, WICDecodeOptions options, IWICBitmapDecoder **decoder)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_CreateDecoderFromFileHandle(&This->IWICImagingFactory2_iface, hFile, vendor,
+        options, decoder);
+}
+
+static HRESULT WINAPI ComponentFactory_CreateComponentInfo(IWICComponentFactory *iface, REFCLSID component,
+    IWICComponentInfo **info)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_CreateComponentInfo(&This->IWICImagingFactory2_iface, component, info);
+}
+
+static HRESULT WINAPI ComponentFactory_CreateDecoder(IWICComponentFactory *iface, REFGUID format, const GUID *vendor,
+    IWICBitmapDecoder **decoder)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_CreateDecoder(&This->IWICImagingFactory2_iface, format, vendor, decoder);
+}
+
+static HRESULT WINAPI ComponentFactory_CreateEncoder(IWICComponentFactory *iface, REFGUID format, const GUID *vendor,
+    IWICBitmapEncoder **encoder)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_CreateEncoder(&This->IWICImagingFactory2_iface, format, vendor, encoder);
+}
+
+static HRESULT WINAPI ComponentFactory_CreatePalette(IWICComponentFactory *iface, IWICPalette **palette)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_CreatePalette(&This->IWICImagingFactory2_iface, palette);
+}
+
+static HRESULT WINAPI ComponentFactory_CreateFormatConverter(IWICComponentFactory *iface, IWICFormatConverter **converter)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_CreateFormatConverter(&This->IWICImagingFactory2_iface, converter);
+}
+
+static HRESULT WINAPI ComponentFactory_CreateBitmapScaler(IWICComponentFactory *iface, IWICBitmapScaler **scaler)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_CreateBitmapScaler(&This->IWICImagingFactory2_iface, scaler);
+}
+
+static HRESULT WINAPI ComponentFactory_CreateBitmapClipper(IWICComponentFactory *iface, IWICBitmapClipper **clipper)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_CreateBitmapClipper(&This->IWICImagingFactory2_iface, clipper);
+}
+
+static HRESULT WINAPI ComponentFactory_CreateBitmapFlipRotator(IWICComponentFactory *iface, IWICBitmapFlipRotator **fliprotator)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_CreateBitmapFlipRotator(&This->IWICImagingFactory2_iface, fliprotator);
+}
+
+static HRESULT WINAPI ComponentFactory_CreateStream(IWICComponentFactory *iface, IWICStream **stream)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_CreateStream(&This->IWICImagingFactory2_iface, stream);
+}
+
+static HRESULT WINAPI ComponentFactory_CreateColorContext(IWICComponentFactory *iface, IWICColorContext **context)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_CreateColorContext(&This->IWICImagingFactory2_iface, context);
+}
+
+static HRESULT WINAPI ComponentFactory_CreateColorTransformer(IWICComponentFactory *iface, IWICColorTransform **transformer)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_CreateColorTransformer(&This->IWICImagingFactory2_iface, transformer);
+}
+
+static HRESULT WINAPI ComponentFactory_CreateBitmap(IWICComponentFactory *iface, UINT width, UINT height, REFWICPixelFormatGUID pixel_format,
+    WICBitmapCreateCacheOption option, IWICBitmap **bitmap)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_CreateBitmap(&This->IWICImagingFactory2_iface, width, height, pixel_format, option, bitmap);
+}
+
+static HRESULT WINAPI ComponentFactory_CreateBitmapFromSource(IWICComponentFactory *iface, IWICBitmapSource *source,
+    WICBitmapCreateCacheOption option, IWICBitmap **bitmap)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_CreateBitmapFromSource(&This->IWICImagingFactory2_iface, source, option, bitmap);
+}
+
+static HRESULT WINAPI ComponentFactory_CreateBitmapFromSourceRect(IWICComponentFactory *iface, IWICBitmapSource *source,
+    UINT x, UINT y, UINT width, UINT height, IWICBitmap **bitmap)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_CreateBitmapFromSourceRect(&This->IWICImagingFactory2_iface, source, x, y, width, height, bitmap);
+}
+
+static HRESULT WINAPI ComponentFactory_CreateBitmapFromMemory(IWICComponentFactory *iface, UINT width, UINT height,
+    REFWICPixelFormatGUID format, UINT stride, UINT size, BYTE *buffer, IWICBitmap **bitmap)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_CreateBitmapFromMemory(&This->IWICImagingFactory2_iface, width, height, format, stride,
+        size, buffer, bitmap);
+}
+
+static HRESULT WINAPI ComponentFactory_CreateBitmapFromHBITMAP(IWICComponentFactory *iface, HBITMAP hbm, HPALETTE hpal,
+    WICBitmapAlphaChannelOption option, IWICBitmap **bitmap)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_CreateBitmapFromHBITMAP(&This->IWICImagingFactory2_iface, hbm, hpal, option, bitmap);
+}
+
+static HRESULT WINAPI ComponentFactory_CreateBitmapFromHICON(IWICComponentFactory *iface, HICON hicon, IWICBitmap **bitmap)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_CreateBitmapFromHICON(&This->IWICImagingFactory2_iface, hicon, bitmap);
+}
+
+static HRESULT WINAPI ComponentFactory_CreateComponentEnumerator(IWICComponentFactory *iface, DWORD component_types,
+    DWORD options, IEnumUnknown **enumerator)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_CreateComponentEnumerator(&This->IWICImagingFactory2_iface, component_types,
+        options, enumerator);
+}
+
+static HRESULT WINAPI ComponentFactory_CreateFastMetadataEncoderFromDecoder(IWICComponentFactory *iface, IWICBitmapDecoder *decoder,
+    IWICFastMetadataEncoder **encoder)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_CreateFastMetadataEncoderFromDecoder(&This->IWICImagingFactory2_iface, decoder, encoder);
+}
+
+static HRESULT WINAPI ComponentFactory_CreateFastMetadataEncoderFromFrameDecode(IWICComponentFactory *iface,
+    IWICBitmapFrameDecode *frame_decode, IWICFastMetadataEncoder **encoder)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_CreateFastMetadataEncoderFromFrameDecode(&This->IWICImagingFactory2_iface, frame_decode, encoder);
+}
+
+static HRESULT WINAPI ComponentFactory_CreateQueryWriter(IWICComponentFactory *iface, REFGUID format, const GUID *vendor,
+    IWICMetadataQueryWriter **writer)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_CreateQueryWriter(&This->IWICImagingFactory2_iface, format, vendor, writer);
+}
+
+static HRESULT WINAPI ComponentFactory_CreateQueryWriterFromReader(IWICComponentFactory *iface, IWICMetadataQueryReader *reader,
+    const GUID *vendor, IWICMetadataQueryWriter **writer)
+{
+    ImagingFactory *This = impl_from_IWICComponentFactory(iface);
+    return IWICImagingFactory2_CreateQueryWriterFromReader(&This->IWICImagingFactory2_iface, reader, vendor, writer);
+}
+
 static HRESULT WINAPI ComponentFactory_CreateMetadataReader(IWICComponentFactory *iface,
         REFGUID format, const GUID *vendor, DWORD options, IStream *stream, IWICMetadataReader **reader)
 {
@@ -1185,23 +1467,24 @@ static const IWICComponentFactoryVtbl ComponentFactory_Vtbl = {
     ComponentFactory_CreateEncoderPropertyBag
 };
 
-HRESULT ComponentFactory_CreateInstance(REFIID iid, void** ppv)
+HRESULT ImagingFactory_CreateInstance(REFIID iid, void** ppv)
 {
-    ComponentFactory *This;
+    ImagingFactory *This;
     HRESULT ret;
 
     TRACE("(%s,%p)\n", debugstr_guid(iid), ppv);
 
     *ppv = NULL;
 
-    This = HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentFactory));
+    This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
     if (!This) return E_OUTOFMEMORY;
 
+    This->IWICImagingFactory2_iface.lpVtbl = &ImagingFactory_Vtbl;
     This->IWICComponentFactory_iface.lpVtbl = &ComponentFactory_Vtbl;
     This->ref = 1;
 
-    ret = IWICComponentFactory_QueryInterface(&This->IWICComponentFactory_iface, iid, ppv);
-    IWICComponentFactory_Release(&This->IWICComponentFactory_iface);
+    ret = IWICImagingFactory2_QueryInterface(&This->IWICImagingFactory2_iface, iid, ppv);
+    IWICImagingFactory2_Release(&This->IWICImagingFactory2_iface);
 
     return ret;
 }
index 0a86266..8c81574 100644 (file)
@@ -222,7 +222,7 @@ typedef struct {
 
 static inline BitmapDecoderInfo *impl_from_IWICBitmapDecoderInfo(IWICBitmapDecoderInfo *iface)
 {
-    return CONTAINING_RECORD(iface, BitmapDecoderInfo, base.IWICComponentInfo_iface);
+    return CONTAINING_RECORD((IWICComponentInfo*)iface, BitmapDecoderInfo, base.IWICComponentInfo_iface);
 }
 
 static HRESULT WINAPI BitmapDecoderInfo_QueryInterface(IWICBitmapDecoderInfo *iface, REFIID iid,
@@ -713,7 +713,7 @@ typedef struct {
 
 static inline BitmapEncoderInfo *impl_from_IWICBitmapEncoderInfo(IWICBitmapEncoderInfo *iface)
 {
-    return CONTAINING_RECORD(iface, BitmapEncoderInfo, base.IWICComponentInfo_iface);
+    return CONTAINING_RECORD((IWICComponentInfo*)iface, BitmapEncoderInfo, base.IWICComponentInfo_iface);
 }
 
 static HRESULT WINAPI BitmapEncoderInfo_QueryInterface(IWICBitmapEncoderInfo *iface, REFIID iid,
@@ -1005,7 +1005,7 @@ typedef struct {
 
 static inline FormatConverterInfo *impl_from_IWICFormatConverterInfo(IWICFormatConverterInfo *iface)
 {
-    return CONTAINING_RECORD(iface, FormatConverterInfo, base.IWICComponentInfo_iface);
+    return CONTAINING_RECORD((IWICComponentInfo*)iface, FormatConverterInfo, base.IWICComponentInfo_iface);
 }
 
 static HRESULT WINAPI FormatConverterInfo_QueryInterface(IWICFormatConverterInfo *iface, REFIID iid,
@@ -1219,7 +1219,7 @@ typedef struct {
 
 static inline PixelFormatInfo *impl_from_IWICPixelFormatInfo2(IWICPixelFormatInfo2 *iface)
 {
-    return CONTAINING_RECORD(iface, PixelFormatInfo, base.IWICComponentInfo_iface);
+    return CONTAINING_RECORD((IWICComponentInfo*)iface, PixelFormatInfo, base.IWICComponentInfo_iface);
 }
 
 static HRESULT WINAPI PixelFormatInfo_QueryInterface(IWICPixelFormatInfo2 *iface, REFIID iid,
@@ -1531,7 +1531,7 @@ static struct metadata_container *get_metadata_container(MetadataReaderInfo *inf
 
 static inline MetadataReaderInfo *impl_from_IWICMetadataReaderInfo(IWICMetadataReaderInfo *iface)
 {
-    return CONTAINING_RECORD(iface, MetadataReaderInfo, base.IWICComponentInfo_iface);
+    return CONTAINING_RECORD((IWICComponentInfo*)iface, MetadataReaderInfo, base.IWICComponentInfo_iface);
 }
 
 static HRESULT WINAPI MetadataReaderInfo_QueryInterface(IWICMetadataReaderInfo *iface,
index 26dc76c..1df898f 100644 (file)
@@ -467,7 +467,7 @@ static HRESULT WINAPI JpegDecoder_CopyPalette(IWICBitmapDecoder *iface,
 static HRESULT WINAPI JpegDecoder_GetMetadataQueryReader(IWICBitmapDecoder *iface,
     IWICMetadataQueryReader **reader)
 {
-    FIXME("(%p,%p): stub\n", iface, reader);
+    TRACE("(%p,%p)\n", iface, reader);
 
     if (!reader) return E_INVALIDARG;
 
@@ -644,7 +644,7 @@ static HRESULT WINAPI JpegDecoder_Frame_CopyPixels(IWICBitmapFrameDecode *iface,
 {
     JpegDecoder *This = impl_from_IWICBitmapFrameDecode(iface);
 
-    TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer);
+    TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
 
     return copy_pixels(This->bpp, This->image_data,
         This->cinfo.output_width, This->cinfo.output_height, This->stride,
@@ -1168,7 +1168,7 @@ static HRESULT WINAPI JpegEncoder_Frame_WriteSource(IWICBitmapFrameEncode *iface
 {
     JpegEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
     HRESULT hr;
-    TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc);
+    TRACE("(%p,%p,%s)\n", iface, pIBitmapSource, debug_wic_rect(prc));
 
     if (!This->frame_initialized)
         return WINCODEC_ERR_WRONGSTATE;
@@ -1345,11 +1345,15 @@ static HRESULT WINAPI JpegEncoder_Initialize(IWICBitmapEncoder *iface,
     return S_OK;
 }
 
-static HRESULT WINAPI JpegEncoder_GetContainerFormat(IWICBitmapEncoder *iface,
-    GUID *pguidContainerFormat)
+static HRESULT WINAPI JpegEncoder_GetContainerFormat(IWICBitmapEncoder *iface, GUID *format)
 {
-    FIXME("(%p,%s): stub\n", iface, debugstr_guid(pguidContainerFormat));
-    return E_NOTIMPL;
+    TRACE("(%p,%p)\n", iface, format);
+
+    if (!format)
+        return E_INVALIDARG;
+
+    memcpy(format, &GUID_ContainerFormatJpeg, sizeof(*format));
+    return S_OK;
 }
 
 static HRESULT WINAPI JpegEncoder_GetEncoderInfo(IWICBitmapEncoder *iface, IWICBitmapEncoderInfo **info)
@@ -1438,7 +1442,7 @@ static HRESULT WINAPI JpegEncoder_CreateNewFrame(IWICBitmapEncoder *iface,
 
     if (ppIEncoderOptions)
     {
-        hr = CreatePropertyBag2(opts, sizeof(opts)/sizeof(opts[0]), ppIEncoderOptions);
+        hr = CreatePropertyBag2(opts, ARRAY_SIZE(opts), ppIEncoderOptions);
         if (FAILED(hr))
         {
             LeaveCriticalSection(&This->lock);
index 6f781b8..7828151 100644 (file)
@@ -82,7 +82,7 @@ HRESULT copy_pixels(UINT bpp, const BYTE *srcbuffer,
     if (dststride < bytesperrow)
         return E_INVALIDARG;
 
-    if ((dststride * (rc->Height-1)) + ((rc->Width * bpp) + 7)/8 > dstbuffersize)
+    if ((dststride * (rc->Height-1)) + bytesperrow > dstbuffersize)
         return E_INVALIDARG;
 
     /* if the whole bitmap is copied and the buffer format matches then it's a matter of a single memcpy */
@@ -182,7 +182,7 @@ HRESULT write_source(IWICBitmapFrameEncode *iface,
     if (FAILED(hr))
     {
         ERR("Failed to convert source, target format %s, %#x\n", debugstr_guid(format), hr);
-        return hr;
+        return E_NOTIMPL;
     }
 
     stride = (bpp * width + 7)/8;
index e338848..c4c188d 100644 (file)
@@ -164,7 +164,7 @@ static VARTYPE map_type(struct string_t *str)
 {
     UINT i;
 
-    for (i = 0; i < sizeof(str2vt)/sizeof(str2vt[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(str2vt); i++)
     {
         if (str2vt[i].len == str->len)
         {
@@ -589,7 +589,7 @@ static HRESULT WINAPI mqr_GetMetadataByName(IWICMetadataQueryReader *iface, LPCW
     PropVariantClear(&tk_id);
     PropVariantClear(&tk_schema);
 
-    if (hr == S_OK)
+    if (hr == S_OK && value)
         *value = new_value;
     else
         PropVariantClear(&new_value);
@@ -743,7 +743,7 @@ HRESULT WINAPI WICMapGuidToShortName(REFGUID guid, UINT len, WCHAR *name, UINT *
 
     if (!guid) return E_INVALIDARG;
 
-    for (i = 0; i < sizeof(guid2name)/sizeof(guid2name[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(guid2name); i++)
     {
         if (IsEqualGUID(guid, guid2name[i].guid))
         {
@@ -774,7 +774,7 @@ HRESULT WINAPI WICMapShortNameToGuid(PCWSTR name, GUID *guid)
 
     if (!name || !guid) return E_INVALIDARG;
 
-    for (i = 0; i < sizeof(guid2name)/sizeof(guid2name[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(guid2name); i++)
     {
         if (!lstrcmpiW(name, guid2name[i].name))
         {
@@ -884,7 +884,7 @@ static const WCHAR *map_shortname_to_schema(const GUID *format, const WCHAR *nam
         !IsEqualGUID(format, &GUID_MetadataFormatXMPStruct))
         return NULL;
 
-    for (i = 0; i < sizeof(name2schema)/sizeof(name2schema[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(name2schema); i++)
     {
         if (!lstrcmpW(name2schema[i].name, name))
             return name2schema[i].schema;
@@ -909,7 +909,7 @@ HRESULT WINAPI WICMapSchemaToName(REFGUID format, LPWSTR schema, UINT len, WCHAR
         !IsEqualGUID(format, &GUID_MetadataFormatXMPStruct))
         return WINCODEC_ERR_PROPERTYNOTFOUND;
 
-    for (i = 0; i < sizeof(name2schema)/sizeof(name2schema[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(name2schema); i++)
     {
         if (!lstrcmpW(name2schema[i].schema, schema))
         {
index a8370ff..1c1e858 100644 (file)
@@ -681,7 +681,7 @@ static HRESULT WINAPI PaletteImpl_InitializeFromBitmap(IWICPalette *palette,
     else
         rgb24_source = source;
 
-    hr = ComponentFactory_CreateInstance(&IID_IWICImagingFactory, (void **)&factory);
+    hr = ImagingFactory_CreateInstance(&IID_IWICImagingFactory, (void **)&factory);
     if (hr != S_OK) goto fail;
 
     hr = IWICImagingFactory_CreateBitmapFromSource(factory, rgb24_source, WICBitmapCacheOnLoad, &rgb24_bitmap);
index 42c905c..7050c95 100644 (file)
@@ -844,7 +844,7 @@ static HRESULT WINAPI PngDecoder_CopyPalette(IWICBitmapDecoder *iface,
 static HRESULT WINAPI PngDecoder_GetMetadataQueryReader(IWICBitmapDecoder *iface,
     IWICMetadataQueryReader **reader)
 {
-    FIXME("(%p,%p): stub\n", iface, reader);
+    TRACE("(%p,%p)\n", iface, reader);
 
     if (!reader) return E_INVALIDARG;
 
@@ -1061,7 +1061,7 @@ static HRESULT WINAPI PngDecoder_Frame_CopyPalette(IWICBitmapFrameDecode *iface,
                           png_palette[i].blue);
         }
     }
-    else if (color_type == PNG_COLOR_TYPE_GRAY) {
+    else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth <= 8) {
         ret = ppng_get_tRNS(This->png_ptr, This->info_ptr, &trans_alpha, &num_trans, &trans_values);
 
         if (!ret)
@@ -1098,7 +1098,7 @@ static HRESULT WINAPI PngDecoder_Frame_CopyPixels(IWICBitmapFrameDecode *iface,
     const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
 {
     PngDecoder *This = impl_from_IWICBitmapFrameDecode(iface);
-    TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer);
+    TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
 
     return copy_pixels(This->bpp, This->image_bits,
         This->width, This->height, This->stride,
@@ -1244,7 +1244,7 @@ static HRESULT WINAPI PngDecoder_Block_GetReaderByIndex(IWICMetadataBlockReader
                 This->metadata_blocks[nIndex].ofs, This->metadata_blocks[nIndex].len);
 
             if (SUCCEEDED(hr))
-                hr = ComponentFactory_CreateInstance(&IID_IWICComponentFactory, (void**)&factory);
+                hr = ImagingFactory_CreateInstance(&IID_IWICComponentFactory, (void**)&factory);
 
             if (SUCCEEDED(hr))
             {
@@ -1445,7 +1445,7 @@ static HRESULT WINAPI PngFrameEncode_Initialize(IWICBitmapFrameEncode *iface,
 
     if (pIEncoderOptions)
     {
-        hr = IPropertyBag2_Read(pIEncoderOptions, sizeof(opts)/sizeof(opts[0]), opts, NULL, opt_values, opt_hres);
+        hr = IPropertyBag2_Read(pIEncoderOptions, ARRAY_SIZE(opts), opts, NULL, opt_values, opt_hres);
 
         if (FAILED(hr))
             return hr;
@@ -1749,7 +1749,7 @@ static HRESULT WINAPI PngFrameEncode_WriteSource(IWICBitmapFrameEncode *iface,
 {
     PngEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
     HRESULT hr;
-    TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc);
+    TRACE("(%p,%p,%s)\n", iface, pIBitmapSource, debug_wic_rect(prc));
 
     if (!This->frame_initialized)
         return WINCODEC_ERR_WRONGSTATE;
@@ -1972,11 +1972,15 @@ static HRESULT WINAPI PngEncoder_Initialize(IWICBitmapEncoder *iface,
     return S_OK;
 }
 
-static HRESULT WINAPI PngEncoder_GetContainerFormat(IWICBitmapEncoder *iface,
-    GUID *pguidContainerFormat)
+static HRESULT WINAPI PngEncoder_GetContainerFormat(IWICBitmapEncoder *iface, GUID *format)
 {
-    FIXME("(%p,%s): stub\n", iface, debugstr_guid(pguidContainerFormat));
-    return E_NOTIMPL;
+    TRACE("(%p,%p)\n", iface, format);
+
+    if (!format)
+        return E_INVALIDARG;
+
+    memcpy(format, &GUID_ContainerFormatPng, sizeof(*format));
+    return S_OK;
 }
 
 static HRESULT WINAPI PngEncoder_GetEncoderInfo(IWICBitmapEncoder *iface, IWICBitmapEncoderInfo **info)
@@ -2061,7 +2065,7 @@ static HRESULT WINAPI PngEncoder_CreateNewFrame(IWICBitmapEncoder *iface,
 
     if (ppIEncoderOptions)
     {
-        hr = CreatePropertyBag2(opts, sizeof(opts)/sizeof(opts[0]), ppIEncoderOptions);
+        hr = CreatePropertyBag2(opts, ARRAY_SIZE(opts), ppIEncoderOptions);
         if (FAILED(hr))
         {
             LeaveCriticalSection(&This->lock);
index a28b386..34b618e 100644 (file)
@@ -626,6 +626,21 @@ HRESULT WINAPI IWICStream_InitializeFromMemory_Proxy_W(IWICStream *iface,
     return IWICStream_InitializeFromMemory(iface, pbBuffer, cbBufferSize);
 }
 
+HRESULT WINAPI IWICPixelFormatInfo_GetBitsPerPixel_Proxy_W(IWICPixelFormatInfo *iface, UINT *bpp)
+{
+    return IWICPixelFormatInfo_GetBitsPerPixel(iface, bpp);
+}
+
+HRESULT WINAPI IWICPixelFormatInfo_GetChannelCount_Proxy_W(IWICPixelFormatInfo *iface, UINT *count)
+{
+    return IWICPixelFormatInfo_GetChannelCount(iface, count);
+}
+
+HRESULT WINAPI IWICPixelFormatInfo_GetChannelMask_Proxy_W(IWICPixelFormatInfo *iface, UINT channel, UINT buffer_size, BYTE *buffer, UINT *actual)
+{
+    return IWICPixelFormatInfo_GetChannelMask(iface, channel, buffer_size, buffer, actual);
+}
+
 HRESULT WINAPI WICCreateColorContext_Proxy(IWICImagingFactory *iface, IWICColorContext **ppIWICColorContext)
 {
     TRACE("%p, %p\n", iface, ppIWICColorContext);
@@ -637,7 +652,7 @@ HRESULT WINAPI WICCreateImagingFactory_Proxy(UINT SDKVersion, IWICImagingFactory
 {
     TRACE("%x, %p\n", SDKVersion, ppIImagingFactory);
 
-    return ComponentFactory_CreateInstance(&IID_IWICImagingFactory, (void**)ppIImagingFactory);
+    return ImagingFactory_CreateInstance(&IID_IWICImagingFactory, (void**)ppIImagingFactory);
 }
 
 HRESULT WINAPI WICSetEncoderFormat_Proxy(IWICBitmapSource *pSourceIn,
index 328ea54..158329d 100644 (file)
@@ -1032,10 +1032,10 @@ static HRESULT register_pixelformats(struct regsvr_pixelformat const *list)
         if (res != ERROR_SUCCESS) goto error_close_clsid_key;
 
         if (list->channelmasks) {
+            static const WCHAR valuename_format[] = {'%','d',0};
             HKEY masks_key;
             UINT i, mask_size;
             WCHAR mask_valuename[11];
-            const WCHAR valuename_format[] = {'%','d',0};
 
             mask_size = (list->bitsperpixel + 7)/8;
 
@@ -1354,7 +1354,6 @@ static GUID const * const bmp_encode_formats[] = {
     &GUID_WICPixelFormat32bppBGR,
     &GUID_WICPixelFormatBlackWhite,
     &GUID_WICPixelFormat1bppIndexed,
-    &GUID_WICPixelFormat2bppIndexed,
     &GUID_WICPixelFormat4bppIndexed,
     &GUID_WICPixelFormat8bppIndexed,
     NULL
@@ -1383,7 +1382,6 @@ static GUID const * const tiff_encode_formats[] = {
     &GUID_WICPixelFormat4bppGray,
     &GUID_WICPixelFormat8bppGray,
     &GUID_WICPixelFormat1bppIndexed,
-    &GUID_WICPixelFormat2bppIndexed,
     &GUID_WICPixelFormat4bppIndexed,
     &GUID_WICPixelFormat8bppIndexed,
     &GUID_WICPixelFormat24bppBGR,
index 3801ea5..d19e219 100644 (file)
@@ -119,12 +119,12 @@ static HRESULT WINAPI BitmapScaler_GetSize(IWICBitmapScaler *iface,
     BitmapScaler *This = impl_from_IWICBitmapScaler(iface);
     TRACE("(%p,%p,%p)\n", iface, puiWidth, puiHeight);
 
+    if (!This->source)
+        return WINCODEC_ERR_NOTINITIALIZED;
+
     if (!puiWidth || !puiHeight)
         return E_INVALIDARG;
 
-    if (!This->source)
-        return WINCODEC_ERR_WRONGSTATE;
-
     *puiWidth = This->width;
     *puiHeight = This->height;
 
@@ -141,7 +141,10 @@ static HRESULT WINAPI BitmapScaler_GetPixelFormat(IWICBitmapScaler *iface,
         return E_INVALIDARG;
 
     if (!This->source)
-        return WINCODEC_ERR_WRONGSTATE;
+    {
+        memcpy(pPixelFormat, &GUID_WICPixelFormatDontCare, sizeof(*pPixelFormat));
+        return S_OK;
+    }
 
     return IWICBitmapSource_GetPixelFormat(This->source, pPixelFormat);
 }
@@ -152,12 +155,12 @@ static HRESULT WINAPI BitmapScaler_GetResolution(IWICBitmapScaler *iface,
     BitmapScaler *This = impl_from_IWICBitmapScaler(iface);
     TRACE("(%p,%p,%p)\n", iface, pDpiX, pDpiY);
 
+    if (!This->source)
+        return WINCODEC_ERR_NOTINITIALIZED;
+
     if (!pDpiX || !pDpiY)
         return E_INVALIDARG;
 
-    if (!This->source)
-        return WINCODEC_ERR_WRONGSTATE;
-
     return IWICBitmapSource_GetResolution(This->source, pDpiX, pDpiY);
 }
 
@@ -171,7 +174,7 @@ static HRESULT WINAPI BitmapScaler_CopyPalette(IWICBitmapScaler *iface,
         return E_INVALIDARG;
 
     if (!This->source)
-        return WINCODEC_ERR_WRONGSTATE;
+        return WINCODEC_ERR_PALETTEUNAVAILABLE;
 
     return IWICBitmapSource_CopyPalette(This->source, pIPalette);
 }
@@ -215,7 +218,7 @@ static HRESULT WINAPI BitmapScaler_CopyPixels(IWICBitmapScaler *iface,
     ULONG buffer_size;
     UINT y;
 
-    TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer);
+    TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
 
     EnterCriticalSection(&This->lock);
 
@@ -320,6 +323,9 @@ static HRESULT WINAPI BitmapScaler_Initialize(IWICBitmapScaler *iface,
 
     TRACE("(%p,%p,%u,%u,%u)\n", iface, pISource, uiWidth, uiHeight, mode);
 
+    if (!pISource || !uiWidth || !uiHeight)
+        return E_INVALIDARG;
+
     EnterCriticalSection(&This->lock);
 
     if (This->source)
index 308ef8e..366d11b 100644 (file)
@@ -101,7 +101,8 @@ static HRESULT WINAPI StreamOnMemory_Read(IStream *iface,
 {
     StreamOnMemory *This = StreamOnMemory_from_IStream(iface);
     ULONG uBytesRead;
-    TRACE("(%p)\n", This);
+
+    TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbRead);
 
     if (!pv) return E_INVALIDARG;
 
@@ -121,7 +122,8 @@ static HRESULT WINAPI StreamOnMemory_Write(IStream *iface,
 {
     StreamOnMemory *This = StreamOnMemory_from_IStream(iface);
     HRESULT hr;
-    TRACE("(%p)\n", This);
+
+    TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbWritten);
 
     if (!pv) return E_INVALIDARG;
 
@@ -146,7 +148,8 @@ static HRESULT WINAPI StreamOnMemory_Seek(IStream *iface,
     StreamOnMemory *This = StreamOnMemory_from_IStream(iface);
     LARGE_INTEGER NewPosition;
     HRESULT hr=S_OK;
-    TRACE("(%p)\n", This);
+
+    TRACE("(%p, %s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
 
     EnterCriticalSection(&This->lock);
     if (dwOrigin == STREAM_SEEK_SET) NewPosition.QuadPart = dlibMove.QuadPart;
@@ -174,7 +177,7 @@ static HRESULT WINAPI StreamOnMemory_Seek(IStream *iface,
 static HRESULT WINAPI StreamOnMemory_SetSize(IStream *iface,
     ULARGE_INTEGER libNewSize)
 {
-    TRACE("(%p)\n", iface);
+    TRACE("(%p, %s)\n", iface, wine_dbgstr_longlong(libNewSize.QuadPart));
     return E_NOTIMPL;
 }
 
@@ -182,7 +185,7 @@ static HRESULT WINAPI StreamOnMemory_SetSize(IStream *iface,
 static HRESULT WINAPI StreamOnMemory_CopyTo(IStream *iface,
     IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
 {
-    TRACE("(%p)\n", iface);
+    TRACE("(%p, %p, %s, %p, %p)\n", iface, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
     return E_NOTIMPL;
 }
 
@@ -190,7 +193,7 @@ static HRESULT WINAPI StreamOnMemory_CopyTo(IStream *iface,
 static HRESULT WINAPI StreamOnMemory_Commit(IStream *iface,
     DWORD grfCommitFlags)
 {
-    TRACE("(%p)\n", iface);
+    TRACE("(%p, %#x)\n", iface, grfCommitFlags);
     return E_NOTIMPL;
 }
 
@@ -205,7 +208,8 @@ static HRESULT WINAPI StreamOnMemory_Revert(IStream *iface)
 static HRESULT WINAPI StreamOnMemory_LockRegion(IStream *iface,
     ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 {
-    TRACE("(%p)\n", iface);
+    TRACE("(%p, %s, %s, %d)\n", iface, wine_dbgstr_longlong(libOffset.QuadPart),
+        wine_dbgstr_longlong(cb.QuadPart), dwLockType);
     return E_NOTIMPL;
 }
 
@@ -213,7 +217,8 @@ static HRESULT WINAPI StreamOnMemory_LockRegion(IStream *iface,
 static HRESULT WINAPI StreamOnMemory_UnlockRegion(IStream *iface,
     ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 {
-    TRACE("(%p)\n", iface);
+    TRACE("(%p, %s, %s, %d)\n", iface, wine_dbgstr_longlong(libOffset.QuadPart),
+        wine_dbgstr_longlong(cb.QuadPart), dwLockType);
     return E_NOTIMPL;
 }
 
@@ -221,7 +226,7 @@ static HRESULT WINAPI StreamOnMemory_Stat(IStream *iface,
     STATSTG *pstatstg, DWORD grfStatFlag)
 {
     StreamOnMemory *This = StreamOnMemory_from_IStream(iface);
-    TRACE("(%p)\n", This);
+    TRACE("(%p, %p, %#x)\n", This, pstatstg, grfStatFlag);
 
     if (!pstatstg) return E_INVALIDARG;
 
@@ -236,7 +241,7 @@ static HRESULT WINAPI StreamOnMemory_Stat(IStream *iface,
 static HRESULT WINAPI StreamOnMemory_Clone(IStream *iface,
     IStream **ppstm)
 {
-    TRACE("(%p)\n", iface);
+    TRACE("(%p, %p)\n", iface, ppstm);
     return E_NOTIMPL;
 }
 
@@ -331,7 +336,7 @@ static HRESULT WINAPI StreamOnFileHandle_Read(IStream *iface,
     void *pv, ULONG cb, ULONG *pcbRead)
 {
     StreamOnFileHandle *This = StreamOnFileHandle_from_IStream(iface);
-    TRACE("(%p)\n", This);
+    TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbRead);
 
     return IWICStream_Read(This->stream, pv, cb, pcbRead);
 }
@@ -339,7 +344,7 @@ static HRESULT WINAPI StreamOnFileHandle_Read(IStream *iface,
 static HRESULT WINAPI StreamOnFileHandle_Write(IStream *iface,
     void const *pv, ULONG cb, ULONG *pcbWritten)
 {
-    ERR("(%p)\n", iface);
+    ERR("(%p, %p, %u, %p)\n", iface, pv, cb, pcbWritten);
     return HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED);
 }
 
@@ -347,7 +352,7 @@ static HRESULT WINAPI StreamOnFileHandle_Seek(IStream *iface,
     LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
 {
     StreamOnFileHandle *This = StreamOnFileHandle_from_IStream(iface);
-    TRACE("(%p)\n", This);
+    TRACE("(%p, %s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
 
     return IWICStream_Seek(This->stream, dlibMove, dwOrigin, plibNewPosition);
 }
@@ -355,21 +360,21 @@ static HRESULT WINAPI StreamOnFileHandle_Seek(IStream *iface,
 static HRESULT WINAPI StreamOnFileHandle_SetSize(IStream *iface,
     ULARGE_INTEGER libNewSize)
 {
-    TRACE("(%p)\n", iface);
+    TRACE("(%p, %s)\n", iface, wine_dbgstr_longlong(libNewSize.QuadPart));
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI StreamOnFileHandle_CopyTo(IStream *iface,
     IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
 {
-    TRACE("(%p)\n", iface);
+    TRACE("(%p, %p, %s, %p, %p)\n", iface, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI StreamOnFileHandle_Commit(IStream *iface,
     DWORD grfCommitFlags)
 {
-    TRACE("(%p)\n", iface);
+    TRACE("(%p, %#x)\n", iface, grfCommitFlags);
     return E_NOTIMPL;
 }
 
@@ -382,14 +387,16 @@ static HRESULT WINAPI StreamOnFileHandle_Revert(IStream *iface)
 static HRESULT WINAPI StreamOnFileHandle_LockRegion(IStream *iface,
     ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 {
-    TRACE("(%p)\n", iface);
+    TRACE("(%p, %s, %s, %d)\n", iface, wine_dbgstr_longlong(libOffset.QuadPart),
+        wine_dbgstr_longlong(cb.QuadPart), dwLockType);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI StreamOnFileHandle_UnlockRegion(IStream *iface,
     ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 {
-    TRACE("(%p)\n", iface);
+    TRACE("(%p, %s, %s, %d)\n", iface, wine_dbgstr_longlong(libOffset.QuadPart),
+        wine_dbgstr_longlong(cb.QuadPart), dwLockType);
     return E_NOTIMPL;
 }
 
@@ -397,7 +404,7 @@ static HRESULT WINAPI StreamOnFileHandle_Stat(IStream *iface,
     STATSTG *pstatstg, DWORD grfStatFlag)
 {
     StreamOnFileHandle *This = StreamOnFileHandle_from_IStream(iface);
-    TRACE("(%p)\n", This);
+    TRACE("(%p, %p, %#x)\n", This, pstatstg, grfStatFlag);
 
     return IWICStream_Stat(This->stream, pstatstg, grfStatFlag);
 }
@@ -405,11 +412,10 @@ static HRESULT WINAPI StreamOnFileHandle_Stat(IStream *iface,
 static HRESULT WINAPI StreamOnFileHandle_Clone(IStream *iface,
     IStream **ppstm)
 {
-    TRACE("(%p)\n", iface);
+    TRACE("(%p, %p)\n", iface, ppstm);
     return E_NOTIMPL;
 }
 
-
 static const IStreamVtbl StreamOnFileHandle_Vtbl =
 {
     /*** IUnknown methods ***/
@@ -509,7 +515,8 @@ static HRESULT WINAPI StreamOnStreamRange_Read(IStream *iface,
     HRESULT hr;
     ULARGE_INTEGER OldPosition;
     LARGE_INTEGER SetPosition;
-    TRACE("(%p)\n", This);
+
+    TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbRead);
 
     if (!pv) return E_INVALIDARG;
 
@@ -552,7 +559,7 @@ static HRESULT WINAPI StreamOnStreamRange_Write(IStream *iface,
     ULARGE_INTEGER OldPosition;
     LARGE_INTEGER SetPosition;
     ULONG uBytesWritten=0;
-    TRACE("(%p)\n", This);
+    TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbWritten);
 
     if (!pv) return E_INVALIDARG;
 
@@ -594,7 +601,7 @@ static HRESULT WINAPI StreamOnStreamRange_Seek(IStream *iface,
     ULARGE_INTEGER NewPosition, actual_size;
     HRESULT hr=S_OK;
     STATSTG statstg;
-    TRACE("(%p)\n", This);
+    TRACE("(%p, %s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
 
     EnterCriticalSection(&This->lock);
     actual_size = This->max_size;
@@ -631,7 +638,7 @@ static HRESULT WINAPI StreamOnStreamRange_Seek(IStream *iface,
 static HRESULT WINAPI StreamOnStreamRange_SetSize(IStream *iface,
     ULARGE_INTEGER libNewSize)
 {
-    TRACE("(%p)\n", iface);
+    TRACE("(%p, %s)\n", iface, wine_dbgstr_longlong(libNewSize.QuadPart));
     return E_NOTIMPL;
 }
 
@@ -639,7 +646,8 @@ static HRESULT WINAPI StreamOnStreamRange_SetSize(IStream *iface,
 static HRESULT WINAPI StreamOnStreamRange_CopyTo(IStream *iface,
     IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
 {
-    TRACE("(%p)\n", iface);
+    TRACE("(%p, %p, %s, %p, %p)\n", iface, pstm, wine_dbgstr_longlong(cb.QuadPart),
+        pcbRead, pcbWritten);
     return E_NOTIMPL;
 }
 
@@ -647,7 +655,7 @@ static HRESULT WINAPI StreamOnStreamRange_CopyTo(IStream *iface,
 static HRESULT WINAPI StreamOnStreamRange_Commit(IStream *iface,
     DWORD grfCommitFlags)
 {
-    TRACE("(%p)\n", iface);
+    TRACE("(%p, %#x)\n", iface, grfCommitFlags);
     return E_NOTIMPL;
 }
 
@@ -662,7 +670,8 @@ static HRESULT WINAPI StreamOnStreamRange_Revert(IStream *iface)
 static HRESULT WINAPI StreamOnStreamRange_LockRegion(IStream *iface,
     ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 {
-    TRACE("(%p)\n", iface);
+    TRACE("(%p, %s, %s, %d)\n", iface, wine_dbgstr_longlong(libOffset.QuadPart),
+        wine_dbgstr_longlong(cb.QuadPart), dwLockType);
     return E_NOTIMPL;
 }
 
@@ -670,7 +679,8 @@ static HRESULT WINAPI StreamOnStreamRange_LockRegion(IStream *iface,
 static HRESULT WINAPI StreamOnStreamRange_UnlockRegion(IStream *iface,
     ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 {
-    TRACE("(%p)\n", iface);
+    TRACE("(%p, %s, %s, %d)\n", iface, wine_dbgstr_longlong(libOffset.QuadPart),
+        wine_dbgstr_longlong(cb.QuadPart), dwLockType);
     return E_NOTIMPL;
 }
 
@@ -679,7 +689,7 @@ static HRESULT WINAPI StreamOnStreamRange_Stat(IStream *iface,
 {
     StreamOnStreamRange *This = StreamOnStreamRange_from_IStream(iface);
     HRESULT hr;
-    TRACE("(%p)\n", This);
+    TRACE("(%p, %p, %#x)\n", This, pstatstg, grfStatFlag);
 
     if (!pstatstg) return E_INVALIDARG;
 
@@ -701,11 +711,10 @@ static HRESULT WINAPI StreamOnStreamRange_Stat(IStream *iface,
 static HRESULT WINAPI StreamOnStreamRange_Clone(IStream *iface,
     IStream **ppstm)
 {
-    TRACE("(%p)\n", iface);
+    TRACE("(%p, %p)\n", iface, ppstm);
     return E_NOTIMPL;
 }
 
-
 static const IStreamVtbl StreamOnStreamRange_Vtbl =
 {
     /*** IUnknown methods ***/
@@ -795,7 +804,7 @@ static HRESULT WINAPI IWICStreamImpl_Read(IWICStream *iface,
     void *pv, ULONG cb, ULONG *pcbRead)
 {
     IWICStreamImpl *This = impl_from_IWICStream(iface);
-    TRACE("(%p): relay\n", This);
+    TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbRead);
 
     if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
     return IStream_Read(This->pStream, pv, cb, pcbRead);
@@ -805,7 +814,7 @@ static HRESULT WINAPI IWICStreamImpl_Write(IWICStream *iface,
     void const *pv, ULONG cb, ULONG *pcbWritten)
 {
     IWICStreamImpl *This = impl_from_IWICStream(iface);
-    TRACE("(%p): relay\n", This);
+    TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbWritten);
 
     if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
     return IStream_Write(This->pStream, pv, cb, pcbWritten);
@@ -815,7 +824,8 @@ static HRESULT WINAPI IWICStreamImpl_Seek(IWICStream *iface,
     LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
 {
     IWICStreamImpl *This = impl_from_IWICStream(iface);
-    TRACE("(%p): relay\n", This);
+    TRACE("(%p, %s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart),
+        dwOrigin, plibNewPosition);
 
     if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
     return IStream_Seek(This->pStream, dlibMove, dwOrigin, plibNewPosition);
@@ -825,7 +835,7 @@ static HRESULT WINAPI IWICStreamImpl_SetSize(IWICStream *iface,
     ULARGE_INTEGER libNewSize)
 {
     IWICStreamImpl *This = impl_from_IWICStream(iface);
-    TRACE("(%p): relay\n", This);
+    TRACE("(%p, %s)\n", This, wine_dbgstr_longlong(libNewSize.QuadPart));
 
     if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
     return IStream_SetSize(This->pStream, libNewSize);
@@ -835,7 +845,7 @@ static HRESULT WINAPI IWICStreamImpl_CopyTo(IWICStream *iface,
     IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
 {
     IWICStreamImpl *This = impl_from_IWICStream(iface);
-    TRACE("(%p): relay\n", This);
+    TRACE("(%p, %p, %s, %p, %p)\n", This, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
 
     if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
     return IStream_CopyTo(This->pStream, pstm, cb, pcbRead, pcbWritten);
@@ -845,7 +855,7 @@ static HRESULT WINAPI IWICStreamImpl_Commit(IWICStream *iface,
     DWORD grfCommitFlags)
 {
     IWICStreamImpl *This = impl_from_IWICStream(iface);
-    TRACE("(%p): relay\n", This);
+    TRACE("(%p, %#x)\n", This, grfCommitFlags);
 
     if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
     return IStream_Commit(This->pStream, grfCommitFlags);
@@ -854,7 +864,7 @@ static HRESULT WINAPI IWICStreamImpl_Commit(IWICStream *iface,
 static HRESULT WINAPI IWICStreamImpl_Revert(IWICStream *iface)
 {
     IWICStreamImpl *This = impl_from_IWICStream(iface);
-    TRACE("(%p): relay\n", This);
+    TRACE("(%p)\n", This);
 
     if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
     return IStream_Revert(This->pStream);
@@ -864,7 +874,8 @@ static HRESULT WINAPI IWICStreamImpl_LockRegion(IWICStream *iface,
     ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 {
     IWICStreamImpl *This = impl_from_IWICStream(iface);
-    TRACE("(%p): relay\n", This);
+    TRACE("(%p, %s, %s, %d)\n", This, wine_dbgstr_longlong(libOffset.QuadPart),
+        wine_dbgstr_longlong(cb.QuadPart), dwLockType);
 
     if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
     return IStream_LockRegion(This->pStream, libOffset, cb, dwLockType);
@@ -874,7 +885,8 @@ static HRESULT WINAPI IWICStreamImpl_UnlockRegion(IWICStream *iface,
     ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 {
     IWICStreamImpl *This = impl_from_IWICStream(iface);
-    TRACE("(%p): relay\n", This);
+    TRACE("(%p, %s, %s, %d)\n", This, wine_dbgstr_longlong(libOffset.QuadPart),
+        wine_dbgstr_longlong(cb.QuadPart), dwLockType);
 
     if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
     return IStream_UnlockRegion(This->pStream, libOffset, cb, dwLockType);
@@ -884,7 +896,7 @@ static HRESULT WINAPI IWICStreamImpl_Stat(IWICStream *iface,
     STATSTG *pstatstg, DWORD grfStatFlag)
 {
     IWICStreamImpl *This = impl_from_IWICStream(iface);
-    TRACE("(%p): relay\n", This);
+    TRACE("(%p, %p, %#x)\n", This, pstatstg, grfStatFlag);
 
     if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
     return IStream_Stat(This->pStream, pstatstg, grfStatFlag);
@@ -894,22 +906,32 @@ static HRESULT WINAPI IWICStreamImpl_Clone(IWICStream *iface,
     IStream **ppstm)
 {
     IWICStreamImpl *This = impl_from_IWICStream(iface);
-    TRACE("(%p): relay\n", This);
+    TRACE("(%p, %p)\n", This, ppstm);
 
     if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
     return IStream_Clone(This->pStream, ppstm);
 }
 
-static HRESULT WINAPI IWICStreamImpl_InitializeFromIStream(IWICStream *iface,
-    IStream *pIStream)
+static HRESULT WINAPI IWICStreamImpl_InitializeFromIStream(IWICStream *iface, IStream *stream)
 {
-    ULARGE_INTEGER offset, size;
-    TRACE("(%p): relay\n", iface);
+    IWICStreamImpl *This = impl_from_IWICStream(iface);
+    HRESULT hr = S_OK;
+
+    TRACE("(%p, %p)\n", iface, stream);
+
+    if (!stream) return E_INVALIDARG;
+    if (This->pStream) return WINCODEC_ERR_WRONGSTATE;
+
+    IStream_AddRef(stream);
 
-    offset.QuadPart = 0;
-    size.u.LowPart = 0xffffffff;
-    size.u.HighPart = 0xffffffff;
-    return IWICStream_InitializeFromIStreamRegion(iface, pIStream, offset, size);
+    if (InterlockedCompareExchangePointer((void **)&This->pStream, stream, NULL))
+    {
+        /* Some other thread set the stream first. */
+        IStream_Release(stream);
+        hr = WINCODEC_ERR_WRONGSTATE;
+    }
+
+    return hr;
 }
 
 static HRESULT WINAPI IWICStreamImpl_InitializeFromFilename(IWICStream *iface,
@@ -967,7 +989,7 @@ static HRESULT WINAPI IWICStreamImpl_InitializeFromMemory(IWICStream *iface,
 {
     IWICStreamImpl *This = impl_from_IWICStream(iface);
     StreamOnMemory *pObject;
-    TRACE("(%p,%p)\n", iface, pbBuffer);
+    TRACE("(%p, %p, %u)\n", iface, pbBuffer, cbBufferSize);
 
     if (!pbBuffer) return E_INVALIDARG;
     if (This->pStream) return WINCODEC_ERR_WRONGSTATE;
@@ -1068,7 +1090,9 @@ static HRESULT WINAPI IWICStreamImpl_InitializeFromIStreamRegion(IWICStream *ifa
 {
     IWICStreamImpl *This = impl_from_IWICStream(iface);
     StreamOnStreamRange *pObject;
-    TRACE("(%p,%p)\n", iface, pIStream);
+
+    TRACE("(%p,%p,%s,%s)\n", iface, pIStream, wine_dbgstr_longlong(ulOffset.QuadPart),
+        wine_dbgstr_longlong(ulMaxSize.QuadPart));
 
     if (!pIStream) return E_INVALIDARG;
     if (This->pStream) return WINCODEC_ERR_WRONGSTATE;
index b3d9aea..72c9baa 100644 (file)
@@ -890,7 +890,7 @@ static HRESULT WINAPI TgaDecoder_Frame_CopyPixels(IWICBitmapFrameDecode *iface,
     TgaDecoder *This = impl_from_IWICBitmapFrameDecode(iface);
     HRESULT hr;
 
-    TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer);
+    TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
 
     hr = TgaDecoder_ReadImage(This);
 
index d1ee440..d9b7c4c 100644 (file)
@@ -504,7 +504,7 @@ static HRESULT tiff_get_decode_info(TIFF *tiff, tiff_decode_info *decode_info)
             break;
         default:
             FIXME("unhandled indexed bit count %u\n", bps);
-            return E_FAIL;
+            return E_NOTIMPL;
         }
         break;
 
@@ -836,6 +836,7 @@ static HRESULT WINAPI TiffDecoder_GetFrame(IWICBitmapDecoder *iface,
             result->IWICMetadataBlockReader_iface.lpVtbl = &TiffFrameDecode_BlockVtbl;
             result->ref = 1;
             result->parent = This;
+            IWICBitmapDecoder_AddRef(iface);
             result->index = index;
             result->decode_info = decode_info;
             result->cached_tile_x = -1;
@@ -846,7 +847,7 @@ static HRESULT WINAPI TiffDecoder_GetFrame(IWICBitmapDecoder *iface,
             else
             {
                 hr = E_OUTOFMEMORY;
-                HeapFree(GetProcessHeap(), 0, result);
+                IWICBitmapFrameDecode_Release(&result->IWICBitmapFrameDecode_iface);
             }
         }
         else hr = E_OUTOFMEMORY;
@@ -921,6 +922,7 @@ static ULONG WINAPI TiffFrameDecode_Release(IWICBitmapFrameDecode *iface)
 
     if (ref == 0)
     {
+        IWICBitmapDecoder_Release(&This->parent->IWICBitmapDecoder_iface);
         HeapFree(GetProcessHeap(), 0, This->cached_tile);
         HeapFree(GetProcessHeap(), 0, This);
     }
@@ -1286,7 +1288,7 @@ static HRESULT WINAPI TiffFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface,
     UINT bytesperrow;
     WICRect rect;
 
-    TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer);
+    TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
 
     if (!prc)
     {
@@ -1308,7 +1310,7 @@ static HRESULT WINAPI TiffFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface,
     if (cbStride < bytesperrow)
         return E_INVALIDARG;
 
-    if ((cbStride * (prc->Height-1)) + ((prc->Width * This->decode_info.bpp) + 7)/8 > cbBufferSize)
+    if ((cbStride * (prc->Height-1)) + bytesperrow > cbBufferSize)
         return E_INVALIDARG;
 
     min_tile_x = prc->X / This->decode_info.tile_width;
@@ -1623,7 +1625,6 @@ static const struct tiff_encode_format formats[] = {
     {&GUID_WICPixelFormat64bppRGBA, 2, 16, 4, 64, 1, 2, 0},
     {&GUID_WICPixelFormat64bppPRGBA, 2, 16, 4, 64, 1, 1, 0},
     {&GUID_WICPixelFormat1bppIndexed, 3, 1, 1, 1, 0, 0, 0},
-    {&GUID_WICPixelFormat2bppIndexed, 3, 2, 1, 2, 0, 0, 0},
     {&GUID_WICPixelFormat4bppIndexed, 3, 4, 1, 4, 0, 0, 0},
     {&GUID_WICPixelFormat8bppIndexed, 3, 8, 1, 8, 0, 0, 0},
     {0}
@@ -1797,9 +1798,12 @@ static HRESULT WINAPI TiffFrameEncode_SetPixelFormat(IWICBitmapFrameEncode *ifac
         return WINCODEC_ERR_WRONGSTATE;
     }
 
+    if (IsEqualGUID(pPixelFormat, &GUID_WICPixelFormat2bppIndexed))
+        *pPixelFormat = GUID_WICPixelFormat4bppIndexed;
+
     for (i=0; formats[i].guid; i++)
     {
-        if (memcmp(formats[i].guid, pPixelFormat, sizeof(GUID)) == 0)
+        if (IsEqualGUID(formats[i].guid, pPixelFormat))
             break;
     }
 
@@ -1961,7 +1965,7 @@ static HRESULT WINAPI TiffFrameEncode_WriteSource(IWICBitmapFrameEncode *iface,
     TiffFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
     HRESULT hr;
 
-    TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc);
+    TRACE("(%p,%p,%s)\n", iface, pIBitmapSource, debug_wic_rect(prc));
 
     if (!This->initialized)
         return WINCODEC_ERR_WRONGSTATE;
@@ -2117,6 +2121,11 @@ exit:
 static HRESULT WINAPI TiffEncoder_GetContainerFormat(IWICBitmapEncoder *iface,
     GUID *pguidContainerFormat)
 {
+    TRACE("(%p,%p)\n", iface, pguidContainerFormat);
+
+    if (!pguidContainerFormat)
+        return E_INVALIDARG;
+
     memcpy(pguidContainerFormat, &GUID_ContainerFormatTiff, sizeof(GUID));
     return S_OK;
 }
@@ -2202,7 +2211,7 @@ static HRESULT WINAPI TiffEncoder_CreateNewFrame(IWICBitmapEncoder *iface,
 
     if (ppIEncoderOptions && SUCCEEDED(hr))
     {
-        hr = CreatePropertyBag2(opts, sizeof(opts)/sizeof(opts[0]), ppIEncoderOptions);
+        hr = CreatePropertyBag2(opts, ARRAY_SIZE(opts), ppIEncoderOptions);
         if (SUCCEEDED(hr))
         {
             VARIANT v;
index 2645204..22af9a1 100644 (file)
@@ -21,6 +21,8 @@
 
 #include "wincodec.h"
 #include "wincodecsdk.h"
+
+#include "wine/debug.h"
 #include "wine/unicode.h"
 
 DEFINE_GUID(CLSID_WineTgaDecoder, 0xb11fc79a,0x67cc,0x43e6,0xa9,0xce,0xe3,0xd5,0x49,0x45,0xd3,0x04);
@@ -138,7 +140,7 @@ HRESULT create_instance(CLSID *clsid, const IID *iid, void **ppv) DECLSPEC_HIDDE
 
 typedef HRESULT(*class_constructor)(REFIID,void**);
 extern HRESULT FormatConverter_CreateInstance(REFIID riid, void** ppv) DECLSPEC_HIDDEN;
-extern HRESULT ComponentFactory_CreateInstance(REFIID riid, void** ppv) DECLSPEC_HIDDEN;
+extern HRESULT ImagingFactory_CreateInstance(REFIID riid, void** ppv) DECLSPEC_HIDDEN;
 extern HRESULT BmpDecoder_CreateInstance(REFIID riid, void** ppv) DECLSPEC_HIDDEN;
 extern HRESULT PngDecoder_CreateInstance(REFIID iid, void** ppv) DECLSPEC_HIDDEN;
 extern HRESULT PngEncoder_CreateInstance(REFIID iid, void** ppv) DECLSPEC_HIDDEN;
@@ -242,4 +244,10 @@ static inline WCHAR *heap_strdupW(const WCHAR *src)
     return dst;
 }
 
+static inline const char *debug_wic_rect(const WICRect *rect)
+{
+    if (!rect) return "(null)";
+    return wine_dbg_sprintf("(%u,%u)-(%u,%u)", rect->X, rect->Y, rect->Width, rect->Height);
+}
+
 #endif /* WINCODECS_PRIVATE_H */
index 424b307..ae3660c 100644 (file)
@@ -99,9 +99,9 @@
 @ stdcall IWICPalette_InitializeFromBitmap_Proxy(ptr ptr long long) IWICPalette_InitializeFromBitmap_Proxy_W
 @ stdcall IWICPalette_InitializeFromPalette_Proxy(ptr ptr) IWICPalette_InitializeFromPalette_Proxy_W
 @ stdcall IWICPalette_InitializePredefined_Proxy(ptr long long) IWICPalette_InitializePredefined_Proxy_W
-@ stdcall IWICPixelFormatInfo_GetBitsPerPixel_Proxy(ptr ptr)
-@ stdcall IWICPixelFormatInfo_GetChannelCount_Proxy(ptr ptr)
-@ stdcall IWICPixelFormatInfo_GetChannelMask_Proxy(ptr long long ptr ptr)
+@ stdcall IWICPixelFormatInfo_GetBitsPerPixel_Proxy(ptr ptr) IWICPixelFormatInfo_GetBitsPerPixel_Proxy_W
+@ stdcall IWICPixelFormatInfo_GetChannelCount_Proxy(ptr ptr) IWICPixelFormatInfo_GetChannelCount_Proxy_W
+@ stdcall IWICPixelFormatInfo_GetChannelMask_Proxy(ptr long long ptr ptr) IWICPixelFormatInfo_GetChannelMask_Proxy_W
 @ stdcall IWICStream_InitializeFromIStream_Proxy(ptr ptr) IWICStream_InitializeFromIStream_Proxy_W
 @ stdcall IWICStream_InitializeFromMemory_Proxy(ptr ptr long) IWICStream_InitializeFromMemory_Proxy_W
 @ stdcall WICConvertBitmapSource(ptr ptr ptr)
index 218b028..a073dcc 100644 (file)
@@ -196,7 +196,7 @@ reactos/dll/win32/version             # Synced to WineStaging-4.0
 reactos/dll/win32/vssapi              # Synced to WineStaging-2.9
 reactos/dll/win32/wbemdisp            # Synced to WineStaging-4.0
 reactos/dll/win32/wbemprox            # Synced to WineStaging-4.0
-reactos/dll/win32/windowscodecs       # Synced to WineStaging-3.9
+reactos/dll/win32/windowscodecs       # Synced to WineStaging-4.0
 reactos/dll/win32/windowscodecsext    # Synced to WineStaging-2.9
 reactos/dll/win32/winemp3.acm         # Synced to WineStaging-3.3
 reactos/dll/win32/wing32              # Synced to WineStaging-3.3