ホーム › Graphics.GdiPlus › GdipCreatePen2
GdipCreatePen2
関数指定したブラシ・幅・単位で線描画用のペンを新規作成する。
シグネチャ
// gdiplus.dll
#include <windows.h>
Status GdipCreatePen2(
GpBrush* brush,
FLOAT width,
Unit unit,
GpPen** pen
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| brush | GpBrush* | inout |
| width | FLOAT | in |
| unit | Unit | in |
| pen | GpPen** | inout |
戻り値の型: Status
各言語での呼び出し定義
// gdiplus.dll
#include <windows.h>
Status GdipCreatePen2(
GpBrush* brush,
FLOAT width,
Unit unit,
GpPen** pen
);[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipCreatePen2(
IntPtr brush, // GpBrush* in/out
float width, // FLOAT
int unit, // Unit
IntPtr pen // GpPen** in/out
);<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipCreatePen2(
brush As IntPtr, ' GpBrush* in/out
width As Single, ' FLOAT
unit As Integer, ' Unit
pen As IntPtr ' GpPen** in/out
) As Integer
End Function' brush : GpBrush* in/out
' width : FLOAT
' unit : Unit
' pen : GpPen** in/out
Declare PtrSafe Function GdipCreatePen2 Lib "gdiplus" ( _
ByVal brush As LongPtr, _
ByVal width As Single, _
ByVal unit As Long, _
ByVal pen As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GdipCreatePen2 = ctypes.windll.gdiplus.GdipCreatePen2
GdipCreatePen2.restype = ctypes.c_int
GdipCreatePen2.argtypes = [
ctypes.c_void_p, # brush : GpBrush* in/out
ctypes.c_float, # width : FLOAT
ctypes.c_int, # unit : Unit
ctypes.c_void_p, # pen : GpPen** in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('gdiplus.dll')
GdipCreatePen2 = Fiddle::Function.new(
lib['GdipCreatePen2'],
[
Fiddle::TYPE_VOIDP, # brush : GpBrush* in/out
Fiddle::TYPE_FLOAT, # width : FLOAT
Fiddle::TYPE_INT, # unit : Unit
Fiddle::TYPE_VOIDP, # pen : GpPen** in/out
],
Fiddle::TYPE_INT)#[link(name = "gdiplus")]
extern "system" {
fn GdipCreatePen2(
brush: *mut GpBrush, // GpBrush* in/out
width: f32, // FLOAT
unit: i32, // Unit
pen: *mut *mut GpPen // GpPen** in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("gdiplus.dll")]
public static extern int GdipCreatePen2(IntPtr brush, float width, int unit, IntPtr pen);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipCreatePen2' -Namespace Win32 -PassThru
# $api::GdipCreatePen2(brush, width, unit, pen)#uselib "gdiplus.dll"
#func global GdipCreatePen2 "GdipCreatePen2" sptr, float, sptr, sptr
; GdipCreatePen2 varptr(brush), width, unit, varptr(pen) ; 戻り値は stat
; brush : GpBrush* in/out -> "sptr"
; width : FLOAT -> "float"
; unit : Unit -> "sptr"
; pen : GpPen** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "gdiplus.dll" #cfunc global GdipCreatePen2 "GdipCreatePen2" var, float, int, var ; res = GdipCreatePen2(brush, width, unit, pen) ; brush : GpBrush* in/out -> "var" ; width : FLOAT -> "float" ; unit : Unit -> "int" ; pen : GpPen** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "gdiplus.dll" #cfunc global GdipCreatePen2 "GdipCreatePen2" sptr, float, int, sptr ; res = GdipCreatePen2(varptr(brush), width, unit, varptr(pen)) ; brush : GpBrush* in/out -> "sptr" ; width : FLOAT -> "float" ; unit : Unit -> "int" ; pen : GpPen** in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; Status GdipCreatePen2(GpBrush* brush, FLOAT width, Unit unit, GpPen** pen) #uselib "gdiplus.dll" #cfunc global GdipCreatePen2 "GdipCreatePen2" var, float, int, var ; res = GdipCreatePen2(brush, width, unit, pen) ; brush : GpBrush* in/out -> "var" ; width : FLOAT -> "float" ; unit : Unit -> "int" ; pen : GpPen** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; Status GdipCreatePen2(GpBrush* brush, FLOAT width, Unit unit, GpPen** pen) #uselib "gdiplus.dll" #cfunc global GdipCreatePen2 "GdipCreatePen2" intptr, float, int, intptr ; res = GdipCreatePen2(varptr(brush), width, unit, varptr(pen)) ; brush : GpBrush* in/out -> "intptr" ; width : FLOAT -> "float" ; unit : Unit -> "int" ; pen : GpPen** in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"math"
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
procGdipCreatePen2 = gdiplus.NewProc("GdipCreatePen2")
)
// brush (GpBrush* in/out), width (FLOAT), unit (Unit), pen (GpPen** in/out)
r1, _, err := procGdipCreatePen2.Call(
uintptr(brush),
uintptr(math.Float32bits(width)),
uintptr(unit),
uintptr(pen),
)
_ = 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 GdipCreatePen2(
brush: Pointer; // GpBrush* in/out
width: Single; // FLOAT
unit: Integer; // Unit
pen: Pointer // GpPen** in/out
): Integer; stdcall;
external 'gdiplus.dll' name 'GdipCreatePen2';result := DllCall("gdiplus\GdipCreatePen2"
, "Ptr", brush ; GpBrush* in/out
, "Float", width ; FLOAT
, "Int", unit ; Unit
, "Ptr", pen ; GpPen** in/out
, "Int") ; return: Status●GdipCreatePen2(brush, width, unit, pen) = DLL("gdiplus.dll", "int GdipCreatePen2(void*, float, int, void*)")
# 呼び出し: GdipCreatePen2(brush, width, unit, pen)
# brush : GpBrush* in/out -> "void*"
# width : FLOAT -> "float"
# unit : Unit -> "int"
# pen : GpPen** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。