Win32 API 日本語リファレンス
ホームUI.ColorSystem › WcsCheckColors

WcsCheckColors

関数
WCS色変換で各色が色域内にあるか確認する。
DLLmscms.dll呼出規約winapi

シグネチャ

// mscms.dll
#include <windows.h>

BOOL WcsCheckColors(
    INT_PTR hColorTransform,
    DWORD nColors,
    DWORD nInputChannels,
    COLORDATATYPE cdtInput,
    DWORD cbInput,
    void* pInputData,
    BYTE* paResult
);

パラメーター

名前方向
hColorTransformINT_PTRin
nColorsDWORDin
nInputChannelsDWORDin
cdtInputCOLORDATATYPEin
cbInputDWORDin
pInputDatavoid*in
paResultBYTE*out

戻り値の型: BOOL

各言語での呼び出し定義

// mscms.dll
#include <windows.h>

BOOL WcsCheckColors(
    INT_PTR hColorTransform,
    DWORD nColors,
    DWORD nInputChannels,
    COLORDATATYPE cdtInput,
    DWORD cbInput,
    void* pInputData,
    BYTE* paResult
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mscms.dll", ExactSpelling = true)]
static extern bool WcsCheckColors(
    IntPtr hColorTransform,   // INT_PTR
    uint nColors,   // DWORD
    uint nInputChannels,   // DWORD
    int cdtInput,   // COLORDATATYPE
    uint cbInput,   // DWORD
    IntPtr pInputData,   // void*
    IntPtr paResult   // BYTE* out
);
<DllImport("mscms.dll", ExactSpelling:=True)>
Public Shared Function WcsCheckColors(
    hColorTransform As IntPtr,   ' INT_PTR
    nColors As UInteger,   ' DWORD
    nInputChannels As UInteger,   ' DWORD
    cdtInput As Integer,   ' COLORDATATYPE
    cbInput As UInteger,   ' DWORD
    pInputData As IntPtr,   ' void*
    paResult As IntPtr   ' BYTE* out
) As Boolean
End Function
' hColorTransform : INT_PTR
' nColors : DWORD
' nInputChannels : DWORD
' cdtInput : COLORDATATYPE
' cbInput : DWORD
' pInputData : void*
' paResult : BYTE* out
Declare PtrSafe Function WcsCheckColors Lib "mscms" ( _
    ByVal hColorTransform As LongPtr, _
    ByVal nColors As Long, _
    ByVal nInputChannels As Long, _
    ByVal cdtInput As Long, _
    ByVal cbInput As Long, _
    ByVal pInputData As LongPtr, _
    ByVal paResult As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WcsCheckColors = ctypes.windll.mscms.WcsCheckColors
WcsCheckColors.restype = wintypes.BOOL
WcsCheckColors.argtypes = [
    ctypes.c_ssize_t,  # hColorTransform : INT_PTR
    wintypes.DWORD,  # nColors : DWORD
    wintypes.DWORD,  # nInputChannels : DWORD
    ctypes.c_int,  # cdtInput : COLORDATATYPE
    wintypes.DWORD,  # cbInput : DWORD
    ctypes.POINTER(None),  # pInputData : void*
    ctypes.POINTER(ctypes.c_ubyte),  # paResult : BYTE* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('mscms.dll')
WcsCheckColors = Fiddle::Function.new(
  lib['WcsCheckColors'],
  [
    Fiddle::TYPE_INTPTR_T,  # hColorTransform : INT_PTR
    -Fiddle::TYPE_INT,  # nColors : DWORD
    -Fiddle::TYPE_INT,  # nInputChannels : DWORD
    Fiddle::TYPE_INT,  # cdtInput : COLORDATATYPE
    -Fiddle::TYPE_INT,  # cbInput : DWORD
    Fiddle::TYPE_VOIDP,  # pInputData : void*
    Fiddle::TYPE_VOIDP,  # paResult : BYTE* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "mscms")]
extern "system" {
    fn WcsCheckColors(
        hColorTransform: isize,  // INT_PTR
        nColors: u32,  // DWORD
        nInputChannels: u32,  // DWORD
        cdtInput: i32,  // COLORDATATYPE
        cbInput: u32,  // DWORD
        pInputData: *mut (),  // void*
        paResult: *mut u8  // BYTE* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mscms.dll")]
public static extern bool WcsCheckColors(IntPtr hColorTransform, uint nColors, uint nInputChannels, int cdtInput, uint cbInput, IntPtr pInputData, IntPtr paResult);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mscms_WcsCheckColors' -Namespace Win32 -PassThru
# $api::WcsCheckColors(hColorTransform, nColors, nInputChannels, cdtInput, cbInput, pInputData, paResult)
#uselib "mscms.dll"
#func global WcsCheckColors "WcsCheckColors" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; WcsCheckColors hColorTransform, nColors, nInputChannels, cdtInput, cbInput, pInputData, varptr(paResult)   ; 戻り値は stat
; hColorTransform : INT_PTR -> "sptr"
; nColors : DWORD -> "sptr"
; nInputChannels : DWORD -> "sptr"
; cdtInput : COLORDATATYPE -> "sptr"
; cbInput : DWORD -> "sptr"
; pInputData : void* -> "sptr"
; paResult : BYTE* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "mscms.dll"
#cfunc global WcsCheckColors "WcsCheckColors" sptr, int, int, int, int, sptr, var
; res = WcsCheckColors(hColorTransform, nColors, nInputChannels, cdtInput, cbInput, pInputData, paResult)
; hColorTransform : INT_PTR -> "sptr"
; nColors : DWORD -> "int"
; nInputChannels : DWORD -> "int"
; cdtInput : COLORDATATYPE -> "int"
; cbInput : DWORD -> "int"
; pInputData : void* -> "sptr"
; paResult : BYTE* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL WcsCheckColors(INT_PTR hColorTransform, DWORD nColors, DWORD nInputChannels, COLORDATATYPE cdtInput, DWORD cbInput, void* pInputData, BYTE* paResult)
#uselib "mscms.dll"
#cfunc global WcsCheckColors "WcsCheckColors" intptr, int, int, int, int, intptr, var
; res = WcsCheckColors(hColorTransform, nColors, nInputChannels, cdtInput, cbInput, pInputData, paResult)
; hColorTransform : INT_PTR -> "intptr"
; nColors : DWORD -> "int"
; nInputChannels : DWORD -> "int"
; cdtInput : COLORDATATYPE -> "int"
; cbInput : DWORD -> "int"
; pInputData : void* -> "intptr"
; paResult : BYTE* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mscms = windows.NewLazySystemDLL("mscms.dll")
	procWcsCheckColors = mscms.NewProc("WcsCheckColors")
)

// hColorTransform (INT_PTR), nColors (DWORD), nInputChannels (DWORD), cdtInput (COLORDATATYPE), cbInput (DWORD), pInputData (void*), paResult (BYTE* out)
r1, _, err := procWcsCheckColors.Call(
	uintptr(hColorTransform),
	uintptr(nColors),
	uintptr(nInputChannels),
	uintptr(cdtInput),
	uintptr(cbInput),
	uintptr(pInputData),
	uintptr(paResult),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function WcsCheckColors(
  hColorTransform: NativeInt;   // INT_PTR
  nColors: DWORD;   // DWORD
  nInputChannels: DWORD;   // DWORD
  cdtInput: Integer;   // COLORDATATYPE
  cbInput: DWORD;   // DWORD
  pInputData: Pointer;   // void*
  paResult: Pointer   // BYTE* out
): BOOL; stdcall;
  external 'mscms.dll' name 'WcsCheckColors';
result := DllCall("mscms\WcsCheckColors"
    , "Ptr", hColorTransform   ; INT_PTR
    , "UInt", nColors   ; DWORD
    , "UInt", nInputChannels   ; DWORD
    , "Int", cdtInput   ; COLORDATATYPE
    , "UInt", cbInput   ; DWORD
    , "Ptr", pInputData   ; void*
    , "Ptr", paResult   ; BYTE* out
    , "Int")   ; return: BOOL
●WcsCheckColors(hColorTransform, nColors, nInputChannels, cdtInput, cbInput, pInputData, paResult) = DLL("mscms.dll", "bool WcsCheckColors(int, dword, dword, int, dword, void*, void*)")
# 呼び出し: WcsCheckColors(hColorTransform, nColors, nInputChannels, cdtInput, cbInput, pInputData, paResult)
# hColorTransform : INT_PTR -> "int"
# nColors : DWORD -> "dword"
# nInputChannels : DWORD -> "dword"
# cdtInput : COLORDATATYPE -> "int"
# cbInput : DWORD -> "dword"
# pInputData : void* -> "void*"
# paResult : BYTE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。