• EnumColorProfiles WcsGetDefaultColorProfile WcsSetDefaultColorProfile的使用


    #include <Windows.h>
    #include <Icm.h>
    #include <iostream>
    #include <string>
    
    #pragma comment(lib,"Mscms.lib")
    #define MAX_PATH 1024
    BOOL flag = 0;
    int main()
    {
        WCHAR* szDisplayDeviceName = NULL;
        WCHAR szPath[MAX_PATH];
        memset(szPath, 0, 1024);
        DISPLAY_DEVICE dd;
        dd.cb = sizeof(dd);
    
        if (flag = EnumDisplayDevices(L"\\.\DISPLAY1", 0, &dd, EDD_GET_DEVICE_INTERFACE_NAME))
        {
            if (flag = WcsGetDefaultColorProfile(WCS_PROFILE_MANAGEMENT_SCOPE_CURRENT_USER,
                dd.DeviceKey,
                CPT_ICC,
                CPST_PERCEPTUAL,
                0,  // dwProfileID -- doesn't seem to matter what value you use here
                MAX_PATH * sizeof(WCHAR),
                szPath))
            {
                PROFILE profile;
                profile.cbDataSize = (DWORD)(wcslen(szPath) + 1) * sizeof(WCHAR);
                profile.dwType = PROFILE_FILENAME;
                profile.pProfileData = (PVOID)szPath;
    
                HPROFILE hProfile = OpenColorProfile(&profile,
                    PROFILE_READ, FILE_SHARE_READ, OPEN_EXISTING);
    
                // now do something with the profile
                
            }
        }
    
        LPWSTR buffer;
        ENUMTYPEW pe = { 0 };
        pe.dwSize = sizeof(pe);
        pe.dwVersion = ENUM_TYPE_VERSION;
        pe.dwFields = ET_DEVICENAME;
        pe.dwDeviceClass = CLASS_MONITOR;
        pe.pDeviceName = dd.DeviceKey;
        DWORD p = 0;
        DWORD size = 0;
        BOOL  ret = EnumColorProfilesW(NULL, &pe, NULL, &size, &p);
        buffer = (LPWSTR)malloc(size);
        ret = EnumColorProfilesW(NULL, &pe, (BYTE*)buffer, &size, &p);
        LPWSTR temp = buffer;
        for (int i = 0; i < p; i++)
        {
            wprintf(L"%s
    ", temp);
            printf("without null character: %zu
    ", wcslen(temp));
            temp += wcslen(temp) + 1;      
        }
    
        flag = WcsSetDefaultColorProfile(WCS_PROFILE_MANAGEMENT_SCOPE_CURRENT_USER,
            dd.DeviceKey,
            CPT_ICC,
            CPST_PERCEPTUAL,
            0,  // dwProfileID -- doesn't seem to matter what value you use here
            buffer);
    
        free(buffer);
        return 1;
    }

    这是列举出本机上的所有icm配置文件

    相关链接: https://github.com/AcademySoftwareFoundation/OpenColorIO/blob/master/vendor/aftereffects/win/OpenColorIO_AE_Dialogs_Win.cpp#L348

  • 相关阅读:
    python socket 网络编程
    Python中的MySQL接口:PyMySQL & MySQLdb
    Docker Day1 & 2
    Java数据结构与算法(5):AVL树
    Solr集群环境搭建
    Java数据结构与算法(4):二叉查找树
    Solr单机环境搭建及部署
    Java数据结构与算法(3):队列
    Java数据结构与算法(2):栈
    Java数据结构与算法(1):线性表
  • 原文地址:https://www.cnblogs.com/strive-sun/p/12565714.html
Copyright © 2020-2023  润新知