ホーム › Graphics.GdiPlus › GdipBitmapConvertFormat
GdipBitmapConvertFormat
関数ビットマップを指定したピクセル形式に変換する。
シグネチャ
// gdiplus.dll
#include <windows.h>
Status GdipBitmapConvertFormat(
GpBitmap* pInputBitmap,
INT format,
DitherType dithertype,
PaletteType palettetype,
ColorPalette* palette,
FLOAT alphaThresholdPercent
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pInputBitmap | GpBitmap* | inout | 形式変換を行う対象のGpBitmapオブジェクトへのポインタ。 |
| format | INT | in | 変換後のピクセル形式を表すPixelFormat値。 |
| dithertype | DitherType | in | 減色時に用いるディザリング方法を示すDitherType列挙値。 |
| palettetype | PaletteType | in | 生成または使用するパレット種別を示すPaletteType列挙値。 |
| palette | ColorPalette* | inout | 変換に用いるカラーパレット構造体へのポインタ。 |
| alphaThresholdPercent | FLOAT | in | アルファを透明/不透明に二値化する閾値(0〜100%)。 |
戻り値の型: 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 方式にも切替可。#uselib "gdiplus.dll" #cfunc global GdipBitmapConvertFormat "GdipBitmapConvertFormat" sptr, int, int, int, sptr, float ; res = GdipBitmapConvertFormat(varptr(pInputBitmap), format, dithertype, palettetype, varptr(palette), alphaThresholdPercent) ; pInputBitmap : GpBitmap* in/out -> "sptr" ; format : INT -> "int" ; dithertype : DitherType -> "int" ; palettetype : PaletteType -> "int" ; palette : ColorPalette* in/out -> "sptr" ; alphaThresholdPercent : FLOAT -> "float" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; Status GdipBitmapConvertFormat(GpBitmap* pInputBitmap, INT format, DitherType dithertype, PaletteType palettetype, ColorPalette* palette, FLOAT alphaThresholdPercent) #uselib "gdiplus.dll" #cfunc global GdipBitmapConvertFormat "GdipBitmapConvertFormat" intptr, int, int, int, intptr, float ; res = GdipBitmapConvertFormat(varptr(pInputBitmap), format, dithertype, palettetype, varptr(palette), alphaThresholdPercent) ; pInputBitmap : GpBitmap* in/out -> "intptr" ; format : INT -> "int" ; dithertype : DitherType -> "int" ; palettetype : PaletteType -> "int" ; palette : ColorPalette* in/out -> "intptr" ; alphaThresholdPercent : FLOAT -> "float" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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)。const std = @import("std");
extern "gdiplus" fn GdipBitmapConvertFormat(
pInputBitmap: [*c]GpBitmap, // GpBitmap* in/out
format: i32, // INT
dithertype: i32, // DitherType
palettetype: i32, // PaletteType
palette: [*c]ColorPalette, // ColorPalette* in/out
alphaThresholdPercent: f32 // FLOAT
) callconv(std.os.windows.WINAPI) i32;proc GdipBitmapConvertFormat(
pInputBitmap: ptr GpBitmap, # GpBitmap* in/out
format: int32, # INT
dithertype: int32, # DitherType
palettetype: int32, # PaletteType
palette: ptr ColorPalette, # ColorPalette* in/out
alphaThresholdPercent: float32 # FLOAT
): int32 {.importc: "GdipBitmapConvertFormat", stdcall, dynlib: "gdiplus.dll".}pragma(lib, "gdiplus");
extern(Windows)
int GdipBitmapConvertFormat(
GpBitmap* pInputBitmap, // GpBitmap* in/out
int format, // INT
int dithertype, // DitherType
int palettetype, // PaletteType
ColorPalette* palette, // ColorPalette* in/out
float alphaThresholdPercent // FLOAT
);ccall((:GdipBitmapConvertFormat, "gdiplus.dll"), stdcall, Int32,
(Ptr{GpBitmap}, Int32, Int32, Int32, Ptr{ColorPalette}, Float32),
pInputBitmap, format, dithertype, palettetype, palette, alphaThresholdPercent)
# pInputBitmap : GpBitmap* in/out -> Ptr{GpBitmap}
# format : INT -> Int32
# dithertype : DitherType -> Int32
# palettetype : PaletteType -> Int32
# palette : ColorPalette* in/out -> Ptr{ColorPalette}
# alphaThresholdPercent : FLOAT -> Float32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t GdipBitmapConvertFormat(
void* pInputBitmap,
int32_t format,
int32_t dithertype,
int32_t palettetype,
void* palette,
float alphaThresholdPercent);
]]
local gdiplus = ffi.load("gdiplus")
-- gdiplus.GdipBitmapConvertFormat(pInputBitmap, format, dithertype, palettetype, palette, alphaThresholdPercent)
-- pInputBitmap : GpBitmap* in/out
-- format : INT
-- dithertype : DitherType
-- palettetype : PaletteType
-- palette : ColorPalette* in/out
-- alphaThresholdPercent : FLOAT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('gdiplus.dll');
const GdipBitmapConvertFormat = lib.func('__stdcall', 'GdipBitmapConvertFormat', 'int32_t', ['void *', 'int32_t', 'int32_t', 'int32_t', 'void *', 'float']);
// GdipBitmapConvertFormat(pInputBitmap, format, dithertype, palettetype, palette, alphaThresholdPercent)
// pInputBitmap : GpBitmap* in/out -> 'void *'
// format : INT -> 'int32_t'
// dithertype : DitherType -> 'int32_t'
// palettetype : PaletteType -> 'int32_t'
// palette : ColorPalette* in/out -> 'void *'
// alphaThresholdPercent : FLOAT -> 'float'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("gdiplus.dll", {
GdipBitmapConvertFormat: { parameters: ["pointer", "i32", "i32", "i32", "pointer", "f32"], result: "i32" },
});
// lib.symbols.GdipBitmapConvertFormat(pInputBitmap, format, dithertype, palettetype, palette, alphaThresholdPercent)
// pInputBitmap : GpBitmap* in/out -> "pointer"
// format : INT -> "i32"
// dithertype : DitherType -> "i32"
// palettetype : PaletteType -> "i32"
// palette : ColorPalette* in/out -> "pointer"
// alphaThresholdPercent : FLOAT -> "f32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GdipBitmapConvertFormat(
void* pInputBitmap,
int32_t format,
int32_t dithertype,
int32_t palettetype,
void* palette,
float alphaThresholdPercent);
C, "gdiplus.dll");
// $ffi->GdipBitmapConvertFormat(pInputBitmap, format, dithertype, palettetype, palette, alphaThresholdPercent);
// pInputBitmap : GpBitmap* in/out
// format : INT
// dithertype : DitherType
// palettetype : PaletteType
// palette : ColorPalette* in/out
// alphaThresholdPercent : FLOAT
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Gdiplus extends StdCallLibrary {
Gdiplus INSTANCE = Native.load("gdiplus", Gdiplus.class);
int GdipBitmapConvertFormat(
Pointer pInputBitmap, // GpBitmap* in/out
int format, // INT
int dithertype, // DitherType
int palettetype, // PaletteType
Pointer palette, // ColorPalette* in/out
float alphaThresholdPercent // FLOAT
);
}@[Link("gdiplus")]
lib Libgdiplus
fun GdipBitmapConvertFormat = GdipBitmapConvertFormat(
pInputBitmap : GpBitmap*, # GpBitmap* in/out
format : Int32, # INT
dithertype : Int32, # DitherType
palettetype : Int32, # PaletteType
palette : ColorPalette*, # ColorPalette* in/out
alphaThresholdPercent : Float32 # FLOAT
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GdipBitmapConvertFormatNative = Int32 Function(Pointer<Void>, Int32, Int32, Int32, Pointer<Void>, Float);
typedef GdipBitmapConvertFormatDart = int Function(Pointer<Void>, int, int, int, Pointer<Void>, double);
final GdipBitmapConvertFormat = DynamicLibrary.open('gdiplus.dll')
.lookupFunction<GdipBitmapConvertFormatNative, GdipBitmapConvertFormatDart>('GdipBitmapConvertFormat');
// pInputBitmap : GpBitmap* in/out -> Pointer<Void>
// format : INT -> Int32
// dithertype : DitherType -> Int32
// palettetype : PaletteType -> Int32
// palette : ColorPalette* in/out -> Pointer<Void>
// alphaThresholdPercent : FLOAT -> Float
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GdipBitmapConvertFormat"
c_GdipBitmapConvertFormat :: Ptr () -> Int32 -> Int32 -> Int32 -> Ptr () -> CFloat -> IO Int32
-- pInputBitmap : GpBitmap* in/out -> Ptr ()
-- format : INT -> Int32
-- dithertype : DitherType -> Int32
-- palettetype : PaletteType -> Int32
-- palette : ColorPalette* in/out -> Ptr ()
-- alphaThresholdPercent : FLOAT -> CFloat
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let gdipbitmapconvertformat =
foreign "GdipBitmapConvertFormat"
((ptr void) @-> int32_t @-> int32_t @-> int32_t @-> (ptr void) @-> float @-> returning int32_t)
(* pInputBitmap : GpBitmap* in/out -> (ptr void) *)
(* format : INT -> int32_t *)
(* dithertype : DitherType -> int32_t *)
(* palettetype : PaletteType -> int32_t *)
(* palette : ColorPalette* in/out -> (ptr void) *)
(* alphaThresholdPercent : FLOAT -> float *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library gdiplus (t "gdiplus.dll"))
(cffi:use-foreign-library gdiplus)
(cffi:defcfun ("GdipBitmapConvertFormat" gdip-bitmap-convert-format :convention :stdcall) :int32
(p-input-bitmap :pointer) ; GpBitmap* in/out
(format :int32) ; INT
(dithertype :int32) ; DitherType
(palettetype :int32) ; PaletteType
(palette :pointer) ; ColorPalette* in/out
(alpha-threshold-percent :float)) ; FLOAT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GdipBitmapConvertFormat = Win32::API::More->new('gdiplus',
'int GdipBitmapConvertFormat(LPVOID pInputBitmap, int format, int dithertype, int palettetype, LPVOID palette, float alphaThresholdPercent)');
# my $ret = $GdipBitmapConvertFormat->Call($pInputBitmap, $format, $dithertype, $palettetype, $palette, $alphaThresholdPercent);
# pInputBitmap : GpBitmap* in/out -> LPVOID
# format : INT -> int
# dithertype : DitherType -> int
# palettetype : PaletteType -> int
# palette : ColorPalette* in/out -> LPVOID
# alphaThresholdPercent : FLOAT -> float
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。