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

GdipSetImageAttributesThreshold

関数
画像属性にしきい値による二値化変換を設定する。
DLLgdiplus.dll呼出規約winapi

シグネチャ

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

Status GdipSetImageAttributesThreshold(
    GpImageAttributes* imageattr,
    ColorAdjustType type,
    BOOL enableFlag,
    FLOAT threshold
);

パラメーター

名前方向
imageattrGpImageAttributes*inout
typeColorAdjustTypein
enableFlagBOOLin
thresholdFLOATin

戻り値の型: Status

各言語での呼び出し定義

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

Status GdipSetImageAttributesThreshold(
    GpImageAttributes* imageattr,
    ColorAdjustType type,
    BOOL enableFlag,
    FLOAT threshold
);
[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipSetImageAttributesThreshold(
    IntPtr imageattr,   // GpImageAttributes* in/out
    int type,   // ColorAdjustType
    bool enableFlag,   // BOOL
    float threshold   // FLOAT
);
<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipSetImageAttributesThreshold(
    imageattr As IntPtr,   ' GpImageAttributes* in/out
    type As Integer,   ' ColorAdjustType
    enableFlag As Boolean,   ' BOOL
    threshold As Single   ' FLOAT
) As Integer
End Function
' imageattr : GpImageAttributes* in/out
' type : ColorAdjustType
' enableFlag : BOOL
' threshold : FLOAT
Declare PtrSafe Function GdipSetImageAttributesThreshold Lib "gdiplus" ( _
    ByVal imageattr As LongPtr, _
    ByVal type As Long, _
    ByVal enableFlag As Long, _
    ByVal threshold As Single) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GdipSetImageAttributesThreshold = ctypes.windll.gdiplus.GdipSetImageAttributesThreshold
GdipSetImageAttributesThreshold.restype = ctypes.c_int
GdipSetImageAttributesThreshold.argtypes = [
    ctypes.c_void_p,  # imageattr : GpImageAttributes* in/out
    ctypes.c_int,  # type : ColorAdjustType
    wintypes.BOOL,  # enableFlag : BOOL
    ctypes.c_float,  # threshold : FLOAT
]
require 'fiddle'
require 'fiddle/import'

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

var (
	gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
	procGdipSetImageAttributesThreshold = gdiplus.NewProc("GdipSetImageAttributesThreshold")
)

// imageattr (GpImageAttributes* in/out), type (ColorAdjustType), enableFlag (BOOL), threshold (FLOAT)
r1, _, err := procGdipSetImageAttributesThreshold.Call(
	uintptr(imageattr),
	uintptr(type),
	uintptr(enableFlag),
	uintptr(math.Float32bits(threshold)),
)
_ = 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 GdipSetImageAttributesThreshold(
  imageattr: Pointer;   // GpImageAttributes* in/out
  type: Integer;   // ColorAdjustType
  enableFlag: BOOL;   // BOOL
  threshold: Single   // FLOAT
): Integer; stdcall;
  external 'gdiplus.dll' name 'GdipSetImageAttributesThreshold';
result := DllCall("gdiplus\GdipSetImageAttributesThreshold"
    , "Ptr", imageattr   ; GpImageAttributes* in/out
    , "Int", type   ; ColorAdjustType
    , "Int", enableFlag   ; BOOL
    , "Float", threshold   ; FLOAT
    , "Int")   ; return: Status
●GdipSetImageAttributesThreshold(imageattr, type, enableFlag, threshold) = DLL("gdiplus.dll", "int GdipSetImageAttributesThreshold(void*, int, bool, float)")
# 呼び出し: GdipSetImageAttributesThreshold(imageattr, type, enableFlag, threshold)
# imageattr : GpImageAttributes* in/out -> "void*"
# type : ColorAdjustType -> "int"
# enableFlag : BOOL -> "bool"
# threshold : FLOAT -> "float"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。