c# 多种方法调整屏幕亮度
Github: https://github.com/CHNMaxGor/AjustScreenBrightness
方法一: 使用网上常说的 Gdi32.dll 下的 SetDeviceGammaRamp (修改系统Gamma)
DllImport("gdi32.dll")]
public static extern bool GetDeviceGammaRamp(IntPtr hDC, ref RAMP lpRamp);
[DllImport("gdi32.dll")]
public static extern bool SetDeviceGammaRamp(IntPtr hDC, ref RAMP lpRamp);
方法二: 使用MSDN上的 dxva2.dll SetMonitorBrightness
[DllImport("dxva2.dll")]
public static extern bool GetNumberOfPhysicalMonitorsFromHMONITOR(IntPtr hMonitor, ref uint pdwNumberOfPhysicalMonitors);
[DllImport("dxva2.dll")]
public static extern bool GetPhysicalMonitorsFromHMONITOR(IntPtr hMonitor,
uint dwPhysicalMonitorArraySize, [Out] PhysicalMonitor[] pPhysicalMonitorArray);
[DllImport("dxva2.dll")]
public static extern bool DestroyPhysicalMonitors(uint dwPhysicalMonitorArraySize,
[Out] PhysicalMonitor[] pPhysicalMonitorArray);
[DllImport("dxva2.dll")]
public static extern bool GetMonitorTechnologyType(IntPtr hMonitor,
ref McDisplayTechnologyType pdtyDisplayTechnologyType);
[DllImport("dxva2.dll")]
public static extern bool GetMonitorCapabilities(IntPtr hMonitor, ref uint pdwMonitorCapabilities,
ref uint pdwSupportedColorTemperatures);
[DllImport("dxva2.dll")]
public static extern bool SetMonitorBrightness(IntPtr hMonitor, short brightness);
[DllImport("dxva2.dll")]
public static extern bool SetMonitorContrast(IntPtr hMonitor, short contrast);
[DllImport("dxva2.dll")]
public static extern bool GetMonitorBrightness(IntPtr hMonitor, ref short pdwMinimumBrightness,
ref short pdwCurrentBrightness, ref short pdwMaximumBrightness);
[DllImport("dxva2.dll")]
public static extern bool GetMonitorContrast(IntPtr hMonitor, ref short pwdMinimumContrast,
ref short pwdCurrentContrast, ref short pwdMaximumContrast);
方法三: 使用 C:\Windows\System32\DriverStore\FileRepository\igdlh64.inf_amd64_neutral_3daeca3838e011e0\igfxDHLib.dll (这是驱动的文件,不同机器有自己对应的驱动文件)
DataHandlerClass _cls = new DataHandlerClass();
_CUI_COLOR_DEVICES _screenModel = default(_CUI_COLOR_DEVICES); public AjustScreenByIgfxDHLib()
{
CUI_SUPPORTED_CONFIG cui_SUPPORTED_CONFIG = default(CUI_SUPPORTED_CONFIG);
uint num = _cls.get_SupportedConfig(ref cui_SUPPORTED_CONFIG);
var id = cui_SUPPORTED_CONFIG.DeviceConfig[0].DispDev[0];
uint[] array = new uint[3];
var a = _cls.get_GetDeviceList(id, array);
_screenModel.ulDevices = array[0];
_screenModel.Device = new _CUI_COLOR_INFO[3];
_screenModel.Device[0].Brightness.color = _COLOR_TYPE.NumColors;
_screenModel.Device[0].Contrast.color = _COLOR_TYPE.NumColors;
_screenModel.Device[0].Gamma.color = _COLOR_TYPE.NumColors;
_screenModel.Command = _CUI_COLOR_COMMAND.GET_COLOR;
_cls.get_color(_screenModel.ulDevices, ref _screenModel);
}
注意事项 该方法使用时请注意好参数的范围,比如说把对比度设置太低时屏幕会完全黑掉 什么都看不到,然后你就不能直接把对比度调回来了.
c# 多种方法调整屏幕亮度的更多相关文章
- Android 播放电影时滑动屏幕调整屏幕亮度(转)
(转自:http://blog.csdn.net/piaozhiye/article/details/6544450) 发现有一些主流的播放器播放电影时可以通过滑动屏幕调整屏幕亮度,其实实现起来也很容 ...
- 【转】Windows Phone 调整屏幕亮度的简单实现
之前看到以及其它应用都有调节屏幕亮度的功能,还以为MS有相关的API,就去MSDN找了下,但是怎么都找不到.今天突然想到做自定义MessageBox时,由于要突出弹出框部分,所以会改变LayoutRo ...
- Mint linux中调整屏幕亮度的方法
/********************************************************************* * Author : Samson * Date ...
- Unity shader学习之屏幕后期效果之调整屏幕亮度,饱和度,对比度
Unity的屏幕后期处理效果,使用MonoBehaviour.OnRenderImage来实现. 转载请注明出处:http://www.cnblogs.com/jietian331/p/7228063 ...
- centos调整屏幕亮度
笔记本安装centos6.5后亮度无法通过键盘快捷键调节,可以通过安装软件来调节. 安装:yum install xgamma 设置亮度:xgamma -gamma n( 0.1 < n < ...
- 解决ubuntu无法调整和保存屏幕亮度的问题
整理自解决ubuntu无法调整和保存屏幕亮度的问题 ubuntu无法调整屏幕亮度,对笔记本来说很耗电,同时也很刺眼,因为它是默认以最大亮度来工作的. 所谓的调整,方法为下面的其中一种: 1.Fn+左右 ...
- Android开发调节屏幕亮度
在播放器,我们经常看到这样的设计,即,在用户的特定部分将能够滑动屏幕向上或向下调整屏幕的亮度,上下滑动的某一部分将能够调整播放音量.并以滑动的进程可以进行调整,以玩. 如今,我不得不说一下亮度调节. ...
- iOS获取屏幕亮度及设置
平常很少有功能点需要调整屏幕亮度,但是也会有一些特殊场景,类似支付宝微信的二维码提供扫描时会使屏幕程序高亮状态,查了下资料做了一下简单记录: 获取当前屏幕的亮度 CGFloat value = [UI ...
- Win8.1屏幕亮度自动调节关闭方法
细心的朋友会发现,Win8.1系统的笔记本屏幕亮度有时候,会根据外界光线亮度以及温度自动调节屏幕亮度,尽管看似比较智能,但有时候我们并不希望笔记本屏幕亮度受光线影响,忽暗忽亮.如果我们希望Win8笔记 ...
随机推荐
- CSS 外边距合并。
<div id = "parent"> <div id = "child"> demo </div> </div> ...
- django-团队简介的网页
团队简介的网页,是使用Django完成的 关于Django的教程网址:http://www.runoob.com/django/django-tutorial.html 小组作业成果如下:
- 易用性测试、本地化测试、部署测试、无障碍测试、回归测试、冒烟测试、A/B测试
1.易用性定义: 易用性测试是指测试用户使用软件时是否感觉方便,是否能保证用户使用的测试类型2.本地化测试: ·定义:针对软件的本地化版本实施的针对性测试 ·测试内容: (1)语言,书写习惯 (2)时 ...
- JS方法:数字转换为千分位字符
/** * 数字转为千分位字符 * @param {Number} num * @param {Number} point 保留几位小数,默认2位 */ function parseToThousan ...
- PAT1105:Spiral Matrix
1105. Spiral Matrix (25) 时间限制 150 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue This ti ...
- C3垂直居中均分
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
- UsernamePasswordAuthenticationToken
UsernamePasswordAuthenticationToken继承AbstractAuthenticationToken实现Authentication所以当在页面中输入用户名和密码之后首先会 ...
- javascript 事件编程之事件(流,处理,对象,类型)
1. 事件处理 1.1. 绑定事件方式 1)行内绑定 语法: //最常用的使用方式 <元素 事件="事件处理程序"> 2)动态绑定 //结构+样式+行为分离的页面(ht ...
- app后端设计(10)--数据增量更新
在新浪微博的app中,从别的页面进入主页,在没有网络的情况下,首页中的已经收到的微博还是能显示的,这显然是把相关的数据存储在app本地. 使用数据的app本地存储,能减少网络的流量,同时极大提高了用户 ...
- 【转载】JavaScript基础知识体系
前言 最近总是有一种感觉,对于知识没有积淀,很多时候都是忘记了哪里就去查一下,比如JS这种语言,很是浪费时间,如果能够把这些知识形成知识体系塞进大脑,做到即用即取就好了,那么就可以借助思维导图来帮助我 ...