ホーム › 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 | ガモット判定に使用するカラー変換のハンドル(CMM内部用)。 |
| lpaInputColors | COLOR* | in | 判定対象の色値を格納したCOLOR共用体配列へのポインタ。 |
| nColors | DWORD | in | 判定する色の個数。 |
| ctInput | COLORTYPE | in | 入力色データの色形式を示す列挙値(RGB・CMYK等)。 |
| lpaResult | BYTE* | out | 各色のガモット内外判定結果を受け取るBYTE配列へのポインタ。 |
戻り値の型: 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 <MarshalAs(UnmanagedType.Bool)> 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)。const std = @import("std");
extern "icm32" fn CMCheckColors(
hcmTransform: isize, // INT_PTR
lpaInputColors: [*c]COLOR, // COLOR*
nColors: u32, // DWORD
ctInput: i32, // COLORTYPE
lpaResult: [*c]u8 // BYTE* out
) callconv(std.os.windows.WINAPI) i32;proc CMCheckColors(
hcmTransform: int, # INT_PTR
lpaInputColors: ptr COLOR, # COLOR*
nColors: uint32, # DWORD
ctInput: int32, # COLORTYPE
lpaResult: ptr uint8 # BYTE* out
): int32 {.importc: "CMCheckColors", stdcall, dynlib: "ICM32.dll".}pragma(lib, "icm32");
extern(Windows)
int CMCheckColors(
ptrdiff_t hcmTransform, // INT_PTR
COLOR* lpaInputColors, // COLOR*
uint nColors, // DWORD
int ctInput, // COLORTYPE
ubyte* lpaResult // BYTE* out
);ccall((:CMCheckColors, "ICM32.dll"), stdcall, Int32,
(Int, Ptr{COLOR}, UInt32, Int32, Ptr{UInt8}),
hcmTransform, lpaInputColors, nColors, ctInput, lpaResult)
# hcmTransform : INT_PTR -> Int
# lpaInputColors : COLOR* -> Ptr{COLOR}
# nColors : DWORD -> UInt32
# ctInput : COLORTYPE -> Int32
# lpaResult : BYTE* out -> Ptr{UInt8}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t CMCheckColors(
intptr_t hcmTransform,
void* lpaInputColors,
uint32_t nColors,
int32_t ctInput,
uint8_t* lpaResult);
]]
local icm32 = ffi.load("icm32")
-- icm32.CMCheckColors(hcmTransform, lpaInputColors, nColors, ctInput, lpaResult)
-- hcmTransform : INT_PTR
-- lpaInputColors : COLOR*
-- nColors : DWORD
-- ctInput : COLORTYPE
-- lpaResult : BYTE* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ICM32.dll');
const CMCheckColors = lib.func('__stdcall', 'CMCheckColors', 'int32_t', ['intptr_t', 'void *', 'uint32_t', 'int32_t', 'uint8_t *']);
// CMCheckColors(hcmTransform, lpaInputColors, nColors, ctInput, lpaResult)
// hcmTransform : INT_PTR -> 'intptr_t'
// lpaInputColors : COLOR* -> 'void *'
// nColors : DWORD -> 'uint32_t'
// ctInput : COLORTYPE -> 'int32_t'
// lpaResult : BYTE* out -> 'uint8_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ICM32.dll", {
CMCheckColors: { parameters: ["isize", "pointer", "u32", "i32", "pointer"], result: "i32" },
});
// lib.symbols.CMCheckColors(hcmTransform, lpaInputColors, nColors, ctInput, lpaResult)
// hcmTransform : INT_PTR -> "isize"
// lpaInputColors : COLOR* -> "pointer"
// nColors : DWORD -> "u32"
// ctInput : COLORTYPE -> "i32"
// lpaResult : BYTE* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t CMCheckColors(
intptr_t hcmTransform,
void* lpaInputColors,
uint32_t nColors,
int32_t ctInput,
uint8_t* lpaResult);
C, "ICM32.dll");
// $ffi->CMCheckColors(hcmTransform, lpaInputColors, nColors, ctInput, lpaResult);
// hcmTransform : INT_PTR
// lpaInputColors : COLOR*
// nColors : DWORD
// ctInput : COLORTYPE
// lpaResult : BYTE* out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Icm32 extends StdCallLibrary {
Icm32 INSTANCE = Native.load("icm32", Icm32.class);
boolean CMCheckColors(
long hcmTransform, // INT_PTR
Pointer lpaInputColors, // COLOR*
int nColors, // DWORD
int ctInput, // COLORTYPE
byte[] lpaResult // BYTE* out
);
}@[Link("icm32")]
lib LibICM32
fun CMCheckColors = CMCheckColors(
hcmTransform : LibC::SSizeT, # INT_PTR
lpaInputColors : COLOR*, # COLOR*
nColors : UInt32, # DWORD
ctInput : Int32, # COLORTYPE
lpaResult : UInt8* # BYTE* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef CMCheckColorsNative = Int32 Function(IntPtr, Pointer<Void>, Uint32, Int32, Pointer<Uint8>);
typedef CMCheckColorsDart = int Function(int, Pointer<Void>, int, int, Pointer<Uint8>);
final CMCheckColors = DynamicLibrary.open('ICM32.dll')
.lookupFunction<CMCheckColorsNative, CMCheckColorsDart>('CMCheckColors');
// hcmTransform : INT_PTR -> IntPtr
// lpaInputColors : COLOR* -> Pointer<Void>
// nColors : DWORD -> Uint32
// ctInput : COLORTYPE -> Int32
// lpaResult : BYTE* out -> Pointer<Uint8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function 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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "CMCheckColors"
c_CMCheckColors :: CIntPtr -> Ptr () -> Word32 -> Int32 -> Ptr Word8 -> IO CInt
-- hcmTransform : INT_PTR -> CIntPtr
-- lpaInputColors : COLOR* -> Ptr ()
-- nColors : DWORD -> Word32
-- ctInput : COLORTYPE -> Int32
-- lpaResult : BYTE* out -> Ptr Word8
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let cmcheckcolors =
foreign "CMCheckColors"
(intptr_t @-> (ptr void) @-> uint32_t @-> int32_t @-> (ptr uint8_t) @-> returning int32_t)
(* hcmTransform : INT_PTR -> intptr_t *)
(* lpaInputColors : COLOR* -> (ptr void) *)
(* nColors : DWORD -> uint32_t *)
(* ctInput : COLORTYPE -> int32_t *)
(* lpaResult : BYTE* out -> (ptr uint8_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library icm32 (t "ICM32.dll"))
(cffi:use-foreign-library icm32)
(cffi:defcfun ("CMCheckColors" cmcheck-colors :convention :stdcall) :int32
(hcm-transform :int64) ; INT_PTR
(lpa-input-colors :pointer) ; COLOR*
(n-colors :uint32) ; DWORD
(ct-input :int32) ; COLORTYPE
(lpa-result :pointer)) ; BYTE* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $CMCheckColors = Win32::API::More->new('ICM32',
'BOOL CMCheckColors(LPARAM hcmTransform, LPVOID lpaInputColors, DWORD nColors, int ctInput, LPVOID lpaResult)');
# my $ret = $CMCheckColors->Call($hcmTransform, $lpaInputColors, $nColors, $ctInput, $lpaResult);
# hcmTransform : INT_PTR -> LPARAM
# lpaInputColors : COLOR* -> LPVOID
# nColors : DWORD -> DWORD
# ctInput : COLORTYPE -> int
# lpaResult : BYTE* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型