Commit 1aea88ca authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

gdiplus: Implement GdipGetImage*Resolution.

parent f71cb580
......@@ -219,6 +219,7 @@ struct GpImage{
UINT palette_count;
UINT palette_size;
ARGB *palette_entries;
REAL xres, yres;
};
struct GpMetafile{
......
......@@ -1262,6 +1262,8 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete,
(*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
......
......@@ -1172,6 +1172,20 @@ static void generate_halftone_palette(ARGB *entries, UINT count)
}
}
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 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
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 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
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 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
(*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 GdipGetImageHeight(GpImage *image, UINT *height)
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 GdipGetImageType(GpImage *image, ImageType *type)
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)
......
......@@ -843,11 +843,11 @@ static void test_loadwmf(void)
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 @@ static void test_createfromwmf(void)
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 @@ static void test_resolution(void)
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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment