gdiplus: Fix GdipCreateBitmapFromGraphics implementation.
Vincent Povirk
madewokherd at gmail.com
Sat Mar 9 12:12:32 CST 2013
For bug 33128.
-------------- next part --------------
From 3f6ca2a1acb3ca1af73dccb30f3f56c7c8ff8ba5 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Sat, 9 Mar 2013 12:08:27 -0600
Subject: [PATCH] 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 );
--
1.7.10.4
More information about the wine-patches
mailing list