gdiplus: Implement GdipGetImage*Resolution.
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index 7ce4bd5..9d05e0d 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h
@@ -219,6 +219,7 @@ UINT palette_count; UINT palette_size; ARGB *palette_entries; + REAL xres, yres; }; struct GpMetafile{
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index f7a8eaf..563e43a 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c
@@ -1262,6 +1262,8 @@ (*metafile)->image.palette_count = 0; (*metafile)->image.palette_size = 0; (*metafile)->image.palette_entries = NULL; + (*metafile)->image.xres = (REAL)placeable->Inch; + (*metafile)->image.yres = (REAL)placeable->Inch; (*metafile)->bounds.X = ((REAL) placeable->BoundingBox.Left) / ((REAL) placeable->Inch); (*metafile)->bounds.Y = ((REAL) placeable->BoundingBox.Top) / ((REAL) placeable->Inch); (*metafile)->bounds.Width = ((REAL) (placeable->BoundingBox.Right
diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index e37d028..763c17c 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c
@@ -1172,6 +1172,20 @@ } } +static GpStatus get_screen_resolution(REAL *xres, REAL *yres) +{ + HDC screendc = GetDC(0); + + if (!screendc) return GenericError; + + *xres = (REAL)GetDeviceCaps(screendc, LOGPIXELSX); + *yres = (REAL)GetDeviceCaps(screendc, LOGPIXELSY); + + ReleaseDC(0, screendc); + + return Ok; +} + GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, PixelFormat format, BYTE* scan0, GpBitmap** bitmap) { @@ -1181,6 +1195,8 @@ HDC hdc; BYTE *bits; int i; + REAL xres, yres; + GpStatus stat; TRACE("%d %d %d %d %p %p\n", width, height, stride, format, scan0, bitmap); @@ -1194,6 +1210,9 @@ if(scan0 && !stride) return InvalidParameter; + stat = get_screen_resolution(&xres, &yres); + if (stat != Ok) return stat; + row_size = (width * PIXELFORMATBPP(format)+7) / 8; dib_stride = (row_size + 3) & ~3; @@ -1243,6 +1262,8 @@ (*bitmap)->image.palette_count = 0; (*bitmap)->image.palette_size = 0; (*bitmap)->image.palette_entries = NULL; + (*bitmap)->image.xres = xres; + (*bitmap)->image.yres = yres; (*bitmap)->width = width; (*bitmap)->height = height; (*bitmap)->format = format; @@ -1522,15 +1543,14 @@ GpStatus WINGDIPAPI GdipGetImageHorizontalResolution(GpImage *image, REAL *res) { - static int calls; - if(!image || !res) return InvalidParameter; - if(!(calls++)) - FIXME("not implemented\n"); + *res = image->xres; - return NotImplemented; + TRACE("(%p) <-- %0.2f\n", image, *res); + + return Ok; } GpStatus WINGDIPAPI GdipGetImagePaletteSize(GpImage *image, INT *size) @@ -1590,15 +1610,14 @@ GpStatus WINGDIPAPI GdipGetImageVerticalResolution(GpImage *image, REAL *res) { - static int calls; - if(!image || !res) return InvalidParameter; - if(!(calls++)) - FIXME("not implemented\n"); + *res = image->yres; - return NotImplemented; + TRACE("(%p) <-- %0.2f\n", image, *res); + + return Ok; } GpStatus WINGDIPAPI GdipGetImageWidth(GpImage *image, UINT *width)
diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c index 4721a58..913ba1f 100644 --- a/dlls/gdiplus/tests/image.c +++ b/dlls/gdiplus/tests/image.c
@@ -843,11 +843,11 @@ todo_wine expectf(320.0, bounds.Height); stat = GdipGetImageHorizontalResolution(img, &res); - todo_wine expect(Ok, stat); + expect(Ok, stat); todo_wine expectf(1440.0, res); stat = GdipGetImageVerticalResolution(img, &res); - todo_wine expect(Ok, stat); + expect(Ok, stat); todo_wine expectf(1440.0, res); GdipDisposeImage(img); @@ -879,12 +879,12 @@ todo_wine expectf(320.0, bounds.Height); stat = GdipGetImageHorizontalResolution(img, &res); - todo_wine expect(Ok, stat); - todo_wine expectf(1440.0, res); + expect(Ok, stat); + expectf(1440.0, res); stat = GdipGetImageVerticalResolution(img, &res); - todo_wine expect(Ok, stat); - todo_wine expectf(1440.0, res); + expect(Ok, stat); + expectf(1440.0, res); GdipDisposeImage(img); } @@ -929,23 +929,23 @@ ReleaseDC(0, screendc); stat = GdipGetImageHorizontalResolution((GpImage*)bitmap, &res); - todo_wine expect(Ok, stat); - todo_wine expectf((REAL)screenxres, res); + expect(Ok, stat); + expectf((REAL)screenxres, res); stat = GdipGetImageVerticalResolution((GpImage*)bitmap, &res); - todo_wine expect(Ok, stat); - todo_wine expectf((REAL)screenyres, res); + expect(Ok, stat); + expectf((REAL)screenyres, res); /* test changing the resolution */ stat = GdipBitmapSetResolution(bitmap, screenxres*2.0, screenyres*3.0); todo_wine expect(Ok, stat); stat = GdipGetImageHorizontalResolution((GpImage*)bitmap, &res); - todo_wine expect(Ok, stat); + expect(Ok, stat); todo_wine expectf(screenxres*2.0, res); stat = GdipGetImageVerticalResolution((GpImage*)bitmap, &res); - todo_wine expect(Ok, stat); + expect(Ok, stat); todo_wine expectf(screenyres*3.0, res); stat = GdipDisposeImage((GpImage*)bitmap);