zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    Redis学习笔记
    RedisTemplate操作命令
    RedisTemplate操作命令
    RedisTemplate操作命令
    RedisTemplate操作命令
    将chrome储存的密码转为MarkDown表格
    使用redisson做redis分布式锁
    RocketMQ 整合SpringBoot发送事务消息
    关于java读写锁的测试
    java8 stream记录
  • 原文地址:https://www.cnblogs.com/strive-sun/p/12565714.html
Copyright © 2011-2022 走看看