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