gdiplus: Fix GdipCreateBitmapFromGraphics implementation.
This commit is contained in:
parent
3157534347
commit
636e60b6e0
|
@ -1595,12 +1595,9 @@ GpStatus WINGDIPAPI GdipConvertToEmfPlus(const GpGraphics* ref,
|
||||||
return NotImplemented;
|
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,
|
GpStatus WINGDIPAPI GdipCreateBitmapFromGraphics(INT width, INT height,
|
||||||
GpGraphics* target, GpBitmap** bitmap)
|
GpGraphics* target, GpBitmap** bitmap)
|
||||||
{
|
{
|
||||||
static int calls;
|
|
||||||
GpStatus ret;
|
GpStatus ret;
|
||||||
|
|
||||||
TRACE("(%d, %d, %p, %p)\n", width, height, target, bitmap);
|
TRACE("(%d, %d, %p, %p)\n", width, height, target, bitmap);
|
||||||
|
@ -1608,12 +1605,15 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromGraphics(INT width, INT height,
|
||||||
if(!target || !bitmap)
|
if(!target || !bitmap)
|
||||||
return InvalidParameter;
|
return InvalidParameter;
|
||||||
|
|
||||||
if(!(calls++))
|
ret = GdipCreateBitmapFromScan0(width, height, 0, PixelFormat32bppPARGB,
|
||||||
FIXME("hacked stub\n");
|
|
||||||
|
|
||||||
ret = GdipCreateBitmapFromScan0(width, height, 0, PixelFormat24bppRGB,
|
|
||||||
NULL, bitmap);
|
NULL, bitmap);
|
||||||
|
|
||||||
|
if (ret == Ok)
|
||||||
|
{
|
||||||
|
GdipGetDpiX(target, &(*bitmap)->image.xres);
|
||||||
|
GdipGetDpiY(target, &(*bitmap)->image.yres);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4282,6 +4282,58 @@ static void test_alpha_hdc(void)
|
||||||
DeleteDC(hdc);
|
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)
|
START_TEST(graphics)
|
||||||
{
|
{
|
||||||
struct GdiplusStartupInput gdiplusStartupInput;
|
struct GdiplusStartupInput gdiplusStartupInput;
|
||||||
|
@ -4349,6 +4401,7 @@ START_TEST(graphics)
|
||||||
test_get_set_textrenderinghint();
|
test_get_set_textrenderinghint();
|
||||||
test_getdc_scaled();
|
test_getdc_scaled();
|
||||||
test_alpha_hdc();
|
test_alpha_hdc();
|
||||||
|
test_bitmapfromgraphics();
|
||||||
|
|
||||||
GdiplusShutdown(gdiplusToken);
|
GdiplusShutdown(gdiplusToken);
|
||||||
DestroyWindow( hwnd );
|
DestroyWindow( hwnd );
|
||||||
|
|
Loading…
Reference in New Issue