ホーム › UI.ColorSystem › WcsCheckColors
WcsCheckColors
関数WCS色変換で各色が色域内にあるか確認する。
シグネチャ
// mscms.dll
#include <windows.h>
BOOL WcsCheckColors(
INT_PTR hColorTransform,
DWORD nColors,
DWORD nInputChannels,
COLORDATATYPE cdtInput,
DWORD cbInput,
void* pInputData,
BYTE* paResult
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hColorTransform | INT_PTR | in | ガモット判定に使用するカラー変換のハンドル。 |
| nColors | DWORD | in | 判定する色の個数。 |
| nInputChannels | DWORD | in | 入力色データのチャンネル数。 |
| cdtInput | COLORDATATYPE | in | 入力色データの要素データ型を示す列挙値。 |
| cbInput | DWORD | in | 入力1色あたりのバイトサイズ。 |
| pInputData | void* | in | 判定対象の色データを格納したバッファへのポインタ。 |
| paResult | BYTE* | out | 各色のガモット内外判定結果を受け取るBYTE配列へのポインタ。 |
戻り値の型: BOOL
各言語での呼び出し定義
// mscms.dll
#include <windows.h>
BOOL WcsCheckColors(
INT_PTR hColorTransform,
DWORD nColors,
DWORD nInputChannels,
COLORDATATYPE cdtInput,
DWORD cbInput,
void* pInputData,
BYTE* paResult
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mscms.dll", ExactSpelling = true)]
static extern bool WcsCheckColors(
IntPtr hColorTransform, // INT_PTR
uint nColors, // DWORD
uint nInputChannels, // DWORD
int cdtInput, // COLORDATATYPE
uint cbInput, // DWORD
IntPtr pInputData, // void*
IntPtr paResult // BYTE* out
);<DllImport("mscms.dll", ExactSpelling:=True)>
Public Shared Function WcsCheckColors(
hColorTransform As IntPtr, ' INT_PTR
nColors As UInteger, ' DWORD
nInputChannels As UInteger, ' DWORD
cdtInput As Integer, ' COLORDATATYPE
cbInput As UInteger, ' DWORD
pInputData As IntPtr, ' void*
paResult As IntPtr ' BYTE* out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' hColorTransform : INT_PTR
' nColors : DWORD
' nInputChannels : DWORD
' cdtInput : COLORDATATYPE
' cbInput : DWORD
' pInputData : void*
' paResult : BYTE* out
Declare PtrSafe Function WcsCheckColors Lib "mscms" ( _
ByVal hColorTransform As LongPtr, _
ByVal nColors As Long, _
ByVal nInputChannels As Long, _
ByVal cdtInput As Long, _
ByVal cbInput As Long, _
ByVal pInputData As LongPtr, _
ByVal paResult As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WcsCheckColors = ctypes.windll.mscms.WcsCheckColors
WcsCheckColors.restype = wintypes.BOOL
WcsCheckColors.argtypes = [
ctypes.c_ssize_t, # hColorTransform : INT_PTR
wintypes.DWORD, # nColors : DWORD
wintypes.DWORD, # nInputChannels : DWORD
ctypes.c_int, # cdtInput : COLORDATATYPE
wintypes.DWORD, # cbInput : DWORD
ctypes.POINTER(None), # pInputData : void*
ctypes.POINTER(ctypes.c_ubyte), # paResult : BYTE* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('mscms.dll')
WcsCheckColors = Fiddle::Function.new(
lib['WcsCheckColors'],
[
Fiddle::TYPE_INTPTR_T, # hColorTransform : INT_PTR
-Fiddle::TYPE_INT, # nColors : DWORD
-Fiddle::TYPE_INT, # nInputChannels : DWORD
Fiddle::TYPE_INT, # cdtInput : COLORDATATYPE
-Fiddle::TYPE_INT, # cbInput : DWORD
Fiddle::TYPE_VOIDP, # pInputData : void*
Fiddle::TYPE_VOIDP, # paResult : BYTE* out
],
Fiddle::TYPE_INT)#[link(name = "mscms")]
extern "system" {
fn WcsCheckColors(
hColorTransform: isize, // INT_PTR
nColors: u32, // DWORD
nInputChannels: u32, // DWORD
cdtInput: i32, // COLORDATATYPE
cbInput: u32, // DWORD
pInputData: *mut (), // void*
paResult: *mut u8 // BYTE* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mscms.dll")]
public static extern bool WcsCheckColors(IntPtr hColorTransform, uint nColors, uint nInputChannels, int cdtInput, uint cbInput, IntPtr pInputData, IntPtr paResult);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mscms_WcsCheckColors' -Namespace Win32 -PassThru
# $api::WcsCheckColors(hColorTransform, nColors, nInputChannels, cdtInput, cbInput, pInputData, paResult)#uselib "mscms.dll"
#func global WcsCheckColors "WcsCheckColors" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; WcsCheckColors hColorTransform, nColors, nInputChannels, cdtInput, cbInput, pInputData, varptr(paResult) ; 戻り値は stat
; hColorTransform : INT_PTR -> "sptr"
; nColors : DWORD -> "sptr"
; nInputChannels : DWORD -> "sptr"
; cdtInput : COLORDATATYPE -> "sptr"
; cbInput : DWORD -> "sptr"
; pInputData : void* -> "sptr"
; paResult : BYTE* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "mscms.dll" #cfunc global WcsCheckColors "WcsCheckColors" sptr, int, int, int, int, sptr, var ; res = WcsCheckColors(hColorTransform, nColors, nInputChannels, cdtInput, cbInput, pInputData, paResult) ; hColorTransform : INT_PTR -> "sptr" ; nColors : DWORD -> "int" ; nInputChannels : DWORD -> "int" ; cdtInput : COLORDATATYPE -> "int" ; cbInput : DWORD -> "int" ; pInputData : void* -> "sptr" ; paResult : BYTE* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "mscms.dll" #cfunc global WcsCheckColors "WcsCheckColors" sptr, int, int, int, int, sptr, sptr ; res = WcsCheckColors(hColorTransform, nColors, nInputChannels, cdtInput, cbInput, pInputData, varptr(paResult)) ; hColorTransform : INT_PTR -> "sptr" ; nColors : DWORD -> "int" ; nInputChannels : DWORD -> "int" ; cdtInput : COLORDATATYPE -> "int" ; cbInput : DWORD -> "int" ; pInputData : void* -> "sptr" ; paResult : BYTE* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL WcsCheckColors(INT_PTR hColorTransform, DWORD nColors, DWORD nInputChannels, COLORDATATYPE cdtInput, DWORD cbInput, void* pInputData, BYTE* paResult) #uselib "mscms.dll" #cfunc global WcsCheckColors "WcsCheckColors" intptr, int, int, int, int, intptr, var ; res = WcsCheckColors(hColorTransform, nColors, nInputChannels, cdtInput, cbInput, pInputData, paResult) ; hColorTransform : INT_PTR -> "intptr" ; nColors : DWORD -> "int" ; nInputChannels : DWORD -> "int" ; cdtInput : COLORDATATYPE -> "int" ; cbInput : DWORD -> "int" ; pInputData : void* -> "intptr" ; paResult : BYTE* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL WcsCheckColors(INT_PTR hColorTransform, DWORD nColors, DWORD nInputChannels, COLORDATATYPE cdtInput, DWORD cbInput, void* pInputData, BYTE* paResult) #uselib "mscms.dll" #cfunc global WcsCheckColors "WcsCheckColors" intptr, int, int, int, int, intptr, intptr ; res = WcsCheckColors(hColorTransform, nColors, nInputChannels, cdtInput, cbInput, pInputData, varptr(paResult)) ; hColorTransform : INT_PTR -> "intptr" ; nColors : DWORD -> "int" ; nInputChannels : DWORD -> "int" ; cdtInput : COLORDATATYPE -> "int" ; cbInput : DWORD -> "int" ; pInputData : void* -> "intptr" ; paResult : BYTE* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mscms = windows.NewLazySystemDLL("mscms.dll")
procWcsCheckColors = mscms.NewProc("WcsCheckColors")
)
// hColorTransform (INT_PTR), nColors (DWORD), nInputChannels (DWORD), cdtInput (COLORDATATYPE), cbInput (DWORD), pInputData (void*), paResult (BYTE* out)
r1, _, err := procWcsCheckColors.Call(
uintptr(hColorTransform),
uintptr(nColors),
uintptr(nInputChannels),
uintptr(cdtInput),
uintptr(cbInput),
uintptr(pInputData),
uintptr(paResult),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction WcsCheckColors(
hColorTransform: NativeInt; // INT_PTR
nColors: DWORD; // DWORD
nInputChannels: DWORD; // DWORD
cdtInput: Integer; // COLORDATATYPE
cbInput: DWORD; // DWORD
pInputData: Pointer; // void*
paResult: Pointer // BYTE* out
): BOOL; stdcall;
external 'mscms.dll' name 'WcsCheckColors';result := DllCall("mscms\WcsCheckColors"
, "Ptr", hColorTransform ; INT_PTR
, "UInt", nColors ; DWORD
, "UInt", nInputChannels ; DWORD
, "Int", cdtInput ; COLORDATATYPE
, "UInt", cbInput ; DWORD
, "Ptr", pInputData ; void*
, "Ptr", paResult ; BYTE* out
, "Int") ; return: BOOL●WcsCheckColors(hColorTransform, nColors, nInputChannels, cdtInput, cbInput, pInputData, paResult) = DLL("mscms.dll", "bool WcsCheckColors(int, dword, dword, int, dword, void*, void*)")
# 呼び出し: WcsCheckColors(hColorTransform, nColors, nInputChannels, cdtInput, cbInput, pInputData, paResult)
# hColorTransform : INT_PTR -> "int"
# nColors : DWORD -> "dword"
# nInputChannels : DWORD -> "dword"
# cdtInput : COLORDATATYPE -> "int"
# cbInput : DWORD -> "dword"
# pInputData : void* -> "void*"
# paResult : BYTE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "mscms" fn WcsCheckColors(
hColorTransform: isize, // INT_PTR
nColors: u32, // DWORD
nInputChannels: u32, // DWORD
cdtInput: i32, // COLORDATATYPE
cbInput: u32, // DWORD
pInputData: ?*anyopaque, // void*
paResult: [*c]u8 // BYTE* out
) callconv(std.os.windows.WINAPI) i32;proc WcsCheckColors(
hColorTransform: int, # INT_PTR
nColors: uint32, # DWORD
nInputChannels: uint32, # DWORD
cdtInput: int32, # COLORDATATYPE
cbInput: uint32, # DWORD
pInputData: pointer, # void*
paResult: ptr uint8 # BYTE* out
): int32 {.importc: "WcsCheckColors", stdcall, dynlib: "mscms.dll".}pragma(lib, "mscms");
extern(Windows)
int WcsCheckColors(
ptrdiff_t hColorTransform, // INT_PTR
uint nColors, // DWORD
uint nInputChannels, // DWORD
int cdtInput, // COLORDATATYPE
uint cbInput, // DWORD
void* pInputData, // void*
ubyte* paResult // BYTE* out
);ccall((:WcsCheckColors, "mscms.dll"), stdcall, Int32,
(Int, UInt32, UInt32, Int32, UInt32, Ptr{Cvoid}, Ptr{UInt8}),
hColorTransform, nColors, nInputChannels, cdtInput, cbInput, pInputData, paResult)
# hColorTransform : INT_PTR -> Int
# nColors : DWORD -> UInt32
# nInputChannels : DWORD -> UInt32
# cdtInput : COLORDATATYPE -> Int32
# cbInput : DWORD -> UInt32
# pInputData : void* -> Ptr{Cvoid}
# paResult : BYTE* out -> Ptr{UInt8}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WcsCheckColors(
intptr_t hColorTransform,
uint32_t nColors,
uint32_t nInputChannels,
int32_t cdtInput,
uint32_t cbInput,
void* pInputData,
uint8_t* paResult);
]]
local mscms = ffi.load("mscms")
-- mscms.WcsCheckColors(hColorTransform, nColors, nInputChannels, cdtInput, cbInput, pInputData, paResult)
-- hColorTransform : INT_PTR
-- nColors : DWORD
-- nInputChannels : DWORD
-- cdtInput : COLORDATATYPE
-- cbInput : DWORD
-- pInputData : void*
-- paResult : BYTE* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('mscms.dll');
const WcsCheckColors = lib.func('__stdcall', 'WcsCheckColors', 'int32_t', ['intptr_t', 'uint32_t', 'uint32_t', 'int32_t', 'uint32_t', 'void *', 'uint8_t *']);
// WcsCheckColors(hColorTransform, nColors, nInputChannels, cdtInput, cbInput, pInputData, paResult)
// hColorTransform : INT_PTR -> 'intptr_t'
// nColors : DWORD -> 'uint32_t'
// nInputChannels : DWORD -> 'uint32_t'
// cdtInput : COLORDATATYPE -> 'int32_t'
// cbInput : DWORD -> 'uint32_t'
// pInputData : void* -> 'void *'
// paResult : BYTE* out -> 'uint8_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("mscms.dll", {
WcsCheckColors: { parameters: ["isize", "u32", "u32", "i32", "u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.WcsCheckColors(hColorTransform, nColors, nInputChannels, cdtInput, cbInput, pInputData, paResult)
// hColorTransform : INT_PTR -> "isize"
// nColors : DWORD -> "u32"
// nInputChannels : DWORD -> "u32"
// cdtInput : COLORDATATYPE -> "i32"
// cbInput : DWORD -> "u32"
// pInputData : void* -> "pointer"
// paResult : BYTE* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WcsCheckColors(
intptr_t hColorTransform,
uint32_t nColors,
uint32_t nInputChannels,
int32_t cdtInput,
uint32_t cbInput,
void* pInputData,
uint8_t* paResult);
C, "mscms.dll");
// $ffi->WcsCheckColors(hColorTransform, nColors, nInputChannels, cdtInput, cbInput, pInputData, paResult);
// hColorTransform : INT_PTR
// nColors : DWORD
// nInputChannels : DWORD
// cdtInput : COLORDATATYPE
// cbInput : DWORD
// pInputData : void*
// paResult : 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 Mscms extends StdCallLibrary {
Mscms INSTANCE = Native.load("mscms", Mscms.class);
boolean WcsCheckColors(
long hColorTransform, // INT_PTR
int nColors, // DWORD
int nInputChannels, // DWORD
int cdtInput, // COLORDATATYPE
int cbInput, // DWORD
Pointer pInputData, // void*
byte[] paResult // BYTE* out
);
}@[Link("mscms")]
lib Libmscms
fun WcsCheckColors = WcsCheckColors(
hColorTransform : LibC::SSizeT, # INT_PTR
nColors : UInt32, # DWORD
nInputChannels : UInt32, # DWORD
cdtInput : Int32, # COLORDATATYPE
cbInput : UInt32, # DWORD
pInputData : Void*, # void*
paResult : 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 WcsCheckColorsNative = Int32 Function(IntPtr, Uint32, Uint32, Int32, Uint32, Pointer<Void>, Pointer<Uint8>);
typedef WcsCheckColorsDart = int Function(int, int, int, int, int, Pointer<Void>, Pointer<Uint8>);
final WcsCheckColors = DynamicLibrary.open('mscms.dll')
.lookupFunction<WcsCheckColorsNative, WcsCheckColorsDart>('WcsCheckColors');
// hColorTransform : INT_PTR -> IntPtr
// nColors : DWORD -> Uint32
// nInputChannels : DWORD -> Uint32
// cdtInput : COLORDATATYPE -> Int32
// cbInput : DWORD -> Uint32
// pInputData : void* -> Pointer<Void>
// paResult : BYTE* out -> Pointer<Uint8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WcsCheckColors(
hColorTransform: NativeInt; // INT_PTR
nColors: DWORD; // DWORD
nInputChannels: DWORD; // DWORD
cdtInput: Integer; // COLORDATATYPE
cbInput: DWORD; // DWORD
pInputData: Pointer; // void*
paResult: Pointer // BYTE* out
): BOOL; stdcall;
external 'mscms.dll' name 'WcsCheckColors';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WcsCheckColors"
c_WcsCheckColors :: CIntPtr -> Word32 -> Word32 -> Int32 -> Word32 -> Ptr () -> Ptr Word8 -> IO CInt
-- hColorTransform : INT_PTR -> CIntPtr
-- nColors : DWORD -> Word32
-- nInputChannels : DWORD -> Word32
-- cdtInput : COLORDATATYPE -> Int32
-- cbInput : DWORD -> Word32
-- pInputData : void* -> Ptr ()
-- paResult : BYTE* out -> Ptr Word8
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let wcscheckcolors =
foreign "WcsCheckColors"
(intptr_t @-> uint32_t @-> uint32_t @-> int32_t @-> uint32_t @-> (ptr void) @-> (ptr uint8_t) @-> returning int32_t)
(* hColorTransform : INT_PTR -> intptr_t *)
(* nColors : DWORD -> uint32_t *)
(* nInputChannels : DWORD -> uint32_t *)
(* cdtInput : COLORDATATYPE -> int32_t *)
(* cbInput : DWORD -> uint32_t *)
(* pInputData : void* -> (ptr void) *)
(* paResult : BYTE* out -> (ptr uint8_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library mscms (t "mscms.dll"))
(cffi:use-foreign-library mscms)
(cffi:defcfun ("WcsCheckColors" wcs-check-colors :convention :stdcall) :int32
(h-color-transform :int64) ; INT_PTR
(n-colors :uint32) ; DWORD
(n-input-channels :uint32) ; DWORD
(cdt-input :int32) ; COLORDATATYPE
(cb-input :uint32) ; DWORD
(p-input-data :pointer) ; void*
(pa-result :pointer)) ; BYTE* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WcsCheckColors = Win32::API::More->new('mscms',
'BOOL WcsCheckColors(LPARAM hColorTransform, DWORD nColors, DWORD nInputChannels, int cdtInput, DWORD cbInput, LPVOID pInputData, LPVOID paResult)');
# my $ret = $WcsCheckColors->Call($hColorTransform, $nColors, $nInputChannels, $cdtInput, $cbInput, $pInputData, $paResult);
# hColorTransform : INT_PTR -> LPARAM
# nColors : DWORD -> DWORD
# nInputChannels : DWORD -> DWORD
# cdtInput : COLORDATATYPE -> int
# cbInput : DWORD -> DWORD
# pInputData : void* -> LPVOID
# paResult : BYTE* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型