示例#1
0
        public static float GetDPIScalingFactor()
        {
            Graphics g                    = Graphics.FromHwnd(IntPtr.Zero);
            IntPtr   desktop              = g.GetHdc();
            int      LogicalScreenHeight  = Gdi32Interop.GetDeviceCaps(desktop, (int)DeviceCap.VERTRES);
            int      PhysicalScreenHeight = Gdi32Interop.GetDeviceCaps(desktop, (int)DeviceCap.DESKTOPVERTRES);

            float ScreenScalingFactor = (float)PhysicalScreenHeight / (float)LogicalScreenHeight;

            return(ScreenScalingFactor);
        }
示例#2
0
        /// <summary>
        /// gamma range from 3 - 44
        /// </summary>
        /// <param name="gamma"></param>
        private void SetGamma(int gamma)
        {
            _ramp.Red   = new ushort[256];
            _ramp.Green = new ushort[256];
            _ramp.Blue  = new ushort[256];

            for (int i = 1; i < 256; i++)
            {
                _ramp.Red[i] = _ramp.Green[i] = _ramp.Blue[i]
                                                    = (ushort)Math.Min(
                                                          65535,
                                                          Math.Max(
                                                              0, (Math.Pow((i + 1) / 256.0, gamma * 0.1) * 65535 + 0.5)));
            }

            Gdi32Interop.SetDeviceGammaRamp(_hdc, ref _ramp);
        }