gdiplus: Fix GdipCreateBitmapFromGraphics implementation.

This commit is contained in:
Vincent Povirk 2013-03-09 12:08:27 -06:00 committed by Alexandre Julliard
parent 3157534347
commit 636e60b6e0
2 changed files with 60 additions and 7 deletions

View File

@ -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;
}

View File

@ -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 );