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