gdiplus: Return width and height of metafiles.

This commit is contained in:
Evan Stade 2007-08-07 18:42:09 -07:00 committed by Alexandre Julliard
parent 8726f5ad2d
commit 0794e5daf3
4 changed files with 36 additions and 26 deletions

View File

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

View File

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

View File

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

View File

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