|
@@ -377,7 +377,7 @@ namespace Avalonia
|
|
/// <returns>The device-independent rect.</returns>
|
|
/// <returns>The device-independent rect.</returns>
|
|
public static PixelRect FromRect(Rect rect, double scale) => new PixelRect(
|
|
public static PixelRect FromRect(Rect rect, double scale) => new PixelRect(
|
|
PixelPoint.FromPoint(rect.Position, scale),
|
|
PixelPoint.FromPoint(rect.Position, scale),
|
|
- PixelSize.FromSize(rect.Size, scale));
|
|
|
|
|
|
+ FromPointCeiling(rect.BottomRight, new Vector(scale, scale)));
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Converts a <see cref="Rect"/> to device pixels using the specified scaling factor.
|
|
/// Converts a <see cref="Rect"/> to device pixels using the specified scaling factor.
|
|
@@ -387,7 +387,7 @@ namespace Avalonia
|
|
/// <returns>The device-independent point.</returns>
|
|
/// <returns>The device-independent point.</returns>
|
|
public static PixelRect FromRect(Rect rect, Vector scale) => new PixelRect(
|
|
public static PixelRect FromRect(Rect rect, Vector scale) => new PixelRect(
|
|
PixelPoint.FromPoint(rect.Position, scale),
|
|
PixelPoint.FromPoint(rect.Position, scale),
|
|
- PixelSize.FromSize(rect.Size, scale));
|
|
|
|
|
|
+ FromPointCeiling(rect.BottomRight, scale));
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Converts a <see cref="Rect"/> to device pixels using the specified dots per inch (DPI).
|
|
/// Converts a <see cref="Rect"/> to device pixels using the specified dots per inch (DPI).
|
|
@@ -397,7 +397,7 @@ namespace Avalonia
|
|
/// <returns>The device-independent point.</returns>
|
|
/// <returns>The device-independent point.</returns>
|
|
public static PixelRect FromRectWithDpi(Rect rect, double dpi) => new PixelRect(
|
|
public static PixelRect FromRectWithDpi(Rect rect, double dpi) => new PixelRect(
|
|
PixelPoint.FromPointWithDpi(rect.Position, dpi),
|
|
PixelPoint.FromPointWithDpi(rect.Position, dpi),
|
|
- PixelSize.FromSizeWithDpi(rect.Size, dpi));
|
|
|
|
|
|
+ FromPointCeiling(rect.BottomRight, new Vector(dpi / 96, dpi / 96)));
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Converts a <see cref="Rect"/> to device pixels using the specified dots per inch (DPI).
|
|
/// Converts a <see cref="Rect"/> to device pixels using the specified dots per inch (DPI).
|
|
@@ -407,7 +407,7 @@ namespace Avalonia
|
|
/// <returns>The device-independent point.</returns>
|
|
/// <returns>The device-independent point.</returns>
|
|
public static PixelRect FromRectWithDpi(Rect rect, Vector dpi) => new PixelRect(
|
|
public static PixelRect FromRectWithDpi(Rect rect, Vector dpi) => new PixelRect(
|
|
PixelPoint.FromPointWithDpi(rect.Position, dpi),
|
|
PixelPoint.FromPointWithDpi(rect.Position, dpi),
|
|
- PixelSize.FromSizeWithDpi(rect.Size, dpi));
|
|
|
|
|
|
+ FromPointCeiling(rect.BottomRight, dpi / 96));
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Returns the string representation of the rectangle.
|
|
/// Returns the string representation of the rectangle.
|
|
@@ -441,5 +441,12 @@ namespace Avalonia
|
|
);
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private static PixelPoint FromPointCeiling(Point point, Vector scale)
|
|
|
|
+ {
|
|
|
|
+ return new PixelPoint(
|
|
|
|
+ (int)Math.Ceiling(point.X * scale.X),
|
|
|
|
+ (int)Math.Ceiling(point.Y * scale.Y));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|