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