using System; using CPF.ReoGrid.Rendering; namespace CPF.ReoGrid.Utility { internal static class MeasureToolkit { public static float InchToPixel(float inch, float dpi) { return inch * dpi; } public static float PixelToInch(float px, float dpi) { return px / dpi; } public static float InchToPixel(float inch) { return MeasureToolkit.InchToPixel(inch, 96f); } public static float PixelToInch(float px) { return MeasureToolkit.PixelToInch(px, 96f); } public static float InchToCM(float inch) { return inch * 2.54f; } public static float CMToInch(float cm) { return cm / 2.54f; } public static float CMToPixel(float cm, float dpi) { return cm * dpi / 2.54f; } public static float PixelToCM(float px, float dpi) { return px * 2.54f / dpi; } public static float CMTOPixel(float cm) { return MeasureToolkit.CMToPixel(cm, 96f); } public static float PixelToCM(float px) { return MeasureToolkit.PixelToCM(px, 96f); } public static float EMUToPixel(int emu, float dpi) { return (float)emu / 914400f * dpi; } public static int PixelToEMU(float pixel, float dpi) { return (int)(pixel * 914400f / dpi); } public static T ScaleByDPI(T val) { double num = (double)PlatformUtility.GetDPI(); double num2 = num / 96.0; double num3 = (double)Convert.ChangeType(val, typeof(double)); return (T)((object)Convert.ChangeType(num3 * num2, typeof(T))); } private const float _cm_pre_inch = 2.54f; private const float _windows_standard_dpi = 96f; public const int _emi_in_inch = 914400; } }