ホーム › UI.ColorSystem › CheckColors
CheckColors
関数色変換で各色が色域内にあるか確認する。
シグネチャ
// mscms.dll
#include <windows.h>
BOOL CheckColors(
INT_PTR hColorTransform,
COLOR* paInputColors,
DWORD nColors,
COLORTYPE ctInput,
BYTE* paResult
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hColorTransform | INT_PTR | in |
| paInputColors | COLOR* | in |
| nColors | DWORD | in |
| ctInput | COLORTYPE | in |
| paResult | BYTE* | out |
戻り値の型: BOOL
各言語での呼び出し定義
// mscms.dll
#include <windows.h>
BOOL CheckColors(
INT_PTR hColorTransform,
COLOR* paInputColors,
DWORD nColors,
COLORTYPE ctInput,
BYTE* paResult
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mscms.dll", ExactSpelling = true)]
static extern bool CheckColors(
IntPtr hColorTransform, // INT_PTR
IntPtr paInputColors, // COLOR*
uint nColors, // DWORD
int ctInput, // COLORTYPE
IntPtr paResult // BYTE* out
);<DllImport("mscms.dll", ExactSpelling:=True)>
Public Shared Function CheckColors(
hColorTransform As IntPtr, ' INT_PTR
paInputColors As IntPtr, ' COLOR*
nColors As UInteger, ' DWORD
ctInput As Integer, ' COLORTYPE
paResult As IntPtr ' BYTE* out
) As Boolean
End Function' hColorTransform : INT_PTR
' paInputColors : COLOR*
' nColors : DWORD
' ctInput : COLORTYPE
' paResult : BYTE* out
Declare PtrSafe Function CheckColors Lib "mscms" ( _
ByVal hColorTransform As LongPtr, _
ByVal paInputColors As LongPtr, _
ByVal nColors As Long, _
ByVal ctInput As Long, _
ByVal paResult As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CheckColors = ctypes.windll.mscms.CheckColors
CheckColors.restype = wintypes.BOOL
CheckColors.argtypes = [
ctypes.c_ssize_t, # hColorTransform : INT_PTR
ctypes.c_void_p, # paInputColors : COLOR*
wintypes.DWORD, # nColors : DWORD
ctypes.c_int, # ctInput : COLORTYPE
ctypes.POINTER(ctypes.c_ubyte), # paResult : BYTE* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('mscms.dll')
CheckColors = Fiddle::Function.new(
lib['CheckColors'],
[
Fiddle::TYPE_INTPTR_T, # hColorTransform : INT_PTR
Fiddle::TYPE_VOIDP, # paInputColors : COLOR*
-Fiddle::TYPE_INT, # nColors : DWORD
Fiddle::TYPE_INT, # ctInput : COLORTYPE
Fiddle::TYPE_VOIDP, # paResult : BYTE* out
],
Fiddle::TYPE_INT)#[link(name = "mscms")]
extern "system" {
fn CheckColors(
hColorTransform: isize, // INT_PTR
paInputColors: *mut COLOR, // COLOR*
nColors: u32, // DWORD
ctInput: i32, // COLORTYPE
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 CheckColors(IntPtr hColorTransform, IntPtr paInputColors, uint nColors, int ctInput, IntPtr paResult);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mscms_CheckColors' -Namespace Win32 -PassThru
# $api::CheckColors(hColorTransform, paInputColors, nColors, ctInput, paResult)#uselib "mscms.dll"
#func global CheckColors "CheckColors" sptr, sptr, sptr, sptr, sptr
; CheckColors hColorTransform, varptr(paInputColors), nColors, ctInput, varptr(paResult) ; 戻り値は stat
; hColorTransform : INT_PTR -> "sptr"
; paInputColors : COLOR* -> "sptr"
; nColors : DWORD -> "sptr"
; ctInput : COLORTYPE -> "sptr"
; paResult : BYTE* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "mscms.dll" #cfunc global CheckColors "CheckColors" sptr, var, int, int, var ; res = CheckColors(hColorTransform, paInputColors, nColors, ctInput, paResult) ; hColorTransform : INT_PTR -> "sptr" ; paInputColors : COLOR* -> "var" ; nColors : DWORD -> "int" ; ctInput : COLORTYPE -> "int" ; paResult : BYTE* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "mscms.dll" #cfunc global CheckColors "CheckColors" sptr, sptr, int, int, sptr ; res = CheckColors(hColorTransform, varptr(paInputColors), nColors, ctInput, varptr(paResult)) ; hColorTransform : INT_PTR -> "sptr" ; paInputColors : COLOR* -> "sptr" ; nColors : DWORD -> "int" ; ctInput : COLORTYPE -> "int" ; paResult : BYTE* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL CheckColors(INT_PTR hColorTransform, COLOR* paInputColors, DWORD nColors, COLORTYPE ctInput, BYTE* paResult) #uselib "mscms.dll" #cfunc global CheckColors "CheckColors" intptr, var, int, int, var ; res = CheckColors(hColorTransform, paInputColors, nColors, ctInput, paResult) ; hColorTransform : INT_PTR -> "intptr" ; paInputColors : COLOR* -> "var" ; nColors : DWORD -> "int" ; ctInput : COLORTYPE -> "int" ; paResult : BYTE* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL CheckColors(INT_PTR hColorTransform, COLOR* paInputColors, DWORD nColors, COLORTYPE ctInput, BYTE* paResult) #uselib "mscms.dll" #cfunc global CheckColors "CheckColors" intptr, intptr, int, int, intptr ; res = CheckColors(hColorTransform, varptr(paInputColors), nColors, ctInput, varptr(paResult)) ; hColorTransform : INT_PTR -> "intptr" ; paInputColors : COLOR* -> "intptr" ; nColors : DWORD -> "int" ; ctInput : COLORTYPE -> "int" ; paResult : BYTE* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mscms = windows.NewLazySystemDLL("mscms.dll")
procCheckColors = mscms.NewProc("CheckColors")
)
// hColorTransform (INT_PTR), paInputColors (COLOR*), nColors (DWORD), ctInput (COLORTYPE), paResult (BYTE* out)
r1, _, err := procCheckColors.Call(
uintptr(hColorTransform),
uintptr(paInputColors),
uintptr(nColors),
uintptr(ctInput),
uintptr(paResult),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction CheckColors(
hColorTransform: NativeInt; // INT_PTR
paInputColors: Pointer; // COLOR*
nColors: DWORD; // DWORD
ctInput: Integer; // COLORTYPE
paResult: Pointer // BYTE* out
): BOOL; stdcall;
external 'mscms.dll' name 'CheckColors';result := DllCall("mscms\CheckColors"
, "Ptr", hColorTransform ; INT_PTR
, "Ptr", paInputColors ; COLOR*
, "UInt", nColors ; DWORD
, "Int", ctInput ; COLORTYPE
, "Ptr", paResult ; BYTE* out
, "Int") ; return: BOOL●CheckColors(hColorTransform, paInputColors, nColors, ctInput, paResult) = DLL("mscms.dll", "bool CheckColors(int, void*, dword, int, void*)")
# 呼び出し: CheckColors(hColorTransform, paInputColors, nColors, ctInput, paResult)
# hColorTransform : INT_PTR -> "int"
# paInputColors : COLOR* -> "void*"
# nColors : DWORD -> "dword"
# ctInput : COLORTYPE -> "int"
# paResult : BYTE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。