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

TranslateColors

関数
色変換を用いて色配列を変換する。
DLLmscms.dll呼出規約winapi

シグネチャ

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

BOOL TranslateColors(
    INT_PTR hColorTransform,
    COLOR* paInputColors,
    DWORD nColors,
    COLORTYPE ctInput,
    COLOR* paOutputColors,
    COLORTYPE ctOutput
);

パラメーター

名前方向
hColorTransformINT_PTRin
paInputColorsCOLOR*in
nColorsDWORDin
ctInputCOLORTYPEin
paOutputColorsCOLOR*out
ctOutputCOLORTYPEin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL TranslateColors(
    INT_PTR hColorTransform,
    COLOR* paInputColors,
    DWORD nColors,
    COLORTYPE ctInput,
    COLOR* paOutputColors,
    COLORTYPE ctOutput
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mscms.dll", ExactSpelling = true)]
static extern bool TranslateColors(
    IntPtr hColorTransform,   // INT_PTR
    IntPtr paInputColors,   // COLOR*
    uint nColors,   // DWORD
    int ctInput,   // COLORTYPE
    IntPtr paOutputColors,   // COLOR* out
    int ctOutput   // COLORTYPE
);
<DllImport("mscms.dll", ExactSpelling:=True)>
Public Shared Function TranslateColors(
    hColorTransform As IntPtr,   ' INT_PTR
    paInputColors As IntPtr,   ' COLOR*
    nColors As UInteger,   ' DWORD
    ctInput As Integer,   ' COLORTYPE
    paOutputColors As IntPtr,   ' COLOR* out
    ctOutput As Integer   ' COLORTYPE
) As Boolean
End Function
' hColorTransform : INT_PTR
' paInputColors : COLOR*
' nColors : DWORD
' ctInput : COLORTYPE
' paOutputColors : COLOR* out
' ctOutput : COLORTYPE
Declare PtrSafe Function TranslateColors Lib "mscms" ( _
    ByVal hColorTransform As LongPtr, _
    ByVal paInputColors As LongPtr, _
    ByVal nColors As Long, _
    ByVal ctInput As Long, _
    ByVal paOutputColors 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

TranslateColors = ctypes.windll.mscms.TranslateColors
TranslateColors.restype = wintypes.BOOL
TranslateColors.argtypes = [
    ctypes.c_ssize_t,  # hColorTransform : INT_PTR
    ctypes.c_void_p,  # paInputColors : COLOR*
    wintypes.DWORD,  # nColors : DWORD
    ctypes.c_int,  # ctInput : COLORTYPE
    ctypes.c_void_p,  # paOutputColors : COLOR* out
    ctypes.c_int,  # ctOutput : COLORTYPE
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('mscms.dll')
TranslateColors = Fiddle::Function.new(
  lib['TranslateColors'],
  [
    Fiddle::TYPE_INTPTR_T,  # hColorTransform : INT_PTR
    Fiddle::TYPE_VOIDP,  # paInputColors : COLOR*
    -Fiddle::TYPE_INT,  # nColors : DWORD
    Fiddle::TYPE_INT,  # ctInput : COLORTYPE
    Fiddle::TYPE_VOIDP,  # paOutputColors : COLOR* out
    Fiddle::TYPE_INT,  # ctOutput : COLORTYPE
  ],
  Fiddle::TYPE_INT)
#[link(name = "mscms")]
extern "system" {
    fn TranslateColors(
        hColorTransform: isize,  // INT_PTR
        paInputColors: *mut COLOR,  // COLOR*
        nColors: u32,  // DWORD
        ctInput: i32,  // COLORTYPE
        paOutputColors: *mut COLOR,  // COLOR* out
        ctOutput: i32  // COLORTYPE
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mscms.dll")]
public static extern bool TranslateColors(IntPtr hColorTransform, IntPtr paInputColors, uint nColors, int ctInput, IntPtr paOutputColors, int ctOutput);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mscms_TranslateColors' -Namespace Win32 -PassThru
# $api::TranslateColors(hColorTransform, paInputColors, nColors, ctInput, paOutputColors, ctOutput)
#uselib "mscms.dll"
#func global TranslateColors "TranslateColors" sptr, sptr, sptr, sptr, sptr, sptr
; TranslateColors hColorTransform, varptr(paInputColors), nColors, ctInput, varptr(paOutputColors), ctOutput   ; 戻り値は stat
; hColorTransform : INT_PTR -> "sptr"
; paInputColors : COLOR* -> "sptr"
; nColors : DWORD -> "sptr"
; ctInput : COLORTYPE -> "sptr"
; paOutputColors : COLOR* out -> "sptr"
; ctOutput : COLORTYPE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "mscms.dll"
#cfunc global TranslateColors "TranslateColors" sptr, var, int, int, var, int
; res = TranslateColors(hColorTransform, paInputColors, nColors, ctInput, paOutputColors, ctOutput)
; hColorTransform : INT_PTR -> "sptr"
; paInputColors : COLOR* -> "var"
; nColors : DWORD -> "int"
; ctInput : COLORTYPE -> "int"
; paOutputColors : COLOR* out -> "var"
; ctOutput : COLORTYPE -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL TranslateColors(INT_PTR hColorTransform, COLOR* paInputColors, DWORD nColors, COLORTYPE ctInput, COLOR* paOutputColors, COLORTYPE ctOutput)
#uselib "mscms.dll"
#cfunc global TranslateColors "TranslateColors" intptr, var, int, int, var, int
; res = TranslateColors(hColorTransform, paInputColors, nColors, ctInput, paOutputColors, ctOutput)
; hColorTransform : INT_PTR -> "intptr"
; paInputColors : COLOR* -> "var"
; nColors : DWORD -> "int"
; ctInput : COLORTYPE -> "int"
; paOutputColors : COLOR* out -> "var"
; ctOutput : COLORTYPE -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mscms = windows.NewLazySystemDLL("mscms.dll")
	procTranslateColors = mscms.NewProc("TranslateColors")
)

// hColorTransform (INT_PTR), paInputColors (COLOR*), nColors (DWORD), ctInput (COLORTYPE), paOutputColors (COLOR* out), ctOutput (COLORTYPE)
r1, _, err := procTranslateColors.Call(
	uintptr(hColorTransform),
	uintptr(paInputColors),
	uintptr(nColors),
	uintptr(ctInput),
	uintptr(paOutputColors),
	uintptr(ctOutput),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function TranslateColors(
  hColorTransform: NativeInt;   // INT_PTR
  paInputColors: Pointer;   // COLOR*
  nColors: DWORD;   // DWORD
  ctInput: Integer;   // COLORTYPE
  paOutputColors: Pointer;   // COLOR* out
  ctOutput: Integer   // COLORTYPE
): BOOL; stdcall;
  external 'mscms.dll' name 'TranslateColors';
result := DllCall("mscms\TranslateColors"
    , "Ptr", hColorTransform   ; INT_PTR
    , "Ptr", paInputColors   ; COLOR*
    , "UInt", nColors   ; DWORD
    , "Int", ctInput   ; COLORTYPE
    , "Ptr", paOutputColors   ; COLOR* out
    , "Int", ctOutput   ; COLORTYPE
    , "Int")   ; return: BOOL
●TranslateColors(hColorTransform, paInputColors, nColors, ctInput, paOutputColors, ctOutput) = DLL("mscms.dll", "bool TranslateColors(int, void*, dword, int, void*, int)")
# 呼び出し: TranslateColors(hColorTransform, paInputColors, nColors, ctInput, paOutputColors, ctOutput)
# hColorTransform : INT_PTR -> "int"
# paInputColors : COLOR* -> "void*"
# nColors : DWORD -> "dword"
# ctInput : COLORTYPE -> "int"
# paOutputColors : COLOR* out -> "void*"
# ctOutput : COLORTYPE -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。