簡體   English   中英

無法在 Windows 7 上獲取物理顯示器句柄以進行顏色校准

[英]Unable to get the physical monitor handle on Windows 7 for color calibration

我在 Windows 7 上,我正在嘗試從代碼中更改色彩平衡。 具體來說,我正在嘗試更改顏色校准向導上顯示的這些滑塊 我假設正確的功能是SetMonitorRedGreenOrBlueGainSetMonitorRedGreenOrBlueDrive

這是我的最小工作示例:

#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);    
    
}

output 是:

Monitor: 00010001
GetNumber: 1, number of physical monitors: 1
GetPhysicalMonitor: 1
Handle: 00000000
Description: Generic PnP Monitor

亮度和顏色增益的所有功能都需要HANDLE hPhysicalMonitor ,對於我的顯示器(筆記本電腦屏幕),它始終為null 但是,我知道必須可以更改色彩平衡,因為色彩校准 window 可以做到這一點。

我究竟做錯了什么?

編輯1:

正如評論中提到的, hPhysicalMonitor似乎是正確的。 我的問題是調用GetMonitorBrightness類的函數返回FALSE ,錯誤代碼為ERROR_GRAPHICS_I2C_ERROR_TRANSMITTING_DATA (將數據傳輸到 I2C 總線上的設備時發生錯誤。)

編輯2:

我的顯示器確實支持設置亮度並且有 11 個級別。 Windows 本身和一些程序都可以調節亮度(顯示器的背光直接)。 所以問題一定是軟件相關的。

我的問題是調用 GetMonitorBrightness 之類的函數返回 FALSE,錯誤代碼為 ERROR_GRAPHICS_I2C_ERROR_TRANSMITTING_DATA(將數據傳輸到 I2C 總線上的設備時發生錯誤。)

GetMonitorBrightness對我有用。 我在ie桌面上測試過。 一些類似的案例指出GetMonitorBrightness在某些筆記本電腦上不起作用。

我認為您的筆記本電腦不支持 DDC/CI。

GetMonitorCapabilities : 如果顯示器不支持 DDC/CI,則 function 會失敗。

您可以先檢查您的筆記本電腦是否支持 DDC/Cl。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM