⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wcsapiconv.cpp

📁 WDK 自带的xpsdrv filter之 color
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*++

Copyright (c) 2005 Microsoft Corporation

All rights reserved.

THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

File Name:

   wcsapiconv.cpp

Abstract:

   Implementation of the wrapper to the WCS API's

--*/

#include "precomp.h"
#include "debug.h"
#include "globals.h"
#include "wcsapiconv.h"

CWCSApiConv g_WCSApiConv;

/*++

Routine Name:

    CWCSApiConv::CWCSApiConv

Routine Description:

    CWCSApiConv class constructor

Arguments:

    None

Return Value:

    None

--*/
CWCSApiConv::CWCSApiConv()
{
   m_dllHandle = LoadLibrary(L"mscms.dll");

    //
    // If running on Vista, record the proc address for each WCS API
    //
    if (m_dllHandle != NULL &&
        IsVista())
    {
        m_WcsAssociateColorProfileWithDevice    = GetProcAddress(m_dllHandle,"WcsAssociateColorProfileWithDevice");
        m_WcsDisassociateColorProfileFromDevice = GetProcAddress(m_dllHandle, "WcsDisassociateColorProfileFromDevice");
        m_WcsEnumColorProfilesSize              = GetProcAddress(m_dllHandle, "WcsEnumColorProfilesSize");
        m_WcsGetDefaultColorProfileSize         = GetProcAddress(m_dllHandle, "WcsGetDefaultColorProfileSize");
        m_WcsGetDefaultColorProfile             = GetProcAddress(m_dllHandle, "WcsGetDefaultColorProfile");
        m_WcsSetDefaultColorProfile             = GetProcAddress(m_dllHandle, "WcsSetDefaultColorProfile");
        m_WcsSetDefaultRenderingIntent          = GetProcAddress(m_dllHandle, "WcsSetDefaultRenderingIntent");
        m_WcsGetUsePerUserProfiles              = GetProcAddress(m_dllHandle, "WcsGetUsePerUserProfiles");
        m_WcsSetUsePerUserProfiles              = GetProcAddress(m_dllHandle, "WcsSetUsePerUserProfiles");
        m_WcsTranslateColors                    = GetProcAddress(m_dllHandle, "WcsTranslateColors");
        m_WcsCheckColors                        = GetProcAddress(m_dllHandle, "WcsCheckColors");
        m_WcsOpenColorProfileA                  = GetProcAddress(m_dllHandle, "WcsOpenColorProfileA");
        m_WcsOpenColorProfileW                  = GetProcAddress(m_dllHandle, "WcsOpenColorProfileW");
        m_WcsCreateIccProfile                   = GetProcAddress(m_dllHandle, "WcsCreateIccProfile");

        ASSERTMSG(m_WcsAssociateColorProfileWithDevice    != NULL &&
                  m_WcsDisassociateColorProfileFromDevice != NULL &&
                  m_WcsEnumColorProfilesSize              != NULL &&
                  m_WcsGetDefaultColorProfileSize         != NULL &&
                  m_WcsGetDefaultColorProfile             != NULL &&
                  m_WcsSetDefaultColorProfile             != NULL &&
                  m_WcsSetDefaultRenderingIntent          != NULL &&
                  m_WcsGetUsePerUserProfiles              != NULL &&
                  m_WcsSetUsePerUserProfiles              != NULL &&
                  m_WcsTranslateColors                    != NULL &&
                  m_WcsCheckColors                        != NULL &&
                  m_WcsOpenColorProfileA                  != NULL &&
                  m_WcsOpenColorProfileW                  != NULL &&
                  m_WcsCreateIccProfile                   != NULL,
                  "Failed to load WCS APIs correctly.\n");
    }
}

/*++

Routine Name:

    CWCSApiConv::~CWCSApiConv

Routine Description:

    CWCSApiConv class destructor

Arguments:

    None

Return Value:

    None

--*/
CWCSApiConv::~CWCSApiConv()
{
    FreeLibrary(m_dllHandle);
}

/*++

Routine Name:

    CWCSApiConv::WcsAssociateColorProfileWithDevice

Routine Description:


Arguments:

    scope - Profile management scope for this operation, which could be system wide or for current user.

    pProfileName - Points to the file name of the profile to associate.

    pDeviceName - Points to the name of the device to associate.

Return Value:

    BOOL
    If this function succeeds, the return value is TRUE.

--*/
BOOL
CWCSApiConv::WcsAssociateColorProfileWithDevice(
    __in WCS_PROFILE_MANAGEMENT_SCOPE scope,
    __in PCWSTR pProfileName,
    __in PCWSTR pDeviceName
    )
{
    BOOL bResult = FALSE;

    if (m_WcsAssociateColorProfileWithDevice != NULL)
    {
        bResult = m_WcsAssociateColorProfileWithDevice.GetFunc()(scope, pProfileName, pDeviceName);
    }

    return bResult;
}

/*++

Routine Name:

    CWCSApiConv::WcsDisassociateColorProfileFromDevice

Routine Description:


Arguments:

    scope - Profile management scope for this operation, which could be system wide or for current user.

    pProfileName - Pointer to the file name of the profile to disassociate.

    pDeviceName - Pointer to the name of the device to disassociate.

Return Value:

    BOOL
    If this function succeeds, the return value is TRUE.

--*/
BOOL
CWCSApiConv::WcsDisassociateColorProfileFromDevice(
    __in WCS_PROFILE_MANAGEMENT_SCOPE scope,
    __in PCWSTR pProfileName,
    __in PCWSTR pDeviceName
    )
{
    BOOL bResult = FALSE;

    if (m_WcsDisassociateColorProfileFromDevice != NULL)
    {
        bResult = m_WcsDisassociateColorProfileFromDevice.GetFunc()(scope, pProfileName, pDeviceName);
    }

    return bResult;
}

/*++

Routine Name:

    CWCSApiConv::WcsEnumColorProfilesSize

Routine Description:


Arguments:

    scope - management scope for this operation, which could be system wide or for current user.

    pEnumRecord - Pointer to the structure specifying the enumeration criteria.

    pdwSize - Returns the size in bytes required for the buffer to receive the set of profile names in WcsEnumColorProfiles.

Return Value:

    BOOL
    If this function succeeds, the return value is TRUE.

--*/
BOOL
CWCSApiConv::WcsEnumColorProfilesSize(
    __in WCS_PROFILE_MANAGEMENT_SCOPE scope,
    __in PENUMTYPEW pEnumRecord,
    __out PDWORD pdwSize
    )
{
    BOOL bResult = FALSE;

    if (m_WcsEnumColorProfilesSize != NULL)
    {
        bResult = m_WcsEnumColorProfilesSize.GetFunc()(scope, pEnumRecord, pdwSize);
    }

    return bResult;
}

/*++

Routine Name:

    CWCSApiConv::WcsGetDefaultColorProfileSize

Routine Description:


Arguments:

    scope - Profile management scope for this operation, which could be system wide or for current user.

    pDeviceName - Pointer to the name of the device to get the default profile for. NULL implies device-independent default.

    cptColorProfileType - Specifies the color profile type value.

    cpstColorProfileSubType - Specifies the color profile subtype value.

    dwProfileID - Specifies the ID of the color space that the profile represents.

    pcbProfileName - the size in bytes for receiving the default profile in WcsGetDefaultColorProfile.

Return Value:

    BOOL
    If this function succeeds, the return value is TRUE.

--*/
BOOL
CWCSApiConv::WcsGetDefaultColorProfileSize(
    __in WCS_PROFILE_MANAGEMENT_SCOPE scope,
    __in_opt PCWSTR pDeviceName,
    __in COLORPROFILETYPE cptColorProfileType,
    __in COLORPROFILESUBTYPE cpstColorProfileSubType,
    __in DWORD dwProfileID,
    __out PDWORD pcbProfileName
    )
{
    BOOL bResult = FALSE;

    if (m_WcsGetDefaultColorProfileSize != NULL)
    {
        bResult = m_WcsGetDefaultColorProfileSize.GetFunc()(scope,
                                                            pDeviceName,
                                                            cptColorProfileType,
                                                            cpstColorProfileSubType,
                                                            dwProfileID,
                                                            pcbProfileName);
    }

    return bResult;
}

/*++

Routine Name:

    CWCSApiConv::WcsGetDefaultColorProfile

Routine Description:


Arguments:

    scope - Profile management scope for this operation, which could be system wide or for current user.

    pDeviceName - Pointer to the name of the device to get the default profile for. NULL implies device-independent default.

    cptColorProfileType - Specifies the color profile type value.

    cpstColorProfileSubType - Specifies the color profile subtype value.

    dwProfileID - Specifies the ID of the color space that the profile represents.

    cbProfileName - The size in bytes of the buffer pointed to by pProfileName.

    pProfileName - Pointer to the buffer in which the name of the profile is to be placed.

Return Value:

    BOOL
    If this function succeeds, the return value is TRUE.

--*/
BOOL
CWCSApiConv::WcsGetDefaultColorProfile(
    __in WCS_PROFILE_MANAGEMENT_SCOPE scope,
    __in_opt PCWSTR pDeviceName,
    __in COLORPROFILETYPE cptColorProfileType,
    __in COLORPROFILESUBTYPE cpstColorProfileSubType,
    __in DWORD dwProfileID,
    __in DWORD cbProfileName,
    __out_bcount(cbProfileName) LPWSTR pProfileName
    )
{
    BOOL bResult = FALSE;

    if (m_WcsGetDefaultColorProfile != NULL)
    {
        bResult = m_WcsGetDefaultColorProfile.GetFunc()(scope,
                                                       pDeviceName,
                                                       cptColorProfileType,
                                                       cpstColorProfileSubType,
                                                       dwProfileID,
                                                       cbProfileName,
                                                       pProfileName);
    }

    return bResult;
}

/*++

Routine Name:

    CWCSApiConv::WcsSetDefaultColorProfile

Routine Description:


Arguments:

    scope - Profile management scope for this operation, which could be system wide or for current user.

    pDeviceName - Pointer to the name of the device to set the default profile for. NULL implies device-independent default.

    cptColorProfileType - Specifies the color profile type value.

    cpstColorProfileSubType - Specifies the color profile subtype value.

    dwProfileID - Specifies the ID of the color space that the profile represents.

    pProfileName - Pointer to the buffer in which contains the name of the profile.

Return Value:

    BOOL
    If this function succeeds, the return value is TRUE.

--*/
BOOL
CWCSApiConv::WcsSetDefaultColorProfile(
    __in WCS_PROFILE_MANAGEMENT_SCOPE scope,
    __in_opt PCWSTR pDeviceName,
    __in COLORPROFILETYPE cptColorProfileType,
    __in COLORPROFILESUBTYPE cpstColorProfileSubType,
    __in DWORD dwProfileID,
    __in_opt LPCWSTR pProfileName
    )
{
    BOOL bResult = FALSE;

    if (m_WcsSetDefaultColorProfile != NULL)
    {
        bResult = m_WcsSetDefaultColorProfile.GetFunc()(scope,
                                                        pDeviceName,
                                                        cptColorProfileType,
                                                        cpstColorProfileSubType,
                                                        dwProfileID,
                                                        pProfileName);
    }

    return bResult;
}

/*++

Routine Name:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -