Win32 API 日本語リファレンス
ホームWeb.InternetExplorer › ComputeInvCMAP

ComputeInvCMAP

関数
カラーパレットから逆カラーマップ変換テーブルを算出する。
DLLImgUtil.dll呼出規約winapi

シグネチャ

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

HRESULT ComputeInvCMAP(
    const RGBQUAD* pRGBColors,
    DWORD nColors,
    BYTE* pInvTable,
    DWORD cbTable
);

パラメーター

名前方向
pRGBColorsRGBQUAD*in
nColorsDWORDin
pInvTableBYTE*inout
cbTableDWORDin

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