static int Unscale(int v, ScaleDirection direction) { IntPtr dc = Functions.GetDC(IntPtr.Zero); if (dc != IntPtr.Zero) { int dpi = Functions.GetDeviceCaps(dc, direction == ScaleDirection.X ? DeviceCaps.LogPixelsX : DeviceCaps.LogPixelsY); if (dpi > 0) { float scale = dpi / 96.0f; v = (int)Math.Round(v / scale); } Functions.ReleaseDC(IntPtr.Zero, dc); } return(v); }