ホーム › Web.InternetExplorer › ComputeInvCMAP
ComputeInvCMAP
関数カラーパレットから逆カラーマップ変換テーブルを算出する。
シグネチャ
// ImgUtil.dll
#include <windows.h>
HRESULT ComputeInvCMAP(
const RGBQUAD* pRGBColors,
DWORD nColors,
BYTE* pInvTable,
DWORD cbTable
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pRGBColors | RGBQUAD* | in | 逆カラーマップを生成する元となるパレットのRGBQUAD配列へのポインタを指定する。 |
| nColors | DWORD | in | pRGBColors配列に含まれる色数を指定する。 |
| pInvTable | BYTE* | inout | 生成された逆カラーマップを受け取るバッファへのポインタを指定する。 |
| cbTable | DWORD | in | pInvTableバッファのサイズをバイト単位で指定する。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// ImgUtil.dll
#include <windows.h>
HRESULT ComputeInvCMAP(
const RGBQUAD* pRGBColors,
DWORD nColors,
BYTE* pInvTable,
DWORD cbTable
);[DllImport("ImgUtil.dll", ExactSpelling = true)]
static extern int ComputeInvCMAP(
IntPtr pRGBColors, // RGBQUAD*
uint nColors, // DWORD
IntPtr pInvTable, // BYTE* in/out
uint cbTable // DWORD
);<DllImport("ImgUtil.dll", ExactSpelling:=True)>
Public Shared Function ComputeInvCMAP(
pRGBColors As IntPtr, ' RGBQUAD*
nColors As UInteger, ' DWORD
pInvTable As IntPtr, ' BYTE* in/out
cbTable As UInteger ' DWORD
) As Integer
End Function' pRGBColors : RGBQUAD*
' nColors : DWORD
' pInvTable : BYTE* in/out
' cbTable : DWORD
Declare PtrSafe Function ComputeInvCMAP Lib "imgutil" ( _
ByVal pRGBColors As LongPtr, _
ByVal nColors As Long, _
ByVal pInvTable As LongPtr, _
ByVal cbTable As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ComputeInvCMAP = ctypes.windll.imgutil.ComputeInvCMAP
ComputeInvCMAP.restype = ctypes.c_int
ComputeInvCMAP.argtypes = [
ctypes.c_void_p, # pRGBColors : RGBQUAD*
wintypes.DWORD, # nColors : DWORD
ctypes.POINTER(ctypes.c_ubyte), # pInvTable : BYTE* in/out
wintypes.DWORD, # cbTable : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ImgUtil.dll')
ComputeInvCMAP = Fiddle::Function.new(
lib['ComputeInvCMAP'],
[
Fiddle::TYPE_VOIDP, # pRGBColors : RGBQUAD*
-Fiddle::TYPE_INT, # nColors : DWORD
Fiddle::TYPE_VOIDP, # pInvTable : BYTE* in/out
-Fiddle::TYPE_INT, # cbTable : DWORD
],
Fiddle::TYPE_INT)#[link(name = "imgutil")]
extern "system" {
fn ComputeInvCMAP(
pRGBColors: *const RGBQUAD, // RGBQUAD*
nColors: u32, // DWORD
pInvTable: *mut u8, // BYTE* in/out
cbTable: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ImgUtil.dll")]
public static extern int ComputeInvCMAP(IntPtr pRGBColors, uint nColors, IntPtr pInvTable, uint cbTable);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ImgUtil_ComputeInvCMAP' -Namespace Win32 -PassThru
# $api::ComputeInvCMAP(pRGBColors, nColors, pInvTable, cbTable)#uselib "ImgUtil.dll"
#func global ComputeInvCMAP "ComputeInvCMAP" sptr, sptr, sptr, sptr
; ComputeInvCMAP varptr(pRGBColors), nColors, varptr(pInvTable), cbTable ; 戻り値は stat
; pRGBColors : RGBQUAD* -> "sptr"
; nColors : DWORD -> "sptr"
; pInvTable : BYTE* in/out -> "sptr"
; cbTable : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ImgUtil.dll" #cfunc global ComputeInvCMAP "ComputeInvCMAP" var, int, var, int ; res = ComputeInvCMAP(pRGBColors, nColors, pInvTable, cbTable) ; pRGBColors : RGBQUAD* -> "var" ; nColors : DWORD -> "int" ; pInvTable : BYTE* in/out -> "var" ; cbTable : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ImgUtil.dll" #cfunc global ComputeInvCMAP "ComputeInvCMAP" sptr, int, sptr, int ; res = ComputeInvCMAP(varptr(pRGBColors), nColors, varptr(pInvTable), cbTable) ; pRGBColors : RGBQUAD* -> "sptr" ; nColors : DWORD -> "int" ; pInvTable : BYTE* in/out -> "sptr" ; cbTable : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT ComputeInvCMAP(RGBQUAD* pRGBColors, DWORD nColors, BYTE* pInvTable, DWORD cbTable) #uselib "ImgUtil.dll" #cfunc global ComputeInvCMAP "ComputeInvCMAP" var, int, var, int ; res = ComputeInvCMAP(pRGBColors, nColors, pInvTable, cbTable) ; pRGBColors : RGBQUAD* -> "var" ; nColors : DWORD -> "int" ; pInvTable : BYTE* in/out -> "var" ; cbTable : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT ComputeInvCMAP(RGBQUAD* pRGBColors, DWORD nColors, BYTE* pInvTable, DWORD cbTable) #uselib "ImgUtil.dll" #cfunc global ComputeInvCMAP "ComputeInvCMAP" intptr, int, intptr, int ; res = ComputeInvCMAP(varptr(pRGBColors), nColors, varptr(pInvTable), cbTable) ; pRGBColors : RGBQUAD* -> "intptr" ; nColors : DWORD -> "int" ; pInvTable : BYTE* in/out -> "intptr" ; cbTable : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
imgutil = windows.NewLazySystemDLL("ImgUtil.dll")
procComputeInvCMAP = imgutil.NewProc("ComputeInvCMAP")
)
// pRGBColors (RGBQUAD*), nColors (DWORD), pInvTable (BYTE* in/out), cbTable (DWORD)
r1, _, err := procComputeInvCMAP.Call(
uintptr(pRGBColors),
uintptr(nColors),
uintptr(pInvTable),
uintptr(cbTable),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction ComputeInvCMAP(
pRGBColors: Pointer; // RGBQUAD*
nColors: DWORD; // DWORD
pInvTable: Pointer; // BYTE* in/out
cbTable: DWORD // DWORD
): Integer; stdcall;
external 'ImgUtil.dll' name 'ComputeInvCMAP';result := DllCall("ImgUtil\ComputeInvCMAP"
, "Ptr", pRGBColors ; RGBQUAD*
, "UInt", nColors ; DWORD
, "Ptr", pInvTable ; BYTE* in/out
, "UInt", cbTable ; DWORD
, "Int") ; return: HRESULT●ComputeInvCMAP(pRGBColors, nColors, pInvTable, cbTable) = DLL("ImgUtil.dll", "int ComputeInvCMAP(void*, dword, void*, dword)")
# 呼び出し: ComputeInvCMAP(pRGBColors, nColors, pInvTable, cbTable)
# pRGBColors : RGBQUAD* -> "void*"
# nColors : DWORD -> "dword"
# pInvTable : BYTE* in/out -> "void*"
# cbTable : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "imgutil" fn ComputeInvCMAP(
pRGBColors: [*c]RGBQUAD, // RGBQUAD*
nColors: u32, // DWORD
pInvTable: [*c]u8, // BYTE* in/out
cbTable: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc ComputeInvCMAP(
pRGBColors: ptr RGBQUAD, # RGBQUAD*
nColors: uint32, # DWORD
pInvTable: ptr uint8, # BYTE* in/out
cbTable: uint32 # DWORD
): int32 {.importc: "ComputeInvCMAP", stdcall, dynlib: "ImgUtil.dll".}pragma(lib, "imgutil");
extern(Windows)
int ComputeInvCMAP(
RGBQUAD* pRGBColors, // RGBQUAD*
uint nColors, // DWORD
ubyte* pInvTable, // BYTE* in/out
uint cbTable // DWORD
);ccall((:ComputeInvCMAP, "ImgUtil.dll"), stdcall, Int32,
(Ptr{RGBQUAD}, UInt32, Ptr{UInt8}, UInt32),
pRGBColors, nColors, pInvTable, cbTable)
# pRGBColors : RGBQUAD* -> Ptr{RGBQUAD}
# nColors : DWORD -> UInt32
# pInvTable : BYTE* in/out -> Ptr{UInt8}
# cbTable : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t ComputeInvCMAP(
void* pRGBColors,
uint32_t nColors,
uint8_t* pInvTable,
uint32_t cbTable);
]]
local imgutil = ffi.load("imgutil")
-- imgutil.ComputeInvCMAP(pRGBColors, nColors, pInvTable, cbTable)
-- pRGBColors : RGBQUAD*
-- nColors : DWORD
-- pInvTable : BYTE* in/out
-- cbTable : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ImgUtil.dll');
const ComputeInvCMAP = lib.func('__stdcall', 'ComputeInvCMAP', 'int32_t', ['void *', 'uint32_t', 'uint8_t *', 'uint32_t']);
// ComputeInvCMAP(pRGBColors, nColors, pInvTable, cbTable)
// pRGBColors : RGBQUAD* -> 'void *'
// nColors : DWORD -> 'uint32_t'
// pInvTable : BYTE* in/out -> 'uint8_t *'
// cbTable : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ImgUtil.dll", {
ComputeInvCMAP: { parameters: ["pointer", "u32", "pointer", "u32"], result: "i32" },
});
// lib.symbols.ComputeInvCMAP(pRGBColors, nColors, pInvTable, cbTable)
// pRGBColors : RGBQUAD* -> "pointer"
// nColors : DWORD -> "u32"
// pInvTable : BYTE* in/out -> "pointer"
// cbTable : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t ComputeInvCMAP(
void* pRGBColors,
uint32_t nColors,
uint8_t* pInvTable,
uint32_t cbTable);
C, "ImgUtil.dll");
// $ffi->ComputeInvCMAP(pRGBColors, nColors, pInvTable, cbTable);
// pRGBColors : RGBQUAD*
// nColors : DWORD
// pInvTable : BYTE* in/out
// cbTable : DWORD
// 構造体/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 Imgutil extends StdCallLibrary {
Imgutil INSTANCE = Native.load("imgutil", Imgutil.class);
int ComputeInvCMAP(
Pointer pRGBColors, // RGBQUAD*
int nColors, // DWORD
byte[] pInvTable, // BYTE* in/out
int cbTable // DWORD
);
}@[Link("imgutil")]
lib LibImgUtil
fun ComputeInvCMAP = ComputeInvCMAP(
pRGBColors : RGBQUAD*, # RGBQUAD*
nColors : UInt32, # DWORD
pInvTable : UInt8*, # BYTE* in/out
cbTable : UInt32 # DWORD
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ComputeInvCMAPNative = Int32 Function(Pointer<Void>, Uint32, Pointer<Uint8>, Uint32);
typedef ComputeInvCMAPDart = int Function(Pointer<Void>, int, Pointer<Uint8>, int);
final ComputeInvCMAP = DynamicLibrary.open('ImgUtil.dll')
.lookupFunction<ComputeInvCMAPNative, ComputeInvCMAPDart>('ComputeInvCMAP');
// pRGBColors : RGBQUAD* -> Pointer<Void>
// nColors : DWORD -> Uint32
// pInvTable : BYTE* in/out -> Pointer<Uint8>
// cbTable : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ComputeInvCMAP(
pRGBColors: Pointer; // RGBQUAD*
nColors: DWORD; // DWORD
pInvTable: Pointer; // BYTE* in/out
cbTable: DWORD // DWORD
): Integer; stdcall;
external 'ImgUtil.dll' name 'ComputeInvCMAP';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ComputeInvCMAP"
c_ComputeInvCMAP :: Ptr () -> Word32 -> Ptr Word8 -> Word32 -> IO Int32
-- pRGBColors : RGBQUAD* -> Ptr ()
-- nColors : DWORD -> Word32
-- pInvTable : BYTE* in/out -> Ptr Word8
-- cbTable : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let computeinvcmap =
foreign "ComputeInvCMAP"
((ptr void) @-> uint32_t @-> (ptr uint8_t) @-> uint32_t @-> returning int32_t)
(* pRGBColors : RGBQUAD* -> (ptr void) *)
(* nColors : DWORD -> uint32_t *)
(* pInvTable : BYTE* in/out -> (ptr uint8_t) *)
(* cbTable : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library imgutil (t "ImgUtil.dll"))
(cffi:use-foreign-library imgutil)
(cffi:defcfun ("ComputeInvCMAP" compute-inv-cmap :convention :stdcall) :int32
(p-rgbcolors :pointer) ; RGBQUAD*
(n-colors :uint32) ; DWORD
(p-inv-table :pointer) ; BYTE* in/out
(cb-table :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ComputeInvCMAP = Win32::API::More->new('ImgUtil',
'int ComputeInvCMAP(LPVOID pRGBColors, DWORD nColors, LPVOID pInvTable, DWORD cbTable)');
# my $ret = $ComputeInvCMAP->Call($pRGBColors, $nColors, $pInvTable, $cbTable);
# pRGBColors : RGBQUAD* -> LPVOID
# nColors : DWORD -> DWORD
# pInvTable : BYTE* in/out -> LPVOID
# cbTable : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型