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

HT_Get8BPPFormatPalette

関数
8bppハーフトーン用フォーマットパレットを取得する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

INT HT_Get8BPPFormatPalette(
    PALETTEENTRY* pPaletteEntry,   // optional
    WORD RedGamma,
    WORD GreenGamma,
    WORD BlueGamma
);

パラメーター

名前方向
pPaletteEntryPALETTEENTRY*outoptional
RedGammaWORDin
GreenGammaWORDin
BlueGammaWORDin

戻り値の型: INT

各言語での呼び出し定義

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

INT HT_Get8BPPFormatPalette(
    PALETTEENTRY* pPaletteEntry,   // optional
    WORD RedGamma,
    WORD GreenGamma,
    WORD BlueGamma
);
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern int HT_Get8BPPFormatPalette(
    IntPtr pPaletteEntry,   // PALETTEENTRY* optional, out
    ushort RedGamma,   // WORD
    ushort GreenGamma,   // WORD
    ushort BlueGamma   // WORD
);
<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function HT_Get8BPPFormatPalette(
    pPaletteEntry As IntPtr,   ' PALETTEENTRY* optional, out
    RedGamma As UShort,   ' WORD
    GreenGamma As UShort,   ' WORD
    BlueGamma As UShort   ' WORD
) As Integer
End Function
' pPaletteEntry : PALETTEENTRY* optional, out
' RedGamma : WORD
' GreenGamma : WORD
' BlueGamma : WORD
Declare PtrSafe Function HT_Get8BPPFormatPalette Lib "gdi32" ( _
    ByVal pPaletteEntry As LongPtr, _
    ByVal RedGamma As Integer, _
    ByVal GreenGamma As Integer, _
    ByVal BlueGamma As Integer) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

HT_Get8BPPFormatPalette = ctypes.windll.gdi32.HT_Get8BPPFormatPalette
HT_Get8BPPFormatPalette.restype = ctypes.c_int
HT_Get8BPPFormatPalette.argtypes = [
    ctypes.c_void_p,  # pPaletteEntry : PALETTEENTRY* optional, out
    ctypes.c_ushort,  # RedGamma : WORD
    ctypes.c_ushort,  # GreenGamma : WORD
    ctypes.c_ushort,  # BlueGamma : WORD
]
require 'fiddle'
require 'fiddle/import'

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

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procHT_Get8BPPFormatPalette = gdi32.NewProc("HT_Get8BPPFormatPalette")
)

// pPaletteEntry (PALETTEENTRY* optional, out), RedGamma (WORD), GreenGamma (WORD), BlueGamma (WORD)
r1, _, err := procHT_Get8BPPFormatPalette.Call(
	uintptr(pPaletteEntry),
	uintptr(RedGamma),
	uintptr(GreenGamma),
	uintptr(BlueGamma),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function HT_Get8BPPFormatPalette(
  pPaletteEntry: Pointer;   // PALETTEENTRY* optional, out
  RedGamma: Word;   // WORD
  GreenGamma: Word;   // WORD
  BlueGamma: Word   // WORD
): Integer; stdcall;
  external 'GDI32.dll' name 'HT_Get8BPPFormatPalette';
result := DllCall("GDI32\HT_Get8BPPFormatPalette"
    , "Ptr", pPaletteEntry   ; PALETTEENTRY* optional, out
    , "UShort", RedGamma   ; WORD
    , "UShort", GreenGamma   ; WORD
    , "UShort", BlueGamma   ; WORD
    , "Int")   ; return: INT
●HT_Get8BPPFormatPalette(pPaletteEntry, RedGamma, GreenGamma, BlueGamma) = DLL("GDI32.dll", "int HT_Get8BPPFormatPalette(void*, int, int, int)")
# 呼び出し: HT_Get8BPPFormatPalette(pPaletteEntry, RedGamma, GreenGamma, BlueGamma)
# pPaletteEntry : PALETTEENTRY* optional, out -> "void*"
# RedGamma : WORD -> "int"
# GreenGamma : WORD -> "int"
# BlueGamma : WORD -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。