Vincent Povirk : windowscodecs: Implement IWICImagingFactory::CreateEncoder .

Alexandre Julliard julliard at winehq.org
Tue Jun 26 13:34:15 CDT 2012


Module: wine
Branch: master
Commit: 02aa7ec403e5faf3d89126e39481a4c7209d5540
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=02aa7ec403e5faf3d89126e39481a4c7209d5540

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Tue Feb 28 16:10:08 2012 -0600

windowscodecs: Implement IWICImagingFactory::CreateEncoder.

---

 dlls/windowscodecs/imgfactory.c |   60 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/dlls/windowscodecs/imgfactory.c b/dlls/windowscodecs/imgfactory.c
index fa28c9a..d70c223 100644
--- a/dlls/windowscodecs/imgfactory.c
+++ b/dlls/windowscodecs/imgfactory.c
@@ -335,9 +335,65 @@ static HRESULT WINAPI ComponentFactory_CreateEncoder(IWICComponentFactory *iface
     REFGUID guidContainerFormat, const GUID *pguidVendor,
     IWICBitmapEncoder **ppIEncoder)
 {
-    FIXME("(%p,%s,%s,%p): stub\n", iface, debugstr_guid(guidContainerFormat),
+    static int fixme=0;
+    IEnumUnknown *enumencoders;
+    IUnknown *unkencoderinfo;
+    IWICBitmapEncoderInfo *encoderinfo;
+    IWICBitmapEncoder *encoder=NULL;
+    HRESULT res=S_OK;
+    ULONG num_fetched;
+    GUID actual_containerformat;
+
+    TRACE("(%p,%s,%s,%p)\n", iface, debugstr_guid(guidContainerFormat),
         debugstr_guid(pguidVendor), ppIEncoder);
-    return E_NOTIMPL;
+
+    if (pguidVendor && !fixme++)
+        FIXME("ignoring vendor GUID\n");
+
+    res = CreateComponentEnumerator(WICEncoder, WICComponentEnumerateDefault, &enumencoders);
+    if (FAILED(res)) return res;
+
+    while (!encoder)
+    {
+        res = IEnumUnknown_Next(enumencoders, 1, &unkencoderinfo, &num_fetched);
+
+        if (res == S_OK)
+        {
+            res = IUnknown_QueryInterface(unkencoderinfo, &IID_IWICBitmapEncoderInfo, (void**)&encoderinfo);
+
+            if (SUCCEEDED(res))
+            {
+                res = IWICBitmapEncoderInfo_GetContainerFormat(encoderinfo, &actual_containerformat);
+
+                if (SUCCEEDED(res) && IsEqualGUID(guidContainerFormat, &actual_containerformat))
+                {
+                    res = IWICBitmapEncoderInfo_CreateInstance(encoderinfo, &encoder);
+                    if (FAILED(res))
+                        encoder = NULL;
+                }
+
+                IWICBitmapEncoderInfo_Release(encoderinfo);
+            }
+
+            IUnknown_Release(unkencoderinfo);
+        }
+        else
+            break;
+    }
+
+    IEnumUnknown_Release(enumencoders);
+
+    if (encoder)
+    {
+        *ppIEncoder = encoder;
+        return S_OK;
+    }
+    else
+    {
+        WARN("failed to create encoder\n");
+        *ppIEncoder = NULL;
+        return WINCODEC_ERR_COMPONENTNOTFOUND;
+    }
 }
 
 static HRESULT WINAPI ComponentFactory_CreatePalette(IWICComponentFactory *iface,




More information about the wine-cvs mailing list