首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法在Windows 7上获取物理显示器句柄进行颜色校准

无法在Windows 7上获取物理显示器句柄进行颜色校准
EN

Stack Overflow用户
提问于 2020-06-26 23:49:42
回答 1查看 218关注 0票数 1

我使用的是Windows7,正在尝试更改代码中的颜色平衡。具体地说,我正在尝试更改在颜色校准向导上显示的这些sliders。我假设正确的函数是SetMonitorRedGreenOrBlueGainSetMonitorRedGreenOrBlueDrive

下面是我的最小工作示例:

代码语言:javascript
复制
#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);    
    
}

输出为:

代码语言:javascript
复制
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本身和一些程序能够调节亮度(直接调节显示器的背光)。所以这个问题一定是与软件相关的。

EN

回答 1

Stack Overflow用户

发布于 2020-06-29 16:36:24

我的问题是,调用像GetMonitorBrightness这样的函数会返回FALSE,错误代码为ERROR_GRAPHICS_I2C_ERROR_TRANSMITTING_DATA (在I2C总线上向设备传输数据时发生错误)。

GetMonitorBrightness为我工作。我在电脑上测试过了。一些类似的案例指出,GetMonitorBrightness在一些笔记本电脑上不起作用。

我认为您的笔记本电脑不支持DDC/CI。

GetMonitorCapabilities:如果显示器不支持DDC/CI,则该功能失败。

您可以先检查您的笔记本电脑是否支持DDC/Cl。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62598348

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档