标签:c style class blog code java
public class DPIUtils { private static double _dpiX = 1.0; private static double _dpiY = 1.0; public static double DPIX { get { return DPIUtils._dpiX; } } public static double DPIY { get { return DPIUtils._dpiY; } } public static void Init(System.Windows.Media.Visual visual) { Matrix transformToDevice = System.Windows.PresentationSource.FromVisual(visual).CompositionTarget.TransformToDevice; DPIUtils._dpiX = transformToDevice.M11; DPIUtils._dpiY = transformToDevice.M22; } public static Point DivideByDPI(Point p) { return new Point(p.X / DPIUtils.DPIX, p.Y / DPIUtils.DPIY); } public static Rect DivideByDPI(Rect r) { return new Rect(r.Left / DPIUtils.DPIX, r.Top / DPIUtils.DPIY, r.Width, r.Height); } }
WPF中根据DPI获取准确坐标点啊,布布扣,bubuko.com
标签:c style class blog code java
原文地址:http://www.cnblogs.com/andy1987/p/3765611.html