Vincent Povirk : gdiplus: Implement GdipGetImageRawFormat.

Alexandre Julliard julliard at winehq.org
Tue Sep 15 17:47:52 CDT 2009


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

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Mon Sep 14 11:23:45 2009 -0500

gdiplus: Implement GdipGetImageRawFormat.

---

 dlls/gdiplus/gdiplus_private.h |    1 +
 dlls/gdiplus/graphics.c        |    1 +
 dlls/gdiplus/image.c           |   28 ++++++++++++++--------------
 dlls/gdiplus/tests/image.c     |   16 ++++++++--------
 4 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h
index e87176e..c95f3ff 100644
--- a/dlls/gdiplus/gdiplus_private.h
+++ b/dlls/gdiplus/gdiplus_private.h
@@ -208,6 +208,7 @@ struct GpAdustableArrowCap{
 struct GpImage{
     IPicture* picture;
     ImageType type;
+    GUID format;
     UINT flags;
 };
 
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 8e58fda..6753262 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -1235,6 +1235,7 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete,
 
 
     (*metafile)->image.type = ImageTypeMetafile;
+    memcpy(&(*metafile)->image.format, &ImageFormatWMF, sizeof(GUID));
     (*metafile)->bounds.X = ((REAL) placeable->BoundingBox.Left) / ((REAL) placeable->Inch);
     (*metafile)->bounds.Y = ((REAL) placeable->BoundingBox.Right) / ((REAL) placeable->Inch);
     (*metafile)->bounds.Width = ((REAL) (placeable->BoundingBox.Right
diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c
index 28982a1..f71bf9a 100644
--- a/dlls/gdiplus/image.c
+++ b/dlls/gdiplus/image.c
@@ -413,6 +413,9 @@ GpStatus WINGDIPAPI GdipCloneImage(GpImage *image, GpImage **cloneImage)
             GdipDisposeImage(*cloneImage);
             *cloneImage = NULL;
         }
+
+        memcpy(&(*cloneImage)->format, &image->format, sizeof(GUID));
+
         return stat;
     }
     else
@@ -858,6 +861,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
     }
 
     (*bitmap)->image.type = ImageTypeBitmap;
+    memcpy(&(*bitmap)->image.format, &ImageFormatMemoryBMP, sizeof(GUID));
     (*bitmap)->image.flags = ImageFlagsNone;
     (*bitmap)->width = width;
     (*bitmap)->height = height;
@@ -1144,23 +1148,11 @@ GpStatus WINGDIPAPI GdipGetImagePixelFormat(GpImage *image, PixelFormat *format)
 
 GpStatus WINGDIPAPI GdipGetImageRawFormat(GpImage *image, GUID *format)
 {
-    static int calls;
-
     if(!image || !format)
         return InvalidParameter;
 
-    if(!(calls++))
-        FIXME("stub\n");
+    memcpy(format, &image->format, sizeof(GUID));
 
-    /* FIXME: should be detected from embedded picture or stored separately */
-    switch (image->type)
-    {
-    case ImageTypeBitmap:   *format = ImageFormatBMP; break;
-    case ImageTypeMetafile: *format = ImageFormatEMF; break;
-    default:
-        WARN("unknown type %u\n", image->type);
-        *format = ImageFormatUndefined;
-    }
     return Ok;
 }
 
@@ -1647,7 +1639,15 @@ GpStatus WINGDIPAPI GdipLoadImageFromStream(IStream* stream, GpImage **image)
     if (FAILED(hr)) return hresult_to_status(hr);
 
     /* call on the image decoder to do the real work */
-    return codec->decode_func(stream, &codec->info.Clsid, image);
+    stat = codec->decode_func(stream, &codec->info.Clsid, image);
+
+    /* take note of the original data format */
+    if (stat == Ok)
+    {
+        memcpy(&(*image)->format, &codec->info.FormatID, sizeof(GUID));
+    }
+
+    return stat;
 }
 
 /* FIXME: no ICM */
diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c
index e624e53..5378cb8 100644
--- a/dlls/gdiplus/tests/image.c
+++ b/dlls/gdiplus/tests/image.c
@@ -486,7 +486,7 @@ static void test_GdipCreateBitmapFromHBITMAP(void)
     stat = GdipCreateBitmapFromHBITMAP(hbm, NULL, &gpbm);
     expect(Ok, stat);
     /* raw format */
-    expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)gpbm, __LINE__, TRUE);
+    expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)gpbm, __LINE__, FALSE);
 
     expect(Ok, GdipGetImageDimension((GpImage*) gpbm, &width, &height));
     expectf(WIDTH2,  width);
@@ -564,12 +564,12 @@ static void test_GdipCloneImage(void)
     /* Create an image, clone it, delete the original, make sure the copy works */
     stat = GdipCreateBitmapFromScan0(WIDTH, HEIGHT, 0, PixelFormat24bppRGB, NULL, &bm);
     expect(Ok, stat);
-    expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)bm, __LINE__, TRUE);
+    expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)bm, __LINE__, FALSE);
 
     image_src = ((GpImage*)bm);
     stat = GdipCloneImage(image_src, &image_dest);
     expect(Ok, stat);
-    expect_rawformat(&ImageFormatMemoryBMP, image_dest, __LINE__, TRUE);
+    expect_rawformat(&ImageFormatMemoryBMP, image_dest, __LINE__, FALSE);
 
     stat = GdipDisposeImage((GpImage*)bm);
     expect(Ok, stat);
@@ -646,7 +646,7 @@ static void test_fromhicon(void)
        stat = GdipGetImagePixelFormat((GpImage*)bitmap, &format);
        expect(PixelFormat32bppARGB, format);
        /* raw format */
-       expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)bitmap, __LINE__, TRUE);
+       expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)bitmap, __LINE__, FALSE);
        GdipDisposeImage((GpImage*)bitmap);
     }
     DestroyIcon(hIcon);
@@ -682,7 +682,7 @@ static void test_fromhicon(void)
         stat = GdipGetImagePixelFormat((GpImage*)bitmap, &format);
         expect(PixelFormat32bppARGB, format);
         /* raw format */
-        expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)bitmap, __LINE__, TRUE);
+        expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)bitmap, __LINE__, FALSE);
         GdipDisposeImage((GpImage*)bitmap);
     }
     DestroyIcon(hIcon);
@@ -735,10 +735,10 @@ static const unsigned char jpgimage[285] = {
 };
 static void test_getrawformat(void)
 {
-    test_bufferrawformat((void*)pngimage, sizeof(pngimage), &ImageFormatPNG,  __LINE__, TRUE);
-    test_bufferrawformat((void*)gifimage, sizeof(gifimage), &ImageFormatGIF,  __LINE__, TRUE);
+    test_bufferrawformat((void*)pngimage, sizeof(pngimage), &ImageFormatPNG,  __LINE__, FALSE);
+    test_bufferrawformat((void*)gifimage, sizeof(gifimage), &ImageFormatGIF,  __LINE__, FALSE);
     test_bufferrawformat((void*)bmpimage, sizeof(bmpimage), &ImageFormatBMP,  __LINE__, FALSE);
-    test_bufferrawformat((void*)jpgimage, sizeof(jpgimage), &ImageFormatJPEG, __LINE__, TRUE);
+    test_bufferrawformat((void*)jpgimage, sizeof(jpgimage), &ImageFormatJPEG, __LINE__, FALSE);
 }
 
 static void test_createhbitmap(void)




More information about the wine-cvs mailing list