我使用的是Windows7,正在尝试更改代码中的颜色平衡。具体地说,我正在尝试更改在颜色校准向导上显示的这些sliders。我假设正确的函数是SetMonitorRedGreenOrBlueGain和SetMonitorRedGreenOrBlueDrive。
下面是我的最小工作示例:
#pragma comment(lib, "dxva2.lib")
#include <windows.h>
#include <lowlevelmonitorconfigurationapi.h>
#include <physicalmonitorenumerationapi.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;
int main()
{
HWND hWnd = GetDesktopWindow();
HMONITOR hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY);
cout << "Monitor: " << hMonitor << endl;
DWORD cPhysicalMonitors;
BOOL bSuccess = GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, &cPhysicalMonitors);
cout << "GetNumber: " << bSuccess << ", number of physical monitors: " << cPhysicalMonitors << endl;
LPPHYSICAL_MONITOR pPhysicalMonitors = (LPPHYSICAL_MONITOR)malloc(cPhysicalMonitors * sizeof(PHYSICAL_MONITOR));
bSuccess = GetPhysicalMonitorsFromHMONITOR(hMonitor, cPhysicalMonitors, pPhysicalMonitors);
cout << "GetPhysicalMonitor: " << bSuccess << endl
<< "Handle: " << pPhysicalMonitors[0].hPhysicalMonitor << endl
<< "Description: ";
wcout << (WCHAR*)(pPhysicalMonitors[0].szPhysicalMonitorDescription);
DestroyPhysicalMonitors(cPhysicalMonitors, pPhysicalMonitors);
free(pPhysicalMonitors);
}输出为:
Monitor: 00010001
GetNumber: 1, number of physical monitors: 1
GetPhysicalMonitor: 1
Handle: 00000000
Description: Generic PnP Monitor所有用于亮度和色彩增益的功能都需要HANDLE hPhysicalMonitor,对于我的显示器(笔记本电脑屏幕),它始终是null。但是,我知道必须有可能改变颜色平衡,因为颜色校准窗口可以做到这一点。
我做错了什么?
编辑1:
正如评论中提到的,hPhysicalMonitor似乎是正确的。我的问题是,调用像GetMonitorBrightness这样的函数会返回FALSE,错误代码为ERROR_GRAPHICS_I2C_ERROR_TRANSMITTING_DATA (在I2C总线上向设备传输数据时发生错误)。
编辑2:
我的显示器支持亮度设置,有11个级别。Windows本身和一些程序能够调节亮度(直接调节显示器的背光)。所以这个问题一定是与软件相关的。
发布于 2020-06-29 16:36:24
我的问题是,调用像GetMonitorBrightness这样的函数会返回FALSE,错误代码为ERROR_GRAPHICS_I2C_ERROR_TRANSMITTING_DATA (在I2C总线上向设备传输数据时发生错误)。
GetMonitorBrightness为我工作。我在电脑上测试过了。一些类似的案例指出,GetMonitorBrightness在一些笔记本电脑上不起作用。
我认为您的笔记本电脑不支持DDC/CI。
GetMonitorCapabilities:如果显示器不支持DDC/CI,则该功能失败。
您可以先检查您的笔记本电脑是否支持DDC/Cl。
https://stackoverflow.com/questions/62598348
复制相似问题