Vincent Povirk : gdiplus: Add test for GdipCreateHBITMAPFromBitmap.

Alexandre Julliard julliard at winehq.org
Fri Aug 28 10:18:36 CDT 2009


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

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Thu Aug 27 16:38:07 2009 -0500

gdiplus: Add test for GdipCreateHBITMAPFromBitmap.

---

 dlls/gdiplus/tests/image.c |   59 ++++++++++++++++++++++++++++++++++++++++++++
 include/gdiplusflat.h      |    1 +
 2 files changed, 60 insertions(+), 0 deletions(-)

diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c
index 4443f88..d566c36 100644
--- a/dlls/gdiplus/tests/image.c
+++ b/dlls/gdiplus/tests/image.c
@@ -741,6 +741,64 @@ static void test_getrawformat(void)
     test_bufferrawformat((void*)jpgimage, sizeof(jpgimage), &ImageFormatJPEG, __LINE__, TRUE);
 }
 
+static void test_createhbitmap(void)
+{
+    GpStatus stat;
+    GpBitmap *bitmap;
+    HBITMAP hbitmap, oldhbitmap;
+    BITMAP bm;
+    int ret;
+    HDC hdc;
+    COLORREF pixel;
+    BYTE bits[640];
+
+    memset(bits, 0x68, 640);
+
+    /* create Bitmap */
+    stat = GdipCreateBitmapFromScan0(10, 20, 32, PixelFormat24bppRGB, bits, &bitmap);
+    expect(Ok, stat);
+
+    /* test NULL values */
+    stat = GdipCreateHBITMAPFromBitmap(NULL, &hbitmap, 0);
+    todo_wine expect(InvalidParameter, stat);
+
+    stat = GdipCreateHBITMAPFromBitmap(bitmap, NULL, 0);
+    todo_wine expect(InvalidParameter, stat);
+
+    /* create HBITMAP */
+    stat = GdipCreateHBITMAPFromBitmap(bitmap, &hbitmap, 0);
+    todo_wine expect(Ok, stat);
+
+    if (stat == Ok)
+    {
+        ret = GetObjectA(hbitmap, sizeof(BITMAP), &bm);
+        expect(sizeof(BITMAP), ret);
+
+        expect(0, bm.bmType);
+        expect(10, bm.bmWidth);
+        expect(20, bm.bmHeight);
+        expect(40, bm.bmWidthBytes);
+        expect(1, bm.bmPlanes);
+        expect(32, bm.bmBitsPixel);
+        ok(bm.bmBits != NULL, "got DDB, expected DIB\n");
+
+        hdc = CreateCompatibleDC(NULL);
+
+        oldhbitmap = SelectObject(hdc, hbitmap);
+        pixel = GetPixel(hdc, 5, 5);
+        SelectObject(hdc, oldhbitmap);
+
+        DeleteDC(hdc);
+
+        expect(0x686868, pixel);
+
+        DeleteObject(hbitmap);
+    }
+
+    stat = GdipDisposeImage((GpImage*)bitmap);
+    expect(Ok, stat);
+}
+
 START_TEST(image)
 {
     struct GdiplusStartupInput gdiplusStartupInput;
@@ -766,6 +824,7 @@ START_TEST(image)
     test_testcontrol();
     test_fromhicon();
     test_getrawformat();
+    test_createhbitmap();
 
     GdiplusShutdown(gdiplusToken);
 }
diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h
index 6bad8bd..c06d951 100644
--- a/include/gdiplusflat.h
+++ b/include/gdiplusflat.h
@@ -59,6 +59,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT,INT,INT,PixelFormat,BYTE*,
     GpBitmap**);
 GpStatus WINGDIPAPI GdipCreateBitmapFromStream(IStream*,GpBitmap**);
 GpStatus WINGDIPAPI GdipCreateBitmapFromStreamICM(IStream*,GpBitmap**);
+GpStatus WINGDIPAPI GdipCreateHBITMAPFromBitmap(GpBitmap*,HBITMAP*,ARGB);
 GpStatus WINGDIPAPI GdipCreateHICONFromBitmap(GpBitmap*,HICON*);
 GpStatus WINGDIPAPI GdipDeleteEffect(CGpEffect*);
 




More information about the wine-cvs mailing list