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

GdipBitmapConvertFormat

関数
ビットマップを指定したピクセル形式に変換する。
DLLgdiplus.dll呼出規約winapi

シグネチャ

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

Status GdipBitmapConvertFormat(
    GpBitmap* pInputBitmap,
    INT format,
    DitherType dithertype,
    PaletteType palettetype,
    ColorPalette* palette,
    FLOAT alphaThresholdPercent
);

パラメーター

名前方向
pInputBitmapGpBitmap*inout
formatINTin
dithertypeDitherTypein
palettetypePaletteTypein
paletteColorPalette*inout
alphaThresholdPercentFLOATin

戻り値の型: Status

各言語での呼び出し定義

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

Status GdipBitmapConvertFormat(
    GpBitmap* pInputBitmap,
    INT format,
    DitherType dithertype,
    PaletteType palettetype,
    ColorPalette* palette,
    FLOAT alphaThresholdPercent
);
[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipBitmapConvertFormat(
    IntPtr pInputBitmap,   // GpBitmap* in/out
    int format,   // INT
    int dithertype,   // DitherType
    int palettetype,   // PaletteType
    IntPtr palette,   // ColorPalette* in/out
    float alphaThresholdPercent   // FLOAT
);
<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipBitmapConvertFormat(
    pInputBitmap As IntPtr,   ' GpBitmap* in/out
    format As Integer,   ' INT
    dithertype As Integer,   ' DitherType
    palettetype As Integer,   ' PaletteType
    palette As IntPtr,   ' ColorPalette* in/out
    alphaThresholdPercent As Single   ' FLOAT
) As Integer
End Function
' pInputBitmap : GpBitmap* in/out
' format : INT
' dithertype : DitherType
' palettetype : PaletteType
' palette : ColorPalette* in/out
' alphaThresholdPercent : FLOAT
Declare PtrSafe Function GdipBitmapConvertFormat Lib "gdiplus" ( _
    ByVal pInputBitmap As LongPtr, _
    ByVal format As Long, _
    ByVal dithertype As Long, _
    ByVal palettetype As Long, _
    ByVal palette As LongPtr, _
    ByVal alphaThresholdPercent As Single) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GdipBitmapConvertFormat = ctypes.windll.gdiplus.GdipBitmapConvertFormat
GdipBitmapConvertFormat.restype = ctypes.c_int
GdipBitmapConvertFormat.argtypes = [
    ctypes.c_void_p,  # pInputBitmap : GpBitmap* in/out
    ctypes.c_int,  # format : INT
    ctypes.c_int,  # dithertype : DitherType
    ctypes.c_int,  # palettetype : PaletteType
    ctypes.c_void_p,  # palette : ColorPalette* in/out
    ctypes.c_float,  # alphaThresholdPercent : FLOAT
]
require 'fiddle'
require 'fiddle/import'

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

var (
	gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
	procGdipBitmapConvertFormat = gdiplus.NewProc("GdipBitmapConvertFormat")
)

// pInputBitmap (GpBitmap* in/out), format (INT), dithertype (DitherType), palettetype (PaletteType), palette (ColorPalette* in/out), alphaThresholdPercent (FLOAT)
r1, _, err := procGdipBitmapConvertFormat.Call(
	uintptr(pInputBitmap),
	uintptr(format),
	uintptr(dithertype),
	uintptr(palettetype),
	uintptr(palette),
	uintptr(math.Float32bits(alphaThresholdPercent)),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // Status
// 注意: float/double 引数は proc.Call では XMM レジスタに渡せません。
// windows.SyscallN(proc.Addr(), math.Float64bits(x), ...) もしくは cgo を使用してください。
function GdipBitmapConvertFormat(
  pInputBitmap: Pointer;   // GpBitmap* in/out
  format: Integer;   // INT
  dithertype: Integer;   // DitherType
  palettetype: Integer;   // PaletteType
  palette: Pointer;   // ColorPalette* in/out
  alphaThresholdPercent: Single   // FLOAT
): Integer; stdcall;
  external 'gdiplus.dll' name 'GdipBitmapConvertFormat';
result := DllCall("gdiplus\GdipBitmapConvertFormat"
    , "Ptr", pInputBitmap   ; GpBitmap* in/out
    , "Int", format   ; INT
    , "Int", dithertype   ; DitherType
    , "Int", palettetype   ; PaletteType
    , "Ptr", palette   ; ColorPalette* in/out
    , "Float", alphaThresholdPercent   ; FLOAT
    , "Int")   ; return: Status
●GdipBitmapConvertFormat(pInputBitmap, format, dithertype, palettetype, palette, alphaThresholdPercent) = DLL("gdiplus.dll", "int GdipBitmapConvertFormat(void*, int, int, int, void*, float)")
# 呼び出し: GdipBitmapConvertFormat(pInputBitmap, format, dithertype, palettetype, palette, alphaThresholdPercent)
# pInputBitmap : GpBitmap* in/out -> "void*"
# format : INT -> "int"
# dithertype : DitherType -> "int"
# palettetype : PaletteType -> "int"
# palette : ColorPalette* in/out -> "void*"
# alphaThresholdPercent : FLOAT -> "float"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。