Module: wine Branch: master Commit: 636e60b6e020a8e37e6dac03481bedcb20f3edca URL: http://source.winehq.org/git/wine.git/?a=commit;h=636e60b6e020a8e37e6dac0348...
Author: Vincent Povirk vincent@codeweavers.com Date: Sat Mar 9 12:08:27 2013 -0600
gdiplus: Fix GdipCreateBitmapFromGraphics implementation.
---
dlls/gdiplus/image.c | 14 +++++----- dlls/gdiplus/tests/graphics.c | 53 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 7 deletions(-)
diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index ff27334..98c0bd0 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -1595,12 +1595,9 @@ GpStatus WINGDIPAPI GdipConvertToEmfPlus(const GpGraphics* ref, return NotImplemented; }
-/* FIXME: this should create a bitmap in the given size with the attributes - * (resolution etc.) of the graphics object */ GpStatus WINGDIPAPI GdipCreateBitmapFromGraphics(INT width, INT height, GpGraphics* target, GpBitmap** bitmap) { - static int calls; GpStatus ret;
TRACE("(%d, %d, %p, %p)\n", width, height, target, bitmap); @@ -1608,12 +1605,15 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromGraphics(INT width, INT height, if(!target || !bitmap) return InvalidParameter;
- if(!(calls++)) - FIXME("hacked stub\n"); - - ret = GdipCreateBitmapFromScan0(width, height, 0, PixelFormat24bppRGB, + ret = GdipCreateBitmapFromScan0(width, height, 0, PixelFormat32bppPARGB, NULL, bitmap);
+ if (ret == Ok) + { + GdipGetDpiX(target, &(*bitmap)->image.xres); + GdipGetDpiY(target, &(*bitmap)->image.yres); + } + return ret; }
diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c index 08b2465..e41751a 100644 --- a/dlls/gdiplus/tests/graphics.c +++ b/dlls/gdiplus/tests/graphics.c @@ -4282,6 +4282,58 @@ static void test_alpha_hdc(void) DeleteDC(hdc); }
+static void test_bitmapfromgraphics(void) +{ + GpStatus stat; + GpGraphics *graphics = NULL; + HDC hdc = GetDC( hwnd ); + GpBitmap *bitmap = NULL; + PixelFormat format; + REAL imageres, graphicsres; + UINT width, height; + + stat = GdipCreateFromHDC(hdc, &graphics); + expect(Ok, stat); + + stat = GdipCreateBitmapFromGraphics(12, 13, NULL, &bitmap); + expect(InvalidParameter, stat); + + stat = GdipCreateBitmapFromGraphics(12, 13, graphics, NULL); + expect(InvalidParameter, stat); + + stat = GdipCreateBitmapFromGraphics(12, 13, graphics, &bitmap); + expect(Ok, stat); + + stat = GdipGetImagePixelFormat((GpImage*)bitmap, &format); + expect(Ok, stat); + expect(PixelFormat32bppPARGB, format); + + stat = GdipGetDpiX(graphics, &graphicsres); + expect(Ok, stat); + + stat = GdipGetImageHorizontalResolution((GpImage*)bitmap, &imageres); + expect(Ok, stat); + expectf(graphicsres, imageres); + + stat = GdipGetDpiY(graphics, &graphicsres); + expect(Ok, stat); + + stat = GdipGetImageVerticalResolution((GpImage*)bitmap, &imageres); + expect(Ok, stat); + expectf(graphicsres, imageres); + + stat = GdipGetImageWidth((GpImage*)bitmap, &width); + expect(Ok, stat); + expect(12, width); + + stat = GdipGetImageHeight((GpImage*)bitmap, &height); + expect(Ok, stat); + expect(13, height); + + GdipDeleteGraphics(graphics); + GdipDisposeImage((GpImage*)bitmap); +} + START_TEST(graphics) { struct GdiplusStartupInput gdiplusStartupInput; @@ -4349,6 +4401,7 @@ START_TEST(graphics) test_get_set_textrenderinghint(); test_getdc_scaled(); test_alpha_hdc(); + test_bitmapfromgraphics();
GdiplusShutdown(gdiplusToken); DestroyWindow( hwnd );