Win32 API 日本語リファレンス
ホームDevices.Display › XLATEOBJ_cGetPalette

XLATEOBJ_cGetPalette

関数
色変換オブジェクトからパレット情報を取得する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

DWORD XLATEOBJ_cGetPalette(
    XLATEOBJ* pxlo,
    DWORD iPal,
    DWORD cPal,
    DWORD* pPal
);

パラメーター

名前方向説明
pxloXLATEOBJ*inoutパレットを取得するXLATEOBJ構造体へのポインター。
iPalDWORDin取得するパレット種別(XO_SRCPALETTE/XO_DESTPALETTE等)を示す値。
cPalDWORDin取得するパレットエントリの数。
pPalDWORD*inoutパレットエントリ(RGB値)を受け取る配列へのポインター。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD XLATEOBJ_cGetPalette(
    XLATEOBJ* pxlo,
    DWORD iPal,
    DWORD cPal,
    DWORD* pPal
);
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern uint XLATEOBJ_cGetPalette(
    IntPtr pxlo,   // XLATEOBJ* in/out
    uint iPal,   // DWORD
    uint cPal,   // DWORD
    ref uint pPal   // DWORD* in/out
);
<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function XLATEOBJ_cGetPalette(
    pxlo As IntPtr,   ' XLATEOBJ* in/out
    iPal As UInteger,   ' DWORD
    cPal As UInteger,   ' DWORD
    ByRef pPal As UInteger   ' DWORD* in/out
) As UInteger
End Function
' pxlo : XLATEOBJ* in/out
' iPal : DWORD
' cPal : DWORD
' pPal : DWORD* in/out
Declare PtrSafe Function XLATEOBJ_cGetPalette Lib "gdi32" ( _
    ByVal pxlo As LongPtr, _
    ByVal iPal As Long, _
    ByVal cPal As Long, _
    ByRef pPal As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

XLATEOBJ_cGetPalette = ctypes.windll.gdi32.XLATEOBJ_cGetPalette
XLATEOBJ_cGetPalette.restype = wintypes.DWORD
XLATEOBJ_cGetPalette.argtypes = [
    ctypes.c_void_p,  # pxlo : XLATEOBJ* in/out
    wintypes.DWORD,  # iPal : DWORD
    wintypes.DWORD,  # cPal : DWORD
    ctypes.POINTER(wintypes.DWORD),  # pPal : DWORD* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
XLATEOBJ_cGetPalette = Fiddle::Function.new(
  lib['XLATEOBJ_cGetPalette'],
  [
    Fiddle::TYPE_VOIDP,  # pxlo : XLATEOBJ* in/out
    -Fiddle::TYPE_INT,  # iPal : DWORD
    -Fiddle::TYPE_INT,  # cPal : DWORD
    Fiddle::TYPE_VOIDP,  # pPal : DWORD* in/out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "gdi32")]
extern "system" {
    fn XLATEOBJ_cGetPalette(
        pxlo: *mut XLATEOBJ,  // XLATEOBJ* in/out
        iPal: u32,  // DWORD
        cPal: u32,  // DWORD
        pPal: *mut u32  // DWORD* in/out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("GDI32.dll")]
public static extern uint XLATEOBJ_cGetPalette(IntPtr pxlo, uint iPal, uint cPal, ref uint pPal);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_XLATEOBJ_cGetPalette' -Namespace Win32 -PassThru
# $api::XLATEOBJ_cGetPalette(pxlo, iPal, cPal, pPal)
#uselib "GDI32.dll"
#func global XLATEOBJ_cGetPalette "XLATEOBJ_cGetPalette" sptr, sptr, sptr, sptr
; XLATEOBJ_cGetPalette varptr(pxlo), iPal, cPal, varptr(pPal)   ; 戻り値は stat
; pxlo : XLATEOBJ* in/out -> "sptr"
; iPal : DWORD -> "sptr"
; cPal : DWORD -> "sptr"
; pPal : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "GDI32.dll"
#cfunc global XLATEOBJ_cGetPalette "XLATEOBJ_cGetPalette" var, int, int, var
; res = XLATEOBJ_cGetPalette(pxlo, iPal, cPal, pPal)
; pxlo : XLATEOBJ* in/out -> "var"
; iPal : DWORD -> "int"
; cPal : DWORD -> "int"
; pPal : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD XLATEOBJ_cGetPalette(XLATEOBJ* pxlo, DWORD iPal, DWORD cPal, DWORD* pPal)
#uselib "GDI32.dll"
#cfunc global XLATEOBJ_cGetPalette "XLATEOBJ_cGetPalette" var, int, int, var
; res = XLATEOBJ_cGetPalette(pxlo, iPal, cPal, pPal)
; pxlo : XLATEOBJ* in/out -> "var"
; iPal : DWORD -> "int"
; cPal : DWORD -> "int"
; pPal : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procXLATEOBJ_cGetPalette = gdi32.NewProc("XLATEOBJ_cGetPalette")
)

// pxlo (XLATEOBJ* in/out), iPal (DWORD), cPal (DWORD), pPal (DWORD* in/out)
r1, _, err := procXLATEOBJ_cGetPalette.Call(
	uintptr(pxlo),
	uintptr(iPal),
	uintptr(cPal),
	uintptr(pPal),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function XLATEOBJ_cGetPalette(
  pxlo: Pointer;   // XLATEOBJ* in/out
  iPal: DWORD;   // DWORD
  cPal: DWORD;   // DWORD
  pPal: Pointer   // DWORD* in/out
): DWORD; stdcall;
  external 'GDI32.dll' name 'XLATEOBJ_cGetPalette';
result := DllCall("GDI32\XLATEOBJ_cGetPalette"
    , "Ptr", pxlo   ; XLATEOBJ* in/out
    , "UInt", iPal   ; DWORD
    , "UInt", cPal   ; DWORD
    , "Ptr", pPal   ; DWORD* in/out
    , "UInt")   ; return: DWORD
●XLATEOBJ_cGetPalette(pxlo, iPal, cPal, pPal) = DLL("GDI32.dll", "dword XLATEOBJ_cGetPalette(void*, dword, dword, void*)")
# 呼び出し: XLATEOBJ_cGetPalette(pxlo, iPal, cPal, pPal)
# pxlo : XLATEOBJ* in/out -> "void*"
# iPal : DWORD -> "dword"
# cPal : DWORD -> "dword"
# pPal : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。