}
/* converts a given unit to its value in pixels */
-REAL convert_unit(HDC hdc, GpUnit unit)
+REAL convert_unit(REAL logpixels, GpUnit unit)
{
switch(unit)
{
case UnitInch:
- return (REAL) GetDeviceCaps(hdc, LOGPIXELSX);
+ return logpixels;
case UnitPoint:
- return ((REAL)GetDeviceCaps(hdc, LOGPIXELSX)) / 72.0;
+ return logpixels / 72.0;
case UnitDocument:
- return ((REAL)GetDeviceCaps(hdc, LOGPIXELSX)) / 300.0;
+ return logpixels / 300.0;
case UnitMillimeter:
- return ((REAL)GetDeviceCaps(hdc, LOGPIXELSX)) / 25.4;
+ return logpixels / 25.4;
case UnitWorld:
ERR("cannot convert UnitWorld\n");
return 0.0;
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);
+extern REAL convert_unit(REAL logpixels, GpUnit unit);
extern void calc_curve_bezier(CONST GpPointF *pts, REAL tension, REAL *x1,
REAL *y1, REAL *x2, REAL *y2);
return ret;
}
+static REAL graphics_res(GpGraphics *graphics)
+{
+ if (graphics->image) return graphics->image->xres;
+ else return (REAL)GetDeviceCaps(graphics->hdc, LOGPIXELSX);
+}
+
static INT prepare_dc(GpGraphics *graphics, GpPen *pen)
{
HPEN gdipen;
width = sqrt((pt[1].X - pt[0].X) * (pt[1].X - pt[0].X) +
(pt[1].Y - pt[0].Y) * (pt[1].Y - pt[0].Y)) / sqrt(2.0);
- width *= pen->width * convert_unit(graphics->hdc,
+ width *= pen->width * convert_unit(graphics_res(graphics),
pen->unit == UnitWorld ? graphics->unit : pen->unit);
}
GpMatrix *matrix;
int i;
- unitscale = convert_unit(graphics->hdc, graphics->unit);
+ unitscale = convert_unit(graphics_res(graphics), graphics->unit);
/* apply page scale */
if(graphics->unit != UnitDisplay)
stat = GdipCreateMatrix(&matrix);
if (stat == Ok)
{
- unitscale = convert_unit(graphics->hdc, graphics->unit);
+ unitscale = convert_unit(graphics_res(graphics), graphics->unit);
if(graphics->unit != UnitDisplay)
unitscale *= graphics->scale;
if(image->type == ImageTypeMetafile){
HDC hdc = GetDC(0);
+ REAL res = (REAL)GetDeviceCaps(hdc, LOGPIXELSX);
- *height = convert_unit(hdc, ((GpMetafile*)image)->unit) *
+ ReleaseDC(0, hdc);
+
+ *height = convert_unit(res, ((GpMetafile*)image)->unit) *
((GpMetafile*)image)->bounds.Height;
- *width = convert_unit(hdc, ((GpMetafile*)image)->unit) *
+ *width = convert_unit(res, ((GpMetafile*)image)->unit) *
((GpMetafile*)image)->bounds.Width;
-
- ReleaseDC(0, hdc);
}
else if(image->type == ImageTypeBitmap){
if(image->type == ImageTypeMetafile){
HDC hdc = GetDC(0);
-
- *height = roundr(convert_unit(hdc, ((GpMetafile*)image)->unit) *
- ((GpMetafile*)image)->bounds.Height);
+ REAL res = (REAL)GetDeviceCaps(hdc, LOGPIXELSX);
ReleaseDC(0, hdc);
+
+ *height = roundr(convert_unit(res, ((GpMetafile*)image)->unit) *
+ ((GpMetafile*)image)->bounds.Height);
}
else if(image->type == ImageTypeBitmap)
*height = ((GpBitmap*)image)->height;
if(image->type == ImageTypeMetafile){
HDC hdc = GetDC(0);
-
- *width = roundr(convert_unit(hdc, ((GpMetafile*)image)->unit) *
- ((GpMetafile*)image)->bounds.Width);
+ REAL res = (REAL)GetDeviceCaps(hdc, LOGPIXELSX);
ReleaseDC(0, hdc);
+
+ *width = roundr(convert_unit(res, ((GpMetafile*)image)->unit) *
+ ((GpMetafile*)image)->bounds.Width);
}
else if(image->type == ImageTypeBitmap)
*width = ((GpBitmap*)image)->width;