Kirill K. Smirnov : gdiplus: Whole picture object should be cloned in GdipCloneImage(), not just parent class 'image'.

Alexandre Julliard julliard at winehq.org
Tue Oct 21 07:07:01 CDT 2008


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

Author: Kirill K. Smirnov <lich at math.spbu.ru>
Date:   Mon Oct 20 17:10:10 2008 +0400

gdiplus: Whole picture object should be cloned in GdipCloneImage(), not just parent class 'image'.

---

 dlls/gdiplus/image.c       |   25 ++++---------------------
 dlls/gdiplus/tests/image.c |    4 ++++
 2 files changed, 8 insertions(+), 21 deletions(-)

diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c
index 0cb5ded..9dbefc0 100644
--- a/dlls/gdiplus/image.c
+++ b/dlls/gdiplus/image.c
@@ -254,6 +254,7 @@ GpStatus WINGDIPAPI GdipCloneImage(GpImage *image, GpImage **cloneImage)
     HRESULT hr;
     INT size;
     LARGE_INTEGER move;
+    GpStatus stat = GenericError;
 
     TRACE("%p, %p\n", image, cloneImage);
 
@@ -264,15 +265,6 @@ GpStatus WINGDIPAPI GdipCloneImage(GpImage *image, GpImage **cloneImage)
     if (FAILED(hr))
         return GenericError;
 
-    *cloneImage = GdipAlloc(sizeof(GpImage));
-    if (!*cloneImage)
-    {
-        IStream_Release(stream);
-        return OutOfMemory;
-    }
-    (*cloneImage)->type = image->type;
-    (*cloneImage)->flags = image->flags;
-
     hr = IPicture_SaveAsFile(image->picture, stream, FALSE, &size);
     if(FAILED(hr))
     {
@@ -286,21 +278,12 @@ GpStatus WINGDIPAPI GdipCloneImage(GpImage *image, GpImage **cloneImage)
     if (FAILED(hr))
         goto out;
 
-    hr = OleLoadPicture(stream, size, FALSE, &IID_IPicture,
-            (LPVOID*) &(*cloneImage)->picture);
-    if (FAILED(hr))
-    {
-        WARN("Failed to load image from stream\n");
-        goto out;
-    }
+    stat = GdipLoadImageFromStream(stream, cloneImage);
+    if (stat != Ok) WARN("Failed to load image from stream\n");
 
-    IStream_Release(stream);
-    return Ok;
 out:
     IStream_Release(stream);
-    GdipFree(*cloneImage);
-    *cloneImage = NULL;
-    return GenericError;
+    return stat;
 }
 
 GpStatus WINGDIPAPI GdipCreateBitmapFromFile(GDIPCONST WCHAR* filename,
diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c
index 5d8c535..4d93da4 100644
--- a/dlls/gdiplus/tests/image.c
+++ b/dlls/gdiplus/tests/image.c
@@ -514,6 +514,10 @@ static void test_GdipCloneImage(void)
     stat = GdipGetImageBounds(image_dest, &rectF, &unit);
     expect(Ok, stat);
 
+    /* Treat FP values carefully */
+    ok(fabsf(rectF.Width-WIDTH)<1e-5, "Expected: %d, got %.05f\n", WIDTH, rectF.Width);
+    ok(fabsf(rectF.Height-HEIGHT)<1e-5, "Expected: %d, got %.05f\n", HEIGHT, rectF.Height);
+
     stat = GdipDisposeImage(image_dest);
     expect(Ok, stat);
 }




More information about the wine-cvs mailing list