Win32 API 日本語リファレンス
ホームGraphics.GdiPlus › GdipSetImagePalette

GdipSetImagePalette

関数
イメージのカラーパレットを設定する。
DLLgdiplus.dll呼出規約winapi

シグネチャ

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

Status GdipSetImagePalette(
    GpImage* image,
    const ColorPalette* palette
);

パラメーター

名前方向
imageGpImage*inout
paletteColorPalette*in

戻り値の型: Status

各言語での呼び出し定義

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

Status GdipSetImagePalette(
    GpImage* image,
    const ColorPalette* palette
);
[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipSetImagePalette(
    IntPtr image,   // GpImage* in/out
    IntPtr palette   // ColorPalette*
);
<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipSetImagePalette(
    image As IntPtr,   ' GpImage* in/out
    palette As IntPtr   ' ColorPalette*
) As Integer
End Function
' image : GpImage* in/out
' palette : ColorPalette*
Declare PtrSafe Function GdipSetImagePalette Lib "gdiplus" ( _
    ByVal image As LongPtr, _
    ByVal palette As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GdipSetImagePalette = ctypes.windll.gdiplus.GdipSetImagePalette
GdipSetImagePalette.restype = ctypes.c_int
GdipSetImagePalette.argtypes = [
    ctypes.c_void_p,  # image : GpImage* in/out
    ctypes.c_void_p,  # palette : ColorPalette*
]
require 'fiddle'
require 'fiddle/import'

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

var (
	gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
	procGdipSetImagePalette = gdiplus.NewProc("GdipSetImagePalette")
)

// image (GpImage* in/out), palette (ColorPalette*)
r1, _, err := procGdipSetImagePalette.Call(
	uintptr(image),
	uintptr(palette),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // Status
function GdipSetImagePalette(
  image: Pointer;   // GpImage* in/out
  palette: Pointer   // ColorPalette*
): Integer; stdcall;
  external 'gdiplus.dll' name 'GdipSetImagePalette';
result := DllCall("gdiplus\GdipSetImagePalette"
    , "Ptr", image   ; GpImage* in/out
    , "Ptr", palette   ; ColorPalette*
    , "Int")   ; return: Status
●GdipSetImagePalette(image, palette) = DLL("gdiplus.dll", "int GdipSetImagePalette(void*, void*)")
# 呼び出し: GdipSetImagePalette(image, palette)
# image : GpImage* in/out -> "void*"
# palette : ColorPalette* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。