Commit 0794e5da authored by Evan Stade's avatar Evan Stade Committed by Alexandre Julliard

gdiplus: Return width and height of metafiles.

parent 8726f5ad
......@@ -263,3 +263,26 @@ GpStatus hresult_to_status(HRESULT res)
return GenericError;
}
}
/* converts a given unit to its value in pixels */
REAL convert_unit(HDC hdc, GpUnit unit)
{
switch(unit)
{
case UnitInch:
return (REAL) GetDeviceCaps(hdc, LOGPIXELSX);
case UnitPoint:
return ((REAL)GetDeviceCaps(hdc, LOGPIXELSX)) / 72.0;
case UnitDocument:
return ((REAL)GetDeviceCaps(hdc, LOGPIXELSX)) / 300.0;
case UnitMillimeter:
return ((REAL)GetDeviceCaps(hdc, LOGPIXELSX)) / 25.4;
case UnitWorld:
ERR("cannot convert UnitWorld\n");
return 0.0;
case UnitPixel:
case UnitDisplay:
default:
return 1.0;
}
}
......@@ -42,6 +42,7 @@ extern INT arc2polybezier(GpPointF * points, REAL x1, REAL y1, REAL x2, REAL y2,
REAL startAngle, REAL sweepAngle);
extern REAL gdiplus_atan2(REAL dy, REAL dx);
extern GpStatus hresult_to_status(HRESULT res);
extern REAL convert_unit(HDC hdc, GpUnit unit);
static inline INT roundr(REAL x)
{
......
......@@ -82,28 +82,6 @@ static BYTE convert_path_point_type(BYTE type)
return ret;
}
static REAL convert_unit(HDC hdc, GpUnit unit)
{
switch(unit)
{
case UnitInch:
return (REAL) GetDeviceCaps(hdc, LOGPIXELSX);
case UnitPoint:
return ((REAL)GetDeviceCaps(hdc, LOGPIXELSX)) / 72.0;
case UnitDocument:
return ((REAL)GetDeviceCaps(hdc, LOGPIXELSX)) / 300.0;
case UnitMillimeter:
return ((REAL)GetDeviceCaps(hdc, LOGPIXELSX)) / 25.4;
case UnitWorld:
ERR("cannot convert UnitWorld\n");
return 0.0;
case UnitPixel:
case UnitDisplay:
default:
return 1.0;
}
}
static INT prepare_dc(GpGraphics *graphics, GpPen *pen)
{
HPEN gdipen;
......
......@@ -417,8 +417,12 @@ GpStatus WINGDIPAPI GdipGetImageHeight(GpImage *image, UINT *height)
return InvalidParameter;
if(image->type == ImageTypeMetafile){
FIXME("not implemented for metafiles\n");
return NotImplemented;
HDC hdc = GetDC(0);
*height = roundr(convert_unit(hdc, ((GpMetafile*)image)->unit) *
((GpMetafile*)image)->bounds.Height);
ReleaseDC(0, hdc);
}
else if(image->type == ImageTypeBitmap)
*height = ((GpBitmap*)image)->height;
......@@ -499,8 +503,12 @@ GpStatus WINGDIPAPI GdipGetImageWidth(GpImage *image, UINT *width)
return InvalidParameter;
if(image->type == ImageTypeMetafile){
FIXME("not implemented for metafiles\n");
return NotImplemented;
HDC hdc = GetDC(0);
*width = roundr(convert_unit(hdc, ((GpMetafile*)image)->unit) *
((GpMetafile*)image)->bounds.Width);
ReleaseDC(0, hdc);
}
else if(image->type == ImageTypeBitmap)
*width = ((GpBitmap*)image)->width;
......
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