Dmitry Timoshkov : gdiplus: Reuse an existing image stream in GdipImageSelectActiveFrame.

Alexandre Julliard julliard at winehq.org
Fri Sep 28 11:39:04 CDT 2012


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

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Fri Sep 28 10:15:39 2012 +0900

gdiplus: Reuse an existing image stream in GdipImageSelectActiveFrame.

---

 dlls/gdiplus/image.c |   31 ++++++++++---------------------
 1 files changed, 10 insertions(+), 21 deletions(-)

diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c
index 5e0b1ea..3ee024c 100644
--- a/dlls/gdiplus/image.c
+++ b/dlls/gdiplus/image.c
@@ -3531,6 +3531,8 @@ static GpStatus decode_image_wic(IStream *stream, GDIPCONST CLSID *clsid,
     WICRect wrc;
     HRESULT initresult;
 
+    TRACE("%p,%s,%u,%p\n", stream, wine_dbgstr_guid(clsid), active_frame, image);
+
     initresult = CoInitialize(NULL);
 
     hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER,
@@ -3669,6 +3671,7 @@ end:
         }
         /* Pin the source stream */
         IStream_AddRef(stream);
+        TRACE("=> %p\n", *image);
     }
 
     return status;
@@ -3827,7 +3830,6 @@ GpStatus WINGDIPAPI GdipImageSelectActiveFrame(GpImage *image, GDIPCONST GUID *d
     LARGE_INTEGER seek;
     HRESULT hr;
     const struct image_codec *codec = NULL;
-    IStream *stream;
     GpImage *new_image;
 
     TRACE("(%p,%s,%u)\n", image, debugstr_guid(dimensionID), frame);
@@ -3836,7 +3838,10 @@ GpStatus WINGDIPAPI GdipImageSelectActiveFrame(GpImage *image, GDIPCONST GUID *d
         return InvalidParameter;
 
     if (frame >= image->frame_count)
+    {
+        WARN("requested frame %u, but image has only %u\n", frame, image->frame_count);
         return InvalidParameter;
+    }
 
     if (image->type != ImageTypeBitmap && image->type != ImageTypeMetafile)
     {
@@ -3853,37 +3858,22 @@ GpStatus WINGDIPAPI GdipImageSelectActiveFrame(GpImage *image, GDIPCONST GUID *d
         return Ok;
     }
 
-    hr = IStream_Clone(image->stream, &stream);
-    if (FAILED(hr))
-    {
-        STATSTG statstg;
-
-        hr = IStream_Stat(image->stream, &statstg, STATFLAG_NOOPEN);
-        if (FAILED(hr)) return hresult_to_status(hr);
-
-        stat = GdipCreateStreamOnFile(statstg.pwcsName, GENERIC_READ, &stream);
-        if (stat != Ok) return stat;
-    }
-
     /* choose an appropriate image decoder */
-    stat = get_decoder_info(stream, &codec);
+    stat = get_decoder_info(image->stream, &codec);
     if (stat != Ok)
     {
-        IStream_Release(stream);
+        WARN("can't find decoder info\n");
         return stat;
     }
 
     /* seek to the start of the stream */
     seek.QuadPart = 0;
-    hr = IStream_Seek(stream, seek, STREAM_SEEK_SET, NULL);
+    hr = IStream_Seek(image->stream, seek, STREAM_SEEK_SET, NULL);
     if (FAILED(hr))
-    {
-        IStream_Release(stream);
         return hresult_to_status(hr);
-    }
 
     /* call on the image decoder to do the real work */
-    stat = codec->decode_func(stream, &codec->info.Clsid, frame, &new_image);
+    stat = codec->decode_func(image->stream, &codec->info.Clsid, frame, &new_image);
 
     if (stat == Ok)
     {
@@ -3898,7 +3888,6 @@ GpStatus WINGDIPAPI GdipImageSelectActiveFrame(GpImage *image, GDIPCONST GUID *d
         return Ok;
     }
 
-    IStream_Release(stream);
     return stat;
 }
 




More information about the wine-cvs mailing list