ホーム › Graphics.GdiPlus › GdipCreatePen1
GdipCreatePen1
関数指定した色・幅・単位で線描画用のペンを新規作成する。
シグネチャ
// gdiplus.dll
#include <windows.h>
Status GdipCreatePen1(
DWORD color,
FLOAT width,
Unit unit,
GpPen** pen
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| color | DWORD | in | ペンの線色をARGB形式で指定するDWORD。 |
| width | FLOAT | in | ペンの線幅をunit単位で指定するFLOAT。 |
| unit | Unit | in | widthの測定単位を示すUnit列挙値。 |
| pen | GpPen** | inout | 生成されたペンオブジェクトを受け取るGpPen**。 |
戻り値の型: Status
各言語での呼び出し定義
// gdiplus.dll
#include <windows.h>
Status GdipCreatePen1(
DWORD color,
FLOAT width,
Unit unit,
GpPen** pen
);[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipCreatePen1(
uint color, // DWORD
float width, // FLOAT
int unit, // Unit
IntPtr pen // GpPen** in/out
);<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipCreatePen1(
color As UInteger, ' DWORD
width As Single, ' FLOAT
unit As Integer, ' Unit
pen As IntPtr ' GpPen** in/out
) As Integer
End Function' color : DWORD
' width : FLOAT
' unit : Unit
' pen : GpPen** in/out
Declare PtrSafe Function GdipCreatePen1 Lib "gdiplus" ( _
ByVal color As Long, _
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
GdipCreatePen1 = ctypes.windll.gdiplus.GdipCreatePen1
GdipCreatePen1.restype = ctypes.c_int
GdipCreatePen1.argtypes = [
wintypes.DWORD, # color : DWORD
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')
GdipCreatePen1 = Fiddle::Function.new(
lib['GdipCreatePen1'],
[
-Fiddle::TYPE_INT, # color : DWORD
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 GdipCreatePen1(
color: u32, // DWORD
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 GdipCreatePen1(uint color, float width, int unit, IntPtr pen);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipCreatePen1' -Namespace Win32 -PassThru
# $api::GdipCreatePen1(color, width, unit, pen)#uselib "gdiplus.dll"
#func global GdipCreatePen1 "GdipCreatePen1" sptr, float, sptr, sptr
; GdipCreatePen1 color, width, unit, varptr(pen) ; 戻り値は stat
; color : DWORD -> "sptr"
; width : FLOAT -> "float"
; unit : Unit -> "sptr"
; pen : GpPen** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "gdiplus.dll" #cfunc global GdipCreatePen1 "GdipCreatePen1" int, float, int, var ; res = GdipCreatePen1(color, width, unit, pen) ; color : DWORD -> "int" ; width : FLOAT -> "float" ; unit : Unit -> "int" ; pen : GpPen** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "gdiplus.dll" #cfunc global GdipCreatePen1 "GdipCreatePen1" int, float, int, sptr ; res = GdipCreatePen1(color, width, unit, varptr(pen)) ; color : DWORD -> "int" ; width : FLOAT -> "float" ; unit : Unit -> "int" ; pen : GpPen** in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; Status GdipCreatePen1(DWORD color, FLOAT width, Unit unit, GpPen** pen) #uselib "gdiplus.dll" #cfunc global GdipCreatePen1 "GdipCreatePen1" int, float, int, var ; res = GdipCreatePen1(color, width, unit, pen) ; color : DWORD -> "int" ; width : FLOAT -> "float" ; unit : Unit -> "int" ; pen : GpPen** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; Status GdipCreatePen1(DWORD color, FLOAT width, Unit unit, GpPen** pen) #uselib "gdiplus.dll" #cfunc global GdipCreatePen1 "GdipCreatePen1" int, float, int, intptr ; res = GdipCreatePen1(color, width, unit, varptr(pen)) ; color : DWORD -> "int" ; 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")
procGdipCreatePen1 = gdiplus.NewProc("GdipCreatePen1")
)
// color (DWORD), width (FLOAT), unit (Unit), pen (GpPen** in/out)
r1, _, err := procGdipCreatePen1.Call(
uintptr(color),
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 GdipCreatePen1(
color: DWORD; // DWORD
width: Single; // FLOAT
unit: Integer; // Unit
pen: Pointer // GpPen** in/out
): Integer; stdcall;
external 'gdiplus.dll' name 'GdipCreatePen1';result := DllCall("gdiplus\GdipCreatePen1"
, "UInt", color ; DWORD
, "Float", width ; FLOAT
, "Int", unit ; Unit
, "Ptr", pen ; GpPen** in/out
, "Int") ; return: Status●GdipCreatePen1(color, width, unit, pen) = DLL("gdiplus.dll", "int GdipCreatePen1(dword, float, int, void*)")
# 呼び出し: GdipCreatePen1(color, width, unit, pen)
# color : DWORD -> "dword"
# width : FLOAT -> "float"
# unit : Unit -> "int"
# pen : GpPen** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "gdiplus" fn GdipCreatePen1(
color: u32, // DWORD
width: f32, // FLOAT
unit: i32, // Unit
pen: [*c][*c]GpPen // GpPen** in/out
) callconv(std.os.windows.WINAPI) i32;proc GdipCreatePen1(
color: uint32, # DWORD
width: float32, # FLOAT
unit: int32, # Unit
pen: ptr GpPen # GpPen** in/out
): int32 {.importc: "GdipCreatePen1", stdcall, dynlib: "gdiplus.dll".}pragma(lib, "gdiplus");
extern(Windows)
int GdipCreatePen1(
uint color, // DWORD
float width, // FLOAT
int unit, // Unit
GpPen** pen // GpPen** in/out
);ccall((:GdipCreatePen1, "gdiplus.dll"), stdcall, Int32,
(UInt32, Float32, Int32, Ptr{GpPen}),
color, width, unit, pen)
# color : DWORD -> UInt32
# width : FLOAT -> Float32
# unit : Unit -> Int32
# pen : GpPen** in/out -> Ptr{GpPen}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t GdipCreatePen1(
uint32_t color,
float width,
int32_t unit,
void* pen);
]]
local gdiplus = ffi.load("gdiplus")
-- gdiplus.GdipCreatePen1(color, width, unit, pen)
-- color : DWORD
-- width : FLOAT
-- unit : Unit
-- pen : GpPen** in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('gdiplus.dll');
const GdipCreatePen1 = lib.func('__stdcall', 'GdipCreatePen1', 'int32_t', ['uint32_t', 'float', 'int32_t', 'void *']);
// GdipCreatePen1(color, width, unit, pen)
// color : DWORD -> 'uint32_t'
// width : FLOAT -> 'float'
// unit : Unit -> 'int32_t'
// pen : GpPen** in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("gdiplus.dll", {
GdipCreatePen1: { parameters: ["u32", "f32", "i32", "pointer"], result: "i32" },
});
// lib.symbols.GdipCreatePen1(color, width, unit, pen)
// color : DWORD -> "u32"
// width : FLOAT -> "f32"
// unit : Unit -> "i32"
// pen : GpPen** in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GdipCreatePen1(
uint32_t color,
float width,
int32_t unit,
void* pen);
C, "gdiplus.dll");
// $ffi->GdipCreatePen1(color, width, unit, pen);
// color : DWORD
// width : FLOAT
// unit : Unit
// pen : GpPen** in/out
// 構造体/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 GdipCreatePen1(
int color, // DWORD
float width, // FLOAT
int unit, // Unit
Pointer pen // GpPen** in/out
);
}@[Link("gdiplus")]
lib Libgdiplus
fun GdipCreatePen1 = GdipCreatePen1(
color : UInt32, # DWORD
width : Float32, # FLOAT
unit : Int32, # Unit
pen : GpPen** # GpPen** in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GdipCreatePen1Native = Int32 Function(Uint32, Float, Int32, Pointer<Void>);
typedef GdipCreatePen1Dart = int Function(int, double, int, Pointer<Void>);
final GdipCreatePen1 = DynamicLibrary.open('gdiplus.dll')
.lookupFunction<GdipCreatePen1Native, GdipCreatePen1Dart>('GdipCreatePen1');
// color : DWORD -> Uint32
// width : FLOAT -> Float
// unit : Unit -> Int32
// pen : GpPen** in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GdipCreatePen1(
color: DWORD; // DWORD
width: Single; // FLOAT
unit: Integer; // Unit
pen: Pointer // GpPen** in/out
): Integer; stdcall;
external 'gdiplus.dll' name 'GdipCreatePen1';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GdipCreatePen1"
c_GdipCreatePen1 :: Word32 -> CFloat -> Int32 -> Ptr () -> IO Int32
-- color : DWORD -> Word32
-- width : FLOAT -> CFloat
-- unit : Unit -> Int32
-- pen : GpPen** in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let gdipcreatepen1 =
foreign "GdipCreatePen1"
(uint32_t @-> float @-> int32_t @-> (ptr void) @-> returning int32_t)
(* color : DWORD -> uint32_t *)
(* width : FLOAT -> float *)
(* unit : Unit -> int32_t *)
(* pen : GpPen** in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library gdiplus (t "gdiplus.dll"))
(cffi:use-foreign-library gdiplus)
(cffi:defcfun ("GdipCreatePen1" gdip-create-pen1 :convention :stdcall) :int32
(color :uint32) ; DWORD
(width :float) ; FLOAT
(unit :int32) ; Unit
(pen :pointer)) ; GpPen** in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GdipCreatePen1 = Win32::API::More->new('gdiplus',
'int GdipCreatePen1(DWORD color, float width, int unit, LPVOID pen)');
# my $ret = $GdipCreatePen1->Call($color, $width, $unit, $pen);
# color : DWORD -> DWORD
# width : FLOAT -> float
# unit : Unit -> int
# pen : GpPen** in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
類似 API
- f GdipCreatePen2 — 指定したブラシ・幅・単位で線描画用のペンを新規作成する。