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

CMCheckColorsInGamut

関数
CMMでRGB色が色域内にあるか確認する。
DLLICM32.dll呼出規約winapi

シグネチャ

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

BOOL CMCheckColorsInGamut(
    INT_PTR hcmTransform,
    RGBTRIPLE* lpaRGBTriple,
    BYTE* lpaResult,
    DWORD nCount
);

パラメーター

名前方向
hcmTransformINT_PTRin
lpaRGBTripleRGBTRIPLE*in
lpaResultBYTE*out
nCountDWORDin

戻り値の型: 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 方式にも切替可。
出力引数:
; 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 方式にも切替可。
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   // BOOL
function 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)。